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 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 )

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.

 

 

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 )

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

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

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've been thrown by one type…
Sat, 07/23/2022 - 22:18

I've been thrown by one type of mob in particular, Variations of sheep, There are quite a few "color" related data parts for them so it's not been simple to follow and so far nothing i tried worked. Either it crashed/refused to load or no mob was detected. I had a look online but the few people i found asking about this seemed to never get answers/ are now very old posts.

The idea is to have a shepherd near sheep = shears the sheep/spawns wool at their position but for this it needs to be able to detect what sheep variation it is to spawn the right wool type.

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can't get everything…
Tue, 07/26/2022 - 05:02

You can't get everything through data tags cause you can get everything through code:

((Sheep) entity).getColor() == DyeColor.BLUE. 

You check all colors, that are given by code above, here, look under enum constants:

https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.18.2/net/minecraft/world/item/DyeColor.html

 

In doing stuff that are not in mcreator its good to know how to read documentation qwq. 

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah I was basically skipping…
Tue, 07/26/2022 - 12:49

Ah I was basically skipping the "dye" part and just putting the color. The code you put I assume goes in a code snippet(null). It ends up crashing on activation so not sure why. I think we had a similar issue before and it got figured out somehow but not sure?

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Code above is for IF…
Fri, 07/29/2022 - 16:05

Code above is for IF statement. I didn't test it, i assume i it should work, it would be better to check if entity is a sheep before checking dyecolor.

 

In docs there might be some useful methods that can sometimes will be better than things built in mcreator but you have to know java programing basics at least to use them. :<