Self-attacking-Entity?!

Started by DarkParty on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Self-attacking-Entity?!

So I tried to make a thing that made a zombie spawn, and then made the zombie attack the nearest monster, but the zombie ended up attacking itself (somehow?!). Any ideas?

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Check if the nearest entity…
Fri, 12/05/2025 - 00:34

Check if the nearest entity is not itself to prevent it from attacking itself.

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, I did that, but the…
Fri, 12/05/2025 - 15:14

Well, I did that, but the only way I knew how to do that was "If nearest entity is not same entity as event/target entity, then attack nearest entity." which obviously did not work as that just made it not attack anything since it was always the nearest entity to itself.

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you could make it also spawn…
Sat, 12/06/2025 - 07:50

you could make it also spawn invisible mobs on every zombie around that special zombie using for the each entity block (exclude the special zombie) then set target target as get the nearest entity type of zombie at the nearest invisible entity xyz, this will make it target the closest zombie excluding itself. The invisible mob should also have no ai and despawn in 5 ticks after spawning.

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Not sure that this is what…
Sun, 12/07/2025 - 20:23

Not sure that this is what you meant but I had a different, similar idea. Whenever a mob spawns (unless it is necromanced) It spawns an invisible "Stalker mob" that follows the entity. Then for necromanced mobs (I forgot to mention it was a necromancy mod lol) the "xyz" that the radius starts at for nearest monster is the nearest stalker mob. So, in a very roundabout way, it will attack other mobs.