From 7ac7fbc5ccd59781799ed2cf24eb5cf3e14523c9 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 17:59:43 -0400 Subject: [PATCH] Sustained gas and fluid support for Chemical Washer, Chemical Crystallizer and Chemical Infuser --- .../mekanism/common/block/BlockMachine.java | 53 +++++++++++++++++-- .../common/item/ItemBlockMachine.java | 30 +++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 367abe760..6a4519704 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1140,11 +1140,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer if(tileEntity instanceof TileEntityChemicalOxidizer) { - TileEntityChemicalOxidizer formulator = (TileEntityChemicalOxidizer)tileEntity; + TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity; - if(formulator.gasTank.getGas() != null) + if(oxidizer.gasTank.getGas() != null) { - itemStack.stackTagCompound.setTag("gasTank", formulator.gasTank.getGas().write(new NBTTagCompound())); + itemStack.stackTagCompound.setTag("gasTank", oxidizer.gasTank.getGas().write(new NBTTagCompound())); } } @@ -1164,7 +1164,52 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer if(infuser.centerTank.getGas() != null) { - itemStack.stackTagCompound.setTag("leftTank", infuser.centerTank.getGas().write(new NBTTagCompound())); + itemStack.stackTagCompound.setTag("centerTank", infuser.centerTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalDissolutionChamber) + { + TileEntityChemicalDissolutionChamber chamber = (TileEntityChemicalDissolutionChamber)tileEntity; + + if(chamber.injectTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("injectTank", chamber.injectTank.getGas().write(new NBTTagCompound())); + } + + if(chamber.outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", chamber.outputTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalWasher) + { + TileEntityChemicalWasher washer = (TileEntityChemicalWasher)tileEntity; + + if(washer.fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", washer.fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(washer.inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", washer.inputTank.getGas().write(new NBTTagCompound())); + } + + if(washer.outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", washer.outputTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalCrystallizer) + { + TileEntityChemicalCrystallizer crystallizer = (TileEntityChemicalCrystallizer)tileEntity; + + if(crystallizer.inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", crystallizer.inputTank.getGas().write(new NBTTagCompound())); } } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 5dbde0970..868ea986a 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -29,8 +29,11 @@ import mekanism.common.miner.MinerFilter; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.tile.TileEntityBasicBlock; +import mekanism.common.tile.TileEntityChemicalCrystallizer; +import mekanism.common.tile.TileEntityChemicalDissolutionChamber; import mekanism.common.tile.TileEntityChemicalInfuser; import mekanism.common.tile.TileEntityChemicalOxidizer; +import mekanism.common.tile.TileEntityChemicalWasher; import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricChest; @@ -381,6 +384,33 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } + if(tileEntity instanceof TileEntityChemicalDissolutionChamber) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalDissolutionChamber)tileEntity).injectTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("injectTank"))); + ((TileEntityChemicalDissolutionChamber)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); + } + } + + if(tileEntity instanceof TileEntityChemicalWasher) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalWasher)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank"))); + ((TileEntityChemicalWasher)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); + ((TileEntityChemicalWasher)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); + } + } + + if(tileEntity instanceof TileEntityChemicalCrystallizer) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalCrystallizer)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); + } + } + if(tileEntity instanceof TileEntityElectrolyticSeparator) { if(stack.stackTagCompound != null)