mojira.dev
MC-304997

Stacked tridents with increased max_stack_size are duplicated when thrown and picked up

Steps to reproduce the issue:

Give yourself a trident with a greater than one max stack size. (Note: You also need to remove the max damage component to change max stack size)

/give @p minecraft:trident[minecraft:max_stack_size=64,!minecraft:max_damage] 64
/give @p minecraft:trident[minecraft:max_stack_size=64,!minecraft:max_damage] 64

In survival mode, throw the trident into the ground.

Pick up the trident.

Expected result:

Only one trident item would be picked up.

Actual result:

The player picks up the number of tridents held at the time of throwing. For this example the player would pick up 64 tridents.

Notes:

TridentItem.class (93-94)

ItemStack thrownItemStack = itemStack.consumeAndReturn(1, (LivingEntity)player);
ThrownTrident trident = (ThrownTrident)Projectile.spawnProjectileFromRotation(ThrownTrident::new, serverLevel, thrownItemStack, (LivingEntity)player, 0.0F, 2.5F, 1.0F);
ItemStack thrownItemStack = itemStack.consumeAndReturn(1, (LivingEntity)player);
ThrownTrident trident = (ThrownTrident)Projectile.spawnProjectileFromRotation(ThrownTrident::new, serverLevel, thrownItemStack, (LivingEntity)player, 0.0F, 2.5F, 1.0F);

Could be fixed with ItemStack#copyWithCount(1)

Comments 2

I cannot reproduce this

You’re right, its a PaperMC bug. My bad 😞

I don't know how to close this bug report though.

Colin Nason

(Unassigned)

Unconfirmed

(Unassigned)

1.21.11

Retrieved