Java Code Examples for net.minecraft.nbt.NBTTagCompound#getCompoundTag()

The following examples show how to use net.minecraft.nbt.NBTTagCompound#getCompoundTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileSpaceLaser.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);

	laserSat.readFromNBT(nbt.getCompoundTag("laser"));
	if(nbt.hasKey("GlassPane")) {
		NBTTagCompound tag = nbt.getCompoundTag("GlassPane");
		glassPanel = new ItemStack(tag);
	}

	laserX = nbt.getInteger("laserX");
	laserZ = nbt.getInteger("laserZ");
	mode = MODE.values()[nbt.getByte("mode")];

	if(mode == MODE.SPIRAL && nbt.hasKey("prevDir")){
		xCenter = nbt.getInteger("CenterX");
		yCenter = nbt.getInteger("CenterY");
		radius = nbt.getInteger("radius");
		numSteps = nbt.getInteger("numSteps");
		prevDir = EnumFacing.values()[nbt.getInteger("prevDir")];
	}
}
 
Example 2
Source File: Utils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public String getReforgeFromItem(ItemStack item) {
    if (item.hasTagCompound()) {
        NBTTagCompound extraAttributes = item.getTagCompound();
        if (extraAttributes.hasKey("ExtraAttributes")) {
            extraAttributes = extraAttributes.getCompoundTag("ExtraAttributes");
            if (extraAttributes.hasKey("modifier")) {
                String reforge = WordUtils.capitalizeFully(extraAttributes.getString("modifier"));

                reforge = reforge.replace("_sword", ""); //fixes reforges like "Odd_sword"
                reforge = reforge.replace("_bow", "");

                return reforge;
            }
        }
    }
    return null;
}
 
Example 3
Source File: LPRoutedItem.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
public static LPRoutedItem readFromNBT(NBTTagCompound compound, TileGenericPipe holder) {
	double x = compound.getDouble("posX");
	double y = compound.getDouble("posY");
	double z = compound.getDouble("posZ");
	UUID id = compound.getUniqueId("UID");
	ItemStack content = new ItemStack(compound.getCompoundTag("inventory"));
	int ticks = compound.getInteger("ticks");
	Deque<EnumFacing> routingInfo = new ArrayDeque<>();
	NBTTagList routeList = (NBTTagList) compound.getTag("route");
	for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) {
		NBTTagCompound node = (NBTTagCompound) i.next();
		EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")];
		routingInfo.add(nodeTuple);
	}
	LPRoutedItem item = new LPRoutedItem(x, y, z, content, ticks, id);
	item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]);
	item.setHolding(holder);
	item.route = routingInfo;
	return item;
}
 
Example 4
Source File: SpongeSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void readMetadataFromTag(NBTTagCompound tag)
{
    super.readMetadataFromTag(tag);

    if (tag.hasKey("Metadata", Constants.NBT.TAG_COMPOUND))
    {
        NBTTagCompound metaTag = tag.getCompoundTag("Metadata");

        if (metaTag.hasKey("Date", Constants.NBT.TAG_LONG) &&
            this.getMetadata().getTimeCreated() <= 0)
        {
            long time = metaTag.getLong("Date");
            this.getMetadata().setTimeCreated(time);
            this.getMetadata().setTimeModified(time);
        }
    }
}
 
Example 5
Source File: CraftMetaFirework.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
CraftMetaFirework(NBTTagCompound tag) {
    super(tag);

    if (!tag.hasKey(FIREWORKS.NBT)) {
        return;
    }

    NBTTagCompound fireworks = tag.getCompoundTag(FIREWORKS.NBT);

    power = 0xff & fireworks.getByte(FLIGHT.NBT);

    if (!fireworks.hasKey(EXPLOSIONS.NBT)) {
        return;
    }

    NBTTagList fireworkEffects = fireworks.getTagList(EXPLOSIONS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
    List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.tagCount());

    for (int i = 0; i < fireworkEffects.tagCount(); i++) {
        effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i)));
    }
}
 
