Skip to content

Commit 8fbfc14

Browse files
authored
Avoid parsing mapgen 'chunksize' by hand
1 parent 6ed522b commit 8fbfc14

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

mods/default/mapgen.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,13 @@ function default.register_decorations()
18601860
-- Emergent jungle tree
18611861
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
18621862

1863-
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
1863+
local chunksize
1864+
if core.get_mapgen_chunksize then
1865+
local v = core.get_mapgen_chunksize()
1866+
chunksize = math.max(v.x, v.y, v.z)
1867+
else
1868+
chunksize = tonumber(core.get_mapgen_setting("chunksize"))
1869+
end
18641870
if chunksize >= 5 then
18651871
minetest.register_decoration({
18661872
name = "default:emergent_jungle_tree",

mods/spawn/init.lua

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ local success = false
6666
local spawn_pos = {}
6767

6868

69-
-- Get world 'mapgen_limit' and 'chunksize' to calculate 'spawn_limit'.
70-
-- This accounts for how mapchunks are not generated if they or their shell exceed
71-
-- 'mapgen_limit'.
72-
73-
local mapgen_limit = tonumber(minetest.get_mapgen_setting("mapgen_limit"))
74-
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
75-
local spawn_limit = math.max(mapgen_limit - (chunksize + 1) * 16, 0)
76-
77-
7869
-- Functions
7970
------------
8071

@@ -103,6 +94,7 @@ end
10394
-- Spawn position search
10495

10596
local function search()
97+
local edge1, edge2 = core.get_mapgen_edges()
10698
for iter = 1, checks do
10799
local biome_data = minetest.get_biome_data(pos)
108100
-- Sometimes biome_data is nil
@@ -116,7 +108,7 @@ local function search()
116108

117109
pos = next_pos()
118110
-- Check for position being outside world edge
119-
if math.abs(pos.x) > spawn_limit or math.abs(pos.z) > spawn_limit then
111+
if pos.x < edge1.x or pos.z < edge1.z or pos.x > edge2.x or pos.z > edge2.z then
120112
return false
121113
end
122114
end

0 commit comments

Comments
 (0)