Data Trader
A modification that adds a new trader to the game with full customization through data packs.
Configuring Trade Offers
File Structure
The trader works with JSON files containing lists of trade offers. Here's an example configuration:
{
"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
}
]
}
This example shows one trade offer. The player must provide items from the buy and buyB fields to receive the item from the sell field. The maxUses parameter determines how many times the deal can be made before the trader needs to restock.
If rewardExp is set to true, the player will receive experience points for each transaction in the amount specified in the xp field.
Required parameters:
buysell
Default values:
| Parameter | Default Value |
|---|---|
buyB |
Air |
rewardExp |
false |
xp |
0 |
File Placement
Trade offer files are placed in data packs at the path <modid>/trader_offers/.
Usage
The trader can be summoned using the /summon command or by using a spawn egg. Then set the trade offers with the command /datatrader setOffer @e <modid>:<path>. For a regular trader, it's recommended to set the NoAI parameter to true.
You can also summon a trader with ready-made offers using the command /datatrader summon ~ ~ ~ <offer_id> <NoAI>.
Appearance Customization
To customize the trader's texture, place a file at the path <modid>:textures/entity/trader/<offer_id path>.png. This texture should be similar to villager profession textures, for example, minecraft:textures/entity/villager/profession/cleric.png.