From 0955b9981b7210b51249cfea6b5d2df8b6116b1d Mon Sep 17 00:00:00 2001 From: Eliy21 Date: Sun, 19 Nov 2023 11:46:38 +0000 Subject: [PATCH] Add player velocity to mob knockback --- mods/ENTITIES/mcl_mobs/combat.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index d243f240c..6a2d5648a 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -717,7 +717,14 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) end if hitter and is_player then local wielditem = hitter:get_wielded_item() + local hv = hitter:get_velocity() kb = kb + 9 * mcl_enchanting.get_enchantment(wielditem, "knockback") + -- add player velocity to mob knockback + if (dir.x > 0 and hv.x > 0) or (dir.x < 0 and hv.x < 0) then + if (dir.z > 0 and hv.z > 0) or (dir.z < 0 and hv.z < 0) then + kb = kb + ((math.abs(hv.x) + math.abs(hv.z)) * r) + end + end elseif luaentity and luaentity._knockback then kb = kb + luaentity._knockback end