diff --git a/common/mekanism/api/gas/IGasHandler.java b/common/mekanism/api/gas/IGasHandler.java index 77abf4ca6..6abc06168 100644 --- a/common/mekanism/api/gas/IGasHandler.java +++ b/common/mekanism/api/gas/IGasHandler.java @@ -11,7 +11,7 @@ public interface IGasHandler { /** * Transfer a certain amount of gas to this block. - * @param amount - amount to transfer + * @param stack - gas to add * @return gas added */ public int receiveGas(ForgeDirection side, GasStack stack); diff --git a/common/mekanism/client/render/MekanismRenderer.java b/common/mekanism/client/render/MekanismRenderer.java index af33a5872..6e3dff7d5 100644 --- a/common/mekanism/client/render/MekanismRenderer.java +++ b/common/mekanism/client/render/MekanismRenderer.java @@ -68,6 +68,7 @@ public class MekanismRenderer GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen")); GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen")); GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:WaterVapor")); + GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:Chlorine")); GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurDioxide")); GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide")); GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid")); diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index d6ff320ae..ffcbd22f8 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -637,6 +637,7 @@ public class Mekanism //Electrolytic Separator Recipes RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), new ChemicalInput(new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1))); + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("lava", 10), new ChemicalInput(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1))); //Infuse objects InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); @@ -982,6 +983,7 @@ public class Mekanism GasRegistry.register(new Gas("hydrogen")).registerFluid(); GasRegistry.register(new Gas("oxygen")).registerFluid(); GasRegistry.register(new Gas("water")).registerFluid(); + GasRegistry.register(new Gas("chlorine")).registerFluid(); GasRegistry.register(new Gas("sulfurDioxideGas")).registerFluid(); GasRegistry.register(new Gas("sulfurTrioxideGas")).registerFluid(); GasRegistry.register(new Gas("sulfuricAcid")).registerFluid(); diff --git a/common/mekanism/common/RecipeHandler.java b/common/mekanism/common/RecipeHandler.java index d21ff06d0..2eb9718b7 100644 --- a/common/mekanism/common/RecipeHandler.java +++ b/common/mekanism/common/RecipeHandler.java @@ -347,12 +347,40 @@ public final class RecipeHandler return true; } } + if(entry.getKey() instanceof FluidStack) + { + if(((FluidStack)entry.getKey()).isFluidEqual(input)) + { + return true; + } + } } } return false; } + public boolean containsRecipe(Fluid input) + { + for(Object obj : get().entrySet()) + { + if(obj instanceof Map.Entry) + { + Map.Entry entry = (Map.Entry)obj; + + if(entry.getKey() instanceof FluidStack) + { + if(((FluidStack)entry.getKey()).getFluid() == input) + { + return true; + } + } + } + } + + return false; + } + public HashMap get() { return recipes; diff --git a/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java b/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java index 042bfef60..948c639ef 100644 --- a/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java +++ b/common/mekanism/generators/client/gui/GuiElectrolyticSeparator.java @@ -1,6 +1,10 @@ package mekanism.generators.client.gui; +import mekanism.api.Coord4D; import mekanism.api.gas.Gas; +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; @@ -13,6 +17,8 @@ import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; + @SideOnly(Side.CLIENT) public class GuiElectrolyticSeparator extends GuiContainer { @@ -32,55 +38,23 @@ public class GuiElectrolyticSeparator extends GuiContainer int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) + if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) { - Gas gasToSet = null; - /* - if(tileEntity.outputType == GasRegistry.getGas("hydrogen")) - { - gasToSet = GasRegistry.getGas("oxygen"); - } - else if(tileEntity.outputType == GasRegistry.getGas("oxygen")) - { - gasToSet = null; - } - else if(tileEntity.outputType == null) - { - gasToSet = GasRegistry.getGas("hydrogen"); - } - ArrayList data = new ArrayList(); data.add((byte)0); - data.add(GasRegistry.getGasID(gasToSet)); - + 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) + else if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { - Gas gasToSet = null; - /* - if(tileEntity.dumpType == null) - { - gasToSet = GasRegistry.getGas("oxygen"); - } - else if(tileEntity.dumpType == GasRegistry.getGas("oxygen")) - { - gasToSet = GasRegistry.getGas("hydrogen"); - } - else if(tileEntity.dumpType == GasRegistry.getGas("hydrogen")) - { - gasToSet = null; - } - ArrayList data = new ArrayList(); data.add((byte)1); - data.add(GasRegistry.getGasID(gasToSet)); PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - */ + } } @@ -91,10 +65,24 @@ public class GuiElectrolyticSeparator extends GuiContainer int yAxis = (mouseY - (height - ySize) / 2); fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("gui.output"), 124, 73, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("gui.electrolyticSeparator.dump"), 21, 73, 0x404040); - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + String name = tileEntity.leftTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.leftTank.getGas().getGas().getLocalizedName(); + fontRenderer.drawString(name, 21, 73, 0x404040); + name = tileEntity.rightTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.rightTank.getGas().getGas().getLocalizedName(); + fontRenderer.drawString(name, 152-(name.length()*5), 73, 0x404040); + + if(xAxis >= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) + { + drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluidAmount() + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis); + } + if(xAxis >= 65 && xAxis <= 69 && yAxis >= 17 && yAxis <= 48) + { + drawCreativeTabHoveringText(tileEntity.leftTank.getGas() != null ? tileEntity.leftTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.leftTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); + } + if(xAxis >= 107 && xAxis <= 111 && yAxis >= 17 && yAxis <= 48) + { + drawCreativeTabHoveringText(tileEntity.rightTank.getGas() != null ? tileEntity.rightTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.rightTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); + } + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } @@ -109,11 +97,11 @@ public class GuiElectrolyticSeparator extends GuiContainer int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - 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 leftDisplay = tileEntity.dumpLeft ? 90 : 82; + drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, leftDisplay, 8, 8); - 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 rightDisplay = tileEntity.dumpRight ? 90 : 82; + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, rightDisplay, 8, 8); int displayInt; diff --git a/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java b/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java index ffe2065e6..797767718 100644 --- a/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java +++ b/common/mekanism/generators/client/render/RenderElectrolyticSeparator.java @@ -32,10 +32,10 @@ public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer switch(tileEntity.facing) { - case 2: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; + case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; + case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; } GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); diff --git a/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java b/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java index fe8e5482f..cdc94d06d 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java @@ -2,6 +2,7 @@ package mekanism.generators.common.inventory.container; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.IGasItem; +import mekanism.common.RecipeHandler; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotStorageTank; import mekanism.common.util.ChargeUtils; @@ -23,8 +24,8 @@ public class ContainerElectrolyticSeparator extends Container { tileEntity = tentity; addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotStorageTank(tentity, GasRegistry.getGas("hydrogen"), false, 1, 59, 52)); - addSlotToContainer(new SlotStorageTank(tentity, GasRegistry.getGas("oxygen"), false, 2, 101, 52)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 59, 52)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 101, 52)); addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35)); int slotX; @@ -73,7 +74,7 @@ public class ContainerElectrolyticSeparator extends Container if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { - if(isWater(slotStack)) + if(isCorrectFluid(slotStack)) { if(!mergeItemStack(slotStack, 0, 1, false)) { @@ -166,18 +167,8 @@ public class ContainerElectrolyticSeparator extends Container return stack; } - public boolean isWater(ItemStack itemStack) + public boolean isCorrectFluid(ItemStack itemStack) { - FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(itemStack); - - if(fluid != null) - { - if(fluid.getFluid() == FluidRegistry.WATER) - { - return true; - } - } - - return false; + return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemStack); } } diff --git a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java index 9f67aa3f4..e575bb931 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java @@ -72,13 +72,12 @@ 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(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0])) { - if(fluidTank.getFluid() == null || fluidTank.getFluid().amount+fluid.amount <= fluidTank.getCapacity()) + FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); + if(fluidTank.getFluid() == null || fluid.isFluidEqual(fluidTank.getFluid()) && fluidTank.getFluid().amount+fluid.amount <= fluidTank.getCapacity()) { fluidTank.fill(fluid, true); @@ -96,7 +95,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } } } - }*/ + } if(!worldObj.isRemote) { @@ -256,7 +255,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { if(slotID == 0) { - return FluidContainerRegistry.getFluidForFilledItem(itemstack) != null && FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluid() == FluidRegistry.WATER; + return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemstack); } else if(slotID == 1) { @@ -338,11 +337,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(type == 0) { - dumpLeft = dataStream.readBoolean(); + dumpLeft ^= true; } else if(type == 1) { - dumpRight = dataStream.readBoolean(); + dumpRight ^= true; } return; @@ -559,7 +558,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public boolean canFill(ForgeDirection from, Fluid fluid) { - return fluid == FluidRegistry.WATER; + return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid); } @Override @@ -571,7 +570,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - if(resource.getFluid() == FluidRegistry.WATER) + if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid())) { return fluidTank.fill(resource, doFill); } @@ -598,6 +597,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public GasStack drawGas(ForgeDirection side, int amount) { + if(side == MekanismUtils.getLeft(facing)) + { + return leftTank.draw(amount, true); + } + else if(side == MekanismUtils.getRight(facing)) + { + return rightTank.draw(amount, true); + } return null; } @@ -608,6 +615,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp @Override public boolean canDrawGas(ForgeDirection side, Gas type) { + if(side == MekanismUtils.getLeft(facing)) + { + return leftTank.getGas() != null && leftTank.getGas().getGas() == type; + } + + if(side == MekanismUtils.getRight(facing)) + { + return rightTank.getGas() != null && rightTank.getGas().getGas() == type; + } + return false; } } diff --git a/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png b/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png index 80cae4b02..4fa5a7392 100644 Binary files a/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png and b/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png differ diff --git a/resources/assets/mekanism/lang/en_US.lang b/resources/assets/mekanism/lang/en_US.lang index a79f6504a..712cba6e4 100644 --- a/resources/assets/mekanism/lang/en_US.lang +++ b/resources/assets/mekanism/lang/en_US.lang @@ -153,6 +153,7 @@ item.tinIngot.name=Tin Ingot gas.hydrogen=Hydrogen gas.oxygen=Oxygen gas.water=Water Vapor +gas.chlorine=Chlorine gas.sulfurDioxideGas=Sulfur Dioxide gas.sulfurTrioxideGas=Sulfur Trioxide gas.sulfuricAcid=Sulfuric Acid @@ -160,6 +161,7 @@ gas.sulfuricAcid=Sulfuric Acid //Fluids fluid.hydrogen=Liquid Hydrogen fluid.oxygen=Liquid Oxygen +fluid.chlorine=Liquid Chlorine fluid.sulfurDioxideGas=Liquid Sulfur Dioxide fluid.sulfurTrioxideGas=Liquid Sulfur Trioxide fluid.sulfuricAcid=Liquid Sulfuric Acid diff --git a/resources/assets/mekanism/textures/blocks/Chlorine.png b/resources/assets/mekanism/textures/blocks/Chlorine.png new file mode 100644 index 000000000..8ace07917 Binary files /dev/null and b/resources/assets/mekanism/textures/blocks/Chlorine.png differ diff --git a/resources/assets/mekanism/textures/blocks/Chlorine.png.mcmeta b/resources/assets/mekanism/textures/blocks/Chlorine.png.mcmeta new file mode 100644 index 000000000..4b721e09a --- /dev/null +++ b/resources/assets/mekanism/textures/blocks/Chlorine.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +}