1 minetest.register_biome({
9 node_cave_liquid = "air",
13 node_dungeon_alt = "air",
14 node_dungeon_stair = "air",
19 humidity_point = -100,
23 minetest.register_decoration({
24 name = "Nether Eternal Fire",
26 place_on = {"nether:netherrack"},
32 decoration = "fire:fire",
37 --this is from https://github.com/paramat/lvm_example/blob/master/init.lua
40 -- Set the 3D noise parameters for the terrain.
41 local perlin= minetest.get_mapgen_params()
45 spread = {x = 384, y = 192, z = 384},
46 seed = 5900033, --perlin.seed
54 -- Set singlenode mapgen (air nodes only).
55 -- Disable the engine lighting calculation since that will be done for a
56 -- mapchunk of air nodes and will be incorrect after we place nodes.
58 --minetest.set_mapgen_params({mgname = "singlenode", flags = "nolight"})
61 -- Get the content IDs for the nodes used.
63 local c_sandstone = minetest.get_content_id("nether:netherrack")
64 local c_bedrock = minetest.get_content_id("nether:bedrock")
65 local c_air = minetest.get_content_id("air")
66 local c_lava = minetest.get_content_id("nether:lava")
69 -- Initialize noise object to nil. It will be created once only during the
70 -- generation of the first mapchunk, to minimise memory use.
72 local nobj_terrain = nil
75 -- Localise noise buffer table outside the loop, to be re-used for all
76 -- mapchunks, therefore minimising memory use.
78 local nvals_terrain = {}
81 -- Localise data buffer table outside the loop, to be re-used for all
82 -- mapchunks, therefore minimising memory use.
87 -- On generated function.
89 -- 'minp' and 'maxp' are the minimum and maximum positions of the mapchunk that
90 -- define the 3D volume.
102 local density_gradient
103 minetest.register_on_generated(function(minp, maxp, seed)
104 --nether starts at -10033 y
105 if maxp.y > -10033 or maxp.y < -20033 then
108 -- Start time of mapchunk generation.
109 --local t0 = os.clock()
113 -- Side length of mapchunk.
114 sidelen = maxp.x - minp.x + 1
115 -- Required dimensions of the 3D noise perlin map.
116 permapdims3d = {x = sidelen, y = sidelen, z = sidelen}
117 -- Create the perlin map noise object once only, during the generation of
118 -- the first mapchunk when 'nobj_terrain' is 'nil'.
119 nobj_terrain = minetest.get_perlin_map(np_terrain, permapdims3d) --nobj_terrain or
120 -- Create a flat array of noise values from the perlin map, with the
121 -- minimum point being 'minp'.
122 -- Set the buffer parameter to use and reuse 'nvals_terrain' for this.
123 nobj_terrain:get3dMap_flat(minp, nvals_terrain)
127 -- Load the voxelmanip with the result of engine mapgen. Since 'singlenode'
128 -- mapgen is used this will be a mapchunk of air nodes.
129 vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
130 -- 'area' is used later to get the voxelmanip indexes for positions.
131 area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
132 -- Get the content ID data from the voxelmanip in the form of a flat array.
133 -- Set the buffer parameter to use and reuse 'data' for this.
138 -- Noise index for the flat array of noise values.
140 -- Process the content IDs in 'data'.
141 -- The most useful order is a ZYX loop because:
142 -- 1. This matches the order of the 3D noise flat array.
143 -- 2. This allows a simple +1 incrementing of the voxelmanip index along x
148 for z = minp.z, maxp.z do
149 for y = minp.y, maxp.y do
150 -- Voxelmanip index for the flat array of content IDs.
151 -- Initialise to first node in this x row.
152 vi = area:index(minp.x, y, z)
153 for x = minp.x, maxp.x do
154 -- Consider a 'solidness' value for each node,
155 -- let's call it 'density', where
156 -- density = density noise + density gradient.
157 density_noise = nvals_terrain[ni]
158 -- Density gradient is a value that is 0 at water level (y = 1)
159 -- and falls in value with increasing y. This is necessary to
160 -- create a 'world surface' with only solid nodes deep underground
161 -- and only air high above water level.
162 -- Here '128' determines the typical maximum height of the terrain.
163 density_gradient = (1 - y) / 128
165 --print(density_noise, density_gradient)
166 -- Place solid nodes when 'density' > 0.
167 --if density_noise + density_gradient > 0 then
168 if density_noise > 0 and y ~= -10033 and y ~= -20112 then
169 data[vi] = c_sandstone
170 -- create bedrock layer
171 elseif y == -10033 or y == -20112 then
174 -- data[vi] = c_water
175 elseif y > -15000 then
181 -- Increment noise index.
183 -- Increment voxelmanip index along x row.
184 -- The voxelmanip index increases by 1 when
185 -- moving by 1 node in the +x direction.
191 -- After processing, write content ID data back to the voxelmanip.
193 -- Calculate lighting for what has been created.
196 minetest.generate_ores(vm)
197 --minetest.generate_decorations(vm)
198 vm:set_lighting({day=7,night=7}, minp, maxp)
200 -- Write what has been created to the world.
202 -- Liquid nodes were placed so set them flowing.
203 --vm:update_liquids()
205 -- Print generation time of this mapchunk.
206 --local chugent = math.ceil((os.clock() - t0) * 1000)
207 --print ("[lvm_example] Mapchunk generation time " .. chugent .. " ms")