diff --git a/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java b/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java index 8093c2fda..2dfb212fe 100644 --- a/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java +++ b/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java @@ -18,7 +18,7 @@ public class GuiAmbientAccumulator extends GuiMekanism public GuiAmbientAccumulator(EntityPlayer player, TileEntityAmbientAccumulator tile) { - super(new ContainerNull(player, tile)); + super(tile, new ContainerNull(player, tile)); tileEntity = tile; guiElements.add(new GuiGasGauge(new IGasInfoHandler() { diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java index 17381378a..402b98140 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java @@ -40,7 +40,7 @@ public class GuiDigitalMiner extends GuiMekanism public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) { - super(new ContainerDigitalMiner(inventory, tentity)); + super(tentity, new ContainerDigitalMiner(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java index 95759909b..8d0094119 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -58,7 +58,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism public GuiDigitalMinerConfig(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerNull(player, tentity)); + super(tentity, new ContainerNull(player, tentity)); tileEntity = tentity; } diff --git a/src/main/java/mekanism/client/gui/GuiDynamicTank.java b/src/main/java/mekanism/client/gui/GuiDynamicTank.java index 0e5d47845..117fed927 100644 --- a/src/main/java/mekanism/client/gui/GuiDynamicTank.java +++ b/src/main/java/mekanism/client/gui/GuiDynamicTank.java @@ -22,7 +22,7 @@ public class GuiDynamicTank extends GuiMekanism public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) { - super(new ContainerDynamicTank(inventory, tentity)); + super(tentity, new ContainerDynamicTank(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"))); } diff --git a/src/main/java/mekanism/client/gui/GuiElectricChest.java b/src/main/java/mekanism/client/gui/GuiElectricChest.java index 0bafd37fa..0f1c26b5a 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricChest.java +++ b/src/main/java/mekanism/client/gui/GuiElectricChest.java @@ -32,7 +32,7 @@ public class GuiElectricChest extends GuiMekanism public GuiElectricChest(InventoryPlayer inventory, TileEntityElectricChest tentity) { - super(new ContainerElectricChest(inventory, tentity, null, true)); + super(tentity, new ContainerElectricChest(inventory, tentity, null, true)); xSize+=26; ySize+=64; diff --git a/src/main/java/mekanism/client/gui/GuiElectricPump.java b/src/main/java/mekanism/client/gui/GuiElectricPump.java index feb84df06..725b3c376 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricPump.java +++ b/src/main/java/mekanism/client/gui/GuiElectricPump.java @@ -25,7 +25,7 @@ public class GuiElectricPump extends GuiMekanism public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) { - super(new ContainerElectricPump(inventory, tentity)); + super(tentity, new ContainerElectricPump(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); diff --git a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java index 9048b827f..ac5370bcc 100755 --- a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java @@ -35,7 +35,7 @@ public class GuiElectrolyticSeparator extends GuiMekanism public GuiElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) { - super(new ContainerElectrolyticSeparator(inventory, tentity)); + super(tentity, new ContainerElectrolyticSeparator(inventory, tentity)); tileEntity = tentity; diff --git a/src/main/java/mekanism/client/gui/GuiEnergyCube.java b/src/main/java/mekanism/client/gui/GuiEnergyCube.java index c6aeb260d..41e62ddf4 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergyCube.java +++ b/src/main/java/mekanism/client/gui/GuiEnergyCube.java @@ -26,7 +26,7 @@ public class GuiEnergyCube extends GuiMekanism public GuiEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube tentity) { - super(new ContainerEnergyCube(inventory, tentity)); + super(tentity, new ContainerEnergyCube(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() diff --git a/src/main/java/mekanism/client/gui/GuiEntangledBlock.java b/src/main/java/mekanism/client/gui/GuiEntangledBlock.java index ce51d18ef..b87a7b4eb 100644 --- a/src/main/java/mekanism/client/gui/GuiEntangledBlock.java +++ b/src/main/java/mekanism/client/gui/GuiEntangledBlock.java @@ -29,7 +29,7 @@ public class GuiEntangledBlock extends GuiMekanism public GuiEntangledBlock(InventoryPlayer inventory, TileEntityEntangledBlock tentity) { - super(new ContainerNull(inventory.player, tentity)); + super(tentity, new ContainerNull(inventory.player, tentity)); tileEntity = tentity; isCreative = inventory.player.capabilities.isCreativeMode; } diff --git a/src/main/java/mekanism/client/gui/GuiFluidGauge.java b/src/main/java/mekanism/client/gui/GuiFluidGauge.java index 6d56bef15..1cd46cf75 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidGauge.java +++ b/src/main/java/mekanism/client/gui/GuiFluidGauge.java @@ -11,6 +11,7 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; +import scala.actors.threadpool.Arrays; public class GuiFluidGauge extends GuiGauge { @@ -36,11 +37,11 @@ public class GuiFluidGauge extends GuiGauge { if(guiObj instanceof GuiMekanism) { - TileEntity tile = ((GuiMekanism)guiObj).tileEntity; + TileEntity tile = ((GuiMekanism)guiObj).getTileEntity(); if(tile instanceof IDropperHandler) { - int index = ((IDropperHandler)tile).getTankId(infoHandler.getTank()); + int index = Arrays.asList(((IDropperHandler)tile).getTanks()).indexOf(infoHandler.getTank()); if(index != -1) { diff --git a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java index accfcb071..fa6c66051 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java +++ b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java @@ -26,7 +26,7 @@ public class GuiFluidicPlenisher extends GuiMekanism public GuiFluidicPlenisher(InventoryPlayer inventory, TileEntityFluidicPlenisher tentity) { - super(new ContainerFluidicPlenisher(inventory, tentity)); + super(tentity, new ContainerFluidicPlenisher(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); diff --git a/src/main/java/mekanism/client/gui/GuiGasGauge.java b/src/main/java/mekanism/client/gui/GuiGasGauge.java index 3f226d473..8958c2afa 100644 --- a/src/main/java/mekanism/client/gui/GuiGasGauge.java +++ b/src/main/java/mekanism/client/gui/GuiGasGauge.java @@ -5,12 +5,12 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasTank; import mekanism.common.Mekanism; import mekanism.common.base.IDropperHandler; -import mekanism.common.base.IRedstoneControl.RedstoneControl; import mekanism.common.network.PacketDropperUse.DropperUseMessage; import mekanism.common.util.MekanismUtils; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import scala.actors.threadpool.Arrays; public class GuiGasGauge extends GuiGauge { @@ -34,16 +34,20 @@ public class GuiGasGauge extends GuiGauge @Override public void mouseClicked(int xAxis, int yAxis, int button) { + System.out.println("clicked"); if(guiObj instanceof GuiMekanism) { - TileEntity tile = ((GuiMekanism)guiObj).tileEntity; - + System.out.println("mekanism"); + TileEntity tile = ((GuiMekanism)guiObj).getTileEntity(); + System.out.println(tile); if(tile instanceof IDropperHandler) { - int index = ((IDropperHandler)tile).getTankId(infoHandler.getTank()); + System.out.println("handler"); + int index = Arrays.asList(((IDropperHandler)tile).getTanks()).indexOf(infoHandler.getTank()); if(index != -1) { + System.out.println("sending " + index); Mekanism.packetHandler.sendToServer(new DropperUseMessage(Coord4D.get(tile), button, index)); } } diff --git a/src/main/java/mekanism/client/gui/GuiGasTank.java b/src/main/java/mekanism/client/gui/GuiGasTank.java index a5b71582a..a2aa46de5 100644 --- a/src/main/java/mekanism/client/gui/GuiGasTank.java +++ b/src/main/java/mekanism/client/gui/GuiGasTank.java @@ -22,7 +22,7 @@ public class GuiGasTank extends GuiMekanism public GuiGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) { - super(new ContainerGasTank(inventory, tentity)); + super(tentity, new ContainerGasTank(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); } diff --git a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java index 413ed4eb2..0a2b4ddc7 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java +++ b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java @@ -33,7 +33,7 @@ public class GuiLaserAmplifier extends GuiMekanism public GuiLaserAmplifier(InventoryPlayer inventory, TileEntityLaserAmplifier tentity) { - super(new ContainerLaserAmplifier(inventory, tentity)); + super(tentity, new ContainerLaserAmplifier(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiNumberGauge(new INumberInfoHandler() diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index e33a865c8..a88a1361a 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -54,7 +54,7 @@ public class GuiLogisticalSorter extends GuiMekanism public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerNull(player, tentity)); + super(tentity, new ContainerNull(player, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png"))); } diff --git a/src/main/java/mekanism/client/gui/GuiMFilterSelect.java b/src/main/java/mekanism/client/gui/GuiMFilterSelect.java index 5e43be218..8274f30f7 100644 --- a/src/main/java/mekanism/client/gui/GuiMFilterSelect.java +++ b/src/main/java/mekanism/client/gui/GuiMFilterSelect.java @@ -24,7 +24,7 @@ public class GuiMFilterSelect extends GuiMekanism public GuiMFilterSelect(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerNull(player, tentity)); + super(tentity, new ContainerNull(player, tentity)); tileEntity = tentity; } diff --git a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java index 27222f60a..2c3aca6e1 100644 --- a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java @@ -44,7 +44,7 @@ public class GuiMItemStackFilter extends GuiMekanism public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MItemStackFilter)tileEntity.filters.get(index); @@ -53,7 +53,7 @@ public class GuiMItemStackFilter extends GuiMekanism public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java index 0e3cc652b..c413ad65e 100644 --- a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java @@ -44,7 +44,7 @@ public class GuiMMaterialFilter extends GuiMekanism public GuiMMaterialFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MMaterialFilter)tileEntity.filters.get(index); @@ -53,7 +53,7 @@ public class GuiMMaterialFilter extends GuiMekanism public GuiMMaterialFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java index 74ed4f43e..ab687fdbc 100644 --- a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java @@ -58,7 +58,7 @@ public class GuiMModIDFilter extends GuiMekanism public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MModIDFilter)tileEntity.filters.get(index); @@ -69,7 +69,7 @@ public class GuiMModIDFilter extends GuiMekanism public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java index e21032e33..39d3db2e0 100644 --- a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java @@ -58,7 +58,7 @@ public class GuiMOreDictFilter extends GuiMekanism public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MOreDictFilter)tileEntity.filters.get(index); @@ -69,7 +69,7 @@ public class GuiMOreDictFilter extends GuiMekanism public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index 29a73248b..5d929a4d7 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -23,7 +23,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { public Set guiElements = new HashSet(); - public TileEntityContainerBlock tileEntity; + private TileEntityContainerBlock tileEntity; public GuiMekanism(Container container) { @@ -77,6 +77,11 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper } } } + + public TileEntityContainerBlock getTileEntity() + { + return tileEntity; + } private SideData getFromSlot(Slot slot) { diff --git a/src/main/java/mekanism/client/gui/GuiPortableTank.java b/src/main/java/mekanism/client/gui/GuiPortableTank.java index ea33cc6ab..be9976b61 100644 --- a/src/main/java/mekanism/client/gui/GuiPortableTank.java +++ b/src/main/java/mekanism/client/gui/GuiPortableTank.java @@ -22,7 +22,7 @@ public class GuiPortableTank extends GuiMekanism public GuiPortableTank(InventoryPlayer inventory, TileEntityPortableTank tentity) { - super(new ContainerPortableTank(inventory, tentity)); + super(tentity, new ContainerPortableTank(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() diff --git a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java index ff52a574e..fc00b53b8 100644 --- a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -35,7 +35,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) { - super(new ContainerRotaryCondensentrator(inventory, tentity)); + super(tentity, new ContainerRotaryCondensentrator(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); diff --git a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java index 0a3b370ad..ae55a14aa 100644 --- a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java @@ -24,7 +24,7 @@ public class GuiSolarNeutronActivator extends GuiMekanism public GuiSolarNeutronActivator(InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity) { - super(new ContainerSolarNeutronActivator(inventory, tentity)); + super(tentity, new ContainerSolarNeutronActivator(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); diff --git a/src/main/java/mekanism/client/gui/GuiTFilterSelect.java b/src/main/java/mekanism/client/gui/GuiTFilterSelect.java index c381fd089..3946abaa9 100644 --- a/src/main/java/mekanism/client/gui/GuiTFilterSelect.java +++ b/src/main/java/mekanism/client/gui/GuiTFilterSelect.java @@ -24,7 +24,7 @@ public class GuiTFilterSelect extends GuiMekanism public GuiTFilterSelect(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerNull(player, tentity)); + super(tentity, new ContainerNull(player, tentity)); tileEntity = tentity; } diff --git a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java index d9d39044e..812c2ebdc 100644 --- a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java @@ -47,7 +47,7 @@ public class GuiTItemStackFilter extends GuiMekanism public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TItemStackFilter)tileEntity.filters.get(index); @@ -56,7 +56,7 @@ public class GuiTItemStackFilter extends GuiMekanism public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java index c935a59bf..096c124e1 100644 --- a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java @@ -46,7 +46,7 @@ public class GuiTMaterialFilter extends GuiMekanism public GuiTMaterialFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TMaterialFilter)tileEntity.filters.get(index); @@ -55,7 +55,7 @@ public class GuiTMaterialFilter extends GuiMekanism public GuiTMaterialFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java index a83806b6a..61c877146 100644 --- a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java @@ -57,7 +57,7 @@ public class GuiTModIDFilter extends GuiMekanism public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TModIDFilter)tileEntity.filters.get(index); @@ -68,7 +68,7 @@ public class GuiTModIDFilter extends GuiMekanism public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java index f75acef85..a17260fe8 100644 --- a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java @@ -57,7 +57,7 @@ public class GuiTOreDictFilter extends GuiMekanism public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TOreDictFilter)tileEntity.filters.get(index); @@ -68,7 +68,7 @@ public class GuiTOreDictFilter extends GuiMekanism public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory, tentity)); + super(tentity, new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index dc007e310..68780c280 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -24,7 +24,7 @@ public class GuiTeleporter extends GuiMekanism public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) { - super(new ContainerTeleporter(inventory, tentity)); + super(tentity, new ContainerTeleporter(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 164, 15)); diff --git a/src/main/java/mekanism/common/base/IDropperHandler.java b/src/main/java/mekanism/common/base/IDropperHandler.java index 6086ee18b..9ddb5ae01 100644 --- a/src/main/java/mekanism/common/base/IDropperHandler.java +++ b/src/main/java/mekanism/common/base/IDropperHandler.java @@ -1,10 +1,92 @@ package mekanism.common.base; +import mekanism.api.gas.GasStack; +import mekanism.api.gas.GasTank; +import mekanism.common.item.ItemGaugeDropper; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; public interface IDropperHandler { - public int getTankId(Object tank); + public Object[] getTanks(); - public void useDropper(EntityPlayer player, int tankId); -} + public static class DropperHandler + { + public static void useDropper(EntityPlayer player, Object tank, int button) + { + ItemStack stack = player.inventory.getItemStack(); + ItemGaugeDropper dropper = (ItemGaugeDropper)stack.getItem(); + + System.out.println("use dropper " + player + " " + tank + " " + button + " " + stack); + if(stack != null) + { + if(tank instanceof GasTank) + { + GasTank gasTank = (GasTank)tank; + int dropperStored = dropper.getGas(stack) != null ? dropper.getGas(stack).amount : 0; + + if(dropper.getGas(stack) != null && !dropper.getGas(stack).isGasEqual(gasTank.getGas())) + { + return; + } + + if(button == 0) //Insert gas into dropper + { + if(dropper.getFluid(stack) != null || gasTank.getGas() == null) + { + return; + } + + int toInsert = Math.min(gasTank.getStored(), ItemGaugeDropper.CAPACITY-dropperStored); + GasStack drawn = gasTank.draw(toInsert, true); + dropper.setGas(stack, new GasStack(gasTank.getGasType(), dropperStored+(drawn != null ? drawn.amount : 0))); + } + else { //Extract gas from dropper + if(dropper.getFluid(stack) != null || gasTank.getNeeded() == 0) + { + return; + } + + int toExtract = Math.min(gasTank.getNeeded(), dropperStored); + toExtract = gasTank.receive(new GasStack(dropper.getGas(stack).getGas(), toExtract), true); + dropper.setGas(stack, new GasStack(dropper.getGas(stack).getGas(), dropperStored-toExtract)); + } + } + else if(tank instanceof FluidTank) + { + FluidTank fluidTank = (FluidTank)tank; + int dropperStored = dropper.getFluid(stack) != null ? dropper.getFluid(stack).amount : 0; + + if(dropper.getFluid(stack) != null && !dropper.getFluid(stack).isFluidEqual(fluidTank.getFluid())) + { + return; + } + + if(button == 0) //Insert fluid into dropper + { + if(dropper.getGas(stack) != null || fluidTank.getFluid() == null) + { + return; + } + + int toInsert = Math.min(fluidTank.getFluidAmount(), ItemGaugeDropper.CAPACITY-dropperStored); + FluidStack drawn = fluidTank.drain(toInsert, true); + dropper.setFluid(stack, new FluidStack(fluidTank.getFluid().getFluid(), dropperStored+(drawn != null ? drawn.amount : 0))); + } + else { //Extract fluid from dropper + if(dropper.getGas(stack) != null || fluidTank.getCapacity()-fluidTank.getFluidAmount() == 0) + { + return; + } + + int toExtract = Math.min(fluidTank.getCapacity()-fluidTank.getFluidAmount(), dropperStored); + toExtract = fluidTank.fill(new FluidStack(dropper.getFluid(stack).getFluid(), toExtract), true); + dropper.setFluid(stack, new FluidStack(dropper.getFluid(stack).getFluid(), dropperStored-toExtract)); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketDropperUse.java b/src/main/java/mekanism/common/network/PacketDropperUse.java index 8eb7390fd..415dab2d1 100644 --- a/src/main/java/mekanism/common/network/PacketDropperUse.java +++ b/src/main/java/mekanism/common/network/PacketDropperUse.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; import mekanism.common.base.IDropperHandler; +import mekanism.common.base.IDropperHandler.DropperHandler; import mekanism.common.network.PacketDropperUse.DropperUseMessage; import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -20,7 +21,12 @@ public class PacketDropperUse implements IMessageHandler implements IFluidContainerManager { /** A client-sided and server-sided map of valves on this tank's structure, used on the client for rendering fluids. */ diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricPump.java b/src/main/java/mekanism/common/tile/TileEntityElectricPump.java index 7d3f212d4..e7da5639f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricPump.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricPump.java @@ -15,6 +15,7 @@ import mekanism.api.EnumColor; import mekanism.api.IConfigurable; import mekanism.api.MekanismConfig.usage; import mekanism.common.Upgrade; +import mekanism.common.base.IDropperHandler; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedTank; import mekanism.common.base.IUpgradeTile; @@ -39,7 +40,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile +public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile, IDropperHandler { /** This pump's tank */ public FluidTank fluidTank = new FluidTank(10000); @@ -512,4 +513,10 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { return upgradeComponent; } + + @Override + public Object[] getTanks() + { + return new Object[] {fluidTank}; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index 6ffdb5987..fdf883c7c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import java.util.List; import mekanism.api.Coord4D; import mekanism.api.Range4D; @@ -16,6 +17,8 @@ import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; import mekanism.common.Mekanism; import mekanism.common.Upgrade; +import mekanism.common.Upgrade.IUpgradeInfoHandler; +import mekanism.common.base.IDropperHandler; import mekanism.common.base.ISustainedData; import mekanism.common.base.IUpgradeTile; import mekanism.common.block.BlockMachine.MachineType; @@ -50,7 +53,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler, IUpgradeTile +public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler, IUpgradeTile, IUpgradeInfoHandler, IDropperHandler { /** This separator's water slot. */ public FluidTank fluidTank = new FluidTank(24000); @@ -710,4 +713,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); } } + + @Override + public List getInfo(Upgrade upgrade) + { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); + } + + @Override + public Object[] getTanks() + { + return new Object[] {fluidTank, leftTank, rightTank}; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index 935232f97..2bc9ac206 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -1,5 +1,7 @@ package mekanism.common.tile; +import io.netty.buffer.ByteBuf; + import java.util.ArrayList; import java.util.Map; @@ -13,6 +15,7 @@ import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; import mekanism.common.SideData; +import mekanism.common.base.IDropperHandler; import mekanism.common.base.ISustainedData; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.item.ItemUpgrade; @@ -26,7 +29,6 @@ import mekanism.common.util.ChargeUtils; import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.PipeUtils; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -39,14 +41,11 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import cpw.mods.fml.common.Optional.Method; - -import io.netty.buffer.ByteBuf; - import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData +public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData, IDropperHandler { public FluidTank inputFluidTank = new FluidTank(10000); public GasTank inputGasTank = new GasTank(10000); @@ -430,4 +429,10 @@ public class TileEntityPRC extends TileEntityBasicMachine