0
0
Fork 0

Prevent knockback if player is beyond attack reach limit

This commit is contained in:
Eliy21 2023-12-13 20:36:54 +00:00
parent b0e33793ec
commit 2b71462c1e
1 changed files with 3 additions and 1 deletions

View File

@ -276,7 +276,7 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
if hitter then
luaentity = hitter:get_luaentity()
end
if hitter and hitter:is_player() then
if hitter and hitter:is_player() and distance <= 3 then
local wielditem = hitter:get_wielded_item()
knockback = knockback + 5 * mcl_enchanting.get_enchantment(wielditem, "knockback")
-- add player velocity to knockback
@ -288,6 +288,8 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
if dir_dot > 0 and player_mag <= hitter_mag * 0.625 then
knockback = knockback + hitter_mag * 0.375
end
elseif hitter and hitter:is_player() and distance > 3 then
knockback = 0
elseif luaentity and luaentity._knockback then
local kb = knockback + luaentity._knockback / 4
local punch_dir = dir