From 85b1f5247a691f56201a452db31e0705d6d84e4a Mon Sep 17 00:00:00 2001 From: Eliy21 Date: Thu, 14 Dec 2023 07:46:16 +0000 Subject: [PATCH] Add vertical lift & minimum pvp knockback --- mods/ITEMS/mcl_enchanting/enchantments.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 23145c176..741621f22 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -279,8 +279,20 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool 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 + -- add vertical lift to knockback local v = player:get_velocity() + if v and v.y <= 0.1 and v.y >= -0.1 and dir.y <= 0.44 then + player:add_velocity({ + x = 0, + y = 4.5, + z = 0 + }) + -- add minimum knockback + if knockback <= 1.5 then + knockback = knockback + 6 + end + end + -- add player velocity to knockback local hv = hitter:get_velocity() local dir_dot = (hv.x * dir.x) + (hv.z * dir.z) local hitter_mag = math.sqrt((hv.x * hv.x) + (hv.z * hv.z))