Reset Attack Target?

Started by Mindthemoods on

Topic category: Help with modding (Java Edition)

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Reset Attack Target?

Loving the new pathfinding stuff, but one issue I've come across is a means of resetting an entity's attack target. (That is, not changing it, but rather setting it back to noone.) Attempting to set the attack target to a null entity produces a compilation error, and attempting to stop navigation temporarily stops the entity's pathfinding, but does not affect the attack target, resulting in it still moving slowly towards the source.

In short, I'm looking for a means of returning an entity to a neutral state under various conditions. Is there something I'm missing, or should I just bite the bullet and try to code this?

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The current system I'm using…
Sun, 03/26/2023 - 18:49

The current system I'm using is to simply spawn an invisible/insubstantial entity at the position of the attacker, set the attack target to the invisible entity, and then despawn the invisible entity. This works, of course, but it's hardly the most elegant solution. 

Last seen on 05:31, 19. Aug 2024
Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you could also disable the…
Tue, 08/13/2024 - 22:16

you could also disable the do melee/contact with a function that reads an nbt logic, instead of target null put like logic_nbt: "ai_signal"=false doesnt work with range mobs(thats my actual problem:v)

other idea is to target another mob like a giant, not sure if it will overwrite current target if its place above all ai list

Last seen on 05:31, 19. Aug 2024
Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
your system is alot less…
Tue, 08/13/2024 - 22:27

your system is alot less struggle, i prefer your method, maybe just use a custom projectile, the projectile makes the mob targets itself, then despawn it, and just add invisible texture.

Last seen on 05:31, 19. Aug 2024
Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lots of comments srry, ok…
Tue, 08/13/2024 - 23:17

lots of comments srry, ok has to be an living entity i couldnt get it to target a projectile