Creating your own datapack - DrexHD/VillagerConfig GitHub Wiki
I have developed an online generator to create VillagerConfig datapacks. We will use this generator in this tutorial, however it is also possible to manually create datapacks for this mod.
Generator Overview
Link: https://drexhd.vercel.app/villagerconfig/
The major elements of the generator are:
- The buttons in the center/left, which allows you to create and modify your trades as you wish.
- A trade preview on the right, which showcases a random (you can click the refresh icon to get a new collection of trades) generation of your trades, where all tiers are unlocked.
- A code window, which shows the
json
equivalent of your "button input"
First datapack
You have two options to start working on your custom trades. The first option is: to use a vanilla trade as your base, and modify it according to your preferences. The second option is: to start from nothing and create everything yourself.
Presets
To load a vanilla trade preset click the Presets
button at the top and choose the profession you want to use as your preset.
In this tutorial we will change thae vanilla farmer to replace the wheat to emerald trade with a trade of glow berries to iron ingots
To do this we look for the trade, which has wheat as Cost A
(first input item) and replace it with glow berries. We then navigate a bit further down and look for Result
(what villagers give in return) in the same section and replace it with iron ingots.
Exporting
After we have modified the trades in the generator we want to export them to a datapack that we can use in our world / server.
The first step for this is to save the trade file we just created. You can do this by clicking the 3 dots next to the green version and picking Save as
. When you are prompted for the Resource location
that you want to use for saving you need to type the profession that you want to replace.
At the moment of writing these are all vanilla professions: armorer
, butcher
, cartographer
, cleric
, farmer
, fisherman
, fletcher
, leatherworker
, librarian
, mason
, nitwit
, none
, shepherd
, toolsmith
, weaponsmith
Because we want to modify the farmer
trades we pick farmer
and click Save as
to confirm. You should now be able to click the Show project
(little book icon) to bring up an overview of all your saved files!
You can now click the three dots in the project window and choose Download data pack
to download a usable datapack with your trades.
Testing
To test your datapack put it (the zip you got from the generator) into your worlds / servers datapack
folder. After running /reload
or rejoining your world / rebooting your server, the datapack should now be listed in /datapack list
.
You can now spawn new villagers and check their trades, if you followed all steps correctly you should now see your trades in-game.
Note that in our example the glow berries wont show up for each farmer villager, similar to how vanilla villagers don't always trade wheat. Just try again until you see them. You can optionally also increase the Num to select
value to ensure all trades are picked!
What's next?
You are now equipped with the basic knowledge to create your own custom trades. For more detailed information about the way trades are defined you should continue by reading Understand the trade structure