mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 12:31:05 +01:00
Prevent knockback if player is beyond attack reach limit
This commit is contained in:
parent
b0e33793ec
commit
2b71462c1e
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue