@Override public boolean upgrade(BaseTier upgradeTier) { if (upgradeTier.ordinal() != tier.ordinal() + 1) { return false; } tier = FluidTankTier.values()[upgradeTier.ordinal()]; fluidTank.setCapacity(tier.storage); Mekanism.packetHandler.sendToReceivers( new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); markDirty(); return true; }
@Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); tier = FluidTankTier.values()[nbtTags.getInteger("tier")]; clientActive = isActive = nbtTags.getBoolean("isActive"); editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; if (nbtTags.hasKey("fluidTank")) { fluidTank.setCapacity(tier.storage); fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); } }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); nbtTags.setInteger("tier", tier.ordinal()); nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("editMode", editMode.ordinal()); if (fluidTank.getFluid() != null) { nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } return nbtTags; }
@Override public ArrayList<Object> getNetworkedData(ArrayList<Object> data) { super.getNetworkedData(data); data.add(tier.ordinal()); data.add(isActive); data.add(valve); data.add(editMode.ordinal()); if (valve > 0) { data.add(FluidRegistry.getFluidName(valveFluid)); } if (fluidTank.getFluid() != null) { data.add(1); data.add(FluidRegistry.getFluidName(fluidTank.getFluid())); data.add(fluidTank.getFluid().amount); } else { data.add(0); } return data; }
@Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { FluidTankTier prevTier = tier; tier = FluidTankTier.values()[dataStream.readInt()]; fluidTank.setCapacity(tier.storage); clientActive = dataStream.readBoolean(); valve = dataStream.readInt(); editMode = ContainerEditMode.values()[dataStream.readInt()]; if (valve > 0) { valveFluid = FluidRegistry.getFluid(PacketHandler.readString(dataStream)); } else { valveFluid = null; } if (dataStream.readInt() == 1) { fluidTank.setFluid( new FluidStack( FluidRegistry.getFluid(PacketHandler.readString(dataStream)), dataStream.readInt())); } else { fluidTank.setFluid(null); } if (prevTier != tier || (updateDelay == 0 && clientActive != isActive)) { updateDelay = general.UPDATE_DELAY; isActive = clientActive; MekanismUtils.updateBlock(worldObj, getPos()); } } }
@Override public String getName() { return LangUtils.localize("tile.FluidTank" + tier.getBaseTier().getSimpleName() + ".name"); }