mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-10 02:01:07 +01:00
Remove mcl_structures:structblocks (#4619)
As spawning happens via gennotify anyway, we can omit placing a structblock right away. This also avoids certain cases of holes in snow cover or water. Plus, the code is simpler. Isolated from the big mapgen overhaul, for the main branch. Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4619 Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com> Co-authored-by: kno10 <erich.schubert@gmail.com> Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
parent
05bfe5513f
commit
444c491e14
2 changed files with 28 additions and 54 deletions
|
@ -484,18 +484,14 @@ end
|
||||||
-- This should be moved to mcl_structures eventually if the dependencies can be sorted out.
|
-- This should be moved to mcl_structures eventually if the dependencies can be sorted out.
|
||||||
mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed)
|
mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed)
|
||||||
local gennotify = minetest.get_mapgen_object("gennotify")
|
local gennotify = minetest.get_mapgen_object("gennotify")
|
||||||
local has_struct = {}
|
|
||||||
local has = false
|
local has = false
|
||||||
local poshash = minetest.hash_node_position(minp)
|
local poshash = minetest.hash_node_position(minp)
|
||||||
for _,struct in pairs(mcl_structures.registered_structures) do
|
for _,struct in pairs(mcl_structures.registered_structures) do
|
||||||
local pr = PseudoRandom(blockseed + 42)
|
local pr = PseudoRandom(blockseed + 42)
|
||||||
if struct.deco_id then
|
if struct.deco_id then
|
||||||
for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do
|
for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do
|
||||||
local realpos = vector.offset(pos,0,1,0)
|
|
||||||
minetest.remove_node(realpos)
|
|
||||||
minetest.fix_light(vector.offset(pos,-1,-1,-1),vector.offset(pos,1,3,1))
|
|
||||||
if struct.chunk_probability == nil or (not has and pr:next(1,struct.chunk_probability) == 1 ) then
|
if struct.chunk_probability == nil or (not has and pr:next(1,struct.chunk_probability) == 1 ) then
|
||||||
mcl_structures.place_structure(realpos,struct,pr,blockseed)
|
mcl_structures.place_structure(vector.offset(pos,0,1,0),struct,pr,blockseed)
|
||||||
has=true
|
has=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -325,43 +325,33 @@ function mcl_structures.place_structure(pos, def, pr, blockseed, rot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly
|
local EMPTY_SCHEMATIC = { size = {x = 0, y = 0, z = 0}, data = { } }
|
||||||
if mcl_structures.is_disabled(name) then return end
|
|
||||||
local structblock = "mcl_structures:structblock_"..name
|
|
||||||
local flags = "place_center_x, place_center_z, force_placement"
|
|
||||||
local y_offset = 0
|
|
||||||
local sbgroups = { structblock = 1, not_in_creative_inventory=1 }
|
|
||||||
if def.flags then flags = def.flags end
|
|
||||||
def.name = name
|
|
||||||
if nospawn then
|
|
||||||
sbgroups.structblock = nil
|
|
||||||
sbgroups.structblock_lbm = 1
|
|
||||||
else
|
|
||||||
if def.place_on then
|
|
||||||
minetest.register_on_mods_loaded(function() --make sure all previous decorations and biomes have been registered
|
|
||||||
def.deco = minetest.register_decoration({
|
|
||||||
name = "mcl_structures:deco_"..name,
|
|
||||||
decoration = structblock,
|
|
||||||
deco_type = "simple",
|
|
||||||
place_on = def.place_on,
|
|
||||||
spawn_by = def.spawn_by,
|
|
||||||
num_spawn_by = def.num_spawn_by,
|
|
||||||
sidelen = 80,
|
|
||||||
fill_ratio = def.fill_ratio,
|
|
||||||
noise_params = def.noise_params,
|
|
||||||
flags = flags,
|
|
||||||
biomes = def.biomes,
|
|
||||||
y_max = def.y_max,
|
|
||||||
y_min = def.y_min
|
|
||||||
})
|
|
||||||
minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups,sunlight_propagates = true,})
|
|
||||||
def.structblock = structblock
|
|
||||||
def.deco_id = minetest.get_decoration_id("mcl_structures:deco_"..name)
|
|
||||||
minetest.set_gen_notify({decoration=true}, { def.deco_id })
|
|
||||||
--catching of gennotify happens in mcl_mapgen_core
|
|
||||||
|
|
||||||
end)
|
function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will not be placed by mapgen decoration mechanism
|
||||||
end
|
if mcl_structures.is_disabled(name) then return end
|
||||||
|
flags = def.flags or "place_center_x, place_center_z, force_placement"
|
||||||
|
def.name = name
|
||||||
|
if not nospawn and def.place_on then
|
||||||
|
minetest.register_on_mods_loaded(function() --make sure all previous decorations and biomes have been registered
|
||||||
|
def.deco = minetest.register_decoration({
|
||||||
|
name = "mcl_structures:deco_"..name,
|
||||||
|
deco_type = "schematic",
|
||||||
|
schematic = EMPTY_SCHEMATIC,
|
||||||
|
place_on = def.place_on,
|
||||||
|
spawn_by = def.spawn_by,
|
||||||
|
num_spawn_by = def.num_spawn_by,
|
||||||
|
sidelen = 80,
|
||||||
|
fill_ratio = def.fill_ratio,
|
||||||
|
noise_params = def.noise_params,
|
||||||
|
flags = flags,
|
||||||
|
biomes = def.biomes,
|
||||||
|
y_max = def.y_max,
|
||||||
|
y_min = def.y_min
|
||||||
|
})
|
||||||
|
def.deco_id = minetest.get_decoration_id("mcl_structures:deco_"..name)
|
||||||
|
minetest.set_gen_notify({decoration=true}, { def.deco_id })
|
||||||
|
--catching of gennotify happens in mcl_mapgen_core
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
mcl_structures.registered_structures[name] = def
|
mcl_structures.registered_structures[name] = def
|
||||||
end
|
end
|
||||||
|
@ -395,16 +385,4 @@ function mcl_structures.register_structure_spawn(def)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--lbm for secondary structures (structblock included in base structure)
|
|
||||||
minetest.register_lbm({
|
|
||||||
name = "mcl_structures:struct_lbm",
|
|
||||||
run_at_every_load = true,
|
|
||||||
nodenames = {"group:structblock_lbm"},
|
|
||||||
action = function(pos, node)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
local name = node.name:gsub("mcl_structures:structblock_","")
|
|
||||||
local def = mcl_structures.registered_structures[name]
|
|
||||||
if not def then return end
|
|
||||||
mcl_structures.place_structure(pos)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in a new issue