[SPIGOT-5036] Villager#setProfession() doesn't work as expected Created: 06/Jun/19  Updated: 08/Feb/20

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Nico Hofmann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: 1.14, professions, trade, villager

Version: git-Spigot-baafee9-0fc6922
Guidelines Read: Yes

 Description   

The method Villager#setProfession() sets the villager's profession but it's appearance won't change and he won't offer any trades even if you add some by using Villager#setRecipes().

This could happen because a villager needs a "working block" in order to change it's profession "naturally". By setting the profession using the method Villager#setProfession() he won't get this block, so his appearance won't change and he won't generate (or accept manually added)  offers.



 Comments   
Comment by md_5 [ 08/Feb/20 ]

The API docs state under the (get|set)VillagerLevel methods that 'A villager with a level of 1 and no experience is liable to lose its profession.' I don't think the API needs to be changed in any way, except perhaps adding that note to the (get|set)VillagerExperience and (get|set)Profession methods.

Comment by TheCreeperCow [ 21/Jan/20 ]

In that case ill make it so that if there is already a level set it wont override the level but if there is no level set ill set it to level 1

Comment by Dylan Xaldin [ 20/Jan/20 ]

Agreed - setting the profession should not change the villagers level.... that doesn't make sense. It's also already covered in the API docs that villagers without XP are liable to lose their profession.

Comment by md_5 [ 20/Jan/20 ]

I think a cleaner solution would be ensuring that the villager has an appropriate level when calling setProfession?

Comment by TheCreeperCow [ 18/Dec/19 ]

Would you guys be ok if we automatically assign level 1 if setProfession() is called?

Comment by detig_iii [ 24/Jun/19 ]

Ensure that the villager has an appopriate level for the profession you're trying to set. Otherwise it will revert back to no profession. This seems very unintuitive and should be mentioned in the documentation of Villager#setProfession().

Comment by Black Hole [ 06/Jun/19 ]

Possible a duplicate of SPIGOT-4776

Generated at Tue Apr 22 04:30:17 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.