diff --git a/common/buildcraft/core/RFBattery.java b/common/buildcraft/core/RFBattery.java index eefbc857..f8c21ea0 100644 --- a/common/buildcraft/core/RFBattery.java +++ b/common/buildcraft/core/RFBattery.java @@ -14,10 +14,12 @@ public class RFBattery implements IEnergyStorage { } public void readFromNBT(NBTTagCompound tag) { - this.energy = tag.getInteger("energy"); - this.maxEnergy = tag.getInteger("maxEnergy"); - this.maxReceive = tag.getInteger("maxReceive"); - this.maxExtract = tag.getInteger("maxExtract"); + if (tag.hasKey("energy") && tag.hasKey("maxEnergy") && tag.hasKey("maxReceive") && tag.hasKey("maxExtract")) { + this.energy = tag.getInteger("energy"); + this.maxEnergy = tag.getInteger("maxEnergy"); + this.maxReceive = tag.getInteger("maxReceive"); + this.maxExtract = tag.getInteger("maxExtract"); + } } public void writeToNBT(NBTTagCompound tag) { diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index 5ad63044..ba4d77ad 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -22,8 +22,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyHandler; - import buildcraft.BuildCraftCore; import buildcraft.api.power.IPowerReceptor; import buildcraft.core.network.BuildCraftPacket; @@ -34,6 +32,8 @@ import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.utils.Utils; +import cofh.api.energy.IEnergyHandler; + public abstract class TileBuildCraft extends TileEntity implements ISynchronizedTile, IEnergyHandler { @SuppressWarnings("rawtypes") private static Map updateWrappers = new HashMap(); @@ -147,7 +147,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized if (nbt.hasKey("owner")) { owner = nbt.getString("owner"); } - if (battery != null) { + if (battery != null && nbt.hasKey("battery")) { battery.readFromNBT(nbt.getCompoundTag("battery")); } }