diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java index 4de68096f..1db83d73d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java @@ -76,7 +76,10 @@ public class BlockGiantChest extends BlockContainerBase{ ItemStack[] slots = ((TileEntityGiantChest)tile).slots; for(int i = 0; i < list.tagCount(); i++){ - slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); + NBTTagCompound compound = list.getCompoundTagAt(i); + if(compound != null && compound.hasKey("id")){ + slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java index 55bb2f803..9e6e74a1a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java @@ -48,10 +48,16 @@ public class WorldData{ int dim = world.provider.getDimension(); WorldData data = worldData.get(dim); - if(data == null && world.isRemote){ + if(data == null){ data = new WorldData(null, dim); - worldData.put(dim, data); - ModUtil.LOGGER.info("Creating temporary WorldData for world "+dim+" on the client!"); + + if(world.isRemote){ + worldData.put(dim, data); + ModUtil.LOGGER.info("Creating temporary WorldData for world "+dim+" on the client!"); + } + else{ + ModUtil.LOGGER.warn("Trying to get WorldData from world "+dim+" that doesn't have any data!? This shouldn't happen!"); + } } return data; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 67571056e..51fdcc0c8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -59,9 +59,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements NBTTagList tagList = compound.getTagList("Items", 10); for(int i = 0; i < tagList.tagCount(); i++){ NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - byte slotIndex = tagCompound.getByte("Slot"); - if(slotIndex >= 0 && slotIndex < slots.length){ - slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + if(tagCompound != null && tagCompound.hasKey("id")){ + byte slotIndex = tagCompound.getByte("Slot"); + if(slotIndex >= 0 && slotIndex < slots.length){ + slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index e602a1df8..0053ffd40 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -340,8 +340,16 @@ public class WorldUtil{ * @return If the Block could be harvested normally (so that it drops an item) */ public static boolean playerHarvestBlock(World world, BlockPos pos, EntityPlayer player){ - Block block = PosUtil.getBlock(pos, world); IBlockState state = world.getBlockState(pos); + if(state == null){ + return false; + } + + Block block = state.getBlock(); + if(block == null){ + return false; + } + TileEntity tile = world.getTileEntity(pos); ItemStack stack = player.getHeldItemMainhand(); @@ -351,7 +359,8 @@ public class WorldUtil{ //Send Block Breaking Event int xp = -1; if(player instanceof EntityPlayerMP){ - xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)player).interactionManager.getGameType(), (EntityPlayerMP)player, pos); + EntityPlayerMP playerMP = (EntityPlayerMP)player; + xp = ForgeHooks.onBlockBreakEvent(world, playerMP.interactionManager.getGameType(), playerMP, pos); if(xp == -1){ return false; } @@ -397,6 +406,7 @@ public class WorldUtil{ //Check the Server if a Block that changed on the Client really changed, if not, revert the change Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit)); } + return removed; } }