Repurposed Structures (Neoforge/Forge)

Repurposed Structures (Neoforge/Forge)

58M Downloads

[1.21+] Wrong usage of EnchantRandomly function leads to loot inconsistent with vanilla

pajicadvance opened this issue ยท 0 comments

commented

The default Repurposed Structures loot tables often use EnchantRandomly without any options provided;

        {
          "name": "minecraft:book",
          "type": "minecraft:item",
          "weight": 10,
          "functions": [
            {
              "function": "minecraft:enchant_randomly"
            }
          ]
        }

This causes a problem in 1.21, as it allows items to have enchantments that are not normally accessible in random vanilla loot (Soul Speed, Swift Sneak etc.), because the behavior of EnchantRandomly got changed to randomly pick from every single enchantment in the game.

In 1.21, new enchantment tags were added, with one of them being on_random_loot. If you look at 1.21 vanilla loot tables that give items random enchantments, they always use EnchantRandomly like this:

        {
          "type": "minecraft:item",
          "functions": [
            {
              "function": "minecraft:enchant_randomly",
              "options": "#minecraft:on_random_loot"
            }
          ],
          "name": "minecraft:book",
          "weight": 10
        },

This ensures that enchantments which are exclusive to certain places are not applied to random loot. The loot tables in Repurposed Structures for MC versions 1.21 and above should probably be changed to reflect this.