Attempts to fix server-side crash.
This commit is contained in:
parent
2a54ef6765
commit
918264d1c1
8 changed files with 79 additions and 52 deletions
|
@ -3,6 +3,8 @@ package mekanism.client;
|
|||
|
||||
import mekanism.common.CommonProxy;
|
||||
import mekanism.common.EntityObsidianTNT;
|
||||
import mekanism.common.IElectricChest;
|
||||
import mekanism.common.InventoryElectricChest;
|
||||
import mekanism.common.ItemPortableTeleporter;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.TileEntityAdvancedElectricMachine;
|
||||
|
@ -56,6 +58,59 @@ public class ClientProxy extends CommonProxy
|
|||
return RenderingRegistry.addNewArmourRendererPrefix(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z)
|
||||
{
|
||||
TileEntityElectricChest tileEntity = (TileEntityElectricChest)entityplayer.worldObj.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(id == 0)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, tileEntity));
|
||||
entityplayer.openContainer.windowId = windowId;
|
||||
}
|
||||
else {
|
||||
FMLClientHandler.instance().getClient().sndManager.playSoundFX("random.chestopen", 1.0F, 1.0F);
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
InventoryElectricChest inventory = new InventoryElectricChest(stack);
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory));
|
||||
entityplayer.openContainer.windowId = windowId;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == 1)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(tileEntity));
|
||||
}
|
||||
else {
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == 2)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(tileEntity));
|
||||
}
|
||||
else {
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSpecialTileEntities()
|
||||
{
|
||||
|
|
|
@ -15,15 +15,18 @@ public interface IHasSound
|
|||
* Gets the sound.
|
||||
* @return sound
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Sound getSound();
|
||||
|
||||
/**
|
||||
* Removes the sound;
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeSound();
|
||||
|
||||
/**
|
||||
* Ticks and updates the block's sound.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateSound();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,18 @@ public class CommonProxy
|
|||
GameRegistry.registerTileEntity(TileEntityElectricChest.class, "ElectricChest");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an ELECTRIC_CHEST_CLIENT_OPEN packet via the proxy, not handled on the server-side.
|
||||
* @param entityplayer - player the packet was sent from
|
||||
* @param id - the electric chest gui ID to open
|
||||
* @param windowId - the container-specific window ID
|
||||
* @param isBlock - if the chest is a block
|
||||
* @param x - x coordinate
|
||||
* @param y - y coordinate
|
||||
* @param z - z coordinate
|
||||
*/
|
||||
public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) {}
|
||||
|
||||
/**
|
||||
* Register and load client-only render information.
|
||||
*/
|
||||
|
|
|
@ -9,9 +9,6 @@ import java.util.Random;
|
|||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
|
||||
import mekanism.client.GuiElectricChest;
|
||||
import mekanism.client.GuiPasswordEnter;
|
||||
import mekanism.client.GuiPasswordModify;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -23,7 +20,6 @@ import net.minecraft.world.World;
|
|||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
@ -328,54 +324,7 @@ public class PacketHandler implements IPacketHandler
|
|||
z = dataStream.readInt();
|
||||
}
|
||||
|
||||
TileEntityElectricChest tileEntity = (TileEntityElectricChest)entityplayer.worldObj.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(id == 0)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, tileEntity));
|
||||
entityplayer.openContainer.windowId = windowId;
|
||||
}
|
||||
else {
|
||||
FMLClientHandler.instance().getClient().sndManager.playSoundFX("random.chestopen", 1.0F, 1.0F);
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
InventoryElectricChest inventory = new InventoryElectricChest(stack);
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory));
|
||||
entityplayer.openContainer.windowId = windowId;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == 1)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(tileEntity));
|
||||
}
|
||||
else {
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == 2)
|
||||
{
|
||||
if(isBlock)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(tileEntity));
|
||||
}
|
||||
else {
|
||||
ItemStack stack = entityplayer.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof IElectricChest && ((IElectricChest)stack.getItem()).isElectricChest(stack))
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
Mekanism.proxy.openElectricChest(entityplayer, id, windowId, isBlock, x, y, z);
|
||||
} catch(Exception e) {
|
||||
System.err.println("[Mekanism] Error while handling electric chest open packet.");
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -419,12 +419,14 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Sound getSound()
|
||||
{
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeSound()
|
||||
{
|
||||
audio = null;
|
||||
|
|
|
@ -765,12 +765,14 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Sound getSound()
|
||||
{
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeSound()
|
||||
{
|
||||
audio = null;
|
||||
|
|
|
@ -691,12 +691,14 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Sound getSound()
|
||||
{
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeSound()
|
||||
{
|
||||
audio = null;
|
||||
|
|
|
@ -379,12 +379,14 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Sound getSound()
|
||||
{
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeSound()
|
||||
{
|
||||
audio = null;
|
||||
|
|
Loading…
Reference in a new issue