Example 6
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void readCustomNBT(NBTTagCompound compound) {
    super.readCustomNBT(compound);

    this.multiblockYIndex = compound.getInteger("multiblockYIndex");
    this.isMasterTile = compound.getBoolean("isMasterTile");
    this.multiblockId = compound.getInteger("multiblockId");
    this.isMultiblockPresent = compound.getBoolean("multiblockPresent");
    this.incSize = compound.getInteger("sizeInc");
    AspectList al = new AspectList();
    NBTTagCompound cmp = compound.getCompoundTag("aspects");
    for (Object tag : cmp.func_150296_c()) {
        String strTag = (String) tag;
        int amt = cmp.getInteger(strTag);
        al.add(Aspect.getAspect(strTag), amt);
    }
    this.al = al;
}
 
Example 7
Source File: SpongeSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected boolean readBlocksFromTag(NBTTagCompound tag)
{
    if (tag.hasKey("Palette", Constants.NBT.TAG_COMPOUND) &&
        tag.hasKey("BlockData", Constants.NBT.TAG_BYTE_ARRAY) &&
        isSizeValid(this.getSize()))
    {
        NBTTagCompound paletteTag = tag.getCompoundTag("Palette");
        byte[] blockData = tag.getByteArray("BlockData");
        int paletteSize = paletteTag.getKeySet().size();

        this.blockContainer = LitematicaBlockStateContainerFull.createContainer(paletteSize, blockData, this.getSize());

        if (this.blockContainer == null)
        {
            InfoUtils.printErrorMessage("litematica.message.error.schematic_read.sponge.failed_to_read_blocks");
            return false;
        }

        return this.readPaletteFromTag(paletteTag, this.blockContainer.getPalette());
    }

    return false;
}
 
Example 8
Source File: EntityItemAbducted.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
    this.age = p_70037_1_.getShort("Age");


    NBTTagCompound nbttagcompound1 = p_70037_1_.getCompoundTag("Item");
    this.setEntityItemStack(new ItemStack(nbttagcompound1));

    ItemStack item = (ItemStack)(this.getDataManager().get(ITEM));

    if (item == null || item.getCount() <= 0)
    {
        this.setDead();
    }

    if (p_70037_1_.hasKey("Lifespan"))
    {
        lifespan = p_70037_1_.getInteger("Lifespan");
    }
}
 
Example 9
Source File: TargetData.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean nbtHasTargetTag(NBTTagCompound nbt)
{
    if (nbt == null || nbt.hasKey("Target", Constants.NBT.TAG_COMPOUND) == false)
    {
        return false;
    }

    NBTTagCompound tag = nbt.getCompoundTag("Target");
    if (tag != null &&
        tag.hasKey("posX", Constants.NBT.TAG_INT) &&
        tag.hasKey("posY", Constants.NBT.TAG_INT) &&
        tag.hasKey("posZ", Constants.NBT.TAG_INT) &&
        tag.hasKey("Dim", Constants.NBT.TAG_INT) &&
        //tag.hasKey("BlockName", Constants.NBT.TAG_STRING) &&
        //tag.hasKey("BlockMeta", Constants.NBT.TAG_BYTE) &&
        tag.hasKey("BlockFace", Constants.NBT.TAG_BYTE))
    {
        return true;
    }

    return false;
}
 
Example 10
Source File: EncryptionSavedData.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound encryptionnbt) {
    // Reset
    EncryptionRegistry.Instance.reset();

    // Load NBT
    if (encryptionnbt != null) {
        if (encryptionnbt.hasKey("encryption")) {
            NBTTagCompound encryption = encryptionnbt.getCompoundTag("encryption");
            EncryptionRegistry.Instance.readFromNBT(encryption);
        }
    }
}
 
Example 11
Source File: CraftOfflinePlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
private NBTTagCompound getBukkitData() {
    NBTTagCompound result = getData();

    if (result != null) {
        if (!result.hasKey("bukkit")) {
            result.setTag("bukkit", new net.minecraft.nbt.NBTTagCompound());
        }
        result = result.getCompoundTag("bukkit");
    }

    return result;
}
 
Example 12
Source File: WorldCoordinate.java    From NEI-Integration with MIT License 5 votes vote down vote up
public static WorldCoordinate readFromNBT(NBTTagCompound data, String tag) {
    if (data.hasKey(tag)) {
        NBTTagCompound nbt = data.getCompoundTag(tag);
        int dim = nbt.getInteger("dim");
        int x = nbt.getInteger("x");
        int y = nbt.getInteger("y");
        int z = nbt.getInteger("z");
        return new WorldCoordinate(dim, x, y, z);
    }
    return null;
}
 
