use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityAirCompressor method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setInteger("burnTime", burnTime);
nbtTagCompound.setInteger("maxBurn", maxBurnTime);
nbtTagCompound.setInteger("redstoneMode", redstoneMode);
// 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);
}
}
nbtTagCompound.setTag("Items", tagList);
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityAirCompressor method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound) {
super.readFromNBT(nbtTagCompound);
burnTime = nbtTagCompound.getInteger("burnTime");
maxBurnTime = nbtTagCompound.getInteger("maxBurn");
redstoneMode = nbtTagCompound.getInteger("redstoneMode");
// Read in the ItemStacks in the inventory from NBT
NBTTagList tagList = nbtTagCompound.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);
}
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityAssemblyController method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setBoolean("goingToHomePosition", goingToHomePosition);
tag.setBoolean("foundAllMachines", foundAllMachines);
tag.setBoolean("foundDuplicate", foundDuplicateMachine);
tag.setString("displayedText", displayedText);
if (curProgram != null)
curProgram.writeToNBT(tag);
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);
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityBase method readInventoryFromNBT.
public static void readInventoryFromNBT(NBTTagCompound tag, ItemStack[] stacks, String tagName) {
for (int i = 0; i < stacks.length; i++) {
stacks[i] = null;
}
NBTTagList tagList = tag.getTagList(tagName, 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound itemTag = tagList.getCompoundTagAt(i);
int slot = itemTag.getByte("Slot");
if (slot >= 0 && slot < stacks.length) {
stacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
}
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityElectrostaticCompressor method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setInteger("redstoneMode", redstoneMode);
// 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);
}
}
nbtTagCompound.setTag("Items", tagList);
}
Aggregations