1
0
Fork 0

Use proper distance calculating tools

This commit is contained in:
Eliy21 2023-11-19 10:14:57 +00:00
parent 1f18c6556a
commit 5a7f297e3e
1 changed files with 1 additions and 5 deletions

View File

@ -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