Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crafting job progress bar exceeding 100% #8005

Closed
wants to merge 1 commit into from

Conversation

Mithi83
Copy link
Contributor

@Mithi83 Mithi83 commented Jul 1, 2024

Fix for 1.21 for the bug reported independently in #7468 for 1.20 and #7420 for 1.19.

The bug stems from the discrepancy between the initial calculation that only accounts for recipe outputs and the actual execution of the job which adds recipe outputs as well as any remaining items in the crafting grid, called container items. When decrementing the counter for the remaining items, these container items must not be counted to ensure the counter only decrements down to 0 and not beyond.

Fixing this side of the problem, rather than the initial calculation has two reasons:

  • more accurate progress bar, because recipes with container items don't decrease the counter multiple times per recipe execution, which will become important for more complex crafting jobs with a mix of normal recipes and those with additional container items.
  • the actual number of container items is determined only at the execution stage and not during the initial calculation.

@Mithi83
Copy link
Contributor Author

Mithi83 commented Jul 1, 2024

Simple way to test this: Create a pattern for cable anchors (and make sure it allows for substitution) and craft large quantities (hunderts are sufficient). The damaged knives will trigger this bug.

The most critical part in my opinion is CraftingCpuLogic.insert().

There is a separate bug that messes up crafting jobs that are not done when leaving and rejoining the world, which is why I couldn't properly test the NBT writing portion of my fix.

Fix for 1.21 for the bug reported independently in AppliedEnergistics#7468 for 1.20
and AppliedEnergistics#7420 for 1.19.

The bug stems from the discrepancy between the initial calculation that
only accounts for recipe outputs and the actual execution of the job
which adds recipe outputs as well as any remaining items in the crafting
grid, called container items. When decrementing the counter for the
remaining items, these container items must not be counted to ensure the
counter only decrements down to 0 and not beyond.

Fixing this side of the problem, rather than the initial calculation has
two reasons:
  - more accurate progress bar, because recipes with container items
    don't decrease the counter multiple times per recipe execution, which
    will become important for more complex crafting jobs with a mix of normal
    recipes and those with additional container items.
  - the actual number of container items is determined only at the
    execution stage and not during the initial calculation.
@shartte
Copy link
Member

shartte commented Jul 31, 2024

@Technici4n Can you check this one? This is more up your alley

@Technici4n
Copy link
Member

Tomorrow :)

Technici4n added a commit that referenced this pull request Aug 1, 2024
)

Alternative to
#8005.
We simply add container items to the total number of items expected for
the job.

Fixes #7468. Fixes #7420.

---------

Co-authored-by: Mithi83 <[email protected]>
@Technici4n
Copy link
Member

I merged #8085 instead. Thanks for the analysis and for the fix idea!

@Technici4n Technici4n closed this Aug 1, 2024
@Mithi83
Copy link
Contributor Author

Mithi83 commented Aug 2, 2024

You‘re welcome. I was quite sure the analysis was correct but as always with unfamiliar code there might be a more elegant solution. Thanks for fixing the bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants