Enchantment provider

From Minecraft Wiki
Jump to navigation Jump to search
This feature is exclusive to Java Edition.
 

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

[edit | edit source]

single

[edit | edit source]

Always returns the same enchantment

  • [NBT Compound / JSON Object]

enchantments_by_cost

[edit | edit source]

Returns random enchantments from a list of possible enchantments, using a configured cost. Similar​[more information needed] 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

enchantments_by_cost_with_difficulty

[edit | edit source]

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 between a and b.
  • local_difficulty_factor is: local_difficulty/2 - 1 clamped to a value between 0 and 1.
  • [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 below 2.
    • [Int] max_cost_span: Minimum 0 —Factor of the uniform randomization range for local difficulty.

Usage

[edit | edit source]

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

[edit | edit source]
This section describes an experimental feature in Java Edition.
 
This feature is not enabled in-game by default and requires enabling the "Villager Trade Rebalance" experimental data pack in Java Edition.

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>.

[edit | edit source]