Data Trader
A villager like entity which can be used as trader. Customizable with data packs.
介绍
Porting information for 26.1 update
Data Trader
A mod which adds a new trader to the game.
Defining the trades
File structure
The trader can receive an ID for a trader offers “recipe”. This is a list of single trader offers. An example
file could look like this:
1.20.1
{
"Offers": [
{
"buy": {
"tag": "forge:gems/diamond",
"count": 3
},
"buyB": {
"item": "minecraft:wooden_pickaxe"
},
"sell": {
"item": "minecraft:diamond_pickaxe",
"nbt": "{Damage:0,Enchantments:[{id:\"minecraft:efficiency\",lvl:2},{id:\"minecraft:unbreaking\", lvl:10}]}"
},
"rewardExp": false,
"xp": 0
}
]
}
1.21.1
{
"Offers": [
{
"buy": {
"count": 1,
"items": {
"item": "minecraft:wooden_pickaxe"
}
},
"buyB": {
"count": 3,
"items": {
"tag": "c:gems/diamond"
}
},
"sell": {
"components": {
"minecraft:enchantments": {
"levels": {
"minecraft:efficiency": 2,
"minecraft:unbreaking": 10
}
}
},
"count": 1,
"id": "minecraft:diamond_pickaxe"
}
}
]
}
This example includes only one merchant offer. The trader will sell the item in sell.
The player needs to provide the item in buy and buyB to receive the item.
maxUses is the amount of times the player can use this trade before the trader needs to restock.
If rewardExp is true, the player will receive xp points for each trade, amount defined in xp.
The following values are required:
buysell
The default values are:
| Name | Default value |
|:——————-:|:—————:|
| buyB | Air |
| rewardExp | false |
| xp | 0 |
Where to put it in?
You use a data pack to provide these files. These are located at <modid>/trader_offers/. An example can be found
here.
How to use?
You spawn the trader using the /summon command, or by using the spawn egg. After this, you use the command
/datatrader setOffer @e <modid>:<path> to set the recipe. This can also be done by datapacks.
For a normal trader, I recommend setting NoAI to true.
You can also summon a trader with a specific trading table by using the
command /datatrader summon ~ ~ ~ <offer_id> <NoAI>
Setting custom skin overlay
Just put a texture to <modid>:textures/entity/trader/<offer_id path>.png. This texture should be something like the
profession overlay texture, e.g. minecraft:textures/entity/villager/profession/cleric.png.
You are allowed to put this mod in any modpack you like.
常见问题
Data Trader 支持哪些 Minecraft 版本?
Data Trader 支持 Minecraft Java 版 1.18.2–1.21.1,共 7 个版本,可用的加载器:Forge / NeoForge。下载时注意选择和你游戏版本一致的文件。
Data Trader 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Forge / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。
MelanX 的其他作品
查看全部 →LibX
LibX 是一个前置模组,包含大量在多个模组间共用的代码。
Simple Backups
一个用于创建定时备份的简单模组。
Extra Disks
Extra Disks 为 Refined Storage 1.14+ 添加了更大容量的磁盘。
AIOT Botania
这个模组为植物魔法添加了AIOT。
评论
登录后评论和评分