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