NeoForge
NeoForge copied to clipboard
ForgeHooks.getProjectile() assumes all instances of ProjectileWeaponItem use arrows as valid ammo
Minecraft Version: 1.20.1
NeoForge Version: 47.1.64
Description of issue: ForgeHooks.getProjectile() inside of getProjectile() in Player.class naively assumes all instances of ProjectileWeaponItem use arrows as its ammo if no valid stack is found while the player is in creative mode. Returning ItemStack.EMPTY would prevent any cases where modded weapons are "finding" arrows in the player's inventory even if there is no valid itemstack.
The bow and crossbow handle this in their class level implementation so the proposed change should not affect anything else.
For reference, the behavior within creative mode is from vanilla. Forge simply patches the hook to call the event while maintaining vanilla logic. Returning empty would be fine from a vanilla standpoint, but it might break mod logic if they choose to implement their own release logic. The better scenario is to allow people to specify the returned item stack on the ProjectileWeaponItem
in some extension method imo.
That sounds fine, I've been using a similar approach in one of my mods with getDefaultAmmo()
FirearmItem.java
So if I am understanding this issue, the problem is using a modded projectile weapon in creative is being given vanilla arrows in getProjectile event right? But the weapon should be given an item that is a valid projectile for the weapon instead of the vanilla arrow as they may not accept the vanilla arrow.
Passing itemstack.EMPTY would make the event fire but say a modded weapon is firing no projectile when it is and passing that empty stack to the weapon itself.