diff --git a/src/main/java/cam72cam/immersiverailroading/blocks/BlockRail.java b/src/main/java/cam72cam/immersiverailroading/blocks/BlockRail.java index f45935768..75dcff126 100644 --- a/src/main/java/cam72cam/immersiverailroading/blocks/BlockRail.java +++ b/src/main/java/cam72cam/immersiverailroading/blocks/BlockRail.java @@ -33,7 +33,7 @@ public BlockRail() { @Override public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { TileRail tileEntity = (TileRail) world.getTileEntity(pos); - if (tileEntity != null) { + if (tileEntity != null && tileEntity.getType() != null) { ItemStack stack = new ItemStack(this, 1, tileEntity.getType().getMeta()); ItemRail.setLength(stack, tileEntity.getLength()); drops.add(stack); diff --git a/src/main/java/cam72cam/immersiverailroading/tile/TileRail.java b/src/main/java/cam72cam/immersiverailroading/tile/TileRail.java index 6bf491a40..cbc52e446 100644 --- a/src/main/java/cam72cam/immersiverailroading/tile/TileRail.java +++ b/src/main/java/cam72cam/immersiverailroading/tile/TileRail.java @@ -151,6 +151,11 @@ public void readFromNBT(NBTTagCompound nbt) { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + if (facing == null) { + // Something is wrong... + ImmersiveRailroading.logger.error("INVALID TILE SAVE"); + return super.writeToNBT(nbt); + } nbt.setByte("facing", (byte) facing.getIndex()); nbt.setString("type", type.name());