How do I select specific mob types?

Started by CaptainShark on

Topic category: Help with Minecraft modding (Java Edition)

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?
 

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? 

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

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/

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. 

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 )

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
But both Event class and…
Fri, 07/15/2022 - 18:57

But both Event class and PlayerEvent.EntityInteract class do not have direct access to Villager Profession, so I don't know how it's gonna work?

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Gonna list basically the…
Fri, 07/15/2022 - 20:20

Gonna list basically the full list of what I planned for the specific villagers to do. Are they possible, insanely difficult to do, or simpler than expected lol

When a Farmer is near a crop ( like melon/pumpkin, non vanilla harvested ones ) AND is near a "Farmer's Chest" ( custom block )
Break the Melon, spawn 1 melon in the Farmers Chest

Fisherman near an axolotl = Spawn a salmon at the position of the Axolotl ( on a 2 minute cooldown )

Shepherd near a sheep with wool AND "Shepherds Chest" = Shear nearby sheep and spawn the correct wool in the Shepherds chest

Butcher near pig/cow/chicken AND "Butchers Chest" = Kill 1 animal and spawn the food in the "butchers chest" ( 1 minute cooldown )

Cleric near any villager or golem = gives them 10 seconds of regen 1 ( 1 minute cooldown )

Any villager near 2 of the same: sheep, pig, cow, chicken AND "Breeding Chest" if 2 wheat in chest spawn 1 baby of 1 type of the nearby animals ( 5 minute cooldown )

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So i guess it'll be working…
Fri, 07/15/2022 - 21:36

So i guess it'll be working on entity update tick (or sth like this i don't remember how it's called).

For checking entities (like sheep, chicken etc) you'd have to loop though all entities with some range (there's a procedure for this in mcreator blocks, something like "for each entity") and do your stuff for each found entity.

 

About blocks/crops i have no idea. 

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I assume blocks/crops I can…
Fri, 07/15/2022 - 23:23

I assume blocks/crops I can test for block in radius similar to entity radius checks? I am fairly sure if 1 of them works I can then mostly copy and paste for the others/edit the small parts like which chest/which villager from the first example. I just one doe with pictures of it all so I can understand it lol

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, sorry for the delay, i…
Sun, 07/17/2022 - 19:58

Okay, sorry for the delay, i have Internet and yesterday couldn't make new project (i was re-downloading mcreator cause im trying to do a thing qwq). 

 

Anyway, here how "if" block looks like:

 

Procedure

 

And code snippet you can find here:

Snippet find 1

Snippet find 2

 

And to this snippet paste:

((Villager) entity).getVillagerData().getProfession() == VillagerProfession.FARMER 

 

For other professions just change "FARMER". But remember that it has to be uppercase. 

If pics didn't show or something, here raw url:

https://raw.githubusercontent.com/Azzy380/json-files/main/Img/procedure…

https://raw.githubusercontent.com/Azzy380/json-files/main/Img/Untitled1…

https://raw.githubusercontent.com/Azzy380/json-files/main/Img/Untitled2…

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok but how did this post get…
Sun, 07/17/2022 - 19:59

ok but how did this post get 34 replies

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
in only a few minutes
Sun, 07/17/2022 - 20:00

in only a few minutes

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This thread has a week soo,…
Sun, 07/17/2022 - 20:08

This thread has a week soo,

That happens when you forget stuff qwp.