Fixed a container bug that could have been driving some people nuts

This commit is contained in:
Aidan C. Brady 2013-12-25 00:50:23 -05:00
parent 9730bc261e
commit 7010f03b65
24 changed files with 70 additions and 44 deletions

View file

@ -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;

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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 {

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -29,6 +29,8 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
public int clientFacing;
public Set<EntityPlayer> openedThisTick = new HashSet<EntityPlayer>();
/** The players currently using this block. */
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
@ -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)
{

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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