Jump to content

[1.12] Custom villager trades?


Zeplar

Recommended Posts

If you want to add trades to existing villager professions, you need:

1. Implement EntityVillager.ITradeList

2. Get the profession from ForgeRegistries.VILLAGER_PROFESSIONS

3. Get career from the profession

4. add the ITradeList to the career - #addTrade.

 

Example below:

Implementation which adds 60 emeralds -> 1 Wither skull trade:

public class Trades implements EntityVillager.ITradeList
{
   @Override
   public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random)
   {
      recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD,60),new ItemStack(Items.SKULL,1,1)));
   }
}

 

Then getting a specific profession - nitwit in this case:

VillagerRegistry.VillagerProfession nitwit=ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:nitwit"));

 

And adding the trade to career with id "5":

nitwit.getCareer(5).addTrade(1,new Trades());

 

Figure out desired career and profession by inspecting vanilla classes.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.