mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 22:04:34 +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;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.farming.IFarmComponent;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.tiles.IPowerHandler;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.farming.multiblock.IFarmController;
|
||||
@@ -57,13 +55,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
|
||||
|
||||
@Override
|
||||
public void updateServer(int tickCount) {
|
||||
|
||||
IFarmController farmController = getFarmController();
|
||||
IErrorLogic errorLogic = farmController.getErrorLogic();
|
||||
|
||||
boolean hasPower = energyManager.getTotalEnergyStored() > 0;
|
||||
|
||||
if (errorLogic.setCondition(!hasPower, EnumErrorCode.NOPOWER)) {
|
||||
if (energyManager.getTotalEnergyStored() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,6 +70,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
|
||||
}
|
||||
|
||||
if (workCounter >= WORK_CYCLES && (tickCount % 5 == 0)) {
|
||||
IFarmController farmController = getFarmController();
|
||||
if (farmController.doWork()) {
|
||||
workCounter = 0;
|
||||
previousDelays = 0;
|
||||
|
||||
Reference in new issue
Block a user