@Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); finishedCalc = nbtTags.getBoolean("finishedCalc"); if (nbtTags.hasKey("fluidTank")) { fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); } if (nbtTags.hasKey("activeNodes")) { NBTTagList tagList = nbtTags.getTagList("activeNodes", NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { activeNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i))); } } if (nbtTags.hasKey("usedNodes")) { NBTTagList tagList = nbtTags.getTagList("usedNodes", NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { usedNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i))); } } }
@Override public void writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); nbtTags.setBoolean("finishedCalc", finishedCalc); if (fluidTank.getFluid() != null) { nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } NBTTagList activeList = new NBTTagList(); for (Coord4D wrapper : activeNodes) { NBTTagCompound tagCompound = new NBTTagCompound(); wrapper.write(tagCompound); activeList.appendTag(tagCompound); } if (activeList.tagCount() != 0) { nbtTags.setTag("activeNodes", activeList); } NBTTagList usedList = new NBTTagList(); for (Coord4D obj : usedNodes) { activeList.appendTag(obj.write(new NBTTagCompound())); } if (activeList.tagCount() != 0) { nbtTags.setTag("usedNodes", usedList); } }
@Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); finishedCalc = dataStream.readBoolean(); if (dataStream.readInt() == 1) { fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); } else { fluidTank.setFluid(null); } MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); }
@Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); data.add(finishedCalc); if (fluidTank.getFluid() != null) { data.add(1); data.add(fluidTank.getFluid().getFluidID()); data.add(fluidTank.getFluid().amount); } else { data.add(0); } return data; }