AI ATTACK CONDITIONS

Started by woodcreatures on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
AI ATTACK CONDITIONS

Need help please, I've been stucked here since two weeks now.

I need to make an attack conditions in my entity AI which says my entity only attacks creatures under a specific tag

I see that only way is using "get entity event target rate is targeting for attack" btu this is a NULL block. Any way I try or it crashes the game or it does nothing.

I have tried many different return values, many different ways but nothing to do

Anyone can please show me the correct procedure ?

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try using the "For each…
Sat, 12/14/2024 - 19:07

Try using the "For each entity as entity iterator" block.

Make a new "target" local entity variable and a "distance" local number variable.

Set the number to the range of your custom entity in blocks.

Go through all entities in your custom entities' range, and do the following:
Check if the current entity iterator has the tag.
If it does, check if it's distance to the custom entity is shorter than the "distance" variable.

If both conditions apply, after the "For each entity block" finishes, you will have to set your custom entities' target to the "target" local variable.

Tell me if it worked!