Started by
Pizzaperson23
on
Topic category: Help with Minecraft modding (Java Edition)
I am making a mob(x) that always attacks you unless a tamed version of another entity(y) is nearby. I am also not trying to make the procedure look for the nearest entity but any of the entities that are tamed nearby. Is there a way to do this? If so, how?
You could do this with an entity iterator- essentially, it will check every entity in a radius. In this case, you would want to check if the entity iterator is the desired entity type, and is tamed to another entity. (Probably check that the entity's owner is a subtype of living entity, and therefore exists.) If you're using this to determine whether or not to set the attack target to the nearest player, it'll probably be fine, but if the mob is already aggroed, it won't do anything.
If you want to reset the mob's attack target, there's a weird workaround where you can spawn an invisible entity, set the mob's attack target to that entity, and then despawn the invisible entity, which stops them from attacking, though it can cause some weird visual glitches. (You can make your own invisible entity, or probably just use a built in one like markers.)
Screenshot 2023-12-12 191601.png - Google Drive
/\ This is the procedure I made based on what you said but it doesn't seem to work.
My bad I forgot to show the whole procedure in that one.
Screenshot 2023-12-12 192644.png - Google Drive
Also, I put the procedure under the event/target entity's update tick procedure for that entity.