0
0
Fork 0

Prevent excessive vertical knockbacks if hit by a player from below

This commit is contained in:
Eliy21 2023-12-15 21:02:07 +00:00
parent c9692c6224
commit 9b9747b3d8
1 changed files with 4 additions and 1 deletions

View File

@ -286,7 +286,7 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
-- add vertical lift to knockback -- add vertical lift to knockback
local v = player:get_velocity() local v = player:get_velocity()
local invul = player:get_meta():get_int("mcl_damage:invulnerable") local invul = player:get_meta():get_int("mcl_damage:invulnerable")
if v and v.y <= 0.1 and v.y >= -0.1 and invul == 0 then if v and v.y <= 0.01 and v.y >= -0.01 and invul == 0 then
if dir.y <= 0.44 then if dir.y <= 0.44 then
if mcl_enchanting.get_enchantment(wielditem, "knockback") == 0 then if mcl_enchanting.get_enchantment(wielditem, "knockback") == 0 then
player:add_velocity({x = 0, y = 6.4, z = 0}) player:add_velocity({x = 0, y = 6.4, z = 0})
@ -311,6 +311,9 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
if knockback > 12.875 then if knockback > 12.875 then
knockback = 12.875 knockback = 12.875
end end
if knockback > 6.4375 and dir.y >= 0.3 then
knockback = 6.4375
end
-- remove knockback if invulnerable -- remove knockback if invulnerable
if invul > 0 then if invul > 0 then
knockback = 0 knockback = 0