Skip to content

Commit 8fcb621

Browse files
clauderubensworks
authored andcommitted
Skip the crafting network lookup of an idle crafting interface
CraftingJobHandler.update looked the crafting network capability up to find a job to start, even when the handler has no pending jobs at all, which is what every idle crafting interface does on every tick. It also repeated that same lookup for every finished job instead of once. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MxquU3sDjDpKbeHrVyrV1t
1 parent 6ec73e2 commit 8fcb621

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/org/cyclops/integratedcrafting/core/CraftingJobHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,10 @@ public void update(INetwork network, int channel, PartPos targetPos) {
429429

430430
// Notify the network of finalized crafting jobs
431431
if (finishedCraftingJobs.size() > 0) {
432+
ICraftingNetwork craftingNetwork = CraftingHelpers.getCraftingNetworkChecked(network);
432433
for (CraftingJob finishedCraftingJob : finishedCraftingJobs.values()) {
433434
if (finishedCraftingJob.getAmount() == 0) {
434435
// If the job is fully finished, remove it from the network
435-
ICraftingNetwork craftingNetwork = CraftingHelpers.getCraftingNetworkChecked(network);
436436
craftingNetwork.onCraftingJobFinished(finishedCraftingJob);
437437
allCraftingJobs.remove(finishedCraftingJob.getId());
438438
nonBlockingJobsRunningAmount.remove(finishedCraftingJob.getId());
@@ -471,7 +471,9 @@ public void update(INetwork network, int channel, PartPos targetPos) {
471471
}
472472
}
473473

474-
if (processingJobs < this.maxProcessingJobs) {
474+
// Only look for a job to start if this handler has room for one, and has something to start.
475+
// Skipping this block for an idle handler avoids a crafting network lookup for every idle tick.
476+
if (processingJobs < this.maxProcessingJobs && !this.pendingCraftingJobs.isEmpty()) {
475477
// Handle crafting jobs
476478
CraftingJob startingCraftingJob = null;
477479
ICraftingNetwork craftingNetwork = CraftingHelpers.getCraftingNetworkChecked(network);

0 commit comments

Comments
 (0)