Started by
kapik1403
on
Topic category: Help with Minecraft modding (Java Edition)
im trying to make my custom entity so it will always looks at me but it just like takes a break and stops looking at me for a while and then starts looking at me again i tried everything and i cant solve it even chatgpt and gemini cant help me
Edited by kapik1403 on Sun, 01/11/2026 - 13:00
You can do this with a procedure to run on the entity's tick update trigger:
If [Does entity exist at x: [X] y: [Y] z: [Z] in square cube with size [63] of type {Player}]
do [Make [Event/target entity] look at
x: [X position of [Get nearest entity at x: [X] y: [Y] z [Z] in square cube with size [64] of type {Player}]]
y: [[Y position of [Get nearest entity at x: [X] y: [Y] z [Z] in square cube with size [64] of type {Player}]] + [1.7]]
z: [Z position of [Get nearest entity at x: [X] y: [Y] z [Z] in square cube with size [64] of type {Player}]
Basically, what it does is it makes sure that a player is in an area around it. VERY IMPORTANT OR ELSE IT COULD CRASH.
Then it makes the entity look at the X position of the nearest player in a slightly larger area than the initial check (you could probably have the areas be the same, but I am erring on the side of caution in case somehow the player's position changes slightly during the procedure), the Y position of the nearest player, plus roughly the head height of a player, and the Z position of the nearest player.
That should do it, although it will only work if the player is within a certain area, you could increase the size. Just keep in mind that this procedure will be called twenty times per second per custom entity in the world, so it can easily cause lag if you search in too large an area.
I hope this helps more than AI did.