forked from Mineclonia/Mineclonia
Fix diagonal fire-spread
In Minecraft fire spread logic, “adjacent” does not mean “diagonal”.
This commit is contained in:
parent
db8fbdc5dd
commit
052c9fcbcf
|
@ -27,8 +27,30 @@ local spawn_smoke = function(pos)
|
||||||
}, "high")
|
}, "high")
|
||||||
end
|
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)
|
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
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -387,6 +409,7 @@ else -- Fire enabled
|
||||||
local p = get_ignitable(pos)
|
local p = get_ignitable(pos)
|
||||||
if p then
|
if p then
|
||||||
spawn_fire(p)
|
spawn_fire(p)
|
||||||
|
shuffle_adjacents()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue