How would I make an entity disappear(despawn) when the player looks at it?

Started by Electroman on

Topic category: Help with modding (Java Edition)

Last seen on 00:43, 26. Feb 2024
Joined May 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How would I make an entity disappear(despawn) when the player looks at it?

For context, I have been developing a mod that has an entity similar to the man from the fog, I have made a separate entity from the aggressive version that spawns on occasion in a certain time period, I want to make it to where if I look at the entity(stalker form) he despawns and if you don't, he despawns and spawns his aggressive form. How would I be able to do this?