From cadd088f0be302398ff7668379c3a99fe6e2e54b Mon Sep 17 00:00:00 2001 From: Krapht Date: Thu, 5 Jul 2012 17:36:41 +0200 Subject: [PATCH] Fix NPE when worldObj is null while reading NBT --- .../src/buildcraft/factory/TileQuarry.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java index de4a9e73..ecae9845 100644 --- a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java +++ b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java @@ -70,6 +70,8 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I public @TileNetworkData PowerProvider powerProvider; public static int MAX_ENERGY = 7000; + + NBTTagCompound armStore = null; public TileQuarry() { @@ -95,7 +97,16 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I if (builderDone) { box.deleteLasers(); + + if (armStore != null){ + arm = new EntityMechanicalArm(worldObj); + arm.readFromNBT(armStore); + arm.listener = this; + loadArm = true; + armStore = null; + } + if (arm == null) { createArm(); } @@ -332,12 +343,7 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I targetZ = nbttagcompound.getInteger("targetZ"); if (nbttagcompound.getBoolean("hasArm")) { - NBTTagCompound armStore = nbttagcompound.getCompoundTag("arm"); - arm = new EntityMechanicalArm(worldObj); - arm.readFromNBT(armStore); - arm.listener = this; - - loadArm = true; + armStore = nbttagcompound.getCompoundTag("arm"); } }