Get entity target for attack

Started by U.S.S.DEFIANT on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Get entity target for attack

Good evening.

I want to make a procedure for mob AI: if player have some effects, attack him. How can I get the target, that mob want to attack? I tried to use: Get Entity (Event/target entity) is targeting for attack, but it returned null. How can I fix it?

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Any idea about this?
Thu, 04/04/2024 - 15:36

Any idea about this?

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The returning null error for…
Thu, 04/04/2024 - 15:45

The returning null error for the 'Get Entity (Event/target entity) is targeting for attack' can be bypassed by putting it in an if block that checks is Get Entity (Event/target entity) is targeting for attack (sub)type of LivingEntity. I don't know why, but it works without crashing.

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Got the same issue. So im…
Tue, 09/24/2024 - 14:36

Got the same issue. So im new to mcreator and I want to make my boss detect the player. Can you explain your answer a bit more cause im new? (screenshot would help A LOT)

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Basically, to fix the error…
Tue, 09/24/2024 - 15:29

Basically, to fix the error of the procedure returning null, you need to put the whole thing in an if block.

In the if block's condition, you put the [is [target entity] (sub)type of {type}] block, but you change the {type} dropdown to be LivingEntity, and you replace [target entity] with [get entity [target entity] is targeting for attack] That should fix the issue.

The end result should be:

[if [is [get entity [target entity] is targeting for attack] (sub)type of {LivingEntity}]]

     Do your procedure

Sorry about the lack of screenshot, I don't use image hosting websites, so I can't post a screenshot.

Also, just to clarify, I am using square brackets[] to indicate different procedure blocks, and curly brackets{} to show a dropdown menu.

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could use on entity tick…
Thu, 09/26/2024 - 00:51

You could use on entity tick update. Entity iterator is square cube of (attack range of mob). If entity iterator has effect X then set attack target of event/target entity to entity iterator. You could make a local variable to check whether theres more than 1 entity with the effect in range and target one specifically using a random integer or whatever.

If you want the entity to be passive unless the player has the effect then make the ai for the mob to only attack after being attacked first. Probably works.

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks everyone!
Sat, 09/28/2024 - 09:25

Thanks everyone!