Villager trade definition

From Minecraft Wiki
Jump to navigation Jump to search
This article describes content that is currently in development for Java Edition.
 
This content has appeared in development versions for Java Edition 26.1, but the full update adding it has not been released yet.

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

[edit | edit source]
  • [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.
      • [Int][Float][NBT Compound / JSON Object] count: Optional number provider (defaults to 1) determining the number of items required
      • [NBT Compound / JSON Object] components: Optional map of components that are required on the item
    • [NBT Compound / JSON Object] additional_wants: Secondary item needed for the trade
      • Same format as [NBT Compound / JSON Object] wants
    • [NBT Compound / JSON Object] gives: The item given by the trade
    • [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 reference modifier is not supported.
    • [Int][Float][NBT Compound / JSON Object] max_uses: Optional number provider (defaults to 4, minimum 1) determining the maximum amount of uses of this trade.
    • [Int][Float][NBT Compound / JSON Object] reputation_discount: Optional number provider (defaults to 0, minimum 0) determining how much reputation (such as discounts and penalties) affect the count of [NBT Compound / JSON Object] wants. ​[more information needed]
    • [Int][Float][NBT Compound / JSON Object] xp: Optional number provider (defaults to 1, minimum 0) determining how much xp the merchant gets when the trade is done.
    • [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 reference predicate 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) that when present after [NBT List / JSON Array] given_item_modifiers is run double the count of the [NBT Compound / JSON Object] wants item (when the additional_trade_cost item component is present).

History

[edit | edit source]
Upcoming Java Edition
26.1snap1Villager trades are now data-driven.
[edit | edit source]