Skip to content

CraftingCPULogic::executeCrafting() logic error gives infinite co-processor behavior when two exit conditions collide. #8781

@HaphLife

Description

@HaphLife

Describe the bug

CraftingCPULogic's lines 236 - 243 has two conditions to check exit conditions to skip the rest of that iteration of the loop:

if (task.getValue().value <= 0) {
    it.remove();
    continue taskLoop;
}

if (pushedPatterns == maxPatterns) {
    break taskLoop;
}

However, if the first condition (that the last copy of a particular recipe is executed) is coincident with the second condition (that we hit the limit of patterns which can be pushed this tick), the second condition is skipped.

Skipping the second condition causes the loop to both not break this iteration (incorrect behavior) and not break on any subsequent iteration (unless it overflows and loops all the way back around through every integer value), behaving as if the CPU cluster had "infinite" co-processors for a tick.

How to reproduce the bug

This behavior can occur in-game whenever those two conditions coincide, which is particularly easily to cause if executing a crafting plan with many different recipes each executed once.

Expected behavior

I would expect that when both conditions are true, the task gets removed and the loop breaks, rather than continuing.

Additional details

A simple fix for this bug would be to just add a copy of the pushedPatterns==maxPatterns check between the remove() and the continue.

Which minecraft version are you using?

1.21

On which mod loaders does it happen?

Forge

Crash log

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSelf explanatory?

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions