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
53 minetest.register_decoration({
55 deco_type = "schematic",
56 place_on = {"nether:netherrack"},
61 spread = {x = 250, y = 250, z = 250},
69 schematic = nethertreeSchematic,
70 flags = "place_center_x, place_center_z",
78 -- Set singlenode mapgen (air nodes only).
79 -- Disable the engine lighting calculation since that will be done for a
80 -- mapchunk of air nodes and will be incorrect after we place nodes.
82 --minetest.set_mapgen_params({mgname = "singlenode", flags = "nolight"})
85 -- Get the content IDs for the nodes used.
87 local c_sandstone = minetest.get_content_id("nether:netherrack")
88 local c_bedrock = minetest.get_content_id("nether:bedrock")
89 local c_air = minetest.get_content_id("air")
90 local c_lava = minetest.get_content_id("nether:lava")
93 -- Initialize noise object to nil. It will be created once only during the
94 -- generation of the first mapchunk, to minimise memory use.
96 local nobj_terrain = nil
99 -- Localise noise buffer table outside the loop, to be re-used for all
100 -- mapchunks, therefore minimising memory use.
102 local nvals_terrain = {}
105 -- Localise data buffer table outside the loop, to be re-used for all
106 -- mapchunks, therefore minimising memory use.
111 -- On generated function.
113 -- 'minp' and 'maxp' are the minimum and maximum positions of the mapchunk that
114 -- define the 3D volume.
126 local density_gradient
127 minetest.register_on_generated(function(minp, maxp, seed)
128 --nether starts at -10033 y
129 if maxp.y > -10033 or maxp.y < -20033 then
132 -- Start time of mapchunk generation.
133 --local t0 = os.clock()
137 -- Side length of mapchunk.
138 sidelen = maxp.x - minp.x + 1
139 -- Required dimensions of the 3D noise perlin map.
140 permapdims3d = {x = sidelen, y = sidelen, z = sidelen}
141 -- Create the perlin map noise object once only, during the generation of
142 -- the first mapchunk when 'nobj_terrain' is 'nil'.
143 nobj_terrain = minetest.get_perlin_map(np_terrain, permapdims3d) --nobj_terrain or
144 -- Create a flat array of noise values from the perlin map, with the
145 -- minimum point being 'minp'.
146 -- Set the buffer parameter to use and reuse 'nvals_terrain' for this.
147 nobj_terrain:get3dMap_flat(minp, nvals_terrain)
151 -- Load the voxelmanip with the result of engine mapgen. Since 'singlenode'
152 -- mapgen is used this will be a mapchunk of air nodes.
153 vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
154 -- 'area' is used later to get the voxelmanip indexes for positions.
155 area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
156 -- Get the content ID data from the voxelmanip in the form of a flat array.
157 -- Set the buffer parameter to use and reuse 'data' for this.
162 -- Noise index for the flat array of noise values.
164 -- Process the content IDs in 'data'.
165 -- The most useful order is a ZYX loop because:
166 -- 1. This matches the order of the 3D noise flat array.
167 -- 2. This allows a simple +1 incrementing of the voxelmanip index along x
172 for z = minp.z, maxp.z do
173 for y = minp.y, maxp.y do
174 -- Voxelmanip index for the flat array of content IDs.
175 -- Initialise to first node in this x row.
176 vi = area:index(minp.x, y, z)
177 for x = minp.x, maxp.x do
178 -- Consider a 'solidness' value for each node,
179 -- let's call it 'density', where
180 -- density = density noise + density gradient.
181 density_noise = nvals_terrain[ni]
182 -- Density gradient is a value that is 0 at water level (y = 1)
183 -- and falls in value with increasing y. This is necessary to
184 -- create a 'world surface' with only solid nodes deep underground
185 -- and only air high above water level.
186 -- Here '128' determines the typical maximum height of the terrain.
187 density_gradient = (1 - y) / 128
189 --print(density_noise, density_gradient)
190 -- Place solid nodes when 'density' > 0.
191 --if density_noise + density_gradient > 0 then
192 if density_noise > 0 and y ~= -10033 and y ~= -20112 then
193 data[vi] = c_sandstone
194 -- create bedrock layer
195 elseif y == -10033 or y == -20112 then
198 -- data[vi] = c_water
199 --elseif y > -15000 then
201 elseif y <= -15000 then
205 -- Increment noise index.
207 -- Increment voxelmanip index along x row.
208 -- The voxelmanip index increases by 1 when
209 -- moving by 1 node in the +x direction.
215 -- After processing, write content ID data back to the voxelmanip.
217 -- Calculate lighting for what has been created.
219 minetest.generate_ores(vm)
221 minetest.generate_decorations(vm)
223 --minetest.generate_decorations(vm)
224 vm:set_lighting({day=7,night=7}, minp, maxp)
226 -- Write what has been created to the world.
228 -- Liquid nodes were placed so set them flowing.
229 --vm:update_liquids()
231 -- Print generation time of this mapchunk.
232 --local chugent = math.ceil((os.clock() - t0) * 1000)
233 --print ("[lvm_example] Mapchunk generation time " .. chugent .. " ms")