From 052c9fcbcf68d6b96665213c1b9a19eff4a4f764 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 23 Jan 2022 03:17:51 +0100 Subject: [PATCH] Fix diagonal fire-spread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Minecraft fire spread logic, “adjacent” does not mean “diagonal”. --- mods/ITEMS/mcl_fire/init.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 99a636f3..8ef03fc7 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -27,8 +27,30 @@ local spawn_smoke = function(pos) }, "high") end +local adjacents = { + { x =-1, y = 0, z = 0 }, + { x = 1, y = 0, z = 0 }, + { x = 0, y = 1, z = 0 }, + { x = 0, y =-1, z = 0 }, + { x = 0, y = 0, z =-1 }, + { x = 0, y = 0, z = 1 }, +} + +local function shuffle_adjacents() + for i = #adjacents, 1, -1 do + local r = math.random(i) + adjacents[i], adjacents[r] = adjacents[r], adjacents[i] + end +end + local function has_flammable(pos) - return minetest.find_node_near(pos, 1, {"group:flammable"}) + for k,v in pairs(adjacents) do + local p=vector.add(pos,v) + local n=minetest.get_node_or_nil(p) + if n and minetest.get_item_group(n.name, "flammable") > 0 then + return p + end + end end -- @@ -387,6 +409,7 @@ else -- Fire enabled local p = get_ignitable(pos) if p then spawn_fire(p) + shuffle_adjacents() end end })