Villager trade definition
Minecraft Wiki article. Categories: Java_Edition_upcoming, Data_packs
📌 Mirrored from Minecraft Wiki
This article is reproduced from Villager trade definition on the Minecraft Wiki. Mirrored from revision 3690455. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.
On this page
Villager trades are stored as JSON files within a data pack in the path data/<namespace>/villager_trade. Despite their name, they also control the trades of wandering traders.
JSON format
- [NBT Compound / JSON Object]: The root object.
- [NBT Compound / JSON Object] wants: The item needed for the trade (i.e. the price)
- [String] id: The resource location of the item. Must not be
minecraft:air - [Int][Float][NBT Compound / JSON Object] count: Optional number provider (defaults to
1). Define the cost, number of items needed for the trade. The final cost can be altered by the additional cost (byadditional_trade_costand [String][NBT List / JSON Array] double_trade_price_enchantments). If the cost quantity is less than 1, the trade is removed. Final cost abovemax_stack_sizeare treated asmax_stack_size. - [NBT Compound / JSON Object] components: Optional map of additional (non-default) data components.
- [String] id: The resource location of the item. Must not be
- [NBT Compound / JSON Object] additional_wants: Secondary item needed for the trade, optional. No altered by the additional cost.
- Same format as [NBT Compound / JSON Object] wants
- [NBT Compound / JSON Object] gives: The item given by the trade
- A single item stack see Template:Nbt inherit/itemnoslot/template
- [NBT List / JSON Array] given_item_modifiers: Optional list of modifiers to apply to the item given by the trade
- [NBT Compound / JSON Object]: An inline item modifier. The
referencemodifier is not supported.
- [NBT Compound / JSON Object]: An inline item modifier. The
- [Int][Float][NBT Compound / JSON Object] max_uses: Optional number provider (defaults to
4) determining the maximum amount of uses of this trade. Values below 1 are treated as 1. - [Int][Float][NBT Compound / JSON Object] reputation_discount: Optional number provider (defaults to
0) determining how much reputation (such as discounts and penalties) affect the count of [NBT Compound / JSON Object] wants. Called 'price multiplier' in Trading § Sale prices. Values below 0 are treated as 0. - [Int][Float][NBT Compound / JSON Object] xp: Optional number provider (defaults to
1) determining how much xp the merchant gets when the trade is done. Values below 0 are treated as 0. - [NBT List / JSON Array][NBT Compound / JSON Object] merchant_predicate: Optional predicate on the merchant that needs to pass for this trade to be offered. The
referencepredicate is not supported. - [String][NBT List / JSON Array] double_trade_price_enchantments: Optional — Any number of enchantment(s) (an [String] ID, or a [String] tag with
#, or an [NBT List / JSON Array] array containing [String] IDs). If present in the item [NBT Compound / JSON Object] gives'sstored_enchantmentscomponent after the execution of [NBT List / JSON Array] given_item_modifiers, doubles the additional cost (defined by theadditional_trade_costcomponent) of the item [NBT Compound / JSON Object] wants.
- [NBT Compound / JSON Object] wants: The item needed for the trade (i.e. the price)
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 26.1 | snap1 | Villager trades are now data-driven. | |||||
| Upcoming Java Edition | |||||||
| 26.3 | snap4 | The given_item_modifiers field has been renamed to given_item_modifier. | |||||
Navigation
Sources
- Villager trade definition — Minecraft Wiki, CC BY-NC-SA 3.0, revision 3690455.