From ad21b3ecc37553654056dcae818b210bfc469d59 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 21:12:44 +0100 Subject: [PATCH 01/10] Rovers now take damage and teleport away when it is thundering. And fix somewhere else that ignored thunder. --- mods/ENTITIES/mcl_burning/api.lua | 2 +- mods/ENTITIES/mobs_mc/rover.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 74c66d5f1..56de67a79 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -14,7 +14,7 @@ function mcl_burning.is_burning(obj) end function mcl_burning.is_affected_by_rain(obj) - return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) + return mcl_weather.rain.raining and mcl_weather.is_outdoor(obj:get_pos()) end function mcl_burning.get_collisionbox(obj, smaller, storage) diff --git a/mods/ENTITIES/mobs_mc/rover.lua b/mods/ENTITIES/mobs_mc/rover.lua index d1f21ffd0..57f42559c 100644 --- a/mods/ENTITIES/mobs_mc/rover.lua +++ b/mods/ENTITIES/mobs_mc/rover.lua @@ -157,7 +157,7 @@ mcl_mobs.register_mob("mobs_mc:rover", { local enderpos = self.object:get_pos() local dim = mcl_worlds.pos_to_dimension(enderpos) if dim == "overworld" then - if mcl_weather.state == "rain" or mcl_weather.state == "lightning" then + if mcl_weather.rain.raining then local damage = true local enderpos = self.object:get_pos() enderpos.y = enderpos.y+2.89 From b976c535ae0c844f6bf2a4d71dc1ad3115c11944 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 22:02:50 +0100 Subject: [PATCH 02/10] Fix flashing fire on burning mob during rain/thunder --- mods/ENTITIES/mcl_mobs/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 441156a1d..5d5aeda6e 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -653,7 +653,7 @@ function mob_class:do_env_damage() local _, dim = mcl_worlds.y_to_layer(pos.y) if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if self.ignited_by_sunlight then + if (self.ignited_by_sunlight and not mcl_weather.rain.raining) then mcl_burning.set_on_fire(self.object, 10) else self:deal_light_damage(pos, self.sunlight_damage) From 387b6941a905c9b70175d5eb4c4925991e162a03 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 22:50:46 +0100 Subject: [PATCH 03/10] Change burning API to check whether weather is actually happening (e.g. hot biomes) --- mods/ENTITIES/mcl_burning/api.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 56de67a79..c3348e6c4 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -14,7 +14,8 @@ function mcl_burning.is_burning(obj) end function mcl_burning.is_affected_by_rain(obj) - return mcl_weather.rain.raining and mcl_weather.is_outdoor(obj:get_pos()) + local pos = obj:get_pos() + return mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) and mcl_weather.has_rain(pos) end function mcl_burning.get_collisionbox(obj, smaller, storage) From dc8219fe3125d5bcfd549a2dbc311739fa506354 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 22:51:09 +0100 Subject: [PATCH 04/10] Check mobs are not touching nodes in `group:puts_out_fire` BEFORE burninating. Should fix the remaining flashing (see #3655). --- mods/ENTITIES/mcl_mobs/physics.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 5d5aeda6e..646cd5560 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -653,8 +653,11 @@ function mob_class:do_env_damage() local _, dim = mcl_worlds.y_to_layer(pos.y) if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if (self.ignited_by_sunlight and not mcl_weather.rain.raining) then - mcl_burning.set_on_fire(self.object, 10) + if (self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos))) then + if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then + minetest.log("owow") + mcl_burning.set_on_fire(self.object, 10) + end else self:deal_light_damage(pos, self.sunlight_damage) return true From 14a0546dcedcc44b6b46c8f2cfb3db68c24d3c0f Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 23:02:42 +0100 Subject: [PATCH 05/10] Whoopsie --- mods/ENTITIES/mcl_mobs/physics.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 646cd5560..9a6811384 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -655,7 +655,6 @@ function mob_class:do_env_damage() if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then if (self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos))) then if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then - minetest.log("owow") mcl_burning.set_on_fire(self.object, 10) end else From ae263a19c9aa2aa055cd387c491831c65d91d8fa Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sat, 15 Jun 2024 23:21:55 +0100 Subject: [PATCH 06/10] Remove unnecessary raycast from rover (and use the mcl_burning api where we can) --- mods/ENTITIES/mcl_mobs/physics.lua | 8 +++--- mods/ENTITIES/mobs_mc/rover.lua | 40 +++++++----------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 9a6811384..212b7e084 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -653,7 +653,7 @@ function mob_class:do_env_damage() local _, dim = mcl_worlds.y_to_layer(pos.y) if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if (self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos))) then + if self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos)) then if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then mcl_burning.set_on_fire(self.object, 10) end @@ -694,9 +694,11 @@ function mob_class:do_env_damage() local nodef3 = minetest.registered_nodes[self.standing_under] -- rain - if self.rain_damage > 0 and mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then + if self.rain_damage > 0 and mcl_burning.is_affected_by_rain(self.object) then self.health = self.health - self.rain_damage - if self:check_for_death("rain", {type = "environment", pos = pos, node = self.standing_in}) then + + if self:check_for_death("rain", {type = "environment", + pos = pos, node = self.standing_in}) then return true end end diff --git a/mods/ENTITIES/mobs_mc/rover.lua b/mods/ENTITIES/mobs_mc/rover.lua index 57f42559c..16522f277 100644 --- a/mods/ENTITIES/mobs_mc/rover.lua +++ b/mods/ENTITIES/mobs_mc/rover.lua @@ -156,37 +156,15 @@ mcl_mobs.register_mob("mobs_mc:rover", { -- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE. local enderpos = self.object:get_pos() local dim = mcl_worlds.pos_to_dimension(enderpos) - if dim == "overworld" then - if mcl_weather.rain.raining then - local damage = true - local enderpos = self.object:get_pos() - enderpos.y = enderpos.y+2.89 - local height = {x=enderpos.x, y=enderpos.y+512,z=enderpos.z} - local ray = minetest.raycast(enderpos, height, true) - -- Check for blocks above enderman. - for pointed_thing in ray do - if pointed_thing.type == "node" then - local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name - local def = minetest.registered_nodes[nn] - if (not def) or def.walkable then - -- There's a node in the way. Delete arrow without damage - damage = false - break - end - end - end - - if damage == true then - self.state = "" - --rain hurts enderman - self.object:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=self._damage}, - }, nil) - --randomly teleport hopefully under something. - self:teleport(nil) - end - end + if dim == "overworld" and mcl_burning.is_affected_by_rain(self.object) then + self.state = "" + --rain hurts enderman + self.object:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=self._damage}, + }, nil) + --randomly teleport hopefully under something. + self:teleport(nil) end -- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE. From a643424726b649357ec93af8359adea5bc6519be Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sun, 24 Nov 2024 09:47:04 -0600 Subject: [PATCH 07/10] Specify rain damage for rovers --- mods/ENTITIES/mobs_mc/rover.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/rover.lua b/mods/ENTITIES/mobs_mc/rover.lua index 16522f277..efb57b253 100644 --- a/mods/ENTITIES/mobs_mc/rover.lua +++ b/mods/ENTITIES/mobs_mc/rover.lua @@ -161,7 +161,7 @@ mcl_mobs.register_mob("mobs_mc:rover", { --rain hurts enderman self.object:punch(self.object, 1.0, { full_punch_interval=1.0, - damage_groups={fleshy=self._damage}, + damage_groups={fleshy=self.rain_damage}, }, nil) --randomly teleport hopefully under something. self:teleport(nil) @@ -466,6 +466,7 @@ mcl_mobs.register_mob("mobs_mc:rover", { end, armor = { fleshy = 100, water_vulnerable = 100 }, water_damage = 8, + rain_damage = 2, view_range = 64, fear_height = 4, attack_type = "dogfight", From 42b7dc9ce8a0856df926b8159c6103484ab16319 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Thu, 28 Nov 2024 10:00:45 -0600 Subject: [PATCH 08/10] Switch to using not mcl_burning.is_affected_by_rain() --- mods/ENTITIES/mcl_mobs/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 212b7e084..b07cfcbeb 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -653,7 +653,7 @@ function mob_class:do_env_damage() local _, dim = mcl_worlds.y_to_layer(pos.y) if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos)) then + if self.ignited_by_sunlight and not mcl_burning.is_affected_by_rain(self.object) then if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then mcl_burning.set_on_fire(self.object, 10) end From 835f97a61e91f535aadd4c6d5281fd7aa5e276ff Mon Sep 17 00:00:00 2001 From: teknomunk Date: Thu, 28 Nov 2024 11:23:34 -0600 Subject: [PATCH 09/10] Add mcl_burning.is_affected_by_sunlight(), rework mob light/sunlight damage and burning code --- mods/ENTITIES/mcl_burning/api.lua | 11 +++++++++ mods/ENTITIES/mcl_burning/mod.conf | 2 +- mods/ENTITIES/mcl_mobs/physics.lua | 38 ++++++++++-------------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index c3348e6c4..2a4c6cc4d 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -18,6 +18,17 @@ function mcl_burning.is_affected_by_rain(obj) return mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) and mcl_weather.has_rain(pos) end +function mcl_burning.is_affected_by_sunlight(obj, threshold) + threshold = threshold or core.LIGHT_MAX + + local pos = obj:get_pos() + local _,dim = mcl_worlds.y_to_layer(pos.y) + if dim ~= "overworld" then return false end + + local sunlight = mcl_util.get_natural_light(pos, core.get_timeofday()) or 0 + if sunlight > threshold then return true end +end + function mcl_burning.get_collisionbox(obj, smaller, storage) local cache = storage.collisionbox_cache if cache then diff --git a/mods/ENTITIES/mcl_burning/mod.conf b/mods/ENTITIES/mcl_burning/mod.conf index 8a3d6ea00..bac9a1c10 100644 --- a/mods/ENTITIES/mcl_burning/mod.conf +++ b/mods/ENTITIES/mcl_burning/mod.conf @@ -1,4 +1,4 @@ name = mcl_burning description = Burning Objects for VoxeLibre author = Fleckenstein -depends = mcl_weather +depends = mcl_weather, mcl_worlds diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index b07cfcbeb..7cbbfe08b 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -634,36 +634,24 @@ function mob_class:do_env_damage() return true end - local node = minetest.get_node(pos) - if node then - if node.name ~= "ignore" then - -- put below code in this block if we can prove that unloaded maps are causing crash. - -- it should warn then error - else - --minetest.log("warning", "Pos is ignored: " .. dump(pos)) + -- Simple light damage + if self.light_damage or 0 > 0 and mcl_burning.is_affected_by_sunlight(self.object, 12) then + if self:deal_light_damage(pos, self.light_damage) then + return true end + end - local sunlight = mcl_util.get_natural_light(pos, self.time_of_day) - - if self.light_damage ~= 0 and (sunlight or 0) > 12 then - if self:deal_light_damage(pos, self.light_damage) then - return true - end - end - local _, dim = mcl_worlds.y_to_layer(pos.y) - if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then - if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if self.ignited_by_sunlight and not mcl_burning.is_affected_by_rain(self.object) then - if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then - mcl_burning.set_on_fire(self.object, 10) - end - else - self:deal_light_damage(pos, self.sunlight_damage) - return true + -- Sunlight burning/igniting mobs + if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and mcl_burning.is_affected_by_sunlight(self.object) then + if not (self.armor_list and (self.armor_list.helmet or "") ~= "") then + if self.ignited_by_sunlight and not mcl_burning.is_affected_by_rain(self.object) then + if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then + mcl_burning.set_on_fire(self.object, 10) end + else + self:deal_light_damage(pos, self.sunlight_damage) end end - end local y_level = self.collisionbox[2] From 2f4e23e4030ce44de60a035fac3888bb25a5297f Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 30 Nov 2024 09:03:36 -0600 Subject: [PATCH 10/10] Add parenthesis for clarity, check pos before using, endermen->rovers in comment --- mods/ENTITIES/mcl_burning/api.lua | 2 ++ mods/ENTITIES/mcl_mobs/physics.lua | 2 +- mods/ENTITIES/mobs_mc/rover.lua | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 2a4c6cc4d..75cb0d934 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -15,6 +15,7 @@ end function mcl_burning.is_affected_by_rain(obj) local pos = obj:get_pos() + if not pos then return false end return mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) and mcl_weather.has_rain(pos) end @@ -22,6 +23,7 @@ function mcl_burning.is_affected_by_sunlight(obj, threshold) threshold = threshold or core.LIGHT_MAX local pos = obj:get_pos() + if not pos then return false end local _,dim = mcl_worlds.y_to_layer(pos.y) if dim ~= "overworld" then return false end diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 7cbbfe08b..ea470d722 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -635,7 +635,7 @@ function mob_class:do_env_damage() end -- Simple light damage - if self.light_damage or 0 > 0 and mcl_burning.is_affected_by_sunlight(self.object, 12) then + if (self.light_damage or 0) > 0 and mcl_burning.is_affected_by_sunlight(self.object, 12) then if self:deal_light_damage(pos, self.light_damage) then return true end diff --git a/mods/ENTITIES/mobs_mc/rover.lua b/mods/ENTITIES/mobs_mc/rover.lua index efb57b253..3a07f2d36 100644 --- a/mods/ENTITIES/mobs_mc/rover.lua +++ b/mods/ENTITIES/mobs_mc/rover.lua @@ -158,7 +158,7 @@ mcl_mobs.register_mob("mobs_mc:rover", { local dim = mcl_worlds.pos_to_dimension(enderpos) if dim == "overworld" and mcl_burning.is_affected_by_rain(self.object) then self.state = "" - --rain hurts enderman + --rain hurts rovers self.object:punch(self.object, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=self.rain_damage},