Fix nodes that should not burn up burning up

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.
master
cora 2022-01-15 23:06:00 +01:00 committed by Nils Dagsson Moskopp
parent c12076e74d
commit 02fa2c9e07
No known key found for this signature in database
GPG Key ID: A3BC671C35191080
1 changed files with 15 additions and 11 deletions

View File

@ -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)