Loot Functions Enchantments - Tmtravlr/LootOverhaul GitHub Wiki

Loot Functions - Enchantments

Structure:

Property Type Description
enchantment Enchantment Object or Enchantment Object List List of potential enchantments to generate.
enchantment -> {} -> name String The name of the enchantment, like minecraft:silk_touch.
enchantment -> {} -> level Integer The level of the enchantment. (Optional, defaults to 1)
number_to_generate Integer or Integer Range How many enchantments from the list to generate (Optional, defaults to 1)
replace String Optional string to replace in the nbt instead of generating a new tag. (Optional)

Description:

Adds enchantments to the item. More of a convenience, since modded enchantment ids change between worlds, and enchantments on items still use numerical ids for some reason.

Example Usage:

Adds silk touch

"functions": [
 	{
 		"function": "lootoverhaul:enchantments",
 		"enchantment": {
 			"name": "minecraft:silk_touch"
 		}
 	}
]

Also can take a list of enchantments to choose randomly between. Will add 2 of sharpness, smite, or bane of arthropods enchantment with level 1-3:

"functions": [
 	{
 		"function": "lootoverhaul:enchantments",
 		"enchantment": [
 			{
 				"name": "minecraft:sharpness",
         		"level": {
         			"min": 1,
         			"max": 3
         		}
 			},
 			{
 				"name": "minecraft:smite",
         		"level": {
         			"min": 1,
         			"max": 3
         		}
 			},
 			{
 				"name": "minecraft:bane_of_arthropods",
         		"level": {
         			"min": 1,
         			"max": 3
         		}
 			}
         ],
         "number_to_generate": 2
 	}
]

If replace is set, instead of generating a new enchantment list, it will try replacing the given string with an enchantment tag. Example: An enchantment book with silk touch, mending, or efficiency

"functions": [
 	{
			"function": "set_nbt",
			"tag": "{StoredEnchantments:\"#GeneratedEnchantments\"}"
		},
		{
 		"function": "lootoverhaul:enchantments",
 		"enchantment": [
 			{
 				"name": "minecraft:silk_touch"
 			},
 			{
 				"name": "minecraft:mending"
 			},
 			{
 				"name": "minecraft:efficiency",
         		"level": {
         			"min": 1,
         			"max": 5
         		}
 			}
         ],
         "replace": "\"#GeneratedEnchantments\""
 	}
]
Previous - Custom Potion Effects Back Next - Function Group
⚠️ **GitHub.com Fallback** ⚠️