-
Notifications
You must be signed in to change notification settings - Fork 2
[1.21.1] Loot Functions
InsaneLib provides additional loot functions that can be used in loot tables or data packs.
All functions support the standard conditions array.
Applies a given number of random enchantments to an item. Unlike vanilla's enchant_randomly, each eligible enchantment is chosen with equal probability regardless of its weight. Incompatible enchantments are never applied together. Books are supported and will be converted to enchanted books.
| Key | Type | Default | Info |
|---|---|---|---|
count |
Number Provider | Required | Number of enchantments to apply. Supports all number providers (e.g. constant, uniform) |
max_lvl |
Boolean | false |
If true, all enchantments are applied at their maximum level instead of a random level |
treasure |
Boolean | false |
If true, treasure enchantments (tag minecraft:treasure) are included in the pool |
The following example applies exactly 2 random enchantments at maximum level, including treasure enchantments:
{
"function": "insanelib:enchant_randomly_weightless",
"count": 2,
"max_lvl": true,
"treasure": true
}The following example applies between 1 and 3 random enchantments at random levels:
{
"function": "insanelib:enchant_randomly_weightless",
"count": {
"type": "minecraft:uniform",
"min": 1,
"max": 3
}
}Applies a single random treasure enchantment (tag minecraft:treasure) to the item. The enchantment is chosen with equal probability from all eligible treasure enchantments. Books are supported and will be converted to enchanted books.
| Key | Type | Default | Info |
|---|---|---|---|
ignore_curses |
Boolean | false |
If true, curse enchantments (tag minecraft:curse) are excluded from the pool |
ignore_treasures |
Boolean | false |
If true, non-curse treasure enchantments are excluded from the pool |
The following example applies a random treasure enchantment, excluding curses:
{
"function": "insanelib:enchant_with_treasure",
"ignore_curses": true
}