1
0
Fork 0

Knockback fixes

release/0.85.1
the-real-herowl 2023-11-28 03:34:26 +01:00 committed by the-real-herowl
parent e29654a0f6
commit 24ffd64cad
4 changed files with 10 additions and 6 deletions

View File

@ -719,12 +719,12 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
end end
if hitter and is_player then if hitter and is_player then
local wielditem = hitter:get_wielded_item() 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 hv = hitter:get_velocity()
local dir_dot = (hv.x * dir.x) + (hv.z * dir.z) 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 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)) 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 if dir_dot > 0 and mob_mag <= player_mag * 0.625 then
kb = kb + ((math.abs(hv.x) + math.abs(hv.z)) * r) kb = kb + ((math.abs(hv.x) + math.abs(hv.z)) * r)
end end

View File

@ -156,7 +156,6 @@ mcl_death_messages = {
plain = "@1 died a sweet death", plain = "@1 died a sweet death",
assist = "@1 was poked to death by a sweet berry bush whilst trying to escape @2", 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.
}, },
} }

View File

@ -278,7 +278,13 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
end end
if hitter and hitter:is_player() then if hitter and hitter:is_player() then
local wielditem = hitter:get_wielded_item() 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 elseif luaentity and luaentity._knockback then
knockback = knockback + luaentity._knockback knockback = knockback + luaentity._knockback
end end

View File

@ -23,8 +23,7 @@ mcl_damage.register_modifier(function(obj, damage, reason)
texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", texture = "mcl_particles_crit.png^[colorize:#bc7a57:127",
}) })
minetest.sound_play("mcl_criticals_hit", {object = obj}) 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(1.5, 2.5)
return damage + math.random(0, math.floor(damage * 1.5 + 2))
end end
end end
end, -100) end, -100)