forked from VoxeLibre/VoxeLibre
Speedup placing villages 2/2 (update mcl_villages through Gitea, as direct push doesn't work)
This commit is contained in:
parent
3b196da12f
commit
1d792a650f
|
@ -4,7 +4,7 @@
|
|||
-------------------------------------------------------------------------------
|
||||
function settlements.build_schematic(vm, data, va, pos, building, replace_wall, name)
|
||||
-- get building node material for better integration to surrounding
|
||||
local platform_material = minetest.get_node_or_nil(pos)
|
||||
local platform_material = mcl_util.get_far_node(pos, true)
|
||||
if not platform_material then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
mcl_util
|
||||
mcl_core
|
||||
mcl_loot
|
||||
mcl_farming?
|
||||
|
|
|
@ -52,8 +52,7 @@ function settlements.terraform(settlement_info, pr)
|
|||
else
|
||||
-- write ground
|
||||
local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi}
|
||||
minetest.forceload_block(p)
|
||||
local node = minetest.get_node_or_nil(p)
|
||||
local node = mcl_util.get_far_node(p, true)
|
||||
if node and node.name ~= "air" then
|
||||
minetest.swap_node(p,{name="air"})
|
||||
end
|
||||
|
|
|
@ -82,6 +82,7 @@ end
|
|||
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||
if mg_name ~= "singlenode" then
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
minetest.log("warning","[mcl_villages] on_generated("..minetest.pos_to_string(minp)..", "..minetest.pos_to_string(maxp)..", "..tostring(blockseed)..")")
|
||||
-- needed for manual and automated settlement building
|
||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
||||
|
||||
|
@ -94,11 +95,8 @@ if mg_name ~= "singlenode" then
|
|||
-- don't build settlements on (too) uneven terrain
|
||||
local height_difference = settlements.evaluate_heightmap(minp, maxp)
|
||||
if height_difference > max_height_difference then return end
|
||||
|
||||
-- new way - slow :(((((
|
||||
minetest.emerge_area(vector.subtract(minp,24), vector.add(maxp,24), ecb_build_a_settlement, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
||||
-- old way - wait 3 seconds:
|
||||
-- minetest.after(3, ecb_build_a_settlement, nil, 1, 0, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
||||
-- we need 'minetest.after' here to exit from emerging thread we probably currently in:
|
||||
minetest.after(0.1, build_a_settlement_no_delay, vector.new(minp), vector.new(maxp), blockseed)
|
||||
end)
|
||||
end
|
||||
-- manually place villages
|
||||
|
|
|
@ -51,7 +51,7 @@ function settlements.find_surface(pos)
|
|||
local itter -- count up or down
|
||||
local cnt_max = 200
|
||||
-- check, in which direction to look for surface
|
||||
local surface_node = minetest.get_node_or_nil(p6)
|
||||
local surface_node = mcl_util.get_far_node(p6, true)
|
||||
if surface_node and string.find(surface_node.name,"air") then
|
||||
itter = -1
|
||||
else
|
||||
|
@ -61,31 +61,16 @@ function settlements.find_surface(pos)
|
|||
while cnt < cnt_max do
|
||||
cnt = cnt+1
|
||||
minetest.forceload_block(p6)
|
||||
surface_node = minetest.get_node_or_nil(p6)
|
||||
|
||||
if not surface_node then
|
||||
-- Load the map at pos and try again
|
||||
minetest.get_voxel_manip():read_from_map(p6, p6)
|
||||
surface_node = minetest.get_node(p6)
|
||||
if surface_node.name == "ignore" then
|
||||
settlements.debug("find_surface1: nil or ignore")
|
||||
return nil
|
||||
end
|
||||
surface_node = mcl_util.get_far_node(p6, true)
|
||||
if surface_node.name == "ignore" then
|
||||
settlements.debug("find_surface1: nil or ignore")
|
||||
return nil
|
||||
end
|
||||
|
||||
-- if surface_node == nil or surface_node.name == "ignore" then
|
||||
-- --return nil
|
||||
-- local fl = minetest.forceload_block(p6)
|
||||
-- if not fl then
|
||||
--
|
||||
-- return nil
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- Check Surface_node and Node above
|
||||
--
|
||||
if settlements.surface_mat[surface_node.name] then
|
||||
local surface_node_plus_1 = minetest.get_node_or_nil({ x=p6.x, y=p6.y+1, z=p6.z})
|
||||
local surface_node_plus_1 = mcl_util.get_far_node({ x=p6.x, y=p6.y+1, z=p6.z}, true)
|
||||
if surface_node_plus_1 and surface_node and
|
||||
(string.find(surface_node_plus_1.name,"air") or
|
||||
string.find(surface_node_plus_1.name,"snow") or
|
||||
|
@ -257,7 +242,7 @@ function settlements.initialize_nodes(settlement_info, pr)
|
|||
for xi = 0,width do
|
||||
for zi = 0,depth do
|
||||
local ptemp = {x=p.x+xi, y=p.y+yi, z=p.z+zi}
|
||||
local node = minetest.get_node(ptemp)
|
||||
local node = mcl_util.get_far_node(ptemp, true)
|
||||
if node.name == "mcl_furnaces:furnace" or
|
||||
node.name == "mcl_chests:chest" or
|
||||
node.name == "mcl_anvils:anvil" then
|
||||
|
|
Reference in New Issue