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

ArrowLooseEvent fired for BowItem passed in the wrong ItemStack #1326

Closed
RaymondBlaze opened this issue Jul 17, 2024 · 1 comment · Fixed by #1329
Closed

ArrowLooseEvent fired for BowItem passed in the wrong ItemStack #1326

RaymondBlaze opened this issue Jul 17, 2024 · 1 comment · Fixed by #1329
Labels
triage Needs triaging and confirmation

Comments

@RaymondBlaze
Copy link
Contributor

Introduced by #1189 when trying to re-implement the event for BowItem.

 public void releaseUsing(ItemStack p_40667_, Level p_40668_, LivingEntity p_40669_, int p_40670_) {
         if (p_40669_ instanceof Player player) {
             ItemStack itemstack = player.getProjectile(p_40667_);
             if (!itemstack.isEmpty()) {
                 int i = this.getUseDuration(p_40667_, p_40669_) - p_40670_;
-                // PR #1189's implementation
-                i = net.neoforged.neoforge.event.EventHooks.onArrowLoose(itemstack, p_40668_, player, i, !itemstack.isEmpty());
+                // Correct implementation
+                i = net.neoforged.neoforge.event.EventHooks.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.isEmpty());

The PR mistakenly passed in the local variable itemstack (the projectile ItemStack) instead of the method parameter p_40667_ (the bow ItemStack), while ArrowLooseEvent needs the bow/crossbow ItemStack.

As there's also discussions and confusions on the naming of the event in #1189, I suggest we look into rework the ArrowNockEvent and ArrowLooseEvent to provide a better support on ProjectileWeaponItem related events.

@Spinoscythe
Copy link
Contributor

I'm making a new issue for the projectile event rework

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

Successfully merging a pull request may close this issue.

2 participants