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:
of course below the package…
Fri, 07/15/2022 - 15:51

of course below the package part

Last seen on 15:21, 16. Oct 2023
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?

Last seen on 06:13, 28. Aug 2023
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 )

Last seen on 15:21, 16. Oct 2023
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. 

Last seen on 06:13, 28. Aug 2023
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

Last seen on 15:21, 16. Oct 2023
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…

Last seen on 16:41, 1. May 2024
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

Last seen on 16:41, 1. May 2024
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

Last seen on 15:21, 16. Oct 2023
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. 

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah perfect that works thanks…
Mon, 07/18/2022 - 06:45

Ah perfect that works thanks. I can identify each type individually now as the starting entity and no worries about the delay aha. All that is left now i believe is to work out
1. How to test mob distance ( for example if a fisherman is near an axolotl, then summon a salmon on the position of the axolotl with a cooldown so it is not spammed )

2. How to check a mob is near a block ( for example a farmer near a melon  + near a second block, custom chest ) then break the block/turn it into air and spawn the item in the custom chest

I think the rest are all combinations of the above. Checking blocks in range + an entity or another block. spawning items in the custom chests. cooldowns related to entities actions. specifically targeting entities to use ( such as spawn salmon only for axolotls, clerics only healing villagers and golems )

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The cooldown you can think…
Mon, 07/18/2022 - 07:29

The cooldown you can think out yourself (cause im lazy >:3). 

 

For checking mobs there's procedure "For each entity as EntityIterator at x: _ y: _ z: _ in square cube with size _ do _" 

This is a loop that will do your stuff for each found entity (given as EntityIterator). You can mix it with global trigger "On entity tick update". 

 

I don't know if there's procedure (in mcreator) that will alow you work on blocks within range.

 

For cooldown i would say data tags (nbt tags) to save value (i don't know if mcreator global variables will work). You can save cooldown as (Seconds * 20 ticks) and lower it each tick (1 second = 20 ticks).

You can check if mob's cooldown equal or lower than 0 (mah safety if cooldown somehow gets lower than 0 qwp), if it is you can use for each loop to do stuff to entitles,

otherwise you lower cooldown by one tick qwq.

 

 

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://i.imgur.com/FZLVPvU…
Mon, 07/18/2022 - 09:09

https://i.imgur.com/FZLVPvU.png  <-- That is the current procedure i tried which did not work. I've not managed to work out how to specify what the Iterator is/that was my best guess lol. I've just changed the trigger from right click to "On loaded entity tick update"

I will probably wait to do cooldowns until the rest works because i have not used tags before so it may be a whole other thing lmao. If there is not a way to do it in mcreator ( that will allow you work on blocks within range. ) can this work somehow?:

Farmer every 30 seconds runs a procedure or something that turns all melons in a 5 x 5 radius into air, then spawns the same amount of melons in a chest/custom block with inventory. ( But only 1 chest, not say, break 5 melons, spawn 5 melons in every chest )

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It doesn't work because of…
Mon, 07/18/2022 - 09:25

It doesn't work because of checking entity tags (i guess there's something wrong u entered).

Use "Is Entity iterator (sub)type of Axolotl", instead :3

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That works I overthought it…
Mon, 07/18/2022 - 13:34

That works I overthought it I guess lol. It's just the tags then that I need to figure out and then the fisherman one should work as intended, the rest i can figure out most likely using this as an example. Looked up some examples, I assume the "get event/target entity tag = false" part basically makes the entire procedure only work when it's set to false. I'm not entirely sure how to connect it all up though since the original "if" block has both slots taken up. https://i.imgur.com/9w3oLFu.png