mojira.dev
MC-192982

Loot Table function enchant_randomly can give Non-Stored Enchantments to books if another function enchants it first.

The Bug

The game has two kinds of enchantments, StoredEnchantments for books and Enchantments for everything else. The loot table function enchant_randomly will give the wrong kind of enchantment to books if another function has already enchanted it.

{
  "type": "minecraft:chest",
  "pools": [
    {
      "rolls": {
        "min": 4.0,
        "max": 8.0,
        "type": "minecraft:uniform"
      },
      "entries": [
        {
          "type": "minecraft:item",
          "functions": [
	    {
              "function": "minecraft:enchant_with_levels",
              "levels": 30,
              "treasure": true
            },
	    {
                "function": "enchant_randomly",
                "enchantments": [
                    "protection",
                    "fire_protection",
                    "feather_falling",
                    "blast_protection",
                    "projectile_protection",
                    "thorns",
                    "depth_strider",
                    "frost_walker",
                    "sharpness",
                    "knockback",
                    "fire_aspect",
                    "looting",
                    "efficiency",
                    "silk_touch",
                    "unbreaking",
                    "fortune",
                    "power",
                    "punch",
                    "flame",
                    "infinity",
                    "mending"
                ]
            }
          ],
          "name": "minecraft:book"
        }
      ]
    }
  ]
}

The same thing happens if the function enchant_randomly is used twice, with the second enchantment being bugged.

If the function enchant_randomly is used on its own, then it gives a StoredEnchantment as intended.

If the function enchant_randomly is used, then enchant_with_levels, then enchant_with_levels won't give any enchantments at all.

Attachments

Comments 1

Seems to still be in 22w14a.

Paint

(Unassigned)

Confirmed

(Unassigned)

enchanted_book, enchantments, functions, loot_tables

1.16.1, 20w27a, 20w28a, 20w29a, 1.16.2 Pre-release 1, 1.16.3, 20w48a, 22w14a

Retrieved