VillagersTradingPlus 是一个库,允许模组和数据包通过 JSON 定义村民交易。
可以添加或替换任何村民的交易,更改货币,将交易置于条件限制下并重新定价,所有这些操作均可从数据包中完成。
版本:1.20 至 1.20.1、1.21 至 1.21.1、1.21.6 至 1.21.8、1.21.11、26.1.2、26.2、26.3
在以下平台支持我的工作
这是什么
VillagersTradingPlus 是一个库。它本身不添加任何村民、方块或物品:它替换了村民交易背后的机制,使模组和数据包能够通过 JSON 定义交易。
VillagersPlus 是基于此构建的参考模组。
你可以用它做什么
- 添加、删除或覆盖所有村民职业(包括原版)的交易。
- 更改货币,将绿宝石改为任何你喜欢的物品。
- 设置每项交易的数量、最大使用次数、村民经验和价格行为。
- 将交易置于条件限制下:生物群系、维度、天气、一天中的时间、月相、游戏规则、工作站点方块或配置标志。
- 16 种交易类型(26.1 及更高版本为 15 种),从普通的物品出售到加权池、结构映射以及从你定义的加权列表中抽取的附魔书。交易还可以使用原版的
merchant_predicate 格式,例如将交易限制为一种村民类型(1.21.1 及更高版本)。
- 合并多个修改同一村民的数据包,而不是让最后一个生效。
- 以相同方式自定义流浪商人,拥有其自己的普通和稀有层级,以及在 1.21.8 及更高版本(仅在 1.21.1 且启用“交易重平衡”实验时)拥有的购买层级。
配置
config/villagertradingplus/villagertradingplus-1.0-config.json5
这些设置适用于库构建的所有交易,无论是由哪个模组或数据包定义的。
交易
| 选项 |
默认值 |
作用 |
trade_offers_per_level |
2 |
村民每升一级获得的新交易最大数量。 |
trade_offers_wandering_trader |
5 |
流浪商人提供的交易最大数量。 |
trade_price_multiplier_scale |
1.0 |
缩放需求与声望对价格波动的影响程度。0.0 会冻结两者。不会改变交易的起始价格。 |
trade_cost_scale |
1.0 |
乘以每项交易的基础成本(仅限第一个输入槽位)。2.0 会使所有价格翻倍。结果被限制在 1 .. 一组之间。 |
enable_conditional_trades |
true |
是否实际检查受条件限制的贸易。false 会使所有交易始终显示。 |
enable_time_of_day_pricing |
false |
根据解锁时的游戏时间随机微调交易的成本。价格在解锁时锁定,不会持续变化。 |
time_of_day_price_variance |
0.15 |
该微调的最大幅度,作为成本的分数。仅当上述选项开启时使用。 |
交易屏幕控制
所有三个 allow_ 选项默认关闭。目录对任何玩家开放。重新掷骰按钮和等级控制需要 reroll_permission_level 中的权限级别。它们旨在用于创造模式建造和测试,而非生存服务器。
| 选项 |
默认值 |
作用 |
allow_trade_reroll |
false |
重新掷骰村民或流浪商人交易的按钮,可一次性全部重置或按等级逐个重置。 |
allow_set_villager_level |
false |
设置村民等级(1-5)并重新生成其交易的控件。流浪商人没有等级,因此忽略此设置。 |
reroll_permission_level |
0 |
玩家进行重新掷骰按钮和等级控制所需的命令权限级别(0-4)。0 表示每个玩家,2 表示游戏管理员。 |
allow_view_all_trades |
false |
一个按钮,打开只读目录面板,列出村民在选定等级可能生成的所有交易,包括权重、几率和条件。 |
制作数据包
交易文件位于数据包下的你自己的命名空间中。读取三个文件夹:
| 文件夹 |
作用 |
data/<namespace>/default_villager_trades/<profession>.json |
直接替换某个职业的交易。 |
data/<namespace>/villager_trades/<profession>.json |
添加到某个职业的交易中。 |
data/<namespace>/wandering_trader_trades/<any name>.json |
流浪商人交易。 |
职业文件指定职业名称,并包含五个层级数组:
{
"profession": "minecraft:butcher",
"trades": {
"novice": [],
"apprentice": [],
"journeyman": [],
"expert": [],
"master": []
}
}
下面的每个片段都是一个单一的交易对象,放置在上述五个数组之一中。
注意:jar 包在每个职业的 data/villagertradingplus/vanilla_trades 下都以这种格式提供了所有原版交易。将文件复制到你的数据包中可以替换某个职业。
所有交易类型接受的字段
为了保持示例简短,以下字段未在示例中列出:
| 字段 |
含义 |
max_uses |
交易在锁定前可以使用多少次。 |
villager_experience |
每次使用后村民获得的经验值。 |
price_multiplier |
声望和村庄英雄对该交易价格的影响强度。 |
demand |
播种原版的定价需求:成本随使用次数增加,并随时间衰减。 |
conditions / logic |
见下文条件部分。 |
交易类型带有命名空间 villagertradingplus:。旧的 villagersplus: 命名空间仍被接受,适用于拆分前编写的数据包,但在加载时会记录弃用警告,因此新文件请使用新的命名空间。
交易类型
sell_item
村民以一定价格出售物品。
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:oxeye_daisy", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 2 }
}
buy_item
村民购买物品并支付给你。
{
"type": "villagertradingplus:buy_item",
"buy": { "item": "minecraft:wheat_seeds", "count": 4 },
"reward": { "item": "minecraft:emerald", "count": 1 }
}
sell_tagged_item
出售一个随机成员所属的物品标签(tag)。该成员在交易方案生成时确定,因此拥有此交易的两个村民通常会出售不同的物品。原版交易匹配的是具体物品,所以这并非柜台前的“任意一个”匹配逻辑。
{
"type": "villagertradingplus:sell_tagged_item",
"sell": { "tag": "minecraft:saplings", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 3 }
}
buy_tagged_item
适用于购买的相同逻辑。
{
"type": "villagertradingplus:buy_tagged_item",
"buy": { "tag": "minecraft:flowers", "count": 8 },
"reward": { "item": "minecraft:emerald", "count": 1 }
}
process_item
接受 convertible(可转换物)和 priceIn(输入价格),并返回 sell(出售物),即经典的“给我原材料”类交易。
{
"type": "villagertradingplus:process_item",
"convertible": { "item": "minecraft:dead_tube_coral", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 5 },
"sell": { "item": "minecraft:tube_coral", "count": 1 }
}
multi_input
两个输入,一个输出。原版只有恰好两个购买槽位,因此两个输入中的其中一个就是货币。
{
"type": "villagertradingplus:multi_input",
"input_a": { "item": "minecraft:emerald", "count": 5 },
"input_b": { "item": "minecraft:book", "count": 1 },
"sell": {
"item": "minecraft:enchanted_book",
"enchantments": [ { "id": "minecraft:mending", "lvl": 1 } ]
}
}
weighted_pool
在交易方案生成时,根据权重从多个交易中选择一个。在下例中,雏菊的出现概率是枯萎玫瑰的十倍。
{
"type": "villagertradingplus:weighted_pool",
"pool": [
{
"weight": 10,
"trade": {
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:oxeye_daisy", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 1 }
}
},
{
"weight": 1,
"trade": {
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:wither_rose", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 8 }
}
}
]
}
sell_potion
接受 convertible 和 priceIn,并返回 sell,用于药水形状的交易。sell.count 设置堆叠数量。
{
"type": "villagertradingplus:sell_potion",
"convertible": { "item": "minecraft:potion", "count": 3 },
"priceIn": { "item": "minecraft:emerald", "count": 5 },
"sell": { "item": "minecraft:splash_potion", "count": 1 }
}
sell_map
出售指向某个结构的已填充地图。structure_id 是一个结构标签(tag)。name 是翻译键;省略它将保留原版的地图名称。
{
"type": "villagertradingplus:sell_map",
"structure_id": "minecraft:on_woodland_explorer_maps",
"name": "filled_map.mansion",
"buy": { "item": "minecraft:compass", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 2 },
"price_multiplier": 0.2
}
sell_enchanted_tool
出售带有随机附魔的工具,遵循原版风格。价格会根据随机结果进行缩放。
{
"type": "villagertradingplus:sell_enchanted_tool",
"sell": { "item": "minecraft:diamond_pickaxe", "count": 1 },
"basePriceIn": { "item": "minecraft:emerald", "count": 2 }
}
sell_specific_enchanted_tool
出售带有固定附魔和固定等级的工具,这是确定的结果而非随机抽取。enchantment 默认为 minecraft:fortune,level 默认为 1。
{
"type": "villagertradingplus:sell_specific_enchanted_tool",
"sell": { "item": "minecraft:diamond_pickaxe", "count": 1 },
"basePriceIn": { "item": "minecraft:emerald", "count": 32 },
"enchantment": "minecraft:efficiency",
"level": 4
}
sell_enchanted_book
出售随机附魔的书,遵循原版风格。
{
"type": "villagertradingplus:sell_enchanted_book",
"currency": { "item": "minecraft:emerald" },
"price_multiplier": 0.2
}
sell_specific_enchanted_book
出售带有固定附魔和等级的书。没有 sell 字段,物品始终为书。enchantment 默认为 minecraft:unbreaking,level 默认为 1。
{
"type": "villagertradingplus:sell_specific_enchanted_book",
"basePriceIn": { "item": "minecraft:emerald", "count": 20 },
"enchantment": "minecraft:mending",
"level": 1
}
sell_enchanted_book_from_list
从你定义的加权列表中出售附魔书,这样你可以精确控制图书管理员可以提供哪些附魔。成本计算公式为 base_cost + cost_per_level * level,对于宝藏附魔会乘以 treasure_multiplier。
{
"type": "villagertradingplus:sell_enchanted_book_from_list",
"currency": { "item": "minecraft:emerald" },
"enchantments": [
{ "id": "minecraft:sharpness", "min_level": 1, "max_level": 3, "weight": 5 },
{ "id": "minecraft:unbreaking", "min_level": 1, "max_level": 3, "weight": 5 },
{ "id": "minecraft:mending", "min_level": 1, "max_level": 1, "weight": 1 }
],
"base_cost": 2,
"cost_per_level": 3,
"treasure_multiplier": 2,
"price_multiplier": 0.2
}
条件 (Conditions)
向任何交易添加 conditions 数组以对其施加限制。默认逻辑为“与”(AND);在交易上设置 "logic": "or" 则只需满足其中任意一个条件即可。
时机很重要。 条件仅在交易方案生成时评估一次,即在村民升级时,而不是持续评估。位置相关条件(biome、dimension、job_site_block、config_flag)对于定居的村民是稳定的,因此可靠。世界状态相关条件(weather、day_night、moon_phase、gamerule)则是那一刻的快照:如果一个交易被 night(夜晚)条件限制,一旦它被生成,即使在白天也会保持可用。
可以通过 enable_conditional_trades 全局关闭条件判定。
| 类型 |
字段 |
示例 |
biome |
tag (字符串) 或 biomes (数组) |
{ "type": "biome", "tag": "minecraft:is_ocean" } |
dimension |
dimension |
{ "type": "dimension", "dimension": "minecraft:overworld" } |
weather |
state: clear, rain, thunder |
{ "type": "weather", "state": "rain" } |
day_night |
time: day 或 night |
{ "type": "day_night", "time": "night" } |
moon_phase |
phases (0-7 的数组);默认也要求是夜晚,若需仅按月相判断(即使在白天),请设置 "require_night": false |
{ "type": "moon_phase", "phases": [0] } |
config_flag |
field (布尔值配置项名称),可选 value |
{ "type": "config_flag", "field": "allow_trade_reroll" } |
gamerule |
rule (布尔值游戏内规则),可选 value |
{ "type": "gamerule", "rule": "doInsomnia", "value": true } |
job_site_block |
blocks (数组) 或 wood_variant (与方块 ID 匹配的字符串) |
{ "type": "job_site_block", "blocks": [ "villagersplus:oceanographer_table" ] } |
注意:biomes、blocks 和 phases 接受数组,而 tag、dimension 和 wood_variant 接受单个字符串。
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:heart_of_the_sea", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 30 },
"logic": "or",
"conditions": [
{ "type": "biome", "tag": "minecraft:is_ocean" },
{ "type": "day_night", "time": "night" }
]
}
定价
price_multiplier 和 demand 适用于任何交易,并接入原版的价格机制:
price_multiplier - 决定声望和“村庄英雄”对此次交易价格的影响程度。
demand - 触发原版的库存需求追踪机制。随着交易被使用,成本会上升,随后随时间推移逐渐衰减。
两者均通过 trade_price_multiplier_scale(波动幅度)和 trade_cost_scale(基础成本)在全服范围内进行缩放。原版还会在此基础上应用声望和“村庄英雄”的折扣。
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:diamond", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 12 },
"price_multiplier": 0.1,
"demand": 10
}
自定义物品
任何交易类型的任何物品堆栈都支持此简写功能,无需特殊的交易类型:
| 字段 |
含义 |
name |
显示名称。纯字符串或原始 JSON 文本组件。 |
lore |
描述行数组。 |
enchantments |
{ "id": ..., "lvl": ... } 的数组。 |
color |
可染色护甲的十六进制颜色代码。 |
potion |
药水物品的药水 ID。 |
skull_owner |
玩家头颅的玩家名称。 |
book |
已书写书籍的 { "title": ..., "author": ..., "pages": [...] }。 |
nbt |
原始 SNBT,作为后备方案最后应用。 |
{
"type": "villagertradingplus:sell_item",
"sell": {
"item": "minecraft:diamond_sword",
"name": "{\"text\":\"Excalibur\",\"color\":\"gold\",\"italic\":false}",
"lore": [ "A blade of legend" ],
"enchantments": [ { "id": "minecraft:sharpness", "lvl": 5 } ],
"nbt": "{Unbreakable:1b}"
},
"priceIn": { "item": "minecraft:emerald", "count": 40 }
}
流浪商人交易
创建具有以下目录结构的数据包:
data/<namespace>/wandering_trader_trades
文件名任意。流浪商人不具备村民的五种等级,而是拥有最多三种等级:
buying - 商人购买物品以换取绿宝石的交易(1.21.8 及更高版本;在 1.21.1 中仅在使用“贸易再平衡”实验时可用)。缺少此等级的文件将保留原版的购买交易。
common - 一级。随机选取多个,数量由 trade_offers_wandering_trader 设定。
rare - 二级。恰好选取一个。
设置 "replace": true 以移除原版流浪商人交易并仅使用你自己的。省略该字段(或设置为 false)则会在原版基础上追加。每种交易类型、条件块和定价在此处均与村民完全一致。即使设置了 replace 为 true,没有自定义交易的等级仍会保留原版交易。
{
"replace": false,
"trades": {
"common": [
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:glowstone_dust", "count": 4 },
"priceIn": { "item": "minecraft:emerald", "count": 2 },
"conditions": [ { "type": "day_night", "time": "night" } ],
"max_uses": 6,
"villager_experience": 1
}
],
"rare": [
{
"type": "villagertradingplus:sell_item",
"sell": {
"item": "minecraft:trident",
"name": "{\"text\":\"Traveler's Trident\",\"color\":\"aqua\",\"italic\":false}",
"enchantments": [ { "id": "minecraft:loyalty", "lvl": 3 } ],
"nbt": "{Unbreakable:1b}"
},
"priceIn": { "item": "minecraft:emerald", "count": 30 },
"max_uses": 2,
"villager_experience": 1
}
]
}
}
现成示例文件
在 jar 包内的 data/villagertradingplus/available_trade_examples 目录下,你可以找到完整的、可复制的文件,用于展示片段无法良好展示的案例:
full_profession.json - 涵盖所有五个等级的单一职业,混合了多种交易类型。
conditions_and_pricing.json - 现实交易中条件和定价的应用。
wandering_trader.json - 完整的流浪商人文件。
社区
在 Discord 上提问、分享截图和获取帮助。
LithiumPlus 的其他模组
VanillaTales 是一组小型独立模组的合集,为原版内容增添小故事。仅安装你需要的模组即可。链接均指向 CurseForge。
- Golem Patrol:铁傀儡白天巡逻,夜间站岗,听到钟声会集结。
- Zombie Sieges:将原版的僵尸围攻变成一个真实事件,包含钟声、Boss 血条以及两波僵尸进攻。
- Sherd Stories:为每个装饰花瓶赋予标题及其碎片被发现的地点故事。
- Ghost Crews:为每艘沉船赋予名称,并生成一群溺尸船员守护它,直到被洗劫一空。
- Illager Scouts:掠夺者斥候会监视你的村庄,并在巡逻队到达前两天发出警告。
- Occupied Villages:部分新刷新的村庄已被你可以解放的掠夺者驻军占据。
- Bonded Pairs:将来自同一刷新组的两个生物绑定为一对,它们会互相复仇。
- Raid Aftermath:村民会修复袭击或爆炸在村庄留下的破坏。
- Wayfarer's Landmarks:当你进入某个结构时,显示标题和有用的图标提示。
VillagersTradingPlus is a library that lets mods and datapacks define villager trades in JSON.
Add or replace the trades of any villager, change the currency, gate trades behind conditions and reprice them, all from a datapack.
Versions: 1.20 to 1.20.1, 1.21 to 1.21.1, 1.21.6 to 1.21.8, 1.21.11, 26.1.2, 26.2, 26.3
Support my work on
What this is
VillagersTradingPlus is a library. On its own it adds no villagers, blocks or items: it replaces
the machinery behind villager trading so that mods and datapacks can define trades in JSON.
VillagersPlus is the reference mod built on top of it.
What you can do with it
- Add, delete or overwrite trades for every villager profession, the vanilla ones included.
- Change the currency from emeralds to any item you like.
- Set the amount, max usages, villager experience and price behaviour of each trade.
- Gate trades behind conditions: biome, dimension, weather, time of day, moon phase, gamerule,
job site block or a config flag.
- 16 trade types (15 on 26.1 and newer), from a plain item sale to weighted pools, structure maps and enchanted
books drawn from a weighted list you define. Trades can also use the vanilla
merchant_predicate format, for example to limit a trade to one villager type (1.21.1 and newer).
- Merge multiple datapacks that modify the same villager, instead of letting the last one win.
- Customize the wandering trader the same way, with its own common and rare tiers, plus a buying tier on 1.21.8 and newer (on 1.21.1 only with the Trade Rebalance experiment).
Configuration
config/villagertradingplus/villagertradingplus-1.0-config.json5
These apply to every trade the library builds, no matter which mod or datapack defined it.
Trades
| Option |
Default |
What it does |
trade_offers_per_level |
2 |
Max new trades a villager gains per level. |
trade_offers_wandering_trader |
5 |
Max trades the wandering trader offers. |
trade_price_multiplier_scale |
1.0 |
Scales how strongly prices swing from demand and reputation. 0.0 freezes both. Does not change a trade's starting price. |
trade_cost_scale |
1.0 |
Multiplies the base cost of every trade (first input slot only). 2.0 doubles all prices. Result is clamped to 1 .. one stack. |
enable_conditional_trades |
true |
Whether condition-gated trades are actually checked. false makes every trade always appear. |
enable_time_of_day_pricing |
false |
Randomly nudges a trade's cost based on the in-game time it is unlocked. The price is locked in at unlock and does not keep changing. |
time_of_day_price_variance |
0.15 |
How far that nudge can go, as a fraction of the cost. Only used when the option above is on. |
Trading screen controls
All three allow_ options are off by default. The catalog is open to any player. The re-roll
buttons and the level control need the permission level in reroll_permission_level. They are meant
for creative building and testing rather than survival servers.
| Option |
Default |
What it does |
allow_trade_reroll |
false |
Buttons to re-roll a villager's or wandering trader's trades, all at once or one level at a time. |
allow_set_villager_level |
false |
A control to set a villager's level (1-5) and regenerate its trades. Wandering traders have no levels and ignore it. |
reroll_permission_level |
0 |
Command permission level (0-4) a player needs for the re-roll buttons and the level control. 0 means every player, 2 means game masters. |
allow_view_all_trades |
false |
A button that opens a read-only catalog panel listing every trade a villager could roll at a chosen level, with weights, chances and conditions. |
Making a datapack
Trade files go into a datapack under your own namespace. Three folders are read:
| Folder |
What it does |
data/<namespace>/default_villager_trades/<profession>.json |
Replaces a profession's trades outright. |
data/<namespace>/villager_trades/<profession>.json |
Adds to a profession's trades. |
data/<namespace>/wandering_trader_trades/<any name>.json |
Wandering trader trades. |
A profession file names the profession and holds five tier arrays:
{
"profession": "minecraft:butcher",
"trades": {
"novice": [],
"apprentice": [],
"journeyman": [],
"expert": [],
"master": []
}
}
Every snippet below is a single trade object that goes inside one of those five arrays.
Notice: the jar ships every vanilla trade in this format under data/villagertradingplus/vanilla_trades. Copy a file into your datapack to replace a profession.
Fields every trade type accepts
These are left out of the examples below to keep them short:
| Field |
Meaning |
max_uses |
How often the trade can be used before it locks. |
villager_experience |
Experience the villager gains per use. |
price_multiplier |
How strongly reputation and Hero of the Village move this trade's price. |
demand |
Seeds vanilla's demand pricing: the cost climbs with use and decays over time. |
conditions / logic |
See Conditions further down. |
Trade types are namespaced villagertradingplus:. The old villagersplus: namespace is still
accepted for datapacks written before the split, but it logs a deprecation warning on load, so write
new files against the new one.
Trade types
sell_item
The villager sells an item for a price.
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:oxeye_daisy", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 2 }
}
buy_item
The villager buys an item and pays you.
{
"type": "villagertradingplus:buy_item",
"buy": { "item": "minecraft:wheat_seeds", "count": 4 },
"reward": { "item": "minecraft:emerald", "count": 1 }
}
sell_tagged_item
Sells one random member of an item tag. The member is chosen when the offer is generated, so two
villagers with this trade will usually sell different things. Vanilla trades match a concrete item,
so this is not an "any of" match at the counter.
{
"type": "villagertradingplus:sell_tagged_item",
"sell": { "tag": "minecraft:saplings", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 3 }
}
buy_tagged_item
The same idea for buying.
{
"type": "villagertradingplus:buy_tagged_item",
"buy": { "tag": "minecraft:flowers", "count": 8 },
"reward": { "item": "minecraft:emerald", "count": 1 }
}
process_item
Takes convertible plus priceIn and returns sell, the classic "bring me raw material" trade.
{
"type": "villagertradingplus:process_item",
"convertible": { "item": "minecraft:dead_tube_coral", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 5 },
"sell": { "item": "minecraft:tube_coral", "count": 1 }
}
multi_input
Two inputs, one output. Vanilla has exactly two buy slots, so one of the two inputs is the
currency.
{
"type": "villagertradingplus:multi_input",
"input_a": { "item": "minecraft:emerald", "count": 5 },
"input_b": { "item": "minecraft:book", "count": 1 },
"sell": {
"item": "minecraft:enchanted_book",
"enchantments": [ { "id": "minecraft:mending", "lvl": 1 } ]
}
}
weighted_pool
Picks one of several trades by weight when the offer is generated. Below, the daisy is ten times as
likely as the wither rose.
{
"type": "villagertradingplus:weighted_pool",
"pool": [
{
"weight": 10,
"trade": {
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:oxeye_daisy", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 1 }
}
},
{
"weight": 1,
"trade": {
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:wither_rose", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 8 }
}
}
]
}
sell_potion
Takes convertible plus priceIn and returns sell, for potion-shaped trades. sell.count sets the stack size.
{
"type": "villagertradingplus:sell_potion",
"convertible": { "item": "minecraft:potion", "count": 3 },
"priceIn": { "item": "minecraft:emerald", "count": 5 },
"sell": { "item": "minecraft:splash_potion", "count": 1 }
}
sell_map
Sells a filled map pointing at a structure. structure_id is a structure tag. name is a translation key; leave it out to keep the vanilla map name.
{
"type": "villagertradingplus:sell_map",
"structure_id": "minecraft:on_woodland_explorer_maps",
"name": "filled_map.mansion",
"buy": { "item": "minecraft:compass", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 2 },
"price_multiplier": 0.2
}
sell_enchanted_tool
Sells a tool with a random enchantment, vanilla-style. The price scales with what was rolled.
{
"type": "villagertradingplus:sell_enchanted_tool",
"sell": { "item": "minecraft:diamond_pickaxe", "count": 1 },
"basePriceIn": { "item": "minecraft:emerald", "count": 2 }
}
sell_specific_enchanted_tool
Sells a tool with a fixed enchantment at a fixed level, a guaranteed result rather than a roll.
enchantment defaults to minecraft:fortune, level to 1.
{
"type": "villagertradingplus:sell_specific_enchanted_tool",
"sell": { "item": "minecraft:diamond_pickaxe", "count": 1 },
"basePriceIn": { "item": "minecraft:emerald", "count": 32 },
"enchantment": "minecraft:efficiency",
"level": 4
}
sell_enchanted_book
Sells a randomly enchanted book, vanilla-style.
{
"type": "villagertradingplus:sell_enchanted_book",
"currency": { "item": "minecraft:emerald" },
"price_multiplier": 0.2
}
sell_specific_enchanted_book
Sells a book with a fixed enchantment and level. There is no sell field, the item is always a
book. enchantment defaults to minecraft:unbreaking, level to 1.
{
"type": "villagertradingplus:sell_specific_enchanted_book",
"basePriceIn": { "item": "minecraft:emerald", "count": 20 },
"enchantment": "minecraft:mending",
"level": 1
}
sell_enchanted_book_from_list
Sells an enchanted book drawn from a weighted list you define, so you control exactly which
enchantments a librarian can offer. Cost is base_cost + cost_per_level * level, multiplied by
treasure_multiplier for treasure enchantments.
{
"type": "villagertradingplus:sell_enchanted_book_from_list",
"currency": { "item": "minecraft:emerald" },
"enchantments": [
{ "id": "minecraft:sharpness", "min_level": 1, "max_level": 3, "weight": 5 },
{ "id": "minecraft:unbreaking", "min_level": 1, "max_level": 3, "weight": 5 },
{ "id": "minecraft:mending", "min_level": 1, "max_level": 1, "weight": 1 }
],
"base_cost": 2,
"cost_per_level": 3,
"treasure_multiplier": 2,
"price_multiplier": 0.2
}
Conditions
Add a conditions array to any trade to gate it. The default logic is AND; set "logic": "or"
on the trade to require only one of them.
Timing matters. Conditions are evaluated once, at the moment the offer is generated as the
villager levels up, not continuously. Location conditions (biome, dimension, job_site_block,
config_flag) are stable for a settled villager and therefore reliable. World-state conditions
(weather, day_night, moon_phase, gamerule) are a snapshot of that moment: a trade gated on
night stays available in broad daylight once it has been rolled.
Conditions can be switched off globally with enable_conditional_trades.
| Type |
Fields |
Example |
biome |
tag (string) or biomes (array) |
{ "type": "biome", "tag": "minecraft:is_ocean" } |
dimension |
dimension |
{ "type": "dimension", "dimension": "minecraft:overworld" } |
weather |
state: clear, rain, thunder |
{ "type": "weather", "state": "rain" } |
day_night |
time: day or night |
{ "type": "day_night", "time": "night" } |
moon_phase |
phases (array of 0-7); also requires night by default, set "require_night": false for the bare lunar day |
{ "type": "moon_phase", "phases": [0] } |
config_flag |
field (a boolean config field name), optional value |
{ "type": "config_flag", "field": "allow_trade_reroll" } |
gamerule |
rule (a boolean gamerule), optional value |
{ "type": "gamerule", "rule": "doInsomnia", "value": true } |
job_site_block |
blocks (array) or wood_variant (string matched against the block id) |
{ "type": "job_site_block", "blocks": [ "villagersplus:oceanographer_table" ] } |
Note that biomes, blocks and phases take arrays, while tag, dimension and
wood_variant take a single string.
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:heart_of_the_sea", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 30 },
"logic": "or",
"conditions": [
{ "type": "biome", "tag": "minecraft:is_ocean" },
{ "type": "day_night", "time": "night" }
]
}
Pricing
price_multiplier and demand work on any trade and feed vanilla's own price machinery:
price_multiplier - how strongly reputation and Hero of the Village move this trade's price.
demand - seeds vanilla's demand tracking. The cost climbs as the trade is used and decays again
over time.
Both are scaled server-wide by trade_price_multiplier_scale (swing size) and trade_cost_scale
(base cost). Reputation and Hero of the Village discounts are applied by vanilla on top.
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:diamond", "count": 1 },
"priceIn": { "item": "minecraft:emerald", "count": 12 },
"price_multiplier": 0.1,
"demand": 10
}
Custom items
Any item stack in any trade type accepts this sugar, no special trade type needed:
| Field |
Meaning |
name |
Display name. Plain string or a raw JSON text component. |
lore |
Array of lore lines. |
enchantments |
Array of { "id": ..., "lvl": ... }. |
color |
Hex colour for dyeable armour. |
potion |
Potion id for potion items. |
skull_owner |
Player name for player heads. |
book |
{ "title": ..., "author": ..., "pages": [...] } for written books. |
nbt |
Raw SNBT, applied last as an escape hatch. |
{
"type": "villagertradingplus:sell_item",
"sell": {
"item": "minecraft:diamond_sword",
"name": "{\"text\":\"Excalibur\",\"color\":\"gold\",\"italic\":false}",
"lore": [ "A blade of legend" ],
"enchantments": [ { "id": "minecraft:sharpness", "lvl": 5 } ],
"nbt": "{Unbreakable:1b}"
},
"priceIn": { "item": "minecraft:emerald", "count": 40 }
}
Wandering trader trades
Create a datapack with this directory structure:
data/<namespace>/wandering_trader_trades
Any file name works. Instead of the five villager tiers, the wandering trader has up to three:
buying - the offers where the trader buys something for emeralds (1.21.8 and newer; on 1.21.1 only with the Trade Rebalance experiment). A file without this tier keeps the vanilla buying offers.
common - level 1. Several are picked, the count is set by trade_offers_wandering_trader.
rare - level 2. Exactly one is picked.
Set "replace": true to drop the vanilla wandering-trader trades and use only yours. Omit it
(or set false) to add on top of vanilla. Every trade type, the conditions block and pricing all
work here exactly as they do on villagers. A tier without custom trades keeps the vanilla trades, even with replace set to true.
{
"replace": false,
"trades": {
"common": [
{
"type": "villagertradingplus:sell_item",
"sell": { "item": "minecraft:glowstone_dust", "count": 4 },
"priceIn": { "item": "minecraft:emerald", "count": 2 },
"conditions": [ { "type": "day_night", "time": "night" } ],
"max_uses": 6,
"villager_experience": 1
}
],
"rare": [
{
"type": "villagertradingplus:sell_item",
"sell": {
"item": "minecraft:trident",
"name": "{\"text\":\"Traveler's Trident\",\"color\":\"aqua\",\"italic\":false}",
"enchantments": [ { "id": "minecraft:loyalty", "lvl": 3 } ],
"nbt": "{Unbreakable:1b}"
},
"priceIn": { "item": "minecraft:emerald", "count": 30 },
"max_uses": 2,
"villager_experience": 1
}
]
}
}
Ready-made example files
Inside the jar under data/villagertradingplus/available_trade_examples you will find complete,
copyable files for the cases a snippet cannot show well:
full_profession.json - one profession across all five tiers, mixing many trade types.
conditions_and_pricing.json - conditions and pricing on realistic trades.
wandering_trader.json - a complete wandering trader file.
Community
Questions, screenshots and help on Discord.
More mods by LithiumPlus
- The Graveyard: structures, mobs, blocks and a boss with a graveyard theme. Forge version: The Graveyard (Forge).
- VillagersPlus: new villager types, trades and workstations.
- Nyctophobia: dark, foggy and unsettling biomes for the Overworld.
- DataDrivenVillagers (CurseForge): create and change villager professions from JSON files or an in-game editor.
VanillaTales is a collection of small, independent mods that add little stories to vanilla content. Install only the ones you want. The links go to CurseForge.
- Golem Patrol: iron golems patrol by day, stand watch by night and rally to a ringing bell.
- Zombie Sieges: turns a vanilla zombie siege into a real event, with a ringing bell, a boss bar and two waves of zombies.
- Sherd Stories: gives every decorated pot a title and the story of where its sherds were found.
- Ghost Crews: gives every shipwreck a name and a crew of drowned that guard it until it is looted clean.
- Illager Scouts: a pillager scout watches your village and warns you two days before a patrol arrives.
- Occupied Villages: some new villages spawn already occupied by an illager garrison you can liberate.
- Bonded Pairs: binds two mobs from the same spawn group into a pair that avenges each other.
- Raid Aftermath: villagers repair the damage a raid or an explosion left in the village.
- Wayfarer's Landmarks: shows a title and helpful icons when you enter a structure.
评论 0
登录后参与评分
还没有评论,来抢沙发吧