fix loosing information on chunk save/load

This commit is contained in:
Flow86 2013-04-03 08:56:01 +02:00
parent c9830eae3d
commit ac3db7f7bd

View file

@ -6,13 +6,14 @@ import buildcraft.api.power.IPowerReceptor;
public class EnergyPulser {
private IPowerReceptor powerReceptor;
private final IPowerReceptor powerReceptor;
private boolean isActive;
private boolean singlePulse;
private boolean hasPulsed;
private int pulseCount;
private int tick;
public EnergyPulser(IPowerReceptor receptor) {
powerReceptor = receptor;
}
@ -21,14 +22,13 @@ public class EnergyPulser {
if (powerReceptor == null || !isActive || tick++ % 10 != 0)
return;
if (!singlePulse || !hasPulsed)
{
powerReceptor.getPowerProvider().receiveEnergy(Math.min(1 << (pulseCount-1),64), ForgeDirection.WEST);
if (!singlePulse || !hasPulsed) {
powerReceptor.getPowerProvider().receiveEnergy(Math.min(1 << (pulseCount - 1), 64), ForgeDirection.WEST);
hasPulsed = true;
}
}
public void enableSinglePulse(int count) {
public void enableSinglePulse(int count) {
singlePulse = true;
isActive = true;
pulseCount = count;
@ -59,10 +59,16 @@ public class EnergyPulser {
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("SinglePulse", singlePulse);
nbttagcompound.setBoolean("IsActive", isActive);
nbttagcompound.setBoolean("hasPulsed", hasPulsed);
nbttagcompound.setInteger("pulseCount", pulseCount);
nbttagcompound.setInteger("tick", tick);
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
isActive = nbttagcompound.getBoolean("IsActive");
singlePulse = nbttagcompound.getBoolean("SinglePulse");
hasPulsed = nbttagcompound.getBoolean("hasPulsed");
pulseCount = nbttagcompound.getInteger("pulseCount");
tick = nbttagcompound.getInteger("tick");
}
}