Fix diagonal fire-spread

In Minecraft fire spread logic, “adjacent” does not mean “diagonal”.
This commit is contained in:
cora 2022-01-23 03:17:51 +01:00 committed by Nils Dagsson Moskopp
parent db8fbdc5dd
commit 052c9fcbcf
Signed by untrusted user who does not match committer: erle
GPG Key ID: A3BC671C35191080
1 changed files with 24 additions and 1 deletions

View File

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