Fixed a container bug that could have been driving some people nuts
This commit is contained in:
parent
9730bc261e
commit
7010f03b65
24 changed files with 70 additions and 44 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue