diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index a2e5de46e..308895ccb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; @@ -67,7 +68,10 @@ public final class PacketHandler{ if(tile instanceof IButtonReactor){ IButtonReactor reactor = (IButtonReactor)tile; - reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"))); + Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); + if(entity != null && entity instanceof EntityPlayer){ + reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity); + } } } }; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java index 9dfc862d9..3f39adf7e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java @@ -45,18 +45,20 @@ public class TileEntityGiantChest extends TileEntityInventoryBase implements IBu @Override public void onButtonPressed(int buttonID, EntityPlayer player){ - GuiHandler.GuiTypes type; + if(player != null && this.pos != null){ + GuiHandler.GuiTypes type; - if(buttonID == 0){ - type = GuiHandler.GuiTypes.GIANT_CHEST; - } - else if(buttonID == 1){ - type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2; - } - else{ - type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3; - } + if(buttonID == 0){ + type = GuiHandler.GuiTypes.GIANT_CHEST; + } + else if(buttonID == 1){ + type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2; + } + else{ + type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3; + } - player.openGui(ActuallyAdditions.instance, type.ordinal(), this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ()); + player.openGui(ActuallyAdditions.instance, type.ordinal(), this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ()); + } } }