Adding a new villager profession
Written
by
for 1.20 - 1.21.1
This guide covers the following:
- Registering a new POI type
- Adding the POI type to acquirable job sites
- Creating a unique sound event
- Registering the new Villager profession
- Adding trades to profession
- Adding assets & resources
Registering a new POI type
-
Use the
PointOfInterestHelperclass from the QSL.public class ModPoiTypes { public static ResourceKey<PoiType> PROFESSION; public static void register() { // `1, 1` are the ticketCount and searchDistance respectively // and all of the default professions use these values by // default for their workstations. PROFESSION = PointOfInterestHelper.register( new ResourceLocation("mod", "profession"), 1, 1, Blocks.BEACON ); } }
Adding the POI type to acquirable job sites
This step is required to make the villager actually start looking for their workstation. If the POI type is not added to the acquirable job sites, villagers will not acknowledge the workstation.
data/minecraft/tags/point_of_interest_type/acquirable_job_site.json
{
"values": [
"mod:profession"
]
}
Creating a unique sound event
Villagers trigger the SoundEvent associated with their profession whenever they interact with their workstation.
Defining sound events
Sound events allow Minecraft to display the correct subtitles and allow you to mix and match existing or new sounds. To
do this, create a sounds.json file in your mod’s asset folder. Refer to the
sounds.json page on the Minecraft Wiki for insights on how to write such file.
In this example we have an Enchanter profession. If its POI was an Enchanting Table then we can re-use Minecraft’s sound.
{
"entity.villager.work_enchanter": {
"subtitle": "subtitles.entity.villager.work_enchanter",
"sounds": [
{
"name": "minecraft:block.enchantment_table.use",
"type": "event"
}
]
}
}
Registering sound events
-
public class ModSoundEvents { public static final SoundEvent SOUND_EVENT = SoundEvent.createVariableRangeEvent( new ResourceLocation("mod:sound_event") ); public static void register() { Registry.register( BuiltInRegistries.SOUND_EVENT, SOUND_EVENT.getLocation(), SOUND_EVENT ); } }
Registering the new Villager profession
-
Instantiate a new
VillagerProfessionwith …- the name of your profession,
- predicates matching primary and secondary job site POIs,
- two sets of blocks that the villager will work with (empty for most Vanilla professions),
- and the
SoundEventcreated previously.
public final class ModVillagerProfessions { public static final VillagerProfession PROFESSION = new VillagerProfession( "profession", // job site predicates holder -> holder.is(ModPoiTypes.PROFESSION), holder -> holder.is(ModPoiTypes.PROFESSION), // used by farmer, crop items ImmutableSet.of(), // used by farmer, farmland ImmutableSet.of(), ModSoundEvents.SOUND_EVENT ); public static void register() { Registry.register( BuiltInRegistries.VILLAGER_PROFESSION, new ResourceLocation("mod", "profession"), PROFESSION ); } }
Adding trades to profession
Minecraft provides several ItemListings, as shown in the table below:
ItemListing |
Example |
|---|---|
ItemsForEmeralds |
![]() |
EmeraldForItems |
![]() |
ItemsAndEmeraldsToItems |
![]() |
EnchantBookForEmeralds |
![]() |
EnchantedItemForEmeralds |
![]() |
SuspiciousStewForEmerald |
![]() |
TippedArrowForItemsAndEmeralds |
![]() |
-
Use the
TradeOfferHelperclass from the QSL.public static void register() { TradeOfferHelper.registerVillagerOffers( CustomVillagerProfession.PROFESSION, /* level */ 1, itemListings -> itemListings.add( new VillagerTrades.ItemsForEmeralds( Items.DIAMOND, 1, 20, 16, 2 ) ) ); }
Adding assets & resources
Language files
Don’t forget to include translation text for the name of your new profession.
assets/mod/lang/en_us.json
{
"entity.minecraft.villager.profession": "Profession"
}
Textures
Provide textures for your new profession in assets/[mod]/textures/entity/villager/profession/[profession].png.
Create a corresponding .mcmeta file, if you want to provide a different hat appearance.
{
"villager": {
"hat": "partial"
}
}






