From 02fa2c9e07e7eca2e6e974e9cfa1ad8934affaad Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 15 Jan 2022 23:06:00 +0100 Subject: [PATCH] Fix nodes that should not burn up burning up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nodes with the group “flammable = -1” (e.g. crafting tables) must be able to catch fire, but must not burn up. This patch adds checks for this group. --- mods/ITEMS/mcl_fire/init.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 95056488..b10ddfb4 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -27,6 +27,10 @@ local spawn_smoke = function(pos) }, "high") end +local function has_flammable(pos) + return minetest.find_node_near(pos, 1, {"group:flammable"}) +end + -- -- Items -- @@ -104,7 +108,8 @@ minetest.register_node("mcl_fire:fire", { drop = "", sounds = {}, on_timer= function(pos) - if not minetest.find_node_near(pos, 1, {"group:flammable"}) then + local p=has_flammable(pos) + if not p or minetest.get_item_group(minetest.get_node(p).name, "flammable") == -1 then minetest.remove_node(pos) return end @@ -339,10 +344,6 @@ minetest.register_abm({ -- [...]a fire that is not adjacent to any flammable block does not spread, even to another flammable block within the normal range. -- https://minecraft.fandom.com/wiki/Fire#Spread -local function has_flammable(pos) - return minetest.find_node_near(pos, 1, {"group:flammable"}) -end - local function check_aircube(p1,p2) local nds=minetest.find_nodes_in_area(p1,p2,{"air"}) for k,v in pairs(nds) do @@ -415,15 +416,18 @@ else -- Fire enabled chance = 18, catch_up = false, action = function(pos) - local p = minetest.find_node_near(pos, 1, {"group:flammable"}) + local p = has_flammable(pos) if not p then return end - local flammable_node = minetest.get_node(p) - local def = minetest.registered_nodes[flammable_node.name] - if def.on_burn then - def.on_burn(p) - else + + local nn = minetest.get_node(p).name + local def = minetest.registered_nodes[nn] + local fgroup = minetest.get_item_group(nn, "flammable") + + if def and def._on_burn then + def._on_burn(p) + elseif fgroup ~= -1 then minetest.swap_node(p, {name = "mcl_fire:fire"}) fire_timer(p) minetest.check_for_falling(p)