Resolve advancement icons lazily to avoid an intermittent RegisterEvent boot crash - #10534
Open
Jus144tice wants to merge 1 commit into
Open
Resolve advancement icons lazily to avoid an intermittent RegisterEvent boot crash#10534Jus144tice wants to merge 1 commit into
Jus144tice wants to merge 1 commit into
Conversation
…nt boot crash AllAdvancements' static initializer builds every CreateAdvancement during the TRIGGER_TYPES RegisterEvent phase, and CreateAdvancement.Builder#icon eagerly resolved the icon ItemStack from a Create item entry (asStack()) at that point. On large modpacks, mod-load order can leave a Create item unbound when this runs, throwing 'Trying to access unbound value: ResourceKey[minecraft:item / create:...]' and failing the boot (seen on create:schedule, create:chocolate_bucket, etc.). Defer icon resolution to save() (datagen, registries frozen) via the existing 'func' path, and likewise defer whenIconCollected()'s criterion so it no longer reads the not-yet-resolved icon at build time. No datagen output changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AllAdvancements' static initializer builds everyCreateAdvancementduring theTRIGGER_TYPESRegisterEventphase.CreateAdvancement.Builder#icon(ItemProviderEntry)eagerly resolved the iconItemStackfrom a Create item entry (asStack()) at that point.On large modpacks, mod-load order can leave a Create item still unbound when this runs, throwing:
and failing the boot. Observed on
create:schedule,create:chocolate_bucket, and others depending on the pack's load order — it's intermittent because it's order-sensitive.Fix
Minimal and defensive — no behavior change at datagen:
icon(ItemProviderEntry)now defers resolution tosave()(where registries are frozen) via the existingfuncpath, instead of resolvingasStack()at build time.whenIconCollected()no longer reads the not-yet-resolved icon at build time; it flags the builder so the realInventoryChangeTriggercriterion is appended insave()once the icon resolves.Icons and the icon-collected criteria resolve at datagen time exactly as before, so generated advancement JSON is unchanged. Verified by building and running on a large NeoForge 1.21.1 pack that previously hit the unbound-value crash — it now boots cleanly.