fix MJ->RF migration with blocks that where already in the world
This commit is contained in:
parent
1ef8640417
commit
5e526416c4
2 changed files with 9 additions and 7 deletions
|
@ -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) {
|
||||
|
|
|
@ -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<Class, TilePacketWrapper> updateWrappers = new HashMap<Class, TilePacketWrapper>();
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue