mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 00:07:29 +00:00
Level Maintainer: don't queue jobs when all CPUs are busy. (#203)
This commit is contained in:
1 parent
f175d70f0c
commit
f7d25c6daa
1 file changed
+16
-3
@@ -26,6 +26,7 @@ import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
@@ -141,6 +142,17 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
final IGrid grid = getProxy().getGrid();
|
||||
final IItemList<IAEItemStack> inv = getProxy().getStorage().getItemInventory().getStorageList();
|
||||
|
||||
// Check there are available crafting CPUs before doing any work.
|
||||
// This hopefully stops level maintainers busy-looping calculating
|
||||
// crafting tasks that cannot be successfully submitted.
|
||||
boolean allBusy = true;
|
||||
for (final ICraftingCPU cpu : craftingGrid.getCpus()) {
|
||||
if (!cpu.isBusy()) {
|
||||
allBusy = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find a request that we can submit to the network.
|
||||
// If there is none, find the next request we can begin calculating.
|
||||
ICraftingJob jobToSubmit = null;
|
||||
@@ -163,9 +175,10 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
boolean shouldCraft = isCraftable && aeItem.getStackSize() < quantity;
|
||||
if (isDone) requests.updateState(i, State.Idle);
|
||||
if (!isCraftable) requests.updateState(i, State.Error);
|
||||
if (craftingGrid.canEmitFor(craftItem) || craftingGrid.isRequesting(craftItem)
|
||||
|| !isDone
|
||||
|| !shouldCraft)
|
||||
if (allBusy || !isDone
|
||||
|| !shouldCraft
|
||||
|| craftingGrid.canEmitFor(craftItem)
|
||||
|| craftingGrid.isRequesting(craftItem))
|
||||
continue;
|
||||
// do crafting
|
||||
Future<ICraftingJob> jobTask = requests.getJob(i);
|
||||
|
||||
Reference in new issue
Block a user