From ea96a7d7478249165f39c8a1e338597e0a3ca5c8 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Thu, 2 Jan 2014 04:02:00 +0000 Subject: [PATCH] Start work on updating the electrolytic separator. It can output both gases now! Should support recipes as well. --- common/mekanism/api/ChemicalInput.java | 7 +- common/mekanism/common/Mekanism.java | 5 + common/mekanism/common/RecipeHandler.java | 46 ++- .../client/gui/GuiElectrolyticSeparator.java | 23 +- .../render/RenderElectrolyticSeparator.java | 3 +- .../TileEntityElectrolyticSeparator.java | 335 +++++++++++------- 6 files changed, 268 insertions(+), 151 deletions(-) diff --git a/common/mekanism/api/ChemicalInput.java b/common/mekanism/api/ChemicalInput.java index 8cb0386ba..d60efcfcd 100644 --- a/common/mekanism/api/ChemicalInput.java +++ b/common/mekanism/api/ChemicalInput.java @@ -50,7 +50,7 @@ public class ChemicalInput * Swaps the right gas and left gas of this input. * @return a swapped ChemicalInput */ - private ChemicalInput swap() + public ChemicalInput swap() { return new ChemicalInput(rightGas, leftGas); } @@ -93,4 +93,9 @@ public class ChemicalInput return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; } + + public ChemicalInput copy() + { + return new ChemicalInput(leftGas.copy(), rightGas.copy()); + } } diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index f09bb849d..d6ff320ae 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -111,6 +111,8 @@ import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapelessOreRecipe; import rebelkeithy.mods.metallurgy.api.IOreInfo; @@ -633,6 +635,9 @@ public class Mekanism RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2)), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); + //Electrolytic Separator Recipes + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), new ChemicalInput(new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1))); + //Infuse objects InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20)); diff --git a/common/mekanism/common/RecipeHandler.java b/common/mekanism/common/RecipeHandler.java index 4d529b499..d21ff06d0 100644 --- a/common/mekanism/common/RecipeHandler.java +++ b/common/mekanism/common/RecipeHandler.java @@ -10,6 +10,9 @@ import mekanism.api.infuse.InfusionInput; import mekanism.api.infuse.InfusionOutput; import mekanism.common.util.StackUtils; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; /** * Class used to handle machine recipes. This is used for both adding recipes and checking outputs. @@ -112,7 +115,17 @@ public final class RecipeHandler { Recipe.CHEMICAL_INJECTION_CHAMBER.put(input, output); } - + + /** + * Add an Electrolytic Separator recipe. + * @param fluid - FluidStack to electrolyze + * @param products - Pair of gases to produce when the fluid is electrolyzed + */ + public static void addElectrolyticSeparatorRecipe(FluidStack fluid, ChemicalInput products) + { + Recipe.ELECTROLYTIC_SEPARATOR.put(fluid, products); + } + /** * Gets the InfusionOutput of the InfusionInput in the parameters. * @param infusion - input Infusion @@ -266,6 +279,34 @@ public final class RecipeHandler return false; } + /** + * Get the result of electrolysing a given fluid + * @param fluidTank - the FluidTank to electrolyse fluid from + */ + public static ChemicalInput getElectrolyticSeparatorOutput(FluidTank fluidTank, boolean doRemove) + { + FluidStack fluid = fluidTank.getFluid(); + + if(fluid != null) + { + HashMap recipes = Recipe.ELECTROLYTIC_SEPARATOR.get(); + + for(Map.Entry entry : recipes.entrySet()) + { + FluidStack key = (FluidStack)entry.getKey(); + + if(fluid.containsFluid(key)) + { + fluidTank.drain(key.amount, doRemove); + + return entry.getValue().copy(); + } + } + } + + return null; + } + public static enum Recipe { ENRICHMENT_CHAMBER(new HashMap()), @@ -276,7 +317,8 @@ public final class RecipeHandler METALLURGIC_INFUSER(new HashMap()), CHEMICAL_INFUSER(new HashMap()), CHEMICAL_OXIDIZER(new HashMap()), - CHEMICAL_INJECTION_CHAMBER(new HashMap()); + CHEMICAL_INJECTION_CHAMBER(new HashMap()), + ELECTROLYTIC_SEPARATOR(new HashMap()); private HashMap recipes; diff --git a/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java b/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java index ac52067e2..042bfef60 100644 --- a/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java +++ b/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java @@ -1,13 +1,6 @@ package mekanism.generators.client.gui; -import java.util.ArrayList; - -import mekanism.api.Coord4D; import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import mekanism.common.PacketHandler; -import mekanism.common.PacketHandler.Transmission; -import mekanism.common.network.PacketTileEntity; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerElectrolyticSeparator; @@ -42,7 +35,7 @@ public class GuiElectrolyticSeparator extends GuiContainer if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { Gas gasToSet = null; - + /* if(tileEntity.outputType == GasRegistry.getGas("hydrogen")) { gasToSet = GasRegistry.getGas("oxygen"); @@ -62,11 +55,12 @@ public class GuiElectrolyticSeparator extends GuiContainer PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + */ } else if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) { Gas gasToSet = null; - + /* if(tileEntity.dumpType == null) { gasToSet = GasRegistry.getGas("oxygen"); @@ -86,6 +80,7 @@ public class GuiElectrolyticSeparator extends GuiContainer PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + */ } } @@ -114,21 +109,21 @@ public class GuiElectrolyticSeparator extends GuiContainer int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int outputDisplay = tileEntity.outputType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.outputType == GasRegistry.getGas("hydrogen") ? 90 : 98); + int outputDisplay = 1;//tileEntity.outputType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.outputType == GasRegistry.getGas("hydrogen") ? 90 : 98); drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, outputDisplay, 8, 8); - int dumpDisplay = tileEntity.dumpType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.dumpType == GasRegistry.getGas("hydrogen") ? 90 : 98); + int dumpDisplay = 1;//tileEntity.dumpType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.dumpType == GasRegistry.getGas("hydrogen") ? 90 : 98); drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, dumpDisplay, 8, 8); int displayInt; - displayInt = tileEntity.getScaledWaterLevel(52); + displayInt = tileEntity.getScaledFluidLevel(52); drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176 + 4, 52 - displayInt, 4, displayInt); - displayInt = tileEntity.getScaledHydrogenLevel(30); + displayInt = tileEntity.getLeftScaledLevel(30); drawTexturedModalRect(guiWidth + 65, guiHeight + 17 + 30 - displayInt, 176, 52 + 30 - displayInt, 4, displayInt); - displayInt = tileEntity.getScaledOxygenLevel(30); + displayInt = tileEntity.getRightScaledLevel(30); drawTexturedModalRect(guiWidth + 107, guiHeight + 17 + 30 - displayInt, 176 + 4, 52 + 30 - displayInt, 4, displayInt); displayInt = tileEntity.getScaledEnergyLevel(52); diff --git a/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java b/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java index 08b442a97..ffe2065e6 100644 --- a/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java +++ b/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java @@ -28,8 +28,7 @@ public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, tileEntity.outputType == GasRegistry.getGas("hydrogen") ? "ElectrolyticSeparatorHydrogen.png" : - (tileEntity.outputType == GasRegistry.getGas("oxygen") ? "ElectrolyticSeparatorOxygen.png" : "ElectrolyticSeparatorNone.png"))); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparatorNone.png")); switch(tileEntity.facing) { diff --git a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java index bfc808e8a..9f67aa3f4 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java @@ -1,19 +1,15 @@ package mekanism.generators.common.tileentity; import java.util.ArrayList; -import java.util.Random; +import mekanism.api.ChemicalInput; import mekanism.api.Coord4D; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.IGasHandler; -import mekanism.api.gas.IGasItem; -import mekanism.api.gas.ITubeConnection; +import mekanism.api.gas.*; import mekanism.common.ISustainedTank; +import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; +import mekanism.common.RecipeHandler; import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityElectricBlock; import mekanism.common.util.ChargeUtils; @@ -38,35 +34,33 @@ import dan200.computer.api.IComputerAccess; import dan200.computer.api.ILuaContext; import dan200.computer.api.IPeripheral; -public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedTank +public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedTank, IGasHandler { /** This separator's water slot. */ - public FluidTank waterTank = new FluidTank(24000); + public FluidTank fluidTank = new FluidTank(24000); /** The maximum amount of gas this block can store. */ public int MAX_GAS = 2400; /** The amount of oxygen this block is storing. */ - public int oxygenStored; + public GasTank leftTank = new GasTank(MAX_GAS); /** The amount of hydrogen this block is storing. */ - public int hydrogenStored; + public GasTank rightTank = new GasTank(MAX_GAS); /** How fast this block can output gas. */ public int output = 16; /** The type of gas this block is outputting. */ - public Gas outputType; + public boolean dumpLeft = false; /** Type type of gas this block is dumping. */ - public Gas dumpType; + public boolean dumpRight = false; public TileEntityElectrolyticSeparator() { super("ElectrolyticSeparator", GeneratorType.ELECTROLYTIC_SEPARATOR.maxEnergy); inventory = new ItemStack[4]; - outputType = GasRegistry.getGas("oxygen"); - dumpType = null; } @Override @@ -78,15 +72,15 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { ChargeUtils.discharge(3, this); - if(inventory[0] != null) + /*if(inventory[0] != null) { FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); if(fluid != null && fluid.getFluid() == FluidRegistry.WATER) { - if(waterTank.getFluid() == null || waterTank.getFluid().amount+fluid.amount <= waterTank.getCapacity()) + if(fluidTank.getFluid() == null || fluidTank.getFluid().amount+fluid.amount <= fluidTank.getCapacity()) { - waterTank.fill(fluid, true); + fluidTank.fill(fluid, true); if(inventory[0].getItem().hasContainerItem()) { @@ -102,87 +96,120 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } } } - } + }*/ if(!worldObj.isRemote) { - if(inventory[1] != null && hydrogenStored > 0) + if(inventory[1] != null && leftTank.getStored() > 0) { - hydrogenStored -= GasTransmission.addGas(inventory[1], new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored)); + leftTank.draw(GasTransmission.addGas(inventory[1], leftTank.getGas()), true); MekanismUtils.saveChunk(this); } - if(inventory[2] != null && oxygenStored > 0) + if(inventory[2] != null && rightTank.getStored() > 0) { - hydrogenStored -= GasTransmission.addGas(inventory[2], new GasStack(GasRegistry.getGas("oxygen"), oxygenStored)); + rightTank.draw(GasTransmission.addGas(inventory[2], rightTank.getGas()), true); MekanismUtils.saveChunk(this); } } - if(oxygenStored < MAX_GAS && hydrogenStored < MAX_GAS && waterTank.getFluid() != null && waterTank.getFluid().amount-2 >= 0 && getEnergy()-100 > 0) + if(canOperate()) { - waterTank.drain(2, true); + fillTanks(RecipeHandler.getElectrolyticSeparatorOutput(fluidTank, true)); setEnergy(getEnergy() - MekanismGenerators.electrolyticSeparatorUsage); - setStored(GasRegistry.getGas("oxygen"), oxygenStored + 1); - setStored(GasRegistry.getGas("hydrogen"), hydrogenStored + 2); } - - if(outputType != null && getStored(outputType) > 0) + + if(leftTank.getGas() != null) { - GasStack toSend = new GasStack(outputType, Math.min(getStored(outputType), output)); - setStored(outputType, getStored(outputType) - GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing))); - - TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - - if(tileEntity instanceof IGasHandler) + if(!dumpLeft) { - if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), outputType)) + GasStack toSend = new GasStack(leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output)); + leftTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing)), true); + + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj); + + if(tileEntity instanceof IGasHandler) { - int added = ((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), new GasStack(outputType, Math.min(getStored(outputType), output))); - - setStored(outputType, getStored(outputType) - added); + if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), leftTank.getGas().getGas())) + { + leftTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend), true); + } + } + } + else + { + leftTank.draw(8, true); + + if(worldObj.rand.nextInt(3) == 2) + { + PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getParticlePacket(new ArrayList())), Coord4D.get(this), 40D); } } } - - if(dumpType != null && getStored(dumpType) > 0) + + if(rightTank.getGas() != null) { - setStored(dumpType, (getStored(dumpType) - 8)); - - if(worldObj.rand.nextInt(3) == 2) + if(!dumpRight) { - PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getParticlePacket(new ArrayList())), Coord4D.get(this), 40D); + GasStack toSend = new GasStack(rightTank.getGas().getGas(), Math.min(rightTank.getStored(), output)); + rightTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getRight(facing)), true); + + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); + + if(tileEntity instanceof IGasHandler) + { + if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), rightTank.getGas().getGas())) + { + rightTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend), true); + } + } + } + else + { + rightTank.draw(8, true); + + if(worldObj.rand.nextInt(3) == 2) + { + PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getParticlePacket(new ArrayList())), Coord4D.get(this), 40D); + } } } + } } - - public int getStored(Gas gas) + + public boolean canOperate() { - if(gas == GasRegistry.getGas("oxygen")) - { - return oxygenStored; - } - else if(gas == GasRegistry.getGas("hydrogen")) - { - return hydrogenStored; - } - - return 0; + return canFillWithSwap(RecipeHandler.getElectrolyticSeparatorOutput(fluidTank, false)) && getEnergy() >= MekanismGenerators.electrolyticSeparatorUsage; + } + + public boolean canFillWithSwap(ChemicalInput gases) + { + if(gases == null) + return false; + return canFill(gases) || canFill(gases.swap()); } - public void setStored(Gas type, int amount) + public boolean canFill(ChemicalInput gases) { - if(type == GasRegistry.getGas("hydrogen")) + return (leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount + && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount); + } + + public void fillTanks(ChemicalInput gases) + { + if(gases == null) return; + + if(canFill(gases)) { - hydrogenStored = Math.max(Math.min(amount, MAX_GAS), 0); + leftTank.receive(gases.leftGas, true); + rightTank.receive(gases.rightGas, true); } - else if(type == GasRegistry.getGas("oxygen")) + else if(canFill(gases.swap())) { - oxygenStored = Math.max(Math.min(amount, MAX_GAS), 0); + leftTank.receive(gases.rightGas, true); + rightTank.receive(gases.leftGas, true); } - - MekanismUtils.saveChunk(this); } public void spawnParticle() @@ -267,9 +294,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp * @param i - multiplier * @return */ - public int getScaledHydrogenLevel(int i) + public int getLeftScaledLevel(int i) { - return hydrogenStored*i / MAX_GAS; + return leftTank.getStored()*i / MAX_GAS; } /** @@ -277,9 +304,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp * @param i - multiplier * @return */ - public int getScaledOxygenLevel(int i) + public int getRightScaledLevel(int i) { - return oxygenStored*i / MAX_GAS; + return rightTank.getStored()*i / MAX_GAS; } /** @@ -287,9 +314,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp * @param i - multiplier * @return */ - public int getScaledWaterLevel(int i) + public int getScaledFluidLevel(int i) { - return waterTank.getFluid() != null ? waterTank.getFluid().amount*i / waterTank.getCapacity() : 0; + return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / fluidTank.getCapacity() : 0; } /** @@ -311,11 +338,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(type == 0) { - outputType = GasRegistry.getGas(dataStream.readInt()); + dumpLeft = dataStream.readBoolean(); } else if(type == 1) { - dumpType = GasRegistry.getGas(dataStream.readInt()); + dumpRight = dataStream.readBoolean(); } return; @@ -327,20 +354,32 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(type == 0) { - int amount = dataStream.readInt(); - - if(amount != 0) + if(dataStream.readBoolean()) { - waterTank.setFluid(new FluidStack(FluidRegistry.WATER, amount)); + fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); } else { - waterTank.setFluid(null); + fluidTank.setFluid(null); } - - oxygenStored = dataStream.readInt(); - hydrogenStored = dataStream.readInt(); - outputType = GasRegistry.getGas(dataStream.readInt()); - dumpType = GasRegistry.getGas(dataStream.readInt()); + + if(dataStream.readBoolean()) + { + leftTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); + } + else { + leftTank.setGas(null); + } + + if(dataStream.readBoolean()) + { + rightTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); + } + else { + rightTank.setGas(null); + } + + dumpLeft = dataStream.readBoolean(); + dumpRight = dataStream.readBoolean(); } else if(type == 1) { @@ -352,21 +391,42 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(0); - if(waterTank.getFluid() != null) + + if(fluidTank.getFluid() != null) { - data.add(waterTank.getFluid().amount); + data.add(true); + data.add(fluidTank.getFluid().getFluid().getID()); + data.add(fluidTank.getFluidAmount()); } else { - data.add(0); + data.add(false); } - - data.add(oxygenStored); - data.add(hydrogenStored); - data.add(GasRegistry.getGasID(outputType)); - data.add(GasRegistry.getGasID(dumpType)); - + + if(leftTank.getGas() != null) + { + data.add(true); + data.add(leftTank.getGas().getGas().getID()); + data.add(leftTank.getStored()); + } + else { + data.add(false); + } + + if(rightTank.getGas() != null) + { + data.add(true); + data.add(rightTank.getGas().getGas().getID()); + data.add(rightTank.getStored()); + } + else { + data.add(false); + } + + data.add(dumpLeft); + data.add(dumpRight); + return data; } @@ -382,42 +442,33 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { super.readFromNBT(nbtTags); - hydrogenStored = nbtTags.getInteger("hydrogenStored"); - oxygenStored = nbtTags.getInteger("oxygenStored"); - - if(nbtTags.hasKey("waterTank")) - { - waterTank.readFromNBT(nbtTags.getCompoundTag("waterTank")); - } - - try { - outputType = Gas.readFromNBT(nbtTags.getCompoundTag("outputType")); - dumpType = Gas.readFromNBT(nbtTags.getCompoundTag("dumpType")); - } catch(Exception e) {} //TODO remove next major release + if(nbtTags.hasKey("fluidTank")) + { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + + leftTank.read(nbtTags.getCompoundTag("leftTank")); + rightTank.read(nbtTags.getCompoundTag("rightTank")); + + dumpLeft = nbtTags.getBoolean("dumpLeft"); + dumpRight = nbtTags.getBoolean("dumpRight"); } @Override public void writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - - nbtTags.setInteger("hydrogenStored", hydrogenStored); - nbtTags.setInteger("oxygenStored", oxygenStored); - - if(waterTank.getFluid() != null) + + if(fluidTank.getFluid() != null) { - nbtTags.setTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); - } - - if(outputType != null) - { - nbtTags.setCompoundTag("outputType", outputType.write(new NBTTagCompound())); - } - - if(dumpType != null) - { - nbtTags.setCompoundTag("dumpType", dumpType.write(new NBTTagCompound())); + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } + + nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound())); + nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound())); + + nbtTags.setBoolean("dumpLeft", dumpLeft); + nbtTags.setBoolean("dumpRight", dumpRight); } @Override @@ -446,17 +497,17 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp case 3: return new Object[] {(MAX_ELECTRICITY-electricityStored)}; case 4: - return new Object[] {waterTank.getFluid() != null ? waterTank.getFluid().amount : 0}; + return new Object[] {fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0}; case 5: - return new Object[] {waterTank.getFluid() != null ? (waterTank.getCapacity()-waterTank.getFluid().amount) : 0}; + return new Object[] {fluidTank.getFluid() != null ? (fluidTank.getCapacity()- fluidTank.getFluid().amount) : 0}; case 6: - return new Object[] {hydrogenStored}; + return new Object[] {leftTank.getStored()}; case 7: - return new Object[] {MAX_GAS-hydrogenStored}; + return new Object[] {leftTank.getNeeded()}; case 8: - return new Object[] {oxygenStored}; + return new Object[] {rightTank.getStored()}; case 9: - return new Object[] {MAX_GAS-oxygenStored}; + return new Object[] {rightTank.getNeeded()}; default: System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID()); return new Object[] {"Unknown command."}; @@ -478,19 +529,19 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public boolean canTubeConnect(ForgeDirection side) { - return side == ForgeDirection.getOrientation(facing); + return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); } @Override public void setFluidStack(FluidStack fluidStack, Object... data) { - waterTank.setFluid(fluidStack); + fluidTank.setFluid(fluidStack); } @Override public FluidStack getFluidStack(Object... data) { - return waterTank.getFluid(); + return fluidTank.getFluid(); } @Override @@ -522,7 +573,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { if(resource.getFluid() == FluidRegistry.WATER) { - return waterTank.fill(resource, doFill); + return fluidTank.fill(resource, doFill); } return 0; @@ -537,6 +588,26 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[] {waterTank.getInfo()}; + return new FluidTankInfo[] {fluidTank.getInfo()}; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return 0; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return null; + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; } }