Search in sources :

Example 71 with NBTTagList

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

the class TileEntityPressureChamberInterface method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for (int i = 0; i < inventory.length; i++) if (inventory[i] != null) {
        NBTTagCompound tagCompound = new NBTTagCompound();
        tagCompound.setByte("Slot", (byte) i);
        inventory[i].writeToNBT(tagCompound);
        tagList.appendTag(tagCompound);
    }
    tag.setTag("Items", tagList);
    tag.setInteger("outputProgress", outputProgress);
    tag.setInteger("inputProgress", inputProgress);
    tag.setInteger("interfaceMode", interfaceMode.ordinal());
    tag.setInteger("filterMode", filterMode.ordinal());
    tag.setInteger("creativeTabID", creativeTabID);
    tag.setString("itemNameFilter", itemNameFilter);
    tag.setInteger("redstoneMode", redstoneMode);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 72 with NBTTagList

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

the class TileEntityUniversalSensor method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    setSensorSetting(tag.getString("sensorSetting"));
    invertedRedstone = tag.getBoolean("invertedRedstone");
    dishSpeed = tag.getFloat("dishSpeed");
    sensorGuiText = tag.getString("sensorText");
    // 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);
        }
    }
    positions = getGPSPositionsStatic(this, getRange());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 73 with NBTTagList

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

the class TileEntityVacuumPump method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    vacuumHandler.readFromNBTI(tag.getCompoundTag("vacuum"));
    turning = tag.getBoolean("turning");
    redstoneMode = tag.getInteger("redstoneMode");
    // 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);
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 74 with NBTTagList

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

the class TileEntityElevatorBase method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    tag.setFloat("extension", extension);
    tag.setFloat("targetExtension", targetExtension);
    tag.setInteger("redstoneMode", redstoneMode);
    tag.setInteger("maxFloorHeight", maxFloorHeight);
    for (int i = 0; i < 6; i++) {
        tag.setBoolean("sideConnected" + i, sidesConnected[i]);
    }
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if (inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte) currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 75 with NBTTagList

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

the class ProgrammedDroneUtils method getChargedDispenserUpgradeDrone.

private static EntityDrone getChargedDispenserUpgradeDrone(World world) {
    EntityDrone drone = new EntityDrone(world);
    NBTTagCompound tag = new NBTTagCompound();
    drone.writeEntityToNBT(tag);
    NBTTagList upgradeList = new NBTTagList();
    NBTTagCompound slotEntry = new NBTTagCompound();
    slotEntry.setByte("Slot", (byte) 0);
    new ItemStack(Itemss.machineUpgrade, 64, ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE).writeToNBT(slotEntry);
    upgradeList.appendTag(slotEntry);
    slotEntry = new NBTTagCompound();
    slotEntry.setByte("Slot", (byte) 1);
    new ItemStack(Itemss.machineUpgrade, 10, ItemMachineUpgrade.UPGRADE_SPEED_DAMAGE).writeToNBT(slotEntry);
    upgradeList.appendTag(slotEntry);
    NBTTagCompound inv = new NBTTagCompound();
    inv.setTag("Items", upgradeList);
    tag.setTag("Inventory", inv);
    tag.setFloat("currentAir", 100000);
    drone.readEntityFromNBT(tag);
    drone.setCustomNameTag(StatCollector.translateToLocal("drone.amadronDeliveryDrone"));
    //Don't let the drone be dropped when wrenching it.
    drone.naturallySpawned = true;
    return drone;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

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