if(message.packetType == ElectricChestPacketType.SERVER_OPEN)
{
try {
if(message.isBlock)
{
TileEntityElectricChest tileEntity = (TileEntityElectricChest)message.coord4D.getTileEntity(player.worldObj);
if(message.useEnergy)
{
tileEntity.setEnergy(tileEntity.getEnergy() - 100);
}
MekanismUtils.openElectricChestGui((EntityPlayerMP)player, tileEntity, null, true);
}
else {
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST)
{
if(message.useEnergy)
{
((IEnergizedItem)stack.getItem()).setEnergy(stack, ((IEnergizedItem)stack.getItem()).getEnergy(stack) - 100);
}
InventoryElectricChest inventory = new InventoryElectricChest(player);
MekanismUtils.openElectricChestGui((EntityPlayerMP)player, null, inventory, false);
}
}
} catch(Exception e) {
Mekanism.logger.error("Error while handling electric chest open packet.");
e.printStackTrace();
}
}
else if(message.packetType == ElectricChestPacketType.CLIENT_OPEN)
{
try {
int x = message.coord4D != null ? message.coord4D.xCoord : 0;
int y = message.coord4D != null ? message.coord4D.yCoord : 0;
int z = message.coord4D != null ? message.coord4D.zCoord : 0;
Mekanism.proxy.openElectricChest(player, message.guiType, message.windowId, message.isBlock, x, y, z);
} catch(Exception e) {
Mekanism.logger.error("Error while handling electric chest open packet.");
e.printStackTrace();
}
}
else if(message.packetType == ElectricChestPacketType.PASSWORD)
{
try {
if(message.isBlock)
{
TileEntityElectricChest tileEntity = (TileEntityElectricChest)message.coord4D.getTileEntity(player.worldObj);
tileEntity.password = message.password;
tileEntity.authenticated = true;
}
else {
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST)
{
((IElectricChest)stack.getItem()).setPassword(stack, message.password);
((IElectricChest)stack.getItem()).setAuthenticated(stack, true);
}
}
} catch(Exception e) {
Mekanism.logger.error("Error while handling electric chest password packet.");
e.printStackTrace();
}
}
else if(message.packetType == ElectricChestPacketType.LOCK)
{
try {
if(message.isBlock)
{
TileEntityElectricChest tileEntity = (TileEntityElectricChest)message.coord4D.getTileEntity(player.worldObj);
tileEntity.locked = message.locked;
player.worldObj.notifyBlocksOfNeighborChange(message.coord4D.xCoord,message.coord4D.yCoord,message.coord4D.zCoord,Mekanism.MachineBlock);
}
else {
ItemStack stack = player.getCurrentEquippedItem();