forked from VoxeLibre/VoxeLibre
Enderman use vectors to check distance between player and self
This commit is contained in:
parent
00db03320b
commit
9f7899c01a
|
@ -331,6 +331,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||
for _,obj in pairs(minetest.get_connected_players()) do
|
||||
-- Check if they are looking at us.
|
||||
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 = 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.
|
||||
|
@ -354,6 +356,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||
look_pos.z = look_pos.z + (.25 * look_dir.z)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- TAKE AND PLACE STUFF BEHAVIOUR BELOW.
|
||||
if not mobs_griefing then
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue