forked from VoxeLibre/VoxeLibre
Use proper distance calculating tools
This commit is contained in:
parent
1f18c6556a
commit
5a7f297e3e
|
@ -544,13 +544,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
|||
|
||||
local mob_pos = self.object:get_pos()
|
||||
local player_pos = hitter:get_pos()
|
||||
local attack_reach = 3
|
||||
local distance_x = math.abs(mob_pos.x - player_pos.x)
|
||||
local distance_y = math.abs(mob_pos.y - player_pos.y)
|
||||
local distance_z = math.abs(mob_pos.z - player_pos.z)
|
||||
|
||||
-- is mob out of reach?
|
||||
if distance_x > attack_reach or distance_y > attack_reach or distance_z > attack_reach then
|
||||
if vector.distance(mob_pos, player_pos) > 3 then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue