
SimpleJsonVillagerTrades
This library provides a straightforward way to customize villager trading in Minecraft using datapacks. The mod allows you to both modify existing trades and add completely new offers through JSON files.
For Datapack Creators
You can edit villager trade offers using JSON files placed in the data/<namespace>/trade_offers/
directory. Here's an example of adding a ruined portal map to the cartographer's trades:
{
"__COMMENT": "Adds a ruined portal map to the cartographer's trades",
"profession": "minecraft:cartographer",
"replace": false,
"offers": {
"apprentice": [
{
"type": "minecraft:sell_map",
"price": 5,
"name_key": "filled_map.ruined_portal",
"feature_tag": "minecraft:ruined_portal",
"icon": "target_x",
"max_uses": 10,
"experience": 2
}
]
}
}
Compatibility
The library uses Minecraft's standard trading system as a foundation, making it compatible with most mods, including those that add new villager professions. You can also export all current trade offers as a datapack using the sjvt:build
command.
For Mod Developers
To integrate into your project, add the following settings to your build.gradle
file (replace [TAG]
with the current version):
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
dependencies {
modImplementation include("maven.modrinth:sjvt:[TAG]") // To include in your mod
modImplementation "maven.modrinth:sjvt:[TAG]" // For separate installation
}
Creating Custom Trade Offer Factories
To create your own trade offer factory, implement the SerializableTradeOfferFactory
interface. Then register the codec in the TradeOfferFactories.TRADE_OFFER_FACTORY_REGISTRY
registry. The CodecHelper
class provides helper methods to simplify codec creation.