2 -- Aliases for map generator outputs
6 minetest.register_alias("mapgen_stone", "default:stone")
7 minetest.register_alias("mapgen_dirt", "default:dirt")
8 minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
9 minetest.register_alias("mapgen_sand", "default:sand")
10 minetest.register_alias("mapgen_water_source", "default:water_source")
11 minetest.register_alias("mapgen_river_water_source", "default:river_water_source")
12 minetest.register_alias("mapgen_lava_source", "default:lava_source")
13 minetest.register_alias("mapgen_gravel", "default:gravel")
14 minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
15 minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
16 minetest.register_alias("mapgen_dirt_with_snow", "default:dirt_with_snow")
17 minetest.register_alias("mapgen_snowblock", "default:snowblock")
18 minetest.register_alias("mapgen_snow", "default:snow")
19 minetest.register_alias("mapgen_ice", "default:ice")
21 minetest.register_alias("mapgen_tree", "default:tree")
22 minetest.register_alias("mapgen_leaves", "default:leaves")
23 minetest.register_alias("mapgen_apple", "default:apple")
24 minetest.register_alias("mapgen_jungletree", "default:jungletree")
25 minetest.register_alias("mapgen_jungleleaves", "default:jungleleaves")
26 minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
27 minetest.register_alias("mapgen_pinetree", "default:pinetree")
28 minetest.register_alias("mapgen_pine_needles", "default:pine_needles")
30 minetest.register_alias("mapgen_cobble", "default:cobble")
31 minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble")
32 minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
33 minetest.register_alias("mapgen_sandstonebrick", "default:sandstonebrick")
34 minetest.register_alias("mapgen_stair_sandstonebrick", "stairs:stair_sandstonebrick")
42 -- Blob ore first to avoid other ores inside blobs
44 function default.register_ores()
45 minetest.register_ore({
48 wherein = {"default:sand"},
49 clust_scarcity = 24*24*24,
57 spread={x=5, y=5, z=5},
64 minetest.register_ore({
67 wherein = {"default:stone"},
68 clust_scarcity = 24*24*24,
76 spread={x=5, y=5, z=5},
83 minetest.register_ore({
86 wherein = {"default:stone"},
87 clust_scarcity = 24*24*24,
95 spread={x=5, y=5, z=5},
102 minetest.register_ore({
104 ore = "default:gravel",
105 wherein = {"default:stone"},
106 clust_scarcity = 24*24*24,
110 noise_threshhold = 0,
114 spread={x=5, y=5, z=5},
121 minetest.register_ore({
122 ore_type = "scatter",
123 ore = "default:stone_with_coal",
124 wherein = "default:stone",
125 clust_scarcity = 8*8*8,
132 minetest.register_ore({
133 ore_type = "scatter",
134 ore = "default:stone_with_coal",
135 wherein = "default:stone",
136 clust_scarcity = 24*24*24,
143 minetest.register_ore({
144 ore_type = "scatter",
145 ore = "default:stone_with_iron",
146 wherein = "default:stone",
147 clust_scarcity = 12*12*12,
154 minetest.register_ore({
155 ore_type = "scatter",
156 ore = "default:stone_with_iron",
157 wherein = "default:stone",
158 clust_scarcity = 9*9*9,
165 minetest.register_ore({
166 ore_type = "scatter",
167 ore = "default:stone_with_iron",
168 wherein = "default:stone",
169 clust_scarcity = 7*7*7,
176 minetest.register_ore({
177 ore_type = "scatter",
178 ore = "default:stone_with_iron",
179 wherein = "default:stone",
180 clust_scarcity = 24*24*24,
187 minetest.register_ore({
188 ore_type = "scatter",
189 ore = "default:stone_with_mese",
190 wherein = "default:stone",
191 clust_scarcity = 18*18*18,
198 minetest.register_ore({
199 ore_type = "scatter",
200 ore = "default:stone_with_mese",
201 wherein = "default:stone",
202 clust_scarcity = 14*14*14,
209 minetest.register_ore({
210 ore_type = "scatter",
211 ore = "default:mese",
212 wherein = "default:stone",
213 clust_scarcity = 36*36*36,
220 minetest.register_ore({
221 ore_type = "scatter",
222 ore = "default:stone_with_gold",
223 wherein = "default:stone",
224 clust_scarcity = 15*15*15,
231 minetest.register_ore({
232 ore_type = "scatter",
233 ore = "default:stone_with_gold",
234 wherein = "default:stone",
235 clust_scarcity = 13*13*13,
242 minetest.register_ore({
243 ore_type = "scatter",
244 ore = "default:stone_with_diamond",
245 wherein = "default:stone",
246 clust_scarcity = 17*17*17,
253 minetest.register_ore({
254 ore_type = "scatter",
255 ore = "default:stone_with_diamond",
256 wherein = "default:stone",
257 clust_scarcity = 15*15*15,
264 minetest.register_ore({
265 ore_type = "scatter",
266 ore = "default:stone_with_copper",
267 wherein = "default:stone",
268 clust_scarcity = 12*12*12,
275 minetest.register_ore({
276 ore_type = "scatter",
277 ore = "default:stone_with_copper",
278 wherein = "default:stone",
279 clust_scarcity = 9*9*9,
293 function default.register_biomes()
294 minetest.clear_registered_biomes()
296 minetest.register_biome({
297 name = "default:grassland",
299 node_top = "default:dirt_with_grass",
301 node_filler = "default:dirt",
304 --node_water_top = "",
305 --depth_water_top = ,
313 minetest.register_biome({
314 name = "default:grassland_ocean",
316 node_top = "default:sand",
318 node_filler = "default:sand",
321 --node_water_top = "",
322 --depth_water_top = ,
333 -- Register mgv6 decorations
337 function default.register_mgv6_decorations()
341 minetest.register_decoration({
342 deco_type = "simple",
343 place_on = {"default:dirt_with_grass"},
348 spread = {x=100, y=100, z=100},
355 decoration = "default:papyrus",
358 spawn_by = "default:water_source",
364 minetest.register_decoration({
365 deco_type = "simple",
366 place_on = {"default:desert_sand"},
371 spread = {x=100, y=100, z=100},
378 decoration = "default:cactus",
386 minetest.register_decoration({
387 deco_type = "simple",
388 place_on = {"default:dirt_with_grass"},
393 spread = {x=100, y=100, z=100},
400 decoration = "default:grass_"..length,
406 minetest.register_decoration({
407 deco_type = "simple",
408 place_on = {"default:desert_sand", "default:dirt_with_snow"},
413 spread = {x=100, y=100, z=100},
420 decoration = "default:dry_shrub",
426 -- Register decorations
430 function default.register_decorations()
434 minetest.register_decoration({
435 deco_type = "simple",
436 place_on = {"default:dirt_with_grass"},
441 spread = {x=200, y=200, z=200},
446 biomes = {"default:grassland"},
449 decoration = "flowers:rose",
452 minetest.register_decoration({
453 deco_type = "simple",
454 place_on = {"default:dirt_with_grass"},
459 spread = {x=200, y=200, z=200},
464 biomes = {"default:grassland"},
467 decoration = "flowers:tulip",
470 minetest.register_decoration({
471 deco_type = "simple",
472 place_on = {"default:dirt_with_grass"},
477 spread = {x=200, y=200, z=200},
482 biomes = {"default:grassland"},
485 decoration = "flowers:dandelion_yellow",
488 minetest.register_decoration({
489 deco_type = "simple",
490 place_on = {"default:dirt_with_grass"},
495 spread = {x=200, y=200, z=200},
500 biomes = {"default:grassland"},
503 decoration = "flowers:geranium",
506 minetest.register_decoration({
507 deco_type = "simple",
508 place_on = {"default:dirt_with_grass"},
513 spread = {x=200, y=200, z=200},
518 biomes = {"default:grassland"},
521 decoration = "flowers:viola",
524 minetest.register_decoration({
525 deco_type = "simple",
526 place_on = {"default:dirt_with_grass"},
531 spread = {x=200, y=200, z=200},
536 biomes = {"default:grassland"},
539 decoration = "flowers:dandelion_white",
544 minetest.register_decoration({
545 deco_type = "simple",
546 place_on = {"default:dirt_with_grass"},
551 spread = {x=200, y=200, z=200},
556 biomes = {"default:grassland"},
559 decoration = "default:grass_1",
562 minetest.register_decoration({
563 deco_type = "simple",
564 place_on = {"default:dirt_with_grass"},
569 spread = {x=200, y=200, z=200},
574 biomes = {"default:grassland"},
577 decoration = "default:grass_2",
580 minetest.register_decoration({
581 deco_type = "simple",
582 place_on = {"default:dirt_with_grass"},
587 spread = {x=200, y=200, z=200},
592 biomes = {"default:grassland"},
595 decoration = "default:grass_3",
598 minetest.register_decoration({
599 deco_type = "simple",
600 place_on = {"default:dirt_with_grass"},
605 spread = {x=200, y=200, z=200},
610 biomes = {"default:grassland"},
613 decoration = "default:grass_4",
616 minetest.register_decoration({
617 deco_type = "simple",
618 place_on = {"default:dirt_with_grass"},
623 spread = {x=200, y=200, z=200},
628 biomes = {"default:grassland"},
631 decoration = "default:grass_5",
637 -- Detect mapgen to select functions
641 -- Mods using singlenode mapgen can call these functions to enable
642 -- the use of minetest.generate_ores or minetest.generate_decorations
644 local mg_params = minetest.get_mapgen_params()
645 if mg_params.mgname == "v6" then
646 default.register_ores()
647 default.register_mgv6_decorations()
648 elseif mg_params.mgname ~= "singlenode" then
649 default.register_ores()
650 default.register_biomes()
651 default.register_decorations()
656 -- Generate nyan cats in all mapgens
660 -- facedir: 0/1/2/3 (head node facedir value)
661 -- length: length of rainbow tail
662 function default.make_nyancat(pos, facedir, length)
663 local tailvec = {x=0, y=0, z=0}
666 elseif facedir == 1 then
668 elseif facedir == 2 then
670 elseif facedir == 3 then
673 --print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
677 local p = {x=pos.x, y=pos.y, z=pos.z}
678 minetest.set_node(p, {name="default:nyancat", param2=facedir})
680 p.x = p.x + tailvec.x
681 p.z = p.z + tailvec.z
682 minetest.set_node(p, {name="default:nyancat_rainbow", param2=facedir})
687 function default.generate_nyancats(minp, maxp, seed)
688 local height_min = -31000
689 local height_max = -32
690 if maxp.y < height_min or minp.y > height_max then
693 local y_min = math.max(minp.y, height_min)
694 local y_max = math.min(maxp.y, height_max)
695 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
696 local pr = PseudoRandom(seed + 9324342)
697 local max_num_nyancats = math.floor(volume / (16*16*16))
698 for i=1,max_num_nyancats do
699 if pr:next(0, 1000) == 0 then
700 local x0 = pr:next(minp.x, maxp.x)
701 local y0 = pr:next(minp.y, maxp.y)
702 local z0 = pr:next(minp.z, maxp.z)
703 local p0 = {x=x0, y=y0, z=z0}
704 default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
710 minetest.register_on_generated(default.generate_nyancats)
714 -- Deprecated ore generation code
718 function default.generate_ore(name, wherein, minp, maxp, seed,
719 chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
720 minetest.log('action', "WARNING: default.generate_ore is deprecated")
722 if maxp.y < height_min or minp.y > height_max then
725 local y_min = math.max(minp.y, height_min)
726 local y_max = math.min(maxp.y, height_max)
727 if chunk_size >= y_max - y_min + 1 then
730 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
731 local pr = PseudoRandom(seed)
732 local num_chunks = math.floor(chunks_per_volume * volume)
733 local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
734 --print("generate_ore num_chunks: "..dump(num_chunks))
735 for i=1,num_chunks do
736 local y0 = pr:next(y_min, y_max-chunk_size+1)
737 if y0 >= height_min and y0 <= height_max then
738 local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
739 local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
740 local p0 = {x=x0, y=y0, z=z0}
741 for x1=0,chunk_size-1 do
742 for y1=0,chunk_size-1 do
743 for z1=0,chunk_size-1 do
744 if pr:next(1,inverse_chance) == 1 then
748 local p2 = {x=x2, y=y2, z=z2}
749 if minetest.get_node(p2).name == wherein then
750 minetest.set_node(p2, {name=name})
758 --print("generate_ore done")