How can I make my creature only attack players with a certain name?

Started by ulisesmendozas… on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I make my creature only attack players with a certain name?

Hi, I'm new to this, and I don't speak English so I'm using Google Translate.

As you can see in the title, I'm looking to make an entity behave peacefully for the most part, but when it's near a player with a certain name, let's say "Mati", it becomes aggressive only with that player and doesn't attack any other player. (I clarify this because it's likely that if it recognizes a player with that name it will become aggressive and attack all players). How would it be done?
I put that the event starts on each tick of the loaded creature, and then I put a repeater that says that for each player in the world as an entity iterator it checks if there is an entity iterator with the visual name of "Mati" and it will do such a thing, and then I got stuck, I don't know how to continue haha. I need help, it would be great to be able to do this on the server. And if there's no way through blocks, it's also valid for me in code format.