Skip to content

fix: resolve EntityTossedItem initialization issue (#2346)#2348

Open
HaykKocharyan wants to merge 1 commit into
AlexModGuy:1.21from
HaykKocharyan:fix/tossed-item-default-item
Open

fix: resolve EntityTossedItem initialization issue (#2346)#2348
HaykKocharyan wants to merge 1 commit into
AlexModGuy:1.21from
HaykKocharyan:fix/tossed-item-default-item

Conversation

@HaykKocharyan
Copy link
Copy Markdown

Summary

This changes how EntityTossedItem determines 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 ThrowableItemProjectile in 1.21.1 calls getDefaultItem() during initialization. The current EntityTossedItem implementation makes getDefaultItem() depend on isDart(), which in turn depends on synced entity data that is not initialized yet at that stage.

Current implementation:

protected Item getDefaultItem() {
    return isDart() ? AMItemRegistry.ANCIENT_DART.get() : Items.COBBLESTONE;
}

Changes

  • Make getDefaultItem() return a single stable fallback item
  • Update the projectile ItemStack when the dart boolean changes instead of resolving the item dynamically inside getDefaultItem()

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 ThrowableItemProjectile already supports changing its internal ItemStack, 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.

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 participant