Data Trades
此模组允许玩家、服务器管理员或整合包制作者使用数据包覆盖村民交易。
可以使用 JSON 文件自定义每个等级的交易数量以及实际交易的物品。
名为 /villagers refresh 的开发用命令可手动触发所有已加载村民的交易重新分配。
文件夹结构
使用数据包时,可以通过创建遵循以下模式的 JSON 文件来覆盖特定村民职业的交易:
data/[namespace]/villager/professions/[path].json
[namespace] 和 [path] 应替换为具体的村民职业 ID。
例如,要为 minecraft:fletcher(箭匠)职业创建交易,
应在 data/minecraft/villager/professions/fletcher.json 下创建一个文件。
其内容应符合 Profession 模式。
类似地,可以通过在以下位置添加文件来覆盖流浪商人:
data/minecraft/villager/traders/wandering.json
并遵循 Trader 模式。
示例
包含示例的数据包可以在 这里 找到。
JSON 模式
JSON 文件应包含具有以下属性的对象:
Profession
| Property | Type | Default | Description |
|---|---|---|---|
| levels | map<int,TradeLevel> | {} |
见下文 |
levels 对象采用带有数字键和对象值的映射形式。
键代表实际的村民等级,1 对应 Novice(新手),直到 5 对应 Master(大师)。
Trader
| Property | Type | Default | Description |
|---|---|---|---|
| generic | TradeLevel | null |
普通交易 |
| rare | TradeLevel | null |
稀有交易 |
在原版 Minecraft 中,每个流浪商人在生成时会选择 5 个普通交易和 1 个稀有交易。 可以使用与村民等级相同的格式来覆盖这些交易本身及其数量。
TradeLevel
| Property | Type | Default | Description |
|---|---|---|---|
| take | NumberProvider | null |
此等级添加的交易数量 |
| trades | (Trade | string)[] | [] |
从中随机选择被取出的交易的列表 |
Trade
| Property | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false |
禁用的交易将被忽略 |
| sells | TradeIngredient | [] |
出售给玩家的物品 |
| wants | TradeIngredient[] | [] |
玩家必须支付的最大两项物品 |
| uses | int | 0 |
|
| maxUses | int | 10 |
|
| xp | int | 1 |
|
| priceMultiplier | float | 2.0 |
|
| demand | int | 0 |
TradeIngredient
对原版 Ingredient 的扩展,带有几个额外属性。
它们可以是物品或标签的形式,并指定原版 Ingredient JSON 的所有属性。
由于村民交易是基于 ItemStack 的,这并不意味着玩家可以用 #minecraft:stone_tool_materials
中的任何石头类型进行支付,而只能是用每次使用该交易时从标签中随机选定的那种石头类型。
| Property | Type | Default |
|---|---|---|
| functions | LootFunction[] | [] |
| count | int | null |
levels 对象采用带有数字键和对象值的映射形式。
键代表实际的村民等级,1 对应 Novice(新手),直到 5 对应 Master(大师)。
高级用法
除了 Trade 对象外,TradeLevel 的 trades 属性还可以包含引用外部交易的 string ID。
这些交易可以保存在以下路径下,以便组织和重用。
data/[namespace]/villager/trades/[path].json
Data Trades
This mod adds the ability for players, serverowners or modpack creators to overwrite villager trades using datapacks.
The amount of trades per level and the actual items traded can be customized using json files.
A command for development purposes called /villagers refresh will manually trigger a re-asign of trades to all loaded villagers.
Folder Structure
Using a datapack, the trades of a specific villager profession can be overwritten by creating a JSON file following this pattern:
data/[namespace]/villager/professions/[path].json
[namespace] and [path] should be overwritten by the specific villager professions ID.
For example, to create trades for the minecraft:fletcher profession,
a file under data/minecraft/villager/professions/fletcher.json should be created.
It's content should follow the Profession Schema
Similar, the wandering trader can be overwritten by adding a file at
data/minecraft/villager/traders/wandering.json
following the Trader Schema
Examples
Datapacks with examples can be found here.
JSON Schema
The JSON file should contain an object with these properties:
Profession
| Property | Type | Default | Description |
|---|---|---|---|
| levels | map<int,TradeLevel> | {} |
see below |
The levels object takes the form of a map with numeric keys and object values.
The keys represent the actual villagers level with 1 being Novice until 5 being Master.
Trader
| Property | Type | Default | Description |
|---|---|---|---|
| generic | TradeLevel | null |
generic trades |
| rare | TradeLevel | null |
rare trades |
In vanilla minecraft, each wandering trader chooses 5 generic and 1 rare trades once it spawns. Both the trades themselves and their count can be overwritten using the same format as the one used for a villager's level.
TradeLevel
| Property | Type | Default | Description |
|---|---|---|---|
| take | NumberProvider | null |
amount of trades added by this level |
| trades | (Trade | string)[] | [] |
list of trades from which the taken ones are randomly choosen |
Trade
| Property | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false |
disabled trades will be ignored |
| sells | TradeIngredient | [] |
item sold to the player |
| wants | TradeIngredient[] | [] |
maximum of two items the player has to pay |
| uses | int | 0 |
|
| maxUses | int | 10 |
|
| xp | int | 1 |
|
| priceMultiplier | float | 2.0 |
|
| demand | int | 0 |
TradeIngredient
Extension of the vanilla Ingredient with a few extra properties.
They can take the form of an item or tag and specify all properties of the vanilla Ingredient JSON.
Since Villager trades are ItemStack based that does not mean that a player can pay a #minecraft:stone_tool_materials
with any stone type, but only the one that is randomly selected from the tag each time the trade is used.
| Property | Type | Default |
|---|---|---|
| functions | LootFunction[] | [] |
| count | int | null |
The levels object takes the form of a map with numeric keys and object values.
The keys represent the actual villagers level with 1 being Novice until 5 being Master.
Advanced Usage
Instead of a Trade object, the TradeLevel trades property can also contain string IDs referencing an external
trade.
These trades can be saved under the path below to organize & reuse them.
data/[namespace]/villager/trades/[path].json
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
下载 Data Trades
- 再次捕获解码战利品条件与函数时的异常
- 为编解码器提供注册表上下文
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
评论 0
登录后参与评分
还没有评论,来抢沙发吧