Data Trades
This mod enables players, server owners, and modpack creators to customize villager trades using datapacks. You can configure the number of trades per profession level and the actual exchange items through JSON files.
For development convenience, the /villagers refresh command is available, which forcibly updates trade offers for all loaded villagers.
Folder Structure
To override trades for a specific villager profession, create a JSON file at the following path:
data/[namespace]/villager/professions/[path].json
Replace [namespace] and [path] with the identifier of the desired profession. For example, for the minecraft:fletcher profession, the file should be located at data/minecraft/villager/professions/fletcher.json and follow the Profession schema.
Similarly, you can modify the wandering trader's offers by creating a file at:
data/minecraft/villager/traders/wandering.json
which should follow the Trader schema.
JSON Schemas
Profession
The file should contain an object with the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
| levels | map<int,TradeLevel> | {} |
see below |
The levels object represents a map with numeric keys and object values. The keys correspond to villager levels: from 1 (Novice) to 5 (Master).
Trader
| Property | Type | Default | Description |
|---|---|---|---|
| generic | TradeLevel | null |
generic trades |
| rare | TradeLevel | null |
rare trades |
In vanilla Minecraft, each wandering trader selects 5 generic and 1 rare trade upon spawning. Both trade types and their quantities can be modified using the same format as for villager levels.
TradeLevel
| Property | Type | Default | Description |
|---|---|---|---|
| take | NumberProvider | null |
number of trades added by this level |
| trades | (Trade | string)[] | [] |
list of trades from which active ones are randomly selected |
Trade
| Property | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false |
disabled trades are ignored |
| sells | TradeIngredient | [] |
item sold to the player |
| wants | TradeIngredient[] | [] |
up to two items the player must pay |
| uses | int | 0 |
|
| maxUses | int | 10 |
|
| xp | int | 1 |
|
| priceMultiplier | float | 2.0 |
|
| demand | int | 0 |
TradeIngredient
An extension of the vanilla Ingredient with additional properties. Can take the form of an item or tag and define all properties of the vanilla ingredient JSON. Since villager trades are based on ItemStack, this doesn't mean the player can pay #minecraft:stone_tool_materials with any stone type, but only the one randomly selected from the tag each time the trade is used.
| Property | Type | Default |
|---|---|---|
| functions | LootFunction[] | [] |
| count | int | null |
Advanced Usage
Instead of a Trade object, the trades property in TradeLevel can contain string identifiers referencing external trades. These trades can be saved at the path below for organization and reuse:
data/[namespace]/villager/trades/[path].json