mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
#666 Fix performance regression from checking for flowers constantly
This commit is contained in:
1 parent
43d8b18d2d
commit
cd7d5f10e6
1 file changed
+17
-11
@@ -154,6 +154,22 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
if (queenWorkCycleThrottle >= PluginApiculture.ticksPerBeeWorkCycle) {
|
||||
queenWorkCycleThrottle = 0;
|
||||
|
||||
boolean hasFlower = queen.hasFlower(housing);
|
||||
|
||||
if (housingSupportsMultipleErrorStates) {
|
||||
housing.setErrorCondition(!hasFlower, EnumErrorCode.NOFLOWER);
|
||||
} else {
|
||||
if (hasFlower) {
|
||||
housing.setErrorState(EnumErrorCode.OK);
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFlower) {
|
||||
return;
|
||||
}
|
||||
|
||||
doProduction();
|
||||
queen.plantFlowerRandom(housing);
|
||||
doPollination();
|
||||
@@ -278,7 +294,6 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
}
|
||||
|
||||
private boolean queenCanWork() {
|
||||
boolean hasFlower = queen.hasFlower(housing);
|
||||
|
||||
if (housingSupportsMultipleErrorStates) {
|
||||
try {
|
||||
@@ -287,9 +302,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
housing.setErrorCondition(true, errorState);
|
||||
}
|
||||
|
||||
housing.setErrorCondition(!hasFlower, EnumErrorCode.NOFLOWER);
|
||||
|
||||
return (errorStates.size() == 0) && hasFlower;
|
||||
return (errorStates.size() == 0);
|
||||
} catch (Throwable ignored) {
|
||||
// queen might not support getCanWork(housing)
|
||||
}
|
||||
@@ -301,13 +314,6 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasFlower) {
|
||||
housing.setErrorState(EnumErrorCode.OK);
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user