fix: resolve EntityTossedItem initialization issue (#2346)#2348
Open
HaykKocharyan wants to merge 1 commit into
Open
fix: resolve EntityTossedItem initialization issue (#2346)#2348HaykKocharyan wants to merge 1 commit into
HaykKocharyan wants to merge 1 commit into
Conversation
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.
Summary
This changes how
EntityTossedItemdetermines its projectile item in order to avoid initialization-related issues for Minecraft 1.21.1.As far as I could trace, issue #2346 happens because
ThrowableItemProjectilein 1.21.1 callsgetDefaultItem()during initialization. The currentEntityTossedItemimplementation makesgetDefaultItem()depend onisDart(), which in turn depends on synced entity data that is not initialized yet at that stage.Current implementation:
Changes
getDefaultItem()return a single stable fallback itemItemStackwhen the dart boolean changes instead of resolving the item dynamically insidegetDefaultItem()Why
From what I could tell while digging through the project and vanilla behavior,
getDefaultItem()seems intended to behave as a constant fallback provider rather than a state-dependent resolver.Since
ThrowableItemProjectilealready supports changing its internalItemStack, changing the actual projectile item when the dart state changes appears to be a safer and more stable approach than relying on initialization-time synced data access.Notes
A cleaner long-term solution would probably be separating cobblestone and dart projectiles into separate entity classes entirely. However, I wanted to keep this patch as small and non-invasive as possible while stabilizing the current behavior.
I have not tested this change in-game.