From e29654a0f697e1333f57612aa72d318699d1877e Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Mon, 27 Nov 2023 03:37:28 +0100 Subject: [PATCH 1/6] Revert healing interval default to the lower value --- mods/PLAYER/mcl_hunger/init.lua | 2 +- settingtypes.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index cc3965f57..a039169e3 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -146,7 +146,7 @@ minetest.register_globalstep(function(dtime) local food_level = mcl_hunger.get_hunger(player) local food_saturation_level = mcl_hunger.get_saturation(player) local player_health = player:get_hp() - local max_tick_timer = tonumber(minetest.settings:get("mcl_health_regen_delay")) or 4 + local max_tick_timer = tonumber(minetest.settings:get("mcl_health_regen_delay")) or 0.5 if food_tick_timer > max_tick_timer then food_tick_timer = 0 diff --git a/settingtypes.txt b/settingtypes.txt index a78b33e3b..f5743bc1d 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -99,8 +99,8 @@ mcl_creative_dig_speed (Creative mode dig speed) float 0.2 mcl_enable_hunger (Hunger mechanic) bool true # Health regeneration delay when hunger bar is full -# Default:4 -mcl_health_regen_delay (Health regen delay) float 4 0 +# Default: 0.5 s +mcl_health_regen_delay (Health regen delay) float 0.5 0 [Mobs] # If enabled, mobs will spawn naturally. This does not affect From 24ffd64cadb9dbce40fdabb9fc8a9b2ac9351200 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 28 Nov 2023 03:34:26 +0100 Subject: [PATCH 2/6] 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) From cca664552483df860c0495f426b87d9e2b4287d2 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 28 Nov 2023 04:28:05 +0100 Subject: [PATCH 3/6] Added player damage invulnerability --- mods/PLAYER/mcl_playerplus/init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 99da0a01a..61ca0e103 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -721,6 +721,20 @@ mcl_damage.register_modifier(function(obj, damage, reason) end end, -200) +-- damage invulnerability +mcl_damage.register_modifier(function(obj, damage, reason) + local invul = obj:get_meta():get_int("mcl_damage:invulnerable") + if invul > 0 then + return 0 + else + obj:get_meta():set_int("mcl_damage:invulnerable", 1) + minetest.after(0.5, function() + obj:get_meta():set_int("mcl_damage:invulnerable", 0) + end) + return damage + end +end, -1000) + minetest.register_on_respawnplayer(function(player) local pos = player:get_pos() minetest.add_particlespawner({ From 46d9c6600047bf39cb9bd597d328791c877d60cc Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 28 Nov 2023 04:35:19 +0100 Subject: [PATCH 4/6] Fixed mobs executing custom on_punch with punch fail --- mods/ENTITIES/mcl_mobs/combat.lua | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index ad7e202c6..6b660c787 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -516,6 +516,28 @@ end -- deal damage and effects when mob punched function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) + local is_player = hitter:is_player() + local mob_pos = self.object:get_pos() + local player_pos = hitter:get_pos() + + if is_player then + -- is mob out of reach? + if vector.distance(mob_pos, player_pos) > 3 then + return + end + -- is mob protected? + if self.protected and minetest.is_protected(mob_pos, hitter:get_player_name()) then + return + end + end + + local time_now = minetest.get_us_time() + local time_diff = time_now - self.invul_timestamp + + -- check for invulnerability time in microseconds (0.5 second) + if time_diff <= 500000 and time_diff >= 0 then + return + end -- custom punch function if self.do_punch then @@ -534,29 +556,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) local time_now = minetest.get_us_time() - local is_player = hitter:is_player() - if is_player then - local time_diff = time_now - self.invul_timestamp - - -- check for invulnerability time in microseconds (0.5 second) - if time_diff <= 500000 and time_diff >= 0 then - return - end - - local mob_pos = self.object:get_pos() - local player_pos = hitter:get_pos() - - -- is mob out of reach? - if vector.distance(mob_pos, player_pos) > 3 then - return - end - - -- is mob protected? - if self.protected and minetest.is_protected(mob_pos, hitter:get_player_name()) then - return - end - if minetest.is_creative_enabled(hitter:get_player_name()) then self.health = 0 end From 1857341b59ab9ed7d2b084c2162b45431c32d291 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 28 Nov 2023 04:35:42 +0100 Subject: [PATCH 5/6] Fixed player knockback from arrows --- mods/ITEMS/mcl_enchanting/enchantments.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 7e06ae43b..c6436339c 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -286,7 +286,13 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool knockback = knockback + dir_dot * 2 end elseif luaentity and luaentity._knockback then - knockback = knockback + luaentity._knockback + local kb = knockback + luaentity._knockback / 4 + local punch_dir = dir + punch_dir.y = 0 + punch_dir = vector.normalize(punch_dir) * kb + punch_dir.y = 4 + player:add_velocity(punch_dir) + knockback = 0 end return knockback end From 589de76613c3966b82f3992d5289cb29c1b82bdf Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 5 Dec 2023 01:57:40 +0100 Subject: [PATCH 6/6] Fixed a code branch never being run --- mods/PLAYER/mcl_hunger/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index a039169e3..ff625a5f7 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -148,7 +148,7 @@ minetest.register_globalstep(function(dtime) local player_health = player:get_hp() local max_tick_timer = tonumber(minetest.settings:get("mcl_health_regen_delay")) or 0.5 - if food_tick_timer > max_tick_timer then + if food_tick_timer > 4 then food_tick_timer = 0 -- let hunger work always