mojira.dev
MC-313824

Using the `set_enchantments` loot function to add very high levels to existing enchantments removes them

The Bug:

Using the set_enchantments loot function to add very high levels to existing enchantments removes them.

The set_enchantments loot function limits levels to 255, so adding a very high level to an enchantment the item doesn't have gives level 255. However, adding it to an enchantment the item already has removes that enchantment, therefore introducing an inconsistency.

Steps to Reproduce:

  1. Obtain an iron sword with sharpness I and hold it in your main hand by using the command provided below.

    /give @s minecraft:iron_sword[minecraft:enchantments={"minecraft:sharpness":1}]
  2. Add 2,147,483,647 levels of sharpness to the sword by using the command provided below.

    /item modify entity @s weapon.mainhand {type:"minecraft:set_enchantments",add:true,enchantments:{"minecraft:sharpness":2147483647}}
  3. Observe if the sword still has sharpness.

Observed Behavior:

Using the set_enchantments loot function to add very high levels to existing enchantments removes them.

Expected Behavior:

Using the set_enchantments loot function to add very high levels to existing enchantments would not remove them.

Attachments

Comments 1

Avoma

(Unassigned)

Confirmed

26.3, 26.4 Release Candidate 1

Retrieved