# Minecraft Villager Trade

> Minecraft Villager Trade 村民交易定义：VILLAGER_TRADE 注册表、data/<namespace>/villager_trade/ 数据包路径、tags/villager_trade/ 标签、JSON 格式（wants 第一购买物品 id+可选components+count 基础数量 number provider、additional_wants 第二购买物品 同格式、gives 出售物品模板、given_item_modifiers 出售物品修改器 仅内联无文件引用 最终堆栈为空则不生成报价、max_uses 最大交易次数 默认4 锁定前、reputation_discount 价格乘数 float 默认0、xp 经验 默认1、merchant_predicate 村民战利品谓词 仅内联 失败则无报价、double_trade_price_enchantments 附魔ID/列表/标签 出售物品stored_enchantments包含则购买额外数量翻倍）、Behavior 行为（服务器启动加载一次、交易通过交易集引用生成实际报价）、Pricing 定价（第一购买物品count=基础数量count+额外数量 additional_trade_cost组件、enchant_with_levels include_additional_cost_component=true 设置为附魔等级、enchant_randomly 设置2+random(0,5+level×10)+3×level、组件修改后移除 成为额外数量 价格翻倍检查匹配则额外翻倍、最终count=基础+额外 钳制[1,最大堆叠大小]）、Generation 生成（使用villager_trade战利品上下文：this_entity 村民、origin 村民脚位置、additional_cost_component_allowed）。

- Skill: `zmjjkk123-hub/minecraft-villager-trade` (Agent Skill)
- Install (CLI): `npx skillmds@latest add zmjjkk123-hub/minecraft-villager-trade`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zmjjkk123-hub/minecraft-villager-trade/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ZMJJKK123-hub (https://skillmd.com/u/zmjjkk123-hub)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/zmjjkk123-hub/minecraft-villager-trade

---


# Villager Trade

Villager trades are the blueprints for actual trade offers generated by villagers and wandering traders. Java Edition only.

## Definition Format

Registry `VILLAGER_TRADE`, data pack path `villager_trade` (files in `data/<namespace>/villager_trade/`; tags in `tags/villager_trade/`).

- `wants` (required) — first bought item: `id` (item type), optional `components` (component checks on the bought item), `count` (default 1; base amount, number provider — see Pricing).
- `additional_wants` — second bought item (same format).
- `gives` (required) — the sold item (item template).
- `given_item_modifiers` — item modifiers on the sold item (inline only, no file references); if the final stack is empty, the trade won't generate an offer.
- `max_uses` (default 4, <1 → 1; floored) — max trades before the offer locks.
- `reputation_discount` (default 0, <0 → 0) — price multiplier (float).
- `xp` (default 1, <0 → 0; floored) — XP given after trading.
- `merchant_predicate` — loot predicate on the villager (inline only); failure → no offer.
- `double_trade_price_enchantments` — enchantment ID/list/tag: if the sold item's `stored_enchantments` contains one, the bought extra amount doubles.

Generation uses the `villager_trade` loot context: `this_entity` (the villager), `origin` (the villager's feet position), `additional_cost_component_allowed`.

## Behavior

Definitions load once at server startup (restart required). Trades are referenced by trade sets, which generate actual offers.

## Pricing

The first bought item's count = base amount (from `count`) + extra amount (from the item's `additional_trade_cost` component, settable only by item modifiers):

- `enchant_with_levels` with `include_additional_cost_component: true` sets it to the enchanting level.
- `enchant_randomly` with it true sets 2 + random(0, 5 + level×10) + 3×level (level = the enchantment's level).

After the item is modified the component is removed and its value becomes the extra amount; if the price-doubling check matches, the extra doubles. Final count = base + extra, clamped to [1, max stack size].

