diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 4ea769949..065897253 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -26,6 +26,7 @@ import mekanism.common.network.PacketElectricChest; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.network.PacketLogisticalSorterGui; import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket; +import mekanism.common.network.PacketSimpleGui; import mekanism.common.tileentity.TileEntityAdvancedFactory; import mekanism.common.tileentity.TileEntityBasicBlock; import mekanism.common.tileentity.TileEntityChargepad; diff --git a/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index 28510acc1..2ac55ef4a 100644 --- a/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -44,7 +44,7 @@ public class ContainerAdvancedElectricMachine extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -53,7 +53,7 @@ public class ContainerAdvancedElectricMachine extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalFormulator.java b/common/mekanism/common/inventory/container/ContainerChemicalFormulator.java index 6a7ca250c..1c732cafb 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalFormulator.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalFormulator.java @@ -38,7 +38,7 @@ public class ContainerChemicalFormulator extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -47,7 +47,7 @@ public class ContainerChemicalFormulator extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java b/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java index decfd139e..cd094db1e 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java @@ -39,7 +39,7 @@ public class ContainerChemicalInfuser extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -48,7 +48,7 @@ public class ContainerChemicalInfuser extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java index 668473a8f..f54af2af3 100644 --- a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -47,7 +47,7 @@ public class ContainerDigitalMiner extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -56,7 +56,7 @@ public class ContainerDigitalMiner extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerDynamicTank.java b/common/mekanism/common/inventory/container/ContainerDynamicTank.java index 31b583fcd..62b8312eb 100644 --- a/common/mekanism/common/inventory/container/ContainerDynamicTank.java +++ b/common/mekanism/common/inventory/container/ContainerDynamicTank.java @@ -33,7 +33,7 @@ public class ContainerDynamicTank extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -42,7 +42,7 @@ public class ContainerDynamicTank extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerElectricChest.java b/common/mekanism/common/inventory/container/ContainerElectricChest.java index f549d4129..4a2ee33e2 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricChest.java +++ b/common/mekanism/common/inventory/container/ContainerElectricChest.java @@ -27,7 +27,7 @@ public class ContainerElectricChest extends Container if(isBlock) { - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } else { @@ -78,7 +78,7 @@ public class ContainerElectricChest extends Container if(isBlock) { - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } else { diff --git a/common/mekanism/common/inventory/container/ContainerElectricMachine.java b/common/mekanism/common/inventory/container/ContainerElectricMachine.java index 2b65d2cd2..070e50e3c 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricMachine.java +++ b/common/mekanism/common/inventory/container/ContainerElectricMachine.java @@ -39,7 +39,7 @@ public class ContainerElectricMachine extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -48,7 +48,7 @@ public class ContainerElectricMachine extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerElectricPump.java b/common/mekanism/common/inventory/container/ContainerElectricPump.java index 4f2b45fd9..6b2ca55be 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricPump.java +++ b/common/mekanism/common/inventory/container/ContainerElectricPump.java @@ -36,7 +36,7 @@ public class ContainerElectricPump extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -45,7 +45,7 @@ public class ContainerElectricPump extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerEnergyCube.java b/common/mekanism/common/inventory/container/ContainerEnergyCube.java index 122dca960..cfe89ee76 100644 --- a/common/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/common/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -37,7 +37,7 @@ public class ContainerEnergyCube extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -46,7 +46,7 @@ public class ContainerEnergyCube extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerFactory.java b/common/mekanism/common/inventory/container/ContainerFactory.java index 1f2f785a0..ab761a908 100644 --- a/common/mekanism/common/inventory/container/ContainerFactory.java +++ b/common/mekanism/common/inventory/container/ContainerFactory.java @@ -95,7 +95,7 @@ public class ContainerFactory extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -104,7 +104,7 @@ public class ContainerFactory extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerFilter.java b/common/mekanism/common/inventory/container/ContainerFilter.java index 75996eb9e..e2c83c443 100644 --- a/common/mekanism/common/inventory/container/ContainerFilter.java +++ b/common/mekanism/common/inventory/container/ContainerFilter.java @@ -30,7 +30,7 @@ public class ContainerFilter extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -39,7 +39,7 @@ public class ContainerFilter extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerGasTank.java b/common/mekanism/common/inventory/container/ContainerGasTank.java index 4ec1c489f..e22f6dadb 100644 --- a/common/mekanism/common/inventory/container/ContainerGasTank.java +++ b/common/mekanism/common/inventory/container/ContainerGasTank.java @@ -34,7 +34,7 @@ public class ContainerGasTank extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -43,7 +43,7 @@ public class ContainerGasTank extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index 2b42c151b..46eb0aa63 100644 --- a/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -43,7 +43,7 @@ public class ContainerMetallurgicInfuser extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -52,7 +52,7 @@ public class ContainerMetallurgicInfuser extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerNull.java b/common/mekanism/common/inventory/container/ContainerNull.java index 826787796..1697c173e 100644 --- a/common/mekanism/common/inventory/container/ContainerNull.java +++ b/common/mekanism/common/inventory/container/ContainerNull.java @@ -12,7 +12,7 @@ public class ContainerNull extends Container { tileEntity = tile; - tileEntity.playersUsing.add(player); + tileEntity.open(player); tileEntity.openChest(); } @@ -21,7 +21,7 @@ public class ContainerNull extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java b/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java index ad75d0011..6b234c5eb 100644 --- a/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java +++ b/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java @@ -41,7 +41,7 @@ public class ContainerRotaryCondensentrator extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -50,7 +50,7 @@ public class ContainerRotaryCondensentrator extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/inventory/container/ContainerTeleporter.java b/common/mekanism/common/inventory/container/ContainerTeleporter.java index 31e78a478..2820608d2 100644 --- a/common/mekanism/common/inventory/container/ContainerTeleporter.java +++ b/common/mekanism/common/inventory/container/ContainerTeleporter.java @@ -32,7 +32,7 @@ public class ContainerTeleporter extends Container addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); tileEntity.openChest(); } @@ -41,7 +41,7 @@ public class ContainerTeleporter extends Container { super.onContainerClosed(entityplayer); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); tileEntity.closeChest(); } diff --git a/common/mekanism/common/tileentity/TileEntityBasicBlock.java b/common/mekanism/common/tileentity/TileEntityBasicBlock.java index 7a71de4c7..2135392c4 100644 --- a/common/mekanism/common/tileentity/TileEntityBasicBlock.java +++ b/common/mekanism/common/tileentity/TileEntityBasicBlock.java @@ -29,6 +29,8 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench public int clientFacing; + public Set openedThisTick = new HashSet(); + /** The players currently using this block. */ public Set playersUsing = new HashSet(); @@ -53,6 +55,8 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench if(!worldObj.isRemote) { + openedThisTick.clear(); + if(doAutoSync && playersUsing.size() > 0) { for(EntityPlayer player : playersUsing) @@ -65,6 +69,22 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench ticker++; } + public void open(EntityPlayer player) + { + openedThisTick.add(player); + playersUsing.add(player); + } + + public void close(EntityPlayer player) + { + if(!openedThisTick.contains(player)) + { + playersUsing.remove(player); + } + + openedThisTick.remove(player); + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { diff --git a/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java index 10a28e2cd..f4e371959 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java @@ -36,15 +36,16 @@ public class ContainerBioGenerator extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override diff --git a/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java b/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java index bd0c87215..fe8e5482f 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerElectrolyticSeparator.java @@ -42,15 +42,16 @@ public class ContainerElectrolyticSeparator extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override diff --git a/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java index ab40b1532..e3c3203e8 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java @@ -34,15 +34,16 @@ public class ContainerHeatGenerator extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override diff --git a/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java index c5f13acf9..f8862e0f1 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java @@ -36,7 +36,7 @@ public class ContainerHydrogenGenerator extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override @@ -44,7 +44,7 @@ public class ContainerHydrogenGenerator extends Container { super.onContainerClosed(entityplayer); tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override diff --git a/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java index cc36883b1..538d8d9c8 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java @@ -33,15 +33,16 @@ public class ContainerSolarGenerator extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override diff --git a/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java b/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java index 63d6eaf2d..802d1e445 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java +++ b/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java @@ -33,15 +33,16 @@ public class ContainerWindTurbine extends Container } tileEntity.openChest(); - tileEntity.playersUsing.add(inventory.player); + tileEntity.open(inventory.player); } @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); - tileEntity.playersUsing.remove(entityplayer); + tileEntity.close(entityplayer); } @Override