How do I select specific mob types?

Started by CaptainShark on

Topic category: Help with modding (Java Edition)

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I select specific mob types?

Currently messing around with a villager related mod but it relies on 4 types.

I have 4 new chests, a farmer, butcher, shepherd and then an "all villager types" chest.
How do I use a procedure to work with just the one type of villager, for example a farmer?
 

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
the code snippet :- (event…
Fri, 07/15/2022 - 13:46

template code

original code (we will replace the 0 == 0)

final code

the code snippet :-

(event.getType() == VillagerProfession.FARMER)

replace the FARMER with any profession of choice the spelling is in all caps no special characters like_,-+= anything in between

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hope it helps ;) 
Fri, 07/15/2022 - 13:47

Hope it helps ;) 

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
also I mean the spelling of…
Fri, 07/15/2022 - 13:48

also I mean the spelling of the profession of choice in all caps

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah should help now
Fri, 07/15/2022 - 14:04

yeah should help now

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Uhh, you sure that there's  …
Fri, 07/15/2022 - 14:08

Uhh, you sure that there's 

event.getType()

method that returns enum VillagerProfession? 

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I believe I copied it all…
Fri, 07/15/2022 - 14:28

I believe I copied it all including the despawn part. When test running the workspace though it comes back with the "your workspace contains mod elements" message and lists the same element as the issue

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I only mean this part: …
Fri, 07/15/2022 - 14:33

I only mean this part:

(event.getType() == VillagerProfession.FARMER)

 

I answered basing on pretty good (unofficial) forge documentation. Also by code snippet i meant the one in Advanced category. 

https://nekoyue.github.io/ForgeJavaDocs-NG/

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also i just noticed that…
Fri, 07/15/2022 - 14:37

Also i just noticed that there's no

import net.minecraft.world.entity.npc.VillagerProfession;

Which stores vanilla Villager professions.

Im sure it will crush.

 

I'll send picture tomorrow. It'll be easier to explain how to do it. 

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay cool lmao. It will  be…
Fri, 07/15/2022 - 14:49

Okay cool lmao. It will  be a lot easier after seeing the working versions of the procedure blocks and the working code if it gets edited. It will get a bit more complicated at the next few steps of the mod but to keep it simple for now it just needs to make sure a specific villager type is required to summon an entity ( purely so it is easier to understand, eventually it will have to involve breaking blocks/custom chests )

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh yeah I realised that too …
Fri, 07/15/2022 - 15:45

oh yeah I realised that too 

import net.minecraft.world.entity.npc.VillagerProfession;

heres that

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah I'm pretty sure I even…
Fri, 07/15/2022 - 15:47

yeah I'm pretty sure I even checked it from the villager trades code that's how their doin' it

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Fri, 07/15/2022 - 15:49

heres that

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
regarding teh whole import…
Fri, 07/15/2022 - 15:50

regarding teh whole import thing: 

import net.minecraft.world.entity.npc.VillagerProfession;

put that somewhere in the chunck of imports or anywhere at the top really