use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityElectricCompressor method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setInteger("redstoneMode", redstoneMode);
nbtTagCompound.setBoolean("outputTimer", outputTimer > 0);
nbtTagCompound.setFloat("turbineSpeed", turbineSpeed);
nbtTagCompound.setInteger("energyProduction", lastEnergyProduction);
// 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 WailaHeatHandler method getNBTData.
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te instanceof IHeatExchanger) {
Set<IHeatExchangerLogic> heatExchangers = new HashSet<IHeatExchangerLogic>();
IHeatExchangerLogic logic = null;
boolean isMultisided = true;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (logic != null) {
if (heatExchangers.contains(logic)) {
isMultisided = false;
break;
} else {
heatExchangers.add(logic);
}
}
}
if (isMultisided) {
NBTTagList tagList = new NBTTagList();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (logic != null) {
NBTTagCompound heatTag = new NBTTagCompound();
heatTag.setByte("side", (byte) d.ordinal());
heatTag.setInteger("temp", (int) logic.getTemperature());
tagList.appendTag(heatTag);
}
}
tag.setTag("heat", tagList);
} else if (logic != null) {
tag.setInteger("temp", (int) logic.getTemperature());
}
}
return tag;
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityPneumaticGenerator method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setInteger("redstoneMode", redstoneMode);
nbtTagCompound.setBoolean("outputting", outputting);
nbtTagCompound.setInteger("energyProduction", curEnergyProduction);
// 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 TileEntityAirCannon method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setBoolean("redstonePowered", redstonePowered);
tag.setFloat("targetRotationAngle", targetRotationAngle);
tag.setFloat("targetHeightAngle", targetHeightAngle);
tag.setFloat("rotationAngle", rotationAngle);
tag.setFloat("heightAngle", heightAngle);
tag.setInteger("gpsX", gpsX);
tag.setInteger("gpsY", gpsY);
tag.setInteger("gpsZ", gpsZ);
tag.setByte("redstoneMode", (byte) redstoneMode);
tag.setBoolean("targetWithinReach", coordWithinReach);
// 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);
tagList = new NBTTagList();
for (EntityItem entity : trackedItems) {
UUID uuid = entity.getUniqueID();
NBTTagCompound t = new NBTTagCompound();
t.setLong("UUIDMost", uuid.getMostSignificantBits());
t.setLong("UUIDLeast", uuid.getLeastSignificantBits());
tagList.appendTag(t);
}
tag.setTag("trackedItems", tagList);
if (lastInsertingInventory != null) {
tag.setInteger("inventoryX", lastInsertingInventory.chunkPosX);
tag.setInteger("inventoryY", lastInsertingInventory.chunkPosY);
tag.setInteger("inventoryZ", lastInsertingInventory.chunkPosZ);
tag.setByte("inventorySide", (byte) lastInsertingInventorySide.ordinal());
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class TileEntityAirCannon method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
redstonePowered = tag.getBoolean("redstonePowered");
targetRotationAngle = tag.getFloat("targetRotationAngle");
targetHeightAngle = tag.getFloat("targetHeightAngle");
rotationAngle = tag.getFloat("rotationAngle");
heightAngle = tag.getFloat("heightAngle");
gpsX = tag.getInteger("gpsX");
gpsY = tag.getInteger("gpsY");
gpsZ = tag.getInteger("gpsZ");
if (tag.hasKey("fireOnRightAngle")) {
//TODO remove legacy
redstoneMode = tag.getBoolean("fireOnRightAngle") ? 0 : 1;
} else {
redstoneMode = tag.getByte("redstoneMode");
}
coordWithinReach = tag.getBoolean("targetWithinReach");
// 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);
}
}
trackedItemIds = new HashSet<UUID>();
tagList = tag.getTagList("trackedItems", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound t = tagList.getCompoundTagAt(i);
trackedItemIds.add(new UUID(t.getLong("UUIDMost"), t.getLong("UUIDLeast")));
}
if (tag.hasKey("inventoryX")) {
lastInsertingInventory = new ChunkPosition(tag.getInteger("inventoryX"), tag.getInteger("inventoryY"), tag.getInteger("inventoryZ"));
lastInsertingInventorySide = ForgeDirection.getOrientation(tag.getByte("inventorySide"));
} else {
lastInsertingInventory = null;
lastInsertingInventorySide = null;
}
}
Aggregations