Example 13
Source File: TargetData.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NBTTagCompound readTargetTagFromNBT(NBTTagCompound nbt)
{
    if (nbtHasTargetTag(nbt) == false)
    {
        return null;
    }

    NBTTagCompound tag = nbt.getCompoundTag("Target");
    this.pos = new BlockPos(tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ"));
    this.dimension = tag.getInteger("Dim");
    this.dimensionName = tag.getString("DimName");
    this.blockName = tag.getString("BlockName");
    this.blockMeta = tag.getByte("BlockMeta");
    this.itemMeta = tag.getByte("ItemMeta");
    this.blockFace = tag.getByte("BlockFace");
    this.facing = EnumFacing.byIndex(this.blockFace);

    this.dPosX = tag.hasKey("dPosX", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosX") : this.pos.getX() + 0.5d;
    this.dPosY = tag.hasKey("dPosY", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosY") : this.pos.getY();
    this.dPosZ = tag.hasKey("dPosZ", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosZ") : this.pos.getZ() + 0.5d;

    if (tag.hasKey("Yaw", Constants.NBT.TAG_FLOAT) && tag.hasKey("Pitch", Constants.NBT.TAG_FLOAT))
    {
        this.hasRotation = true;
        this.yaw = tag.getFloat("Yaw");
        this.pitch = tag.getFloat("Pitch");
    }

    return tag;
}
 
Example 14
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readCustomNBT(NBTTagCompound compound) {
    super.readCustomNBT(compound);

    NBTTagCompound tag = compound.getCompoundTag("Gadomancy");
    this.multiblockStructurePresent = tag.getBoolean("mBlockPresent");
    this.isMultiblock = tag.getBoolean("mBlockState");
    this.isWorking = tag.getBoolean("manipulating");
    this.workTick = tag.getInteger("workTick");
    if(tag.hasKey("multiblockType")) {
        this.multiblockType = MultiblockType.values()[tag.getInteger("multiblockType")];
    }
    workAspectList.readFromNBT(tag, "workAspectList");
}
 
Example 15
Source File: SaveStates.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
public void read() throws IOException{
	if (file.exists() && file.canRead()){
		NBTTagCompound root = CompressedStreamTools.read(file);
		for (int i =0; i < 7; ++i){
			String name = "slot" + (i+1);
			if (root.hasKey(name))
				tags[i].tag = root.getCompoundTag(name);
			if (root.hasKey(name+"Name"))
				tags[i].name = root.getString(name+"Name");
		}
	}
}
 
Example 16
Source File: CraftMetaSpawnEgg.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
void deserializeInternal(NBTTagCompound tag) {
    super.deserializeInternal(tag);

    if (tag.hasKey(ENTITY_TAG.NBT)) {
        entityTag = tag.getCompoundTag(ENTITY_TAG.NBT);
        MinecraftServer.getServerCB().getDataFixer().process(FixTypes.ENTITY, entityTag); // PAIL: convert TODO: identify DataConverterTypes after implementation

        if (entityTag.hasKey(ENTITY_ID.NBT)) {
            this.spawnedType = EntityType.fromName(new ResourceLocation(entityTag.getString(ENTITY_ID.NBT)).getResourcePath());
        }
    }
}
 
Example 17
Source File: SatelliteBase.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt) {
	satelliteProperties.readFromNBT(nbt.getCompoundTag("properties"));
	dimId = nbt.getInteger("dimId");
	satellite = new ItemStack(nbt.getCompoundTag("item"));
}
 
Example 18
Source File: PackBase.java    From SimplyJetpacks with MIT License 4 votes vote down vote up
public static void readAllConfigsFromNBT(NBTTagCompound tag) {
    for (PackBase pack : ALL_PACKS) {
        NBTTagCompound packTag = tag.getCompoundTag(pack.defaults.section.id);
        pack.readConfigFromNBT(packTag);
    }
}
 
Example 19
Source File: SchematicTile.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void readSchematicFromNBT(NBTTagCompound nbt,	MappingRegistry registry) {
	super.readSchematicFromNBT(nbt, registry);

	tileNBT = nbt.getCompoundTag("blockCpt");
}
 
Example 20
Source File: GTTileQuantumChest.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	this.digitalCount = nbt.getInteger(NBT_DIGITALCOUNT);
	this.display = new ItemStack(nbt.getCompoundTag(NBT_DISPLAYITEM));
}