Mojira Archive
MC-276782

Duplicate entries in a tag does not impact the weight

Having duplicate entries in a tag does not impact the chance of that entry getting randomly picked.

In the attached datapack. There is an enchantment tag with 4 entries for protection and 1 for mending. Using this tag with the enchant_randomly modifier. The chance of getting mending is expected to be lower than 50%. This is not the case.

{
  "function": "minecraft:enchant_randomly",
  "options": "#weighted_enchantments:weighted_list"
}

 
When using the same modifier but using multiple options, the chance of getting mending is much lower.

{
  "function": "minecraft:enchant_randomly",
  "options": [
    "minecraft:protection",
    "minecraft:protection",
    "minecraft:protection",
    "minecraft:protection",
    "minecraft:mending"
  ]
}

 

How to recreate

  1. Install the datapack
  2. Run /loot give @s loot weighted_enchantments:using_options
    → Observe the rarity of getting mending
  3. Run /loot give @s loot weighted_enchantments:using_tag
    → Observe that the chance of getting mending is much higher

 

Invalid

tholleman

2024-09-17, 06:57 AM

2024-09-20, 12:15 PM

2024-09-20, 07:26 AM

0

0

Confirmed

Data Packs

1.21.1, 24w37a

-