Watershed update and cleanup

This commit is contained in:
Gael-de-Sailly 2016-07-13 15:16:52 +02:00
parent fae4d838ea
commit 252f09a17f
7 changed files with 177 additions and 210 deletions

View File

@ -2,4 +2,3 @@ default
farming?
stairs?
stairsplus?
watershed?

View File

@ -1,4 +1,4 @@
watershed 0.6.6 by paramat
For latest stable Minetest back to 0.4.8
Depends default stairs bucket
Licenses: code WTFPL, textures CC BY-SA
watershed 0.7.1 by paramat, modified by the MinetestForFun Team.
For Minetest 0.4.13 and later
Depends default farming darkage
Licenses: WTFPL

View File

@ -1,3 +1,3 @@
default
bucket
stairs
farming
darkage

View File

@ -50,7 +50,7 @@ function watershed_appletree(x, y, z, area, data)
local vit = area:index(x, y + j, z)
-- MFF: Prevent trees from destroying existing blocks
if j == 0 then
-- MFF: the positioon of the sapling itself, replace it without checking.
-- MFF: the position of the sapling itself, replace it without checking.
data[vit] = c_tree
else
safely_set_block(data, vit, c_tree)
@ -219,9 +219,7 @@ local SINGLENODE = true
if SINGLENODE then
-- Set mapgen parameters
minetest.register_on_mapgen_init(function(mgparams)
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
end)
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
-- Spawn player function is useless in minetestforfun
end
@ -233,10 +231,10 @@ end
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-2, y=y-2, z=z-2}
local pos2 = {x=x+2, y=y+4, z=z+2}
local pos1 = {x = x - 2, y = y - 2, z = z - 2}
local pos2 = {x = x + 2, y = y + 4, z = z + 2}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local data = vm:get_data()
watershed_appletree(x, y, z, area, data)
vm:set_data(data)
@ -251,8 +249,8 @@ end
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-2, y=y-4, z=z-2}
local pos2 = {x=x+2, y=y+17, z=z+2}
local pos1 = {x = x - 2, y = y - 4, z = z - 2}
local pos2 = {x = x + 2, y = y + 17, z = z + 2}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data()
@ -271,10 +269,10 @@ end
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-2, y=y-5, z=z-2}
local pos2 = {x=x+2, y=y+23, z=z+2}
local pos1 = {x = x - 2, y = y - 5, z = z - 2}
local pos2 = {x = x + 2, y = y + 23, z = z + 2}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local data = vm:get_data()
watershed_jungletree(x, y, z, area, data)
vm:set_data(data)

View File

