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

Calculate item hash only if needed #4687

Draft
wants to merge 1 commit into
base: 1.19.4
Choose a base branch
from

Conversation

ZacSharp
Copy link
Collaborator

Fixes a stackoverflow with SilentGear.
The problem is that SilentGear has a complicated parts system and to get the damage value of an ItemStack it first constructs the relevant PartInstance, which involves defensively copying the ItemStack before storing it in the new PartInstance. Copying an ItemStack of course triggers our hash calculation in the constructor run for the copy, we query the damage value of the new stack, and the cycle repeats.

With this change we only calculate the hash once we actually need it (and if the hash happens to be 0 we do so every time it is needed).
An alternative would be to try copying the hash from the old stack to the new one, though given the Mixin hackery this would require I'm not sure whether that would actually be better. (Need to redirect the relevant constructor call and probably also need a ThreadLocal to pass the hash)

Testing: TBD

Fixes #4538

Prevents a stack overflow with SilentGear and hence with All The Mods 10
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.

1.21.1 - ATM10 - The Undergarden + Silent Gear + Baritone causes crash
1 participant