1
0
Fork 0

Enderman use vectors to check distance between player and self

This commit is contained in:
jordan4ibanez 2021-04-06 20:37:48 -04:00
parent 00db03320b
commit 9f7899c01a
1 changed files with 22 additions and 19 deletions

View File

@ -331,6 +331,8 @@ mobs:register_mob("mobs_mc:enderman", {
for _,obj in pairs(minetest.get_connected_players()) do for _,obj in pairs(minetest.get_connected_players()) do
-- Check if they are looking at us. -- Check if they are looking at us.
local player_pos = obj:get_pos() local player_pos = obj:get_pos()
if vector.distance(enderpos, player_pos) <= 64 then
local look_dir_not_normalized = obj:get_look_dir() local look_dir_not_normalized = obj:get_look_dir()
local look_dir = vector.normalize(look_dir_not_normalized) local look_dir = vector.normalize(look_dir_not_normalized)
local look_pos = vector.new({x = look_dir.x+player_pos.x, y = look_dir.y+player_pos.y + 1.5, z = look_dir.z+player_pos.z}) -- Arbitrary value (1.5) is head level according to player info mod. local look_pos = vector.new({x = look_dir.x+player_pos.x, y = look_dir.y+player_pos.y + 1.5, z = look_dir.z+player_pos.z}) -- Arbitrary value (1.5) is head level according to player info mod.
@ -354,6 +356,7 @@ mobs:register_mob("mobs_mc:enderman", {
look_pos.z = look_pos.z + (.25 * look_dir.z) look_pos.z = look_pos.z + (.25 * look_dir.z)
end end
end end
end
-- TAKE AND PLACE STUFF BEHAVIOUR BELOW. -- TAKE AND PLACE STUFF BEHAVIOUR BELOW.
if not mobs_griefing then if not mobs_griefing then
return return