(IDEA) Checking the profession of a villager

Started by ImSeyo on

Topic category: Feature requests and ideas for MCreator

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(IDEA) Checking the profession of a villager
Thu, 04/11/2024 - 11:10 (edited)

At the time of development on one of my mods, I ran into a problem - I needed to check if a villager had a certain profession. As it turned out, there is no procedural block in MCreator responsible for this. I would like you to do that. After a while, I managed to find a way to solve this problem (using custom code), but it does not work with the custom professions of the villagers. To make it easier for you, I'll leave the code:
((Villager) entity).getVillagerData().getProfession() == VillagerProfession.PROFESSIONNAME

Edited by ImSeyo on Thu, 04/11/2024 - 11:10
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm trying to check a…
Tue, 05/07/2024 - 16:45

I'm trying to check a vanilla Villager profession (Nitwit, specifically) but I can't figure out how to properly implement it into my procedure blocks; when I try to run the gradle after copy-pasting your above line of code into a Custom Code block, it returns an error and can't compile properly. How did you get it to work?

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
duststar860 The procedure…
Wed, 05/08/2024 - 06:53

duststar860 The procedure must be exactly like this:procedure
I inserted it into the code block:
((Villager) entity).getVillagerData().getProfession() == VillagerProfession.FARMER 

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you so much!! I really…
Fri, 05/10/2024 - 17:24

Thank you so much!! I really appreciate it!

Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
do you know how to use this…
Thu, 08/15/2024 - 18:59

do you know how to use this with professions from other mods? using their namespace i mean

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
mohammed fawzi I have not…
Thu, 08/22/2024 - 05:10

mohammed fawzi I have not found a way to do this. Try asking ChatGPT, he's been helping me a lot lately with the codes for my mod. But it may take you a VERY long time to create the right code using ChatGPT. It sometimes takes me 5 hours for small codes

Joined May 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A few weeks late, but I…
Sun, 09/08/2024 - 21:12

A few weeks late, but I found a "fix" to only work on your custom professions.

You can make the procedure NOT work on every vanilla profession, only leaving the modded ones. This does, annoyingly, restrict it to just one custom profession generally (depending on what you're doing) though.