fixed RF battery save / load
This commit is contained in:
parent
fd8d8531a1
commit
b268433b4c
4 changed files with 21 additions and 20 deletions
|
@ -14,23 +14,17 @@ public class RFBattery implements IEnergyStorage {
|
|||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
if (!(tag.hasKey("battery"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound battery = tag.getCompoundTag("battery");
|
||||
this.energy = battery.getInteger("energy");
|
||||
this.maxEnergy = battery.getInteger("maxEnergy");
|
||||
this.maxReceive = battery.getInteger("maxReceive");
|
||||
this.maxExtract = battery.getInteger("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) {
|
||||
NBTTagCompound battery = new NBTTagCompound();
|
||||
battery.setInteger("energy", this.energy);
|
||||
battery.setInteger("maxEnergy", this.maxEnergy);
|
||||
battery.setInteger("maxReceive", this.maxReceive);
|
||||
battery.setInteger("maxExtract", this.maxExtract);
|
||||
tag.setInteger("energy", this.energy);
|
||||
tag.setInteger("maxEnergy", this.maxEnergy);
|
||||
tag.setInteger("maxReceive", this.maxReceive);
|
||||
tag.setInteger("maxExtract", this.maxExtract);
|
||||
}
|
||||
|
||||
public int addEnergy(int minReceive, int maxReceive, boolean simulate) {
|
||||
|
|
|
@ -135,7 +135,9 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
super.writeToNBT(nbt);
|
||||
nbt.setString("owner", owner);
|
||||
if (battery != null) {
|
||||
battery.writeToNBT(nbt);
|
||||
NBTTagCompound batteryNBT = new NBTTagCompound();
|
||||
battery.writeToNBT(batteryNBT);
|
||||
nbt.setTag("battery", batteryNBT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +148,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
owner = nbt.getString("owner");
|
||||
}
|
||||
if (battery != null) {
|
||||
battery.readFromNBT(nbt);
|
||||
battery.readFromNBT(nbt.getCompoundTag("battery"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -441,7 +441,9 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
laser.writeToNBT(nbtLaser);
|
||||
nbt.setTag("laser", nbtLaser);
|
||||
|
||||
battery.writeToNBT(nbt);
|
||||
NBTTagCompound batteryNBT = new NBTTagCompound();
|
||||
battery.writeToNBT(batteryNBT);
|
||||
nbt.setTag("battery", batteryNBT);
|
||||
|
||||
if (itemInUse != null) {
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
|
@ -498,7 +500,7 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
|
||||
laser.readFromNBT(nbt.getCompoundTag("laser"));
|
||||
|
||||
battery.readFromNBT(nbt);
|
||||
battery.readFromNBT(nbt.getCompoundTag("battery"));
|
||||
|
||||
if (nbt.hasKey("itemInUse")) {
|
||||
itemInUse = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("itemInUse"));
|
||||
|
|
|
@ -175,7 +175,10 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
|||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
battery.writeToNBT(data);
|
||||
|
||||
NBTTagCompound batteryNBT = new NBTTagCompound();
|
||||
battery.writeToNBT(batteryNBT);
|
||||
data.setTag("battery", batteryNBT);
|
||||
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
data.setBoolean("powerSources[" + i + "]", powerSources[i]);
|
||||
|
@ -185,7 +188,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
|||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
battery.readFromNBT(data);
|
||||
battery.readFromNBT(data.getCompoundTag("battery"));
|
||||
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
powerSources[i] = data.getBoolean("powerSources[" + i + "]");
|
||||
|
|
Loading…
Reference in a new issue