mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-07-04 13:47:12 -04:00
Avoid parsing mapgen 'chunksize' by hand
This commit is contained in:
parent
69b2fb7a32
commit
0daf839349
2 changed files with 9 additions and 11 deletions
|
@ -1860,7 +1860,13 @@ function default.register_decorations()
|
||||||
-- Emergent jungle tree
|
-- Emergent jungle tree
|
||||||
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
|
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
|
||||||
|
|
||||||
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
|
local chunksize
|
||||||
|
if core.get_mapgen_chunksize then
|
||||||
|
local v = core.get_mapgen_chunksize()
|
||||||
|
chunksize = math.max(v.x, v.y, v.z)
|
||||||
|
else
|
||||||
|
chunksize = tonumber(core.get_mapgen_setting("chunksize"))
|
||||||
|
end
|
||||||
if chunksize >= 5 then
|
if chunksize >= 5 then
|
||||||
minetest.register_decoration({
|
minetest.register_decoration({
|
||||||
name = "default:emergent_jungle_tree",
|
name = "default:emergent_jungle_tree",
|
||||||
|
|
|
@ -66,15 +66,6 @@ local success = false
|
||||||
local spawn_pos = {}
|
local spawn_pos = {}
|
||||||
|
|
||||||
|
|
||||||
-- Get world 'mapgen_limit' and 'chunksize' to calculate 'spawn_limit'.
|
|
||||||
-- This accounts for how mapchunks are not generated if they or their shell exceed
|
|
||||||
-- 'mapgen_limit'.
|
|
||||||
|
|
||||||
local mapgen_limit = tonumber(minetest.get_mapgen_setting("mapgen_limit"))
|
|
||||||
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
|
|
||||||
local spawn_limit = math.max(mapgen_limit - (chunksize + 1) * 16, 0)
|
|
||||||
|
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -103,6 +94,7 @@ end
|
||||||
-- Spawn position search
|
-- Spawn position search
|
||||||
|
|
||||||
local function search()
|
local function search()
|
||||||
|
local edge1, edge2 = core.get_mapgen_edges()
|
||||||
for iter = 1, checks do
|
for iter = 1, checks do
|
||||||
local biome_data = minetest.get_biome_data(pos)
|
local biome_data = minetest.get_biome_data(pos)
|
||||||
-- Sometimes biome_data is nil
|
-- Sometimes biome_data is nil
|
||||||
|
@ -116,7 +108,7 @@ local function search()
|
||||||
|
|
||||||
pos = next_pos()
|
pos = next_pos()
|
||||||
-- Check for position being outside world edge
|
-- Check for position being outside world edge
|
||||||
if math.abs(pos.x) > spawn_limit or math.abs(pos.z) > spawn_limit then
|
if pos.x < edge1.x or pos.z < edge1.z or pos.x > edge2.x or pos.z > edge2.z then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue