Fix biomes 3/3

This commit is contained in:
kay27 2022-02-01 06:33:03 +04:00
parent 7b47e4d12b
commit e023b96877
4 changed files with 56 additions and 86 deletions

View File

@ -60,14 +60,10 @@ local flat = mcl_mapgen.flat
-- Content IDs
local c_bedrock = minetest.get_content_id("mcl_core:bedrock")
local c_obsidian = minetest.get_content_id("mcl_core:obsidian")
local c_stone = minetest.get_content_id("mcl_core:stone")
local c_dirt = minetest.get_content_id("mcl_core:dirt")
local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_sand = minetest.get_content_id("mcl_core:sand")
local c_void = minetest.get_content_id("mcl_core:void")
local c_lava = minetest.get_content_id("mcl_core:lava_source")
local c_water = minetest.get_content_id("mcl_core:water_source")
local c_nether = nil
if minetest.get_modpath("mcl_nether") then
@ -1328,4 +1324,6 @@ if v6 then
elseif not singlenode then
dofile(modpath .. "/biomes.lua")
end
-- dofile(modpath .. "/nether.lua")
if not singlenode and c_nether then
dofile(modpath .. "/nether.lua")
end

View File

@ -1,3 +1,17 @@
-- Nether Light:
mcl_mapgen.register_mapgen_block_lvm(function(vm_context)
local minp = vm_context.minp
local miny = minp.y
if miny > mcl_mapgen.nether.max then return end
local maxp = vm_context.maxp
local maxy = maxp.y
if maxy < mcl_mapgen.nether.min then return end
local p1 = {x = minp.x, y = math.max(miny, mcl_mapgen.nether.min), z = minp.z}
local p2 = {x = maxp.x, y = math.min(maxy, mcl_mapgen.nether.max), z = maxp.z}
vm_context.vm:set_lighting({day = 3, night = 4}, p1, p2)
vm_context.write = true
end, 999999999)
-- Nether Roof Light:
mcl_mapgen.register_mapgen_block_lvm(function(vm_context)
local minp = vm_context.minp
@ -8,7 +22,7 @@ mcl_mapgen.register_mapgen_block_lvm(function(vm_context)
if maxy <= mcl_mapgen.nether.max then return end
local p1 = {x = minp.x, y = math.max(miny, mcl_mapgen.nether.max + 1), z = minp.z}
local p2 = {x = maxp.x, y = math.min(maxy, mcl_mapgen.nether.max + 127), z = maxp.z}
vm_context.vm:set_lighting({day=15, night=15}, p1, p2)
vm_context.vm:set_lighting({day = 15, night = 15}, p1, p2)
vm_context.write = true
end, 999999999)

View File

@ -2,11 +2,13 @@ local v6 = mcl_mapgen.v6
local mcl_mushrooms = minetest.get_modpath("mcl_mushrooms")
local c_nether = minetest.get_modpath("mcl_nether") and {
soul_sand = minetest.get_content_id("mcl_nether:soul_sand"),
netherrack = minetest.get_content_id("mcl_nether:netherrack"),
lava = minetest.get_content_id("mcl_nether:nether_lava_source")
}
local c_water = minetest.get_content_id("mcl_core:water_source")
local c_stone = minetest.get_content_id("mcl_core:stone")
local c_sand = minetest.get_content_id("mcl_core:sand")
local c_soul_sand = minetest.get_content_id("mcl_nether:soul_sand")
local c_netherrack = minetest.get_content_id("mcl_nether:netherrack")
local c_nether_lava = minetest.get_content_id("mcl_nether:nether_lava_source")
-- Generate mushrooms in caves manually.
-- Minetest's API does not support decorations in caves yet. :-(
@ -41,10 +43,6 @@ end
-- Generate Nether decorations manually: Eternal fire, mushrooms
-- Minetest's API does not support decorations in caves yet. :-(
local function generate_nether_decorations(minp, maxp, seed)
if c_nether == nil then
return
end
local pr_nether = PseudoRandom(seed+667)
if minp.y > mcl_mapgen.nether.max or maxp.y < mcl_mapgen.nether.min then
@ -108,79 +106,26 @@ mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context)
-- Nether block fixes:
-- * Replace water with Nether lava.
-- * Replace stone, sand dirt in v6 so the Nether works in v6.
if min_y <= mcl_mapgen.nether.max and max_y >= mcl_mapgen.nether.min then
if c_nether then
if v6 then
local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
for n=1, #nodes do
local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z)
if data[p_pos] == c_water then
data[p_pos] = c_nether.lava
lvm_used = true
elseif data[p_pos] == c_stone then
data[p_pos] = c_netherrack
lvm_used = true
elseif data[p_pos] == c_sand or data[p_pos] == c_dirt then
data[p_pos] = c_soul_sand
lvm_used = true
end
end
else
local nodes = minetest.find_nodes_in_area(minp, maxp, {"group:water"})
for _, n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_nether.lava
if min_y > mcl_mapgen.nether.max or max_y < mcl_mapgen.nether.min then return end
if v6 then
local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
if #nodes < 1 then return end
vm_context.write = true
local data = vm_context.data
local area = vm_context.area
for n = 1, #nodes do
local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z)
if data[p_pos] == c_water then
data[p_pos] = c_nether_lava
elseif data[p_pos] == c_stone then
data[p_pos] = c_netherrack
elseif data[p_pos] == c_sand or data[p_pos] == c_dirt then
data[p_pos] = c_soul_sand
end
end
end
-- End block fixes:
-- * Replace water with end stone or air (depending on height).
-- * Remove stone, sand, dirt in v6 so our End map generator works in v6.
-- * Generate spawn platform (End portal destination)
elseif minp.y <= mcl_mapgen.end_.max and maxp.y >= mcl_mapgen.end_.min then
local nodes
if v6 then
nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
else
nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:water_source"})
end
if #nodes > 0 then
lvm_used = true
for _,n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_air
end
end
-- Obsidian spawn platform
if minp.y <= mcl_mapgen.end_.platform_pos.y and maxp.y >= mcl_mapgen.end_.platform_pos.y and
minp.x <= mcl_mapgen.end_.platform_pos.x and maxp.x >= mcl_mapgen.end_.platform_pos.z and
minp.z <= mcl_mapgen.end_.platform_pos.z and maxp.z >= mcl_mapgen.end_.platform_pos.z then
--local pos1 = {x = math.max(minp.x, mcl_mapgen.end_.platform_pos.x-2), y = math.max(minp.y, mcl_mapgen.end_.platform_pos.y), z = math.max(minp.z, mcl_mapgen.end_.platform_pos.z-2)}
--local pos2 = {x = math.min(maxp.x, mcl_mapgen.end_.platform_pos.x+2), y = math.min(maxp.y, mcl_mapgen.end_.platform_pos.y+2), z = math.min(maxp.z, mcl_mapgen.end_.platform_pos.z+2)}
for x=math.max(minp.x, mcl_mapgen.end_.platform_pos.x-2), math.min(maxp.x, mcl_mapgen.end_.platform_pos.x+2) do
for z=math.max(minp.z, mcl_mapgen.end_.platform_pos.z-2), math.min(maxp.z, mcl_mapgen.end_.platform_pos.z+2) do
for y=math.max(minp.y, mcl_mapgen.end_.platform_pos.y), math.min(maxp.y, mcl_mapgen.end_.platform_pos.y+2) do
local p_pos = area:index(x, y, z)
if y == mcl_mapgen.end_.platform_pos.y then
data[p_pos] = c_obsidian
else
data[p_pos] = c_air
end
end
end
end
lvm_used = true
end
end
end
if not singlenode then
-- Generate special decorations
generate_underground_mushrooms(minp, maxp, chunkseed)
generate_nether_decorations(minp, maxp, chunkseed)
else
end
generate_underground_mushrooms(minp, maxp, seed)
generate_nether_decorations(minp, maxp, seed)
end, 1)

View File

@ -2,6 +2,19 @@ local c_air = minetest.CONTENT_AIR
mcl_mapgen.register_on_generated(function(vm_context)
local minp, maxp = vm_context.minp, vm_context.maxp
if minp.y <= mcl_mapgen.end_.max and maxp.y >= mcl_mapgen.end_.min then
local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
if #nodes > 0 then
for _, n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_air
end
end
vm_context.write = true
return
end
if minp.y > mcl_mapgen.overworld.max or maxp.y < mcl_mapgen.overworld.min then return end
local vm, data, area = vm_context.vm, vm_context.data, vm_context.area