Search in sources :

Example 61 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.

the class TileEntityPressureChamberValve method readFromNBT.

// NBT methods-----------------------------------------------
@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    multiBlockX = tag.getInteger("multiBlockX");
    multiBlockY = tag.getInteger("multiBlockY");
    multiBlockZ = tag.getInteger("multiBlockZ");
    multiBlockSize = tag.getInteger("multiBlockSize");
    isSufficientPressureInChamber = tag.getBoolean("sufPressure");
    isValidRecipeInChamber = tag.getBoolean("validRecipe");
    recipePressure = tag.getFloat("recipePressure");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
    // Read in the accessory valves from NBT
    NBTTagList tagList2 = tag.getTagList("Valves", 10);
    nbtValveList.clear();
    for (int i = 0; i < tagList2.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList2.getCompoundTagAt(i);
        if (tagCompound != null) {
            nbtValveList.add(new int[] { tagCompound.getInteger("xCoord"), tagCompound.getInteger("yCoord"), tagCompound.getInteger("zCoord") });
        }
    }
    readNBT = true;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 62 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.

the class TileEntityPressureTube method readFromPacket.

@Override
public void readFromPacket(NBTTagCompound tag) {
    super.readFromPacket(tag);
    modules = new TubeModule[6];
    NBTTagList moduleList = tag.getTagList("modules", 10);
    for (int i = 0; i < moduleList.tagCount(); i++) {
        NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i);
        TubeModule module = ModuleRegistrator.getModule(moduleTag.getString("type"));
        module.readFromNBT(moduleTag);
        setModule(module, ForgeDirection.getOrientation(moduleTag.getInteger("side")));
    }
    if (worldObj != null && worldObj.isRemote) {
        rerenderChunk();
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TubeModule(pneumaticCraft.common.block.tubes.TubeModule)

Example 63 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.

the class TileEntitySecurityStation method writeToPacket.

@Override
public void writeToPacket(NBTTagCompound tag) {
    super.writeToPacket(tag);
    NBTTagList sharedList = new NBTTagList();
    for (int i = 0; i < sharedUsers.size(); i++) {
        NBTTagCompound tagCompound = new NBTTagCompound();
        tagCompound.setString("name", sharedUsers.get(i).getName());
        if (sharedUsers.get(i).getId() != null)
            tagCompound.setString("uuid", sharedUsers.get(i).getId().toString());
        sharedList.appendTag(tagCompound);
    }
    tag.setTag("SharedUsers", sharedList);
    NBTTagList hackedList = new NBTTagList();
    for (int i = 0; i < hackedUsers.size(); i++) {
        NBTTagCompound tagCompound = new NBTTagCompound();
        tagCompound.setString("name", hackedUsers.get(i).getName());
        if (hackedUsers.get(i).getId() != null)
            tagCompound.setString("uuid", hackedUsers.get(i).getId().toString());
        hackedList.appendTag(tagCompound);
    }
    tag.setTag("HackedUsers", hackedList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 64 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.

the class TileEntitySecurityStation method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    redstoneMode = tag.getInteger("redstoneMode");
    rebootTimer = tag.getInteger("startupTimer");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
    checkForNetworkValidity();
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 65 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.

the class TileEntityUVLightBox method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    redstoneMode = nbt.getInteger("redstoneMode");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = nbt.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
//  if(worldObj.isRemote) System.out.println("reading from NBT, got a packet?");
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

NBTTagList (net.minecraft.nbt.NBTTagList)451 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)385 ItemStack (net.minecraft.item.ItemStack)69 NBTTagString (net.minecraft.nbt.NBTTagString)42 BlockPos (net.minecraft.util.math.BlockPos)18 HashMap (java.util.HashMap)17 Map (java.util.Map)17 NotNull (org.jetbrains.annotations.NotNull)17 ArrayList (java.util.ArrayList)14 AMVector3 (am2.api.math.AMVector3)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 NBTBase (net.minecraft.nbt.NBTBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Vec3d (net.minecraft.util.math.Vec3d)7 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)6 Block (net.minecraft.block.Block)6 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)5 Entity (net.minecraft.entity.Entity)5 TileEntity (net.minecraft.tileentity.TileEntity)5 ChunkPos (net.minecraft.util.math.ChunkPos)5