From acd2b8e691c2fc5a19e288e4865fd8fd46487f58 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 6 Apr 2021 21:29:52 -0400 Subject: [PATCH] Add line of sight calculations to the enderman --- mods/ENTITIES/mobs_mc/enderman.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index e3f2c8e48..cd8986aad 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -351,12 +351,13 @@ mobs:register_mob("mobs_mc:enderman", { --calculate very quickly the exact location the player is looking --within the distance between the two "heads" (player and enderman) local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z) + local look_pos_base = look_pos local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) --if looking in general head position, turn hostile - if vector.distance(look_pos, ender_eye_pos) <= 0.4 then + if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then self.provoked = "staring" self.attack = minetest.get_player_by_name(obj:get_player_name()) break