From 24ffd64cadb9dbce40fdabb9fc8a9b2ac9351200 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 28 Nov 2023 03:34:26 +0100 Subject: [PATCH] Knockback fixes --- mods/ENTITIES/mcl_mobs/combat.lua | 4 ++-- mods/HUD/mcl_death_messages/init.lua | 1 - mods/ITEMS/mcl_enchanting/enchantments.lua | 8 +++++++- mods/PLAYER/mcl_criticals/init.lua | 3 +-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 6952f6581..ad7e202c6 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -719,12 +719,12 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) end if hitter and is_player then local wielditem = hitter:get_wielded_item() + kb = kb + 9 * mcl_enchanting.get_enchantment(wielditem, "knockback") + -- add player velocity to mob knockback local hv = hitter:get_velocity() local dir_dot = (hv.x * dir.x) + (hv.z * dir.z) local player_mag = math.sqrt((hv.x * hv.x) + (hv.z * hv.z)) local mob_mag = math.sqrt((v.x * v.x) + (v.z * v.z)) - kb = kb + 9 * mcl_enchanting.get_enchantment(wielditem, "knockback") - -- add player velocity to mob knockback if dir_dot > 0 and mob_mag <= player_mag * 0.625 then kb = kb + ((math.abs(hv.x) + math.abs(hv.z)) * r) end diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 6c2040545..82749ca94 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -156,7 +156,6 @@ mcl_death_messages = { plain = "@1 died a sweet death", assist = "@1 was poked to death by a sweet berry bush whilst trying to escape @2", }, - -- Missing snowballs: The Minecraft wiki mentions them but the MC source code does not. }, } diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index f137b4230..7e06ae43b 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -278,7 +278,13 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool end if hitter and hitter:is_player() then local wielditem = hitter:get_wielded_item() - knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback") + knockback = knockback + 5 * mcl_enchanting.get_enchantment(wielditem, "knockback") + -- add player velocity to knockback + local hv = hitter:get_velocity() + local dir_dot = (hv.x * dir.x) + (hv.z * dir.z) + if dir_dot > 0 then + knockback = knockback + dir_dot * 2 + end elseif luaentity and luaentity._knockback then knockback = knockback + luaentity._knockback end diff --git a/mods/PLAYER/mcl_criticals/init.lua b/mods/PLAYER/mcl_criticals/init.lua index 27d09abb2..3e292d165 100644 --- a/mods/PLAYER/mcl_criticals/init.lua +++ b/mods/PLAYER/mcl_criticals/init.lua @@ -23,8 +23,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", }) minetest.sound_play("mcl_criticals_hit", {object = obj}) - -- the minecraft wiki is actually wrong about a crit dealing 150% damage, see minecraft source code - return damage + math.random(0, math.floor(damage * 1.5 + 2)) + return damage * math.random(1.5, 2.5) end end end, -100)