Started by
DarkParty
on
Topic category: Help with Minecraft modding (Java Edition)
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?
Check if the nearest entity is not itself to prevent it from attacking itself.
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.
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.
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.