Search in sources :

Example 56 with NBTTagList

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

the class TileEntityAssemblyPlatform method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    tag.setBoolean("clawClosing", shouldClawClose);
    tag.setFloat("clawProgress", clawProgress);
    tag.setFloat("speed", speed);
    tag.setBoolean("drilled", hasDrilledStack);
    tag.setBoolean("lasered", hasLaseredStack);
    // 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 57 with NBTTagList

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

the class TileEntityBase method writeInventoryToNBT.

public static void writeInventoryToNBT(NBTTagCompound tag, ItemStack[] stacks, String tagName) {
    NBTTagList tagList = new NBTTagList();
    for (int i = 0; i < stacks.length; i++) {
        if (stacks[i] != null) {
            NBTTagCompound itemTag = new NBTTagCompound();
            stacks[i].writeToNBT(itemTag);
            itemTag.setByte("Slot", (byte) i);
            tagList.appendTag(itemTag);
        }
    }
    tag.setTag(tagName, tagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 58 with NBTTagList

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

the class TileEntityProgrammableController method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    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);
    NBTTagCompound tankTag = new NBTTagCompound();
    tank.writeToNBT(tankTag);
    tag.setTag("tank", tankTag);
    NBTTagList droneItems = new NBTTagList();
    for (int currentIndex = 0; currentIndex < getDroneSlots(); ++currentIndex) {
        if (getFakePlayer().inventory.getStackInSlot(currentIndex) != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte) currentIndex);
            getFakePlayer().inventory.getStackInSlot(currentIndex).writeToNBT(tagCompound);
            droneItems.appendTag(tagCompound);
        }
    }
    tag.setTag("droneItems", droneItems);
    NBTTagList extendedList = new NBTTagList();
    for (Map.Entry<String, IExtendedEntityProperties> entry : properties.entrySet()) {
        NBTTagCompound propertyTag = new NBTTagCompound();
        propertyTag.setString("key", entry.getKey());
        entry.getValue().saveNBTData(propertyTag);
        extendedList.appendTag(propertyTag);
    }
    tag.setTag("extendedProperties", extendedList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IExtendedEntityProperties(net.minecraftforge.common.IExtendedEntityProperties) Map(java.util.Map) HashMap(java.util.HashMap)

Example 59 with NBTTagList

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

the class TileEntityProgrammer method setWidgetsToNBT.

public static void setWidgetsToNBT(List<IProgWidget> widgets, NBTTagCompound tag) {
    NBTTagList widgetTags = new NBTTagList();
    for (IProgWidget widget : widgets) {
        NBTTagCompound widgetTag = new NBTTagCompound();
        widget.writeToNBT(widgetTag);
        widgetTags.appendTag(widgetTag);
    }
    tag.setTag("widgets", widgetTags);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 60 with NBTTagList

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

the class TileEntityPressureChamberValve method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    tag.setInteger("multiBlockX", multiBlockX);
    tag.setInteger("multiBlockY", multiBlockY);
    tag.setInteger("multiBlockZ", multiBlockZ);
    tag.setInteger("multiBlockSize", multiBlockSize);
    tag.setBoolean("sufPressure", isSufficientPressureInChamber);
    tag.setBoolean("validRecipe", isValidRecipeInChamber);
    tag.setFloat("recipePressure", recipePressure);
    // 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);
    // Write the accessory valve to NBT
    NBTTagList tagList2 = new NBTTagList();
    for (TileEntityPressureChamberValve valve : accessoryValves) {
        NBTTagCompound tagCompound = new NBTTagCompound();
        tagCompound.setInteger("xCoord", valve.xCoord);
        tagCompound.setInteger("yCoord", valve.yCoord);
        tagCompound.setInteger("zCoord", valve.zCoord);
        tagList2.appendTag(tagCompound);
    }
    tag.setTag("Valves", tagList2);
}
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