Started by
Mindthemoods
on
Topic category: Help with Minecraft modding (Java Edition)
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?
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.
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
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.
lots of comments srry, ok has to be an living entity i couldnt get it to target a projectile
forget everything use this
code snippet: if (entity instanceof Mob _entity) _entity.setTarget(null);
source: https://mcreator.net/forum/96359/reset-attack-target-entity-stop-entity-targeting-entity
tks RedWirePlatinum