@ -1,10 +1,3 @@
-- watershed 0.6.6 by paramat
-- For latest stable Minetest and back to 0.4.8
-- Depends default stairs bucket
-- License: code WTFPL, textures CC BY-SA
-- re-add z=1 for z component of 2D noisemap size to fix crashes
-- Parameters
local YMIN = -33000 -- Approximate base of realm stone
@ -21,7 +14,8 @@ local XLSAMP = 0.1 -- Extra large scale height variation amplitude
local BASAMP = 0.3 -- Base terrain amplitude
local MIDAMP = 0.1 -- Mid terrain amplitude
local CANAMP = 0.4 -- Canyon terrain maximum amplitude
local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges
local ATANAMP = 1.1 -- Arctan function amplitude,
-- smaller = more and larger floatlands above ridges
local BLENEXP = 2 -- Terrain blend exponent
local TSTONE = 0.02 -- Density threshold for stone, depth of soil at TERCEN
@ -29,7 +23,8 @@ local TRIVER = -0.028 -- Densitybase threshold for river surface
local TRSAND = -0.035 -- Densitybase threshold for river sand
local TSTREAM = -0.004 -- Densitymid threshold for stream surface
local TSSAND = -0.005 -- Densitymid threshold for stream sand
local TLAVA = 2 -- Maximum densitybase threshold for lava, small because grad is non-linear
local TLAVA = 2 -- Maximum densitybase threshold for lava,
-- small because grad is non-linear
local TFIS = 0.01 -- Fissure threshold, controls width
local TSEAM = 0.2 -- Seam threshold, width of seams
local ORESCA = 512 -- Seam system vertical scale
@ -37,13 +32,14 @@ local ORETHI = 0.002 -- Ore seam thickness tuner
local BERGDEP = 32 -- Maximum iceberg depth
local TFOG = -0.04 -- Fog top densitymid threshold
local HITET = 0.35 -- High temperature threshold
local LOTET = -0.35 -- Low ..
local ICETET = -0.7 -- Ice ..
local HIHUT = 0.35 -- High humidity threshold
local LOHUT = -0.35 -- Low ..
local FOGHUT = 1.0 -- Fog ..
local BLEND = 0.02 -- Biome blend randomness
local biomeparams = {
HITET = 0.35, -- High temperature threshold
LOTET = -0.35, -- Low ..
ICETET = -0.7, -- Ice ..
HIHUT = 0.35, -- High humidity threshold
LOHUT = -0.35, -- Low ..
BLEND = 0.02, -- Biome blend randomness
}
local flora = {
PINCHA = 36, -- Pine tree 1/x chance per node
@ -71,7 +67,7 @@ local np = {
terrain = {
offset = 0,
scale = 1,
spread = {x=384, y=192, z=384},
spread = {x = 384, y = 192, z = 384},
seed = 593,
octaves = 5,
persist = 0.67
@ -82,7 +78,7 @@ terrain = {
fissure = {
offset = 0,
scale = 1,
spread = {x=256, y=512, z=256},
spread = {x = 256, y = 512, z = 256},
seed = 20099,
octaves = 5,
persist = 0.5
@ -93,7 +89,7 @@ fissure = {
seam = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
spread = {x = 512, y = 512, z = 512},
seed = -992221,
octaves = 2,
persist = 0.5
@ -104,7 +100,7 @@ seam = {
strata = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
spread = {x = 512, y = 512, z = 512},
seed = 92219,
octaves = 3,
persist = 0.5
@ -155,7 +151,7 @@ cave4 = {
mid = {
offset = 0,
scale = 1,
spread = {x=768, y=768, z=768},
spread = {x = 768, y = 768, z = 768},
seed = 85546,
octaves = 5,
persist = 0.5
@ -166,7 +162,7 @@ mid = {
base = {
offset = 0,
scale = 1,
spread = {x=1024, y=1024, z=1024},
spread = {x = 1024, y = 1024, z = 1024},
seed = 8890,
octaves = 3,
persist = 0.33
@ -177,7 +173,7 @@ base = {
xlscale = {
offset = 0,
scale = 1,
spread = {x=4096, y=4096, z=4096},
spread = {x = 4096, y = 4096, z = 4096},
seed = -72,
octaves = 3,
persist = 0.33
@ -188,7 +184,7 @@ xlscale = {
magma = {
offset = 0,
scale = 1,
spread = {x=128, y=128, z=128},
spread = {x = 128, y = 128, z = 128},
seed = -13,
octaves = 2,
persist = 0.5
@ -199,7 +195,7 @@ magma = {
temp = {
offset = 0,
scale = 1,
spread = {x=256, y=256, z=256},
spread = {x = 256, y = 256, z = 256},
seed = 112,
octaves = 3,
persist = 0.5
@ -210,7 +206,7 @@ temp = {
humid = {
offset = 0,
scale = 1,
spread = {x=256, y=256, z=256},
spread = {x = 256, y = 256, z = 256},
seed = 72384,
octaves = 4,
persist = 0.66
@ -218,28 +214,49 @@ humid = {
}
-- Stuff
-- Do files
-- initialize 3D and 2D noise objects to nil
dofile(minetest.get_modpath("watershed") .. "/nodes.lua")
dofile(minetest.get_modpath("watershed") .. "/functions.lua")
-- Initialize 3D and 2D noise objects to nil
local nobj_terrain = nil
local nobj_fissure = nil
local nobj_temp = nil
local nobj_humid = nil
local nobj_seam = nil
local nobj_strata = nil
local nobj_cave1 = nil
local nobj_cave2 = nil
local nobj_cave3 = nil
local nobj_cave4 = nil
local nobj_mid = nil
local nobj_base = nil
local nobj_xlscale = nil
local nobj_magma = nil
local nobj_temp = nil
local nobj_humid = nil
dofile(minetest.get_modpath("watershed").."/nodes.lua")
dofile(minetest.get_modpath("watershed").."/functions.lua")
-- Localise noise buffers
local nbuf_terrain
local nbuf_fissure
local nbuf_temp
local nbuf_humid
local nbuf_seam
local nbuf_strata
local nbuf_cave1
local nbuf_cave2
local nbuf_cave3
local nbuf_cave4
local nbuf_mid
local nbuf_base
local nbuf_xlscale
local nbuf_magma
-- Mapchunk generation function
@ -275,7 +292,6 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
local c_obsidian = minetest.get_content_id("default:obsidian")
local c_wsfreshwater = minetest.get_content_id("watershed:freshwater")
local c_wsmixwater = minetest.get_content_id("watershed:mixwater")
local c_wsstone = minetest.get_content_id("watershed:stone")
local c_wsredstone = minetest.get_content_id("watershed:redstone")
local c_wsgrass = minetest.get_content_id("watershed:grass")
@ -286,19 +302,24 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
local c_wslava = minetest.get_content_id("watershed:lava")
local c_wsfreshice = minetest.get_content_id("watershed:freshice")
local c_wscloud = minetest.get_content_id("air") -- disable clouds
local c_wsluxore = minetest.get_content_id("watershed:luxore")
local c_wsicydirt = minetest.get_content_id("watershed:icydirt")
-- perlinmap stuff
local sidelen = x1 - x0 + 1 -- chunk sidelength
local chulensxyz = {x=sidelen, y=sidelen+2, z=sidelen} -- chunk dimensions, '+2' for overgeneration
local chulensxz = {x=sidelen, y=sidelen, z=1} -- here x = map x, y = map z
local minposxyz = {x=x0, y=y0-1, z=z0}
local minposxz = {x=x0, y=z0} -- here x = map x, y = map z
local sidelen = x1 - x0 + 1
local sqr_sidelen = sidelen ^ 2
local chulensxyz = {x = sidelen, y = sidelen + 2, z = sidelen}
local chulensxz = {x = sidelen, y = sidelen, z = 1}
local minposxyz = {x = x0, y = y0 - 1, z = z0}
local minposxz = {x = x0, y = z0}
-- 3D and 2D noise objects created once on first mapchunk generation only
nobj_terrain = nobj_terrain or minetest.get_perlin_map(np.terrain, chulensxyz)
nobj_fissure = nobj_fissure or minetest.get_perlin_map(np.fissure, chulensxyz)
nobj_temp = nobj_temp or minetest.get_perlin_map(np.temp, chulensxyz)
nobj_humid = nobj_humid or minetest.get_perlin_map(np.humid, chulensxyz)
nobj_seam = nobj_seam or minetest.get_perlin_map(np.seam, chulensxyz)
nobj_strata = nobj_strata or minetest.get_perlin_map(np.strata, chulensxyz)
nobj_cave1 = nobj_cave1 or minetest.get_perlin_map(np.cave1, chulensxyz)
nobj_cave2 = nobj_cave2 or minetest.get_perlin_map(np.cave2, chulensxyz)
nobj_cave3 = nobj_cave3 or minetest.get_perlin_map(np.cave3, chulensxyz)
@ -308,40 +329,41 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
nobj_base = nobj_base or minetest.get_perlin_map(np.base, chulensxz)
nobj_xlscale = nobj_xlscale or minetest.get_perlin_map(np.xlscale, chulensxz)
nobj_magma = nobj_magma or minetest.get_perlin_map(np.magma, chulensxz)
nobj_temp = nobj_temp or minetest.get_perlin_map(np.temp, chulensxyz)
nobj_humid = nobj_humid or minetest.get_perlin_map(np.humid, chulensxyz)
-- 3D and 2D perlinmaps created per mapchunk
local nvals_terrain = nobj_terrain:get3dMap_flat(minposxyz)
local nvals_fissure = nobj_fissure:get3dMap_flat(minposxyz)
local nvals_seam = nobj_seam:get3dMap_flat(minposxyz)
local nvals_strata = nobj_strata:get3dMap_flat(minposxyz)
local nvals_cave1 = nobj_cave1:get3dMap_flat(minposxyz)
local nvals_cave2 = nobj_cave2:get3dMap_flat(minposxyz)
local nvals_cave3 = nobj_cave3:get3dMap_flat(minposxyz)
local nvals_cave4 = nobj_cave4:get3dMap_flat(minposxyz)
local nvals_temp = nobj_temp :get2dMap_flat(minposxz)
local nvals_humid = nobj_humid :get2dMap_flat(minposxz)
local nvals_seam = nobj_seam :get3dMap_flat(minposxyz)
local nvals_strata = nobj_strata :get3dMap_flat(minposxyz)
local nvals_mid = nobj_mid:get2dMap_flat(minposxz)
local nvals_base = nobj_base:get2dMap_flat(minposxz)
local nvals_cave1 = nobj_cave1 :get3dMap_flat(minposxyz)
local nvals_cave2 = nobj_cave2 :get3dMap_flat(minposxyz)
local nvals_cave3 = nobj_cave3 :get3dMap_flat(minposxyz)
local nvals_cave4 = nobj_cave4 :get3dMap_flat(minposxyz)
local nvals_mid = nobj_mid :get2dMap_flat(minposxz)
local nvals_base = nobj_base :get2dMap_flat(minposxz)
local nvals_xlscale = nobj_xlscale:get2dMap_flat(minposxz)
local nvals_magma = nobj_magma:get2dMap_flat(minposxz)
local nvals_temp = nobj_temp:get2dMap_flat(minposxz)
local nvals_humid = nobj_humid:get2dMap_flat(minposxz)
local nvals_magma = nobj_magma :get2dMap_flat(minposxz)
-- ungenerated chunk below?
local viu = area:index(x0, y0-1, z0)
local viu = area:index(x0, y0 - 1, z0)
local ungen = data[viu] == c_ignore
-- mapgen loop
local nixyz = 1 -- 3D and 2D perlinmap indexes
local nixz = 1
local stable = {} -- stability table of true/false. is node supported from below by 2 stone or nodes on 2 stone?
local under = {} -- biome table. biome number of previous fine material placed in column
local increment_y = (x1 - x0 + 1)
local increment_z = increment_y * (y1 - y0 + 1)
for z = z0, z1 do -- for each xy plane progressing northwards
for y = y0 - 1, y1 + 1 do -- for each x row progressing upwards
local vi = area:index(x0, y, z) -- voxelmanip index for first node in this x row
local viu = area:index(x0, y-1, z) -- index for under node
for x = x0, x1 do -- for each node do
local stable = {} -- stability table of true/false.
-- is node supported from below by 2 stone or nodes on 2 stone?
local under = {} -- biome table.
-- biome number of previous fine material placed in column
for z = z0, z1 do
for y = y0 - 1, y1 + 1 do
local vi = area:index(x0, y, z)
local viu = area:index(x0, y - 1, z)
for x = x0, x1 do
local si = x - x0 + 1 -- stable, under tables index
-- noise values for node
local n_absterrain = math.abs(nvals_terrain[nixyz])
@ -385,26 +407,32 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
end
local biome = false -- select biome for node
if n_temp < LOTET + (math.random() - 0.5) * BLEND then
if n_humid < LOHUT + (math.random() - 0.5) * BLEND then
if n_temp < biomeparams.LOTET +
(math.random() - 0.5) * biomeparams.BLEND then
if n_humid < biomeparams.LOHUT +
(math.random() - 0.5) * biomeparams.BLEND then
biome = 1 -- tundra
elseif n_humid > HIHUT + (math.random() - 0.5) * BLEND then
elseif n_humid > biomeparams.HIHUT +
(math.random() - 0.5) * biomeparams.BLEND then
biome = 3 -- taiga
else
biome = 2 -- snowy plains
end
elseif n_temp > HITET + (math.random() - 0.5) * BLEND then
if n_humid < LOHUT + (math.random() - 0.5) * BLEND then
elseif n_temp > biomeparams.HITET +
(math.random() - 0.5) * biomeparams.BLEND then
if n_humid < biomeparams.LOHUT +
(math.random() - 0.5) * biomeparams.BLEND then
biome = 7 -- desert
elseif n_humid > HIHUT + (math.random() - 0.5) * BLEND then
elseif n_humid > biomeparams.HIHUT +
(math.random() - 0.5) * biomeparams.BLEND then
biome = 9 -- rainforest
else
biome = 8 -- savanna
end
else
if n_humid < LOHUT then
if n_humid < biomeparams.LOHUT then
biome = 4 -- dry grassland
elseif n_humid > HIHUT then
elseif n_humid > biomeparams.HIHUT then
biome = 6 -- deciduous forest
else
biome = 5 -- grassland
@ -423,22 +451,21 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
else -- scan top layer of chunk below
local nodid = data[vi]
if nodid == c_wsstone
or nodid == c_wsredstone
or nodid == c_wsdirt
or nodid == c_wspermafrost
or nodid == c_wsluxore
or nodid == c_sand
or nodid == c_desand
or nodid == c_mese
or nodid == c_stodiam
or nodid == c_stogold
or nodid == c_stocopp
or nodid == c_stoiron
or nodid == c_stocoal
or nodid == c_sandstone
or nodid == c_gravel
or nodid == c_clay
or nodid == c_obsidian then
or nodid == c_wsredstone
or nodid == c_wsdirt
or nodid == c_wspermafrost
or nodid == c_sand
or nodid == c_desand
or nodid == c_mese
or nodid == c_stodiam
or nodid == c_stogold
or nodid == c_stocopp
or nodid == c_stoiron
or nodid == c_stocoal
or nodid == c_sandstone
or nodid == c_gravel
or nodid == c_clay
or nodid == c_obsidian then
stable[si] = 2
else
stable[si] = 0
@ -453,35 +480,41 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
stable[si] = 0
under[si] = 0
elseif densitybase >= tlava - math.min(0.6 + density * 6, 0.6)
and density < tstone then -- obsidian
and density < tstone then -- obsidian
data[vi] = c_obsidian
stable[si] = 1
under[si] = 0
elseif density >= tstone and nofis -- stone cut by fissures
or (density >= tstone and density < TSTONE * 1.2 and y <= YWAT) -- stone around water
or (density >= tstone and density < TSTONE * 1.2 and densitybase >= triver ) -- stone around river
or (density >= tstone and density < TSTONE * 1.2 and densitymid >= tstream ) then -- stone around stream
or (density >= tstone and density < TSTONE * 1.2 and
y <= YWAT) -- stone around water
or (density >= tstone and density < TSTONE * 1.2 and
densitybase >= triver ) -- stone around river
or (density >= tstone and density < TSTONE * 1.2 and
densitymid >= tstream ) then -- stone around stream
local densitystr = n_strata * 0.25 + (TERCEN - y) / ORESCA
local densityper = densitystr - math.floor(densitystr) -- periodic strata 'density'
-- periodic strata 'density'
local densityper = densitystr - math.floor(densitystr)
if (densityper >= 0.05 and densityper <= 0.09) -- sandstone strata
or (densityper >= 0.25 and densityper <= 0.28)
or (densityper >= 0.45 and densityper <= 0.47)
or (densityper >= 0.74 and densityper <= 0.76)
or (densityper >= 0.77 and densityper <= 0.79)
or (densityper >= 0.84 and densityper <= 0.87)
or (densityper >= 0.95 and densityper <= 0.98) then
or (densityper >= 0.25 and densityper <= 0.28)
or (densityper >= 0.45 and densityper <= 0.47)
or (densityper >= 0.74 and densityper <= 0.76)
or (densityper >= 0.77 and densityper <= 0.79)
or (densityper >= 0.84 and densityper <= 0.87)
or (densityper >= 0.95 and densityper <= 0.98) then
if y > -84 and (y >= -80 or math.random() > 0.5) then
data[vi] = c_sandstone
else
data[vi] = c_wsstone
end
elseif biome == 7 and density < TSTONE * 3 then -- desert stone as surface layer
elseif biome == 7 and density < TSTONE * 3 then
-- desert stone as surface layer
data[vi] = c_wsredstone
elseif math.abs(n_seam) < TSEAM then
-- ore seams
if densityper >= 0.55 and densityper <= 0.55 + ORETHI * 2 then
data[vi] = c_gravel
elseif densityper >= 0.1 and densityper <= 0.1 + ORETHI * 2 then
data[vi] = c_wsluxore
else
data[vi] = c_wsstone
end
@ -490,6 +523,8 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
end
stable[si] = stable[si] + 1
under[si] = 0
-- fine materials
elseif density >= 0 and density < tstone and stable[si] >= 2 then -- fine materials
if y == YWAT - 2 and math.abs(n_temp) < 0.05 then -- clay
data[vi] = c_clay
@ -536,8 +571,8 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
under[si] = 0
end
elseif y >= YWAT - bergdep and y <= YWAT + bergdep / 8 -- icesheet
and n_temp < ICETET and density < tstone
and nofis then
and n_temp < biomeparams.ICETET and density < tstone
and nofis then
data[vi] = c_ice
under[si] = 12
stable[si] = 0
@ -545,31 +580,29 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
data[vi] = c_water
under[si] = 0
stable[si] = 0
elseif densitybase >= triver and density < tstone then -- river water not in fissures
if n_temp < ICETET then
-- river water not in fissures
elseif densitybase >= triver and density < tstone then
if n_temp < biomeparams.ICETET then
data[vi] = c_wsfreshice
else
if y == YWAT + 1 then
data[vi] = c_wsmixwater
else
data[vi] = c_wsfreshwater
end
data[vi] = c_wsfreshwater
end
stable[si] = 0
under[si] = 0
elseif densitymid >= tstream and density < tstone then -- stream water not in fissures
if n_temp < ICETET then
-- stream water not in fissures
elseif densitymid >= tstream and density < tstone then
if n_temp < biomeparams.ICETET then
data[vi] = c_wsfreshice
else
if y == YWAT + 1 then
data[vi] = c_wsmixwater
else
data[vi] = c_wsfreshwater
end
data[vi] = c_wsfreshwater
end
stable[si] = 0
under[si] = 0
elseif density < 0 and y >= YWAT and under[si] ~= 0 then -- air above surface node
-- air above surface node
elseif density < 0 and y >= YWAT and under[si] ~= 0 then
local fnoise = n_fissure -- noise for flower colours
if under[si] == 1 then
data[viu] = c_wsicydirt
@ -611,7 +644,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
data[vi] = c_grass5
end
end
elseif under[si] == 7 and n_temp < HITET + 0.1 then
elseif under[si] == 7 and n_temp < biomeparams.HITET + 0.1 then
if math.random(flora.CACCHA) == 2 then
watershed_cactus(x, y, z, area, data)
elseif math.random(flora.DRYCHA) == 2 then
@ -637,34 +670,20 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
end
elseif under[si] == 10 then -- dunes
if math.random(flora.DUGCHA) == 2 and y > YSAV
and biome >= 4 then
and biome >= 4 then
data[vi] = c_wsgoldengrass
end
elseif under[si] == 11 and n_temp > HITET then -- hot biome riverbank
elseif under[si] == 11 and n_temp > biomeparams.HITET then -- hot biome riverbank
if math.random(flora.PAPCHA) == 2 then
watershed_papyrus(x, y, z, area, data)
end
elseif under[si] == 12
and n_humid > LOHUT + (math.random() - 0.5) * BLEND then -- snowy iceberg
-- snowy iceberg
elseif under[si] == 12 and n_humid > biomeparams.LOHUT +
(math.random() - 0.5) * biomeparams.BLEND then
data[vi] = c_snowblock
end
stable[si] = 0
under[si] = 0
elseif density < 0 and densitymid > TFOG and n_humid > FOGHUT then -- fog
data[vi] = c_wscloud
stable[si] = 0
under[si] = 0
elseif density < 0 and CLOUDS and y == y1 and y >= YCLOMIN then -- clouds
local xrq = 16 * math.floor((x - x0) / 16) -- quantise to 16x16 lattice
local zrq = 16 * math.floor((z - z0) / 16)
local yrq = y1 - y0
local qixyz = zrq * increment_z + yrq * increment_y + xrq + 1 -- quantised 3D index
local qixz = zrq * increment_y + xrq + 1
if nvals_fissure[qixyz] and math.abs(nvals_fissure[qixyz]) < nvals_humid[qixz] * 0.1 then
data[vi] = c_wscloud
end
stable[si] = 0
under[si] = 0
else -- air
stable[si] = 0
under[si] = 0
@ -692,7 +711,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
end
end
end
nixyz = nixyz + 1 -- increment perlinmap and voxelarea indexes along x row
nixyz = nixyz + 1
nixz = nixz + 1
vi = vi + 1
viu = viu + 1
@ -723,10 +742,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
local y0 = minp.y
local z0 = minp.z
print ("[watershed] generate mapchunk minp ("..x0.." "..y0.." "..z0..")")
print ("[watershed] generate mapchunk minp (" .. x0 .. " " .. y0 .. " " .. z0 .. ")")
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
local data = vm:get_data()
watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data)
@ -740,7 +759,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
vm:update_liquids()
local chugent = math.ceil((os.clock() - t1) * 1000)
print ("[watershed] "..chugent.." ms")
print ("[watershed] " .. chugent .. " ms")
end)
default.register_ores()

View File

@ -1,86 +1,37 @@
minetest.register_alias("watershed:appleleaf", "default:leaves")
minetest.register_alias("watershed:appling", "default:sapling")
minetest.register_alias("watershed:acaciatree", "moretrees:acacia_trunk")
minetest.register_alias("watershed:acacialeaf", "moretrees:acacia_leaves")
minetest.register_alias("watershed:acacialing", "moretrees:acacia_sapling")
minetest.register_alias("watershed:pinetree", "default:pine_tree")
minetest.register_alias("watershed:needles", "default:pine_needles")
minetest.register_alias("watershed:pineling", "default:pine_sapling")
minetest.register_alias("watershed:jungleleaf", "default:jungleleaves")
minetest.register_alias("watershed:jungling", "default:junglesapling")
minetest.register_alias("watershed:dirt", "default:dirt")
minetest.register_alias("watershed:icydirt", "default:dirt_with_grass")
minetest.register_alias("watershed:grass", "default:dirt_with_grass")
minetest.register_alias("watershed:redstone", "default:desert_stone")
minetest.register_alias("watershed:redcobble", "default:desert_cobble")
minetest.register_alias("watershed:stone", "default:stone")
minetest.register_alias("watershed:cactus", "default:cactus")
minetest.register_alias("watershed:goldengrass", "default:dry_shrub")
minetest.register_alias("watershed:drygrass", "default:dirt_with_dry_grass")
minetest.register_alias("watershed:permafrost", "default:dirt")
minetest.register_alias("watershed:freshice", "default:ice")
minetest.register_alias("watershed:cloud", "default:cloud")
minetest.override_item("default:cloud", {
description = "Cloud",
drawtype = "glasslike",
tiles = {"default_cloud.png"},
paramtype = "light",
is_ground_content = false,
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
post_effect_color = {a=23, r=241, g=248, b=255},
groups = {not_in_creative_inventory=1},
})
minetest.register_alias("watershed:luxore", "default:stone")
minetest.register_alias("watershed:light", "lantern:lamp")
minetest.register_alias("watershed:acaciawood", "moretrees:acacia_wood")
minetest.register_alias("watershed:pinewood", "default:pinewood")
minetest.register_alias("watershed:freshwater", "default:river_water_source")
minetest.register_alias("watershed:freshwaterflow", "default:river_water_flowing")
minetest.register_alias("watershed:lava", "default:lava_source")
minetest.register_alias("watershed:lavaflow", "default:lava_flowing")
minetest.register_alias("watershed:mixwater", "default:river_water_source")
minetest.register_alias("watershed:mixwaterflow", "default:river_water_flowing")
-- Items
minetest.register_alias("watershed:luxcrystal", "default:cobble")
-- Crafting

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B