mojira.dev
MC-272585

Crash when bow or crossbow enchanted with multishot runs out of durability

The game crashes when shooting a bow/crossbow with 1 durability that is enchanted with multishot.

Steps to reproduce:

  1. Run

    /give @s crossbow[damage=464,enchantments={multishot:1}]
  2. Shoot the crossbow in survival mode

  3. Pause the game

Attachments

Comments 2

Relates to MC-271566; can confirm.

Steps to Reproduce

  1. Get a damaged bow with Multishot (so that it will break when used).

  2. Get 1 arrow.

  3. Switch to Survival mode.

  4. Use the bow to shoot one arrow.

  5. Pause the game.

  6. Game crashes.

I can confirm this issue. The issue is a bow or crossbow enchanted with multishot running out of durability, so the following bow will reproduce the issue in survival mode after one use:

/give @s crossbow[damage=464,enchantments={multishot:1}]

Code analysis (Yarn mappings)

In RangedWeaponItem#shootAll, the weapon stack is damaged per each projectile entity created. Each projectile entity is created with a copy of the weapon stack, so if the weapon stack breaks between creating entities, the entities after the weapon stack breaks will have an empty stack. This stack isn't supported by NBT serialization of the projectile entity, so the game crashes.

Max

slicedlime

Confirmed

Crash

1.21 Pre-Release 1

1.21 Pre-Release 2

Retrieved