Get Local Player when sourceentity is not provided.

Started by ZeadenTheBirb on

Topic category: Help with modding (Java Edition)

Last seen on 20:39, 6. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Get Local Player when sourceentity is not provided.

I'm trying to get the local client-side player that a procedure is running on.

I've used "Is Provided World Client-Side" to make sure this code is only running on the client's machine.

What I'm trying to do is have a mob only be visible to players according to a player stat, in this case hunger. This procedure is being run on the mob's Tick Update, so I am not provided a sourceentity or anything to work with, only co-ordinates, the world, and the entity itself.

I have no clue how to get this done without looping over every player in the world, every tick, for every mob, just to find the nearest and check against a hunger value. I'm hoping there's a better way to do this?