Enchantment provider
Enchantment providers are used to source one or more enchantments for use in specific scenarios, such as mobs spawning with enchanted equipment.
Enchantment providers are stored as JSON files within a data pack in the data/<namespace>/enchantment_provider folder.
JSON format
single
Always returns the same enchantment
- [NBT Compound / JSON Object]
- [String] type:
minecraft:single - [String] enchantment: One enchantment (an [String] ID) — the enchantment to return
- [Int][NBT Compound / JSON Object] level: The level of the enchantment
- Int provider see Template:Nbt inherit/int_provider/template
- [String] type:
enchantments_by_cost
Returns random enchantments from a list of possible enchantments, using a configured cost. Similar to the cost of an enchanting table.
- [NBT Compound / JSON Object]
- [String] type:
minecraft:enchantments_by_cost - [String] enchantments: Any number of enchantment(s) (an [String] ID, or a [String] tag with
#, or an [NBT List / JSON Array] array containing [String] IDs) — set of all possible enchantments - [Int][NBT Compound / JSON Object] cost: The cost to use to determine the enchantments
- Int provider see Template:Nbt inherit/int_provider/template
- [String] type:
enchantments_by_cost_with_difficulty
Works the same way as enchantments_by_cost but the cost is determined using the local difficulty of the area.
The effective cost is calculated by min_cost + rand(0, local_difficulty_factor * max_cost_span). Where:
rand(a,b)refers to a random number betweenaandb.local_difficulty_factoris:local_difficulty/2 - 1clamped to a value between0and1.
- [NBT Compound / JSON Object]
- [String] type:
minecraft:enchantments_by_cost_with_difficulty - [String] enchantments: Any number of enchantment(s) (an [String] ID, or a [String] tag with
#, or an [NBT List / JSON Array] array containing [String] IDs) — set of all possible enchantments - [Int] min_cost: Minimum
1— The base cost at local difficulty below2. - [Int] max_cost_span: Minimum
0—Factor of the uniform randomization range for local difficulty.
- [String] type:
Usage
Enchantment providers are used by the game in specific cases listed below:
| Enchantment provider | Used for the enchantments of |
|---|---|
minecraft:mob_spawn_equipment |
armor and weapons of a mob that spawns with enchanted equipment |
minecraft:pillager_spawn_crossbow |
the enchanted crossbow of a spawned pillager |
minecraft:raid/pillager_post_wave_3 |
the enchanted crossbow of a spawned pillager in waves 4 and 5 of a raid |
minecraft:raid/pillager_post_wave_5 |
the enchanted crossbow of a spawned pillager in waves above 5 of a raid |
minecraft:raid/vindicator |
the enchanted axe of a spawned vindicator in waves 1 to 5 of a raid |
minecraft:raid/vindicator_post_wave_5 |
the enchanted axe of a spawned vindicator in waves above 5 of a raid |
minecraft:enderman_loot_drop |
the "fake tool" used in the loot tables of the block held by an enderman when killed. |
With villager trade rebalance
Enchantment providers are used to determine the traded equipment depending on biome, profession, equipment (i.e. the item traded) and trading level. They follow the format minecraft:trades/<biome>_<profession>_<equipment>_<level>.
minecraft:trades/desert_armorer_boots_4minecraft:trades/desert_armorer_chestplate_4minecraft:trades/desert_armorer_chestplate_5minecraft:trades/desert_armorer_helmet_4minecraft:trades/desert_armorer_leggings_4minecraft:trades/desert_armorer_leggings_5minecraft:trades/jungle_armorer_boots_4minecraft:trades/jungle_armorer_boots_5minecraft:trades/jungle_armorer_chestplate_4minecraft:trades/jungle_armorer_helmet_4minecraft:trades/jungle_armorer_helmet_5minecraft:trades/jungle_armorer_leggings_4minecraft:trades/plains_armorer_boots_4minecraft:trades/plains_armorer_boots_5minecraft:trades/plains_armorer_chestplate_4minecraft:trades/plains_armorer_helmet_4minecraft:trades/plains_armorer_leggings_4minecraft:trades/plains_armorer_leggings_5minecraft:trades/savanna_armorer_boots_4minecraft:trades/savanna_armorer_chestplate_4minecraft:trades/savanna_armorer_chestplate_5minecraft:trades/savanna_armorer_helmet_4minecraft:trades/savanna_armorer_helmet_5minecraft:trades/savanna_armorer_leggings_4minecraft:trades/snow_armorer_boots_4minecraft:trades/snow_armorer_boots_5minecraft:trades/snow_armorer_helmet_4minecraft:trades/snow_armorer_helmet_5minecraft:trades/swamp_armorer_boots_4minecraft:trades/swamp_armorer_boots_5minecraft:trades/swamp_armorer_chestplate_4minecraft:trades/swamp_armorer_helmet_4minecraft:trades/swamp_armorer_helmet_5minecraft:trades/swamp_armorer_leggings_4minecraft:trades/taiga_armorer_chestplate_5minecraft:trades/taiga_armorer_leggings_5
| |||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||