Jewelgen: Make v6-compatible
This commit is contained in:
parent
3aec00cfb4
commit
df0af126d0
@ -13,7 +13,15 @@ local y_min = 0
|
|||||||
|
|
||||||
-- Helper variables
|
-- Helper variables
|
||||||
local gigatree_decoration_id = minetest.get_decoration_id("default:gigatree")
|
local gigatree_decoration_id = minetest.get_decoration_id("default:gigatree")
|
||||||
local biome_y = minetest.registered_biomes["Deep Forest"].y_min
|
local biome_y
|
||||||
|
local biome_exists
|
||||||
|
if minetest.registered_biomes["Deep Forest"] then
|
||||||
|
biome_y = minetest.registered_biomes["Deep Forest"].y_min
|
||||||
|
biome_exists = true
|
||||||
|
else
|
||||||
|
biome_y = tonumber(minetest.get_mapgen_setting("water_level")) or 1
|
||||||
|
biome_exists = false
|
||||||
|
end
|
||||||
|
|
||||||
local lvm_buffer = {}
|
local lvm_buffer = {}
|
||||||
|
|
||||||
@ -21,7 +29,7 @@ local c_birch = minetest.get_content_id("default:tree_birch")
|
|||||||
local c_jewel_ore = minetest.get_content_id("jewels:jewel_ore")
|
local c_jewel_ore = minetest.get_content_id("jewels:jewel_ore")
|
||||||
|
|
||||||
-- Generation algorithm:
|
-- Generation algorithm:
|
||||||
if gigatree_decoration_id then
|
do
|
||||||
|
|
||||||
-- Helper function to find a random minimum/maxium range of length clust_size.
|
-- Helper function to find a random minimum/maxium range of length clust_size.
|
||||||
-- Returned numbers are offsets.
|
-- Returned numbers are offsets.
|
||||||
@ -38,10 +46,14 @@ if gigatree_decoration_id then
|
|||||||
end
|
end
|
||||||
local ores_in_mapblock = {}
|
local ores_in_mapblock = {}
|
||||||
local pr = PseudoRandom(blockseed)
|
local pr = PseudoRandom(blockseed)
|
||||||
local mgobj = minetest.get_mapgen_object("gennotify")
|
local deco_ok = true
|
||||||
local deco = mgobj["decoration#"..gigatree_decoration_id]
|
if gigatree_decoration_id then
|
||||||
-- If a giga tree was found anywhere in generated area, activate generation
|
-- Was a giga tree was found anywhere in generated area?
|
||||||
if deco and #deco > 0 then
|
local mgobj = minetest.get_mapgen_object("gennotify")
|
||||||
|
local deco = mgobj["decoration#"..gigatree_decoration_id]
|
||||||
|
deco_ok = deco and #deco > 0
|
||||||
|
end
|
||||||
|
if deco_ok then
|
||||||
-- This code tries to imitate scatter ores in Minetest
|
-- This code tries to imitate scatter ores in Minetest
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||||
@ -53,9 +65,12 @@ if gigatree_decoration_id then
|
|||||||
for x=minp.x, maxp.x do
|
for x=minp.x, maxp.x do
|
||||||
local p_pos = area:index(x,y,z)
|
local p_pos = area:index(x,y,z)
|
||||||
if data[p_pos] == c_birch then
|
if data[p_pos] == c_birch then
|
||||||
local bdata = minetest.get_biome_data({x=x,y=math.max(y, biome_y),z=z})
|
local bdata, bname
|
||||||
local bname = minetest.get_biome_name(bdata.biome)
|
if biome_exists then
|
||||||
if bname == "Deep Forest" and pr:next(1, clust_scarcity) == 1 then
|
bdata = minetest.get_biome_data({x=x,y=math.max(y, biome_y),z=z})
|
||||||
|
bname = minetest.get_biome_name(bdata.biome)
|
||||||
|
end
|
||||||
|
if ((not biome_exists) or (bname == "Deep Forest")) and pr:next(1, clust_scarcity) == 1 then
|
||||||
data[p_pos] = c_jewel_ore
|
data[p_pos] = c_jewel_ore
|
||||||
table.insert(ores_in_mapblock, {x=x,y=y,z=z})
|
table.insert(ores_in_mapblock, {x=x,y=y,z=z})
|
||||||
end
|
end
|
||||||
@ -95,6 +110,4 @@ if gigatree_decoration_id then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
minetest.log("error", "[jewels] Decoration ID for gigatree not found!")
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user