mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 20:12:19 +00:00
Fix #865 Farm with multiple gearboxes has "no power" if one has no power
This commit is contained in:
1 parent
9ee34b06b6
commit
6e68768259
2 files changed
+21
-9
No files matched your search
@@ -125,6 +125,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
private final FarmHydrationManager hydrationManager;
|
||||
private final FarmFertilizerManager fertilizerManager;
|
||||
|
||||
// the number of work ticks that this farm has had no power
|
||||
private int noPowerTime = 0;
|
||||
|
||||
private BiomeGenBase cachedBiome;
|
||||
|
||||
public FarmController(World world) {
|
||||
@@ -269,12 +272,28 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
boolean hasPower = false;
|
||||
for (Map.Entry<IFarmComponent.Active, Integer> entry : farmActiveComponents.entrySet()) {
|
||||
IFarmComponent.Active farmComponent = entry.getKey();
|
||||
if (farmComponent instanceof TileGearbox) {
|
||||
hasPower |= ((TileGearbox) farmComponent).getEnergyManager().getTotalEnergyStored() > 0;
|
||||
}
|
||||
|
||||
int tickOffset = entry.getValue();
|
||||
farmComponent.updateServer(tickCount + tickOffset);
|
||||
}
|
||||
|
||||
if (hasPower) {
|
||||
noPowerTime = 0;
|
||||
getErrorLogic().setCondition(false, EnumErrorCode.NOPOWER);
|
||||
} else {
|
||||
if (noPowerTime <= 4) {
|
||||
noPowerTime++;
|
||||
} else {
|
||||
getErrorLogic().setCondition(true, EnumErrorCode.NOPOWER);
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: be smarter about the farm needing to save
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user