@Override
public void updateEntity() {
super.updateEntity();
RFBattery battery = this.getBattery();
if (rfPrev != battery.getEnergyStored()) {
rfPrev = battery.getEnergyStored();
rfUnchangedCycles = 0;
}
BuildingItem toRemove = null;
for (BuildingItem i : buildersInAction) {
i.update();
if (i.isDone) {
toRemove = i;
}
}
if (toRemove != null) {
buildersInAction.remove(toRemove);
}
if (rfPrev != battery.getEnergyStored()) {
rfPrev = battery.getEnergyStored();
rfUnchangedCycles = 0;
}
rfUnchangedCycles++;
/**
* After 100 cycles with no consumption or additional power, start to
* slowly to decrease the amount of power available in the builder.
*/
if (rfUnchangedCycles > 100) {
battery.useEnergy(0, 1000, false);
rfPrev = battery.getEnergyStored();
}
}