2 -- Aliases for map generator outputs
5 minetest.register_alias("mapgen_stone", "default:stone")
6 minetest.register_alias("mapgen_dirt", "default:dirt")
7 minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
8 minetest.register_alias("mapgen_sand", "default:sand")
9 minetest.register_alias("mapgen_water_source", "default:water_source")
10 minetest.register_alias("mapgen_river_water_source", "default:river_water_source")
11 minetest.register_alias("mapgen_lava_source", "default:lava_source")
12 minetest.register_alias("mapgen_gravel", "default:gravel")
13 minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
14 minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
15 minetest.register_alias("mapgen_dirt_with_snow", "default:dirt_with_snow")
16 minetest.register_alias("mapgen_snowblock", "default:snowblock")
17 minetest.register_alias("mapgen_snow", "default:snow")
18 minetest.register_alias("mapgen_ice", "default:ice")
19 minetest.register_alias("mapgen_sandstone", "default:sandstone")
23 minetest.register_alias("mapgen_tree", "default:tree")
24 minetest.register_alias("mapgen_leaves", "default:leaves")
25 minetest.register_alias("mapgen_apple", "default:apple")
26 minetest.register_alias("mapgen_jungletree", "default:jungletree")
27 minetest.register_alias("mapgen_jungleleaves", "default:jungleleaves")
28 minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
29 minetest.register_alias("mapgen_pine_tree", "default:pine_tree")
30 minetest.register_alias("mapgen_pine_needles", "default:pine_needles")
34 minetest.register_alias("mapgen_cobble", "default:cobble")
35 minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble")
36 minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
37 minetest.register_alias("mapgen_sandstonebrick", "default:sandstonebrick")
38 minetest.register_alias("mapgen_stair_sandstonebrick", "stairs:stair_sandstonebrick")
45 -- All mapgens except singlenode
46 -- Blob ore first to avoid other ores inside blobs
48 function default.register_ores()
52 minetest.register_ore({
55 wherein = {"default:sand"},
56 clust_scarcity = 16 * 16 * 16,
60 noise_threshold = 0.0,
64 spread = {x = 5, y = 5, z = 5},
73 minetest.register_ore({
76 wherein = {"default:stone"},
77 clust_scarcity = 16 * 16 * 16,
81 noise_threshold = 0.0,
85 spread = {x = 5, y = 5, z = 5},
94 minetest.register_ore({
97 wherein = {"default:stone"},
98 clust_scarcity = 16 * 16 * 16,
102 noise_threshold = 0.0,
106 spread = {x = 5, y = 5, z = 5},
115 minetest.register_ore({
117 ore = "default:gravel",
118 wherein = {"default:stone"},
119 clust_scarcity = 16 * 16 * 16,
123 noise_threshold = 0.0,
127 spread = {x = 5, y = 5, z = 5},
136 minetest.register_ore({
137 ore_type = "scatter",
138 ore = "default:stone_with_coal",
139 wherein = "default:stone",
140 clust_scarcity = 8 * 8 * 8,
147 minetest.register_ore({
148 ore_type = "scatter",
149 ore = "default:stone_with_coal",
150 wherein = "default:stone",
151 clust_scarcity = 24 * 24 * 24,
160 minetest.register_ore({
161 ore_type = "scatter",
162 ore = "default:stone_with_iron",
163 wherein = "default:stone",
164 clust_scarcity = 12 * 12 * 12,
171 minetest.register_ore({
172 ore_type = "scatter",
173 ore = "default:stone_with_iron",
174 wherein = "default:stone",
175 clust_scarcity = 9 * 9 * 9,
182 minetest.register_ore({
183 ore_type = "scatter",
184 ore = "default:stone_with_iron",
185 wherein = "default:stone",
186 clust_scarcity = 7 * 7 * 7,
193 minetest.register_ore({
194 ore_type = "scatter",
195 ore = "default:stone_with_iron",
196 wherein = "default:stone",
197 clust_scarcity = 24 * 24 * 24,
206 minetest.register_ore({
207 ore_type = "scatter",
208 ore = "default:stone_with_mese",
209 wherein = "default:stone",
210 clust_scarcity = 18 * 18 * 18,
217 minetest.register_ore({
218 ore_type = "scatter",
219 ore = "default:stone_with_mese",
220 wherein = "default:stone",
221 clust_scarcity = 14 * 14 * 14,
228 minetest.register_ore({
229 ore_type = "scatter",
230 ore = "default:mese",
231 wherein = "default:stone",
232 clust_scarcity = 36 * 36 * 36,
241 minetest.register_ore({
242 ore_type = "scatter",
243 ore = "default:stone_with_gold",
244 wherein = "default:stone",
245 clust_scarcity = 15 * 15 * 15,
252 minetest.register_ore({
253 ore_type = "scatter",
254 ore = "default:stone_with_gold",
255 wherein = "default:stone",
256 clust_scarcity = 13 * 13 * 13,
265 minetest.register_ore({
266 ore_type = "scatter",
267 ore = "default:stone_with_diamond",
268 wherein = "default:stone",
269 clust_scarcity = 17 * 17 * 17,
276 minetest.register_ore({
277 ore_type = "scatter",
278 ore = "default:stone_with_diamond",
279 wherein = "default:stone",
280 clust_scarcity = 15 * 15 * 15,
289 minetest.register_ore({
290 ore_type = "scatter",
291 ore = "default:stone_with_copper",
292 wherein = "default:stone",
293 clust_scarcity = 12 * 12 * 12,
300 minetest.register_ore({
301 ore_type = "scatter",
302 ore = "default:stone_with_copper",
303 wherein = "default:stone",
304 clust_scarcity = 9 * 9 * 9,
317 -- All mapgens except mgv6 and singlenode
319 function default.register_biomes()
320 minetest.clear_registered_biomes()
324 minetest.register_biome({
326 node_dust = "default:snowblock",
327 node_top = "default:snowblock",
329 node_filler = "default:snowblock",
331 node_stone = "default:ice",
332 node_water_top = "default:ice",
333 depth_water_top = 10,
335 node_river_water = "default:ice",
342 minetest.register_biome({
343 name = "glacier_ocean",
344 node_dust = "default:snowblock",
345 node_top = "default:sand",
347 node_filler = "default:sand",
350 --node_water_top = "",
351 --depth_water_top = ,
353 --node_river_water = "",
362 minetest.register_biome({
365 node_top = "default:dirt_with_snow",
367 node_filler = "default:dirt",
370 --node_water_top = "",
371 --depth_water_top = ,
373 --node_river_water = "",
380 minetest.register_biome({
381 name = "tundra_ocean",
383 node_top = "default:sand",
385 node_filler = "default:sand",
388 --node_water_top = "",
389 --depth_water_top = ,
391 --node_river_water = "",
399 minetest.register_biome({
401 node_dust = "default:snow",
402 node_top = "default:dirt_with_snow",
404 node_filler = "default:dirt",
407 --node_water_top = "",
408 --depth_water_top = ,
410 --node_river_water = "",
417 minetest.register_biome({
418 name = "taiga_ocean",
420 node_top = "default:sand",
422 node_filler = "default:sand",
425 --node_water_top = "",
426 --depth_water_top = ,
428 --node_river_water = "",
437 minetest.register_biome({
438 name = "stone_grassland",
440 node_top = "default:dirt_with_grass",
442 node_filler = "default:dirt",
445 --node_water_top = "",
446 --depth_water_top = ,
448 --node_river_water = "",
455 minetest.register_biome({
456 name = "stone_grassland_dunes",
458 node_top = "default:sand",
460 node_filler = "default:sand",
463 --node_water_top = "",
464 --depth_water_top = ,
466 --node_river_water = "",
473 minetest.register_biome({
474 name = "stone_grassland_ocean",
476 node_top = "default:sand",
478 node_filler = "default:sand",
481 --node_water_top = "",
482 --depth_water_top = ,
484 --node_river_water = "",
492 minetest.register_biome({
493 name = "coniferous_forest",
495 node_top = "default:dirt_with_grass",
497 node_filler = "default:dirt",
500 --node_water_top = "",
501 --depth_water_top = ,
503 --node_river_water = "",
510 minetest.register_biome({
511 name = "coniferous_forest_dunes",
513 node_top = "default:sand",
515 node_filler = "default:sand",
518 --node_water_top = "",
519 --depth_water_top = ,
521 --node_river_water = "",
528 minetest.register_biome({
529 name = "coniferous_forest_ocean",
531 node_top = "default:sand",
533 node_filler = "default:sand",
536 --node_water_top = "",
537 --depth_water_top = ,
539 --node_river_water = "",
547 minetest.register_biome({
548 name = "sandstone_grassland",
550 node_top = "default:dirt_with_grass",
552 node_filler = "default:dirt",
554 node_stone = "default:sandstone",
555 --node_water_top = "",
556 --depth_water_top = ,
558 --node_river_water = "",
565 minetest.register_biome({
566 name = "sandstone_grassland_dunes",
568 node_top = "default:sand",
570 node_filler = "default:sand",
572 node_stone = "default:sandstone",
573 --node_water_top = "",
574 --depth_water_top = ,
576 --node_river_water = "",
583 minetest.register_biome({
584 name = "sandstone_grassland_ocean",
586 node_top = "default:sand",
588 node_filler = "default:sand",
590 node_stone = "default:sandstone",
591 --node_water_top = "",
592 --depth_water_top = ,
594 --node_river_water = "",
602 minetest.register_biome({
603 name = "deciduous_forest",
605 node_top = "default:dirt_with_grass",
607 node_filler = "default:dirt",
610 --node_water_top = "",
611 --depth_water_top = ,
613 --node_river_water = "",
620 minetest.register_biome({
621 name = "deciduous_forest_swamp",
623 node_top = "default:dirt",
625 node_filler = "default:dirt",
628 --node_water_top = "",
629 --depth_water_top = ,
631 --node_river_water = "",
638 minetest.register_biome({
639 name = "deciduous_forest_ocean",
641 node_top = "default:sand",
643 node_filler = "default:sand",
646 --node_water_top = "",
647 --depth_water_top = ,
649 --node_river_water = "",
658 minetest.register_biome({
661 node_top = "default:desert_sand",
663 node_filler = "default:desert_sand",
665 node_stone = "default:desert_stone",
666 --node_water_top = "",
667 --depth_water_top = ,
669 --node_river_water = "",
676 minetest.register_biome({
677 name = "desert_ocean",
679 node_top = "default:sand",
681 node_filler = "default:sand",
683 node_stone = "default:desert_stone",
684 --node_water_top = "",
685 --depth_water_top = ,
687 --node_river_water = "",
695 minetest.register_biome({
698 node_top = "default:dirt_with_dry_grass",
700 node_filler = "default:dirt",
703 --node_water_top = "",
704 --depth_water_top = ,
706 --node_river_water = "",
713 minetest.register_biome({
714 name = "savanna_swamp",
716 node_top = "default:dirt",
718 node_filler = "default:dirt",
721 --node_water_top = "",
722 --depth_water_top = ,
724 --node_river_water = "",
731 minetest.register_biome({
732 name = "savanna_ocean",
734 node_top = "default:sand",
736 node_filler = "default:sand",
739 --node_water_top = "",
740 --depth_water_top = ,
742 --node_river_water = "",
750 minetest.register_biome({
753 node_top = "default:dirt_with_grass",
755 node_filler = "default:dirt",
758 --node_water_top = "",
759 --depth_water_top = ,
761 --node_river_water = "",
768 minetest.register_biome({
769 name = "rainforest_swamp",
771 node_top = "default:dirt",
773 node_filler = "default:dirt",
776 --node_water_top = "",
777 --depth_water_top = ,
779 --node_river_water = "",
786 minetest.register_biome({
787 name = "rainforest_ocean",
789 node_top = "default:sand",
791 node_filler = "default:sand",
794 --node_water_top = "",
795 --depth_water_top = ,
797 --node_river_water = "",
806 minetest.register_biome({
807 name = "underground",
814 --node_water_top = "",
815 --depth_water_top = ,
817 --node_river_water = "",
827 -- Register decorations
832 function default.register_mgv6_decorations()
833 minetest.clear_registered_decorations()
837 minetest.register_decoration({
838 deco_type = "simple",
839 place_on = {"default:dirt_with_grass"},
844 spread = {x = 100, y = 100, z = 100},
851 decoration = "default:papyrus",
854 spawn_by = "default:water_source",
860 minetest.register_decoration({
861 deco_type = "simple",
862 place_on = {"default:desert_sand"},
867 spread = {x = 100, y = 100, z = 100},
874 decoration = "default:cactus",
882 minetest.register_decoration({
883 deco_type = "simple",
884 place_on = {"default:dirt_with_grass"},
889 spread = {x = 100, y = 100, z = 100},
896 decoration = "default:grass_"..length,
902 minetest.register_decoration({
903 deco_type = "simple",
904 place_on = {"default:desert_sand", "default:dirt_with_snow"},
909 spread = {x = 100, y = 100, z = 100},
916 decoration = "default:dry_shrub",
920 -- All mapgens except mgv6 and singlenode
922 local function register_grass_decoration(offset, scale, length)
923 minetest.register_decoration({
924 deco_type = "simple",
925 place_on = {"default:dirt_with_grass", "default:sand"},
930 spread = {x = 200, y = 200, z = 200},
935 biomes = {"stone_grassland", "sandstone_grassland",
936 "deciduous_forest", "coniferous_forest",
937 "stone_grassland_dunes", "sandstone_grassland_dunes",
938 "coniferous_forest_dunes"},
941 decoration = "default:grass_"..length,
945 local function register_dry_grass_decoration(offset, scale, length)
946 minetest.register_decoration({
947 deco_type = "simple",
948 place_on = {"default:dirt_with_dry_grass"},
953 spread = {x = 200, y = 200, z = 200},
958 biomes = {"savanna"},
961 decoration = "default:dry_grass_"..length,
965 function default.register_decorations()
966 minetest.clear_registered_decorations()
970 minetest.register_decoration({
971 deco_type = "schematic",
972 place_on = {"default:dirt_with_grass"},
977 spread = {x = 250, y = 250, z = 250},
982 biomes = {"deciduous_forest"},
985 schematic = minetest.get_modpath("default").."/schematics/apple_tree.mts",
986 flags = "place_center_x, place_center_z",
991 minetest.register_decoration({
992 deco_type = "schematic",
993 place_on = {"default:dirt_with_grass", "default:dirt"},
996 biomes = {"rainforest", "rainforest_swamp"},
999 schematic = minetest.get_modpath("default").."/schematics/jungle_tree.mts",
1000 flags = "place_center_x, place_center_z",
1001 rotation = "random",
1004 -- Taiga and temperate coniferous forest pine tree
1006 minetest.register_decoration({
1007 deco_type = "schematic",
1008 place_on = {"default:dirt_with_snow", "default:dirt_with_grass"},
1013 spread = {x = 250, y = 250, z = 250},
1018 biomes = {"taiga", "coniferous_forest"},
1021 schematic = minetest.get_modpath("default").."/schematics/pine_tree.mts",
1022 flags = "place_center_x, place_center_z",
1027 minetest.register_decoration({
1028 deco_type = "schematic",
1029 place_on = {"default:dirt_with_dry_grass"},
1034 spread = {x = 250, y = 250, z = 250},
1039 biomes = {"savanna"},
1042 schematic = minetest.get_modpath("default").."/schematics/acacia_tree.mts",
1043 flags = "place_center_x, place_center_z",
1044 rotation = "random",
1049 minetest.register_decoration({
1050 deco_type = "schematic",
1051 place_on = {"default:desert_sand"},
1056 spread = {x = 200, y = 200, z = 200},
1061 biomes = {"desert"},
1064 schematic = minetest.get_modpath("default").."/schematics/large_cactus.mts",
1065 flags = "place_center_x",
1066 rotation = "random",
1071 minetest.register_decoration({
1072 deco_type = "simple",
1073 place_on = {"default:desert_sand"},
1078 spread = {x = 200, y = 200, z = 200},
1083 biomes = {"desert"},
1086 decoration = "default:cactus",
1093 minetest.register_decoration({
1094 deco_type = "schematic",
1095 place_on = {"default:dirt"},
1100 spread = {x = 200, y = 200, z = 200},
1105 biomes = {"savanna_swamp"},
1108 schematic = minetest.get_modpath("default").."/schematics/papyrus.mts",
1113 register_grass_decoration(-0.03, 0.09, 5)
1114 register_grass_decoration(-0.015, 0.075, 4)
1115 register_grass_decoration(0, 0.06, 3)
1116 register_grass_decoration(0.015, 0.045, 2)
1117 register_grass_decoration(0.03, 0.03, 1)
1121 register_dry_grass_decoration(0.01, 0.05, 5)
1122 register_dry_grass_decoration(0.03, 0.03, 4)
1123 register_dry_grass_decoration(0.05, 0.01, 3)
1124 register_dry_grass_decoration(0.07, -0.01, 2)
1125 register_dry_grass_decoration(0.09, -0.03, 1)
1129 minetest.register_decoration({
1130 deco_type = "simple",
1131 place_on = {"default:dirt_with_grass"},
1134 biomes = {"rainforest"},
1137 decoration = "default:junglegrass",
1142 minetest.register_decoration({
1143 deco_type = "simple",
1144 place_on = {"default:desert_sand", "default:dirt_with_snow"},
1149 spread = {x = 200, y = 200, z = 200},
1154 biomes = {"desert", "tundra"},
1157 decoration = "default:dry_shrub",
1163 -- Generate nyan cats
1166 -- All mapgens except singlenode
1168 function default.make_nyancat(pos, facedir, length)
1169 local tailvec = {x = 0, y = 0, z = 0}
1170 if facedir == 0 then
1172 elseif facedir == 1 then
1174 elseif facedir == 2 then
1176 elseif facedir == 3 then
1182 local p = {x = pos.x, y = pos.y, z = pos.z}
1183 minetest.set_node(p, {name = "default:nyancat", param2 = facedir})
1184 for i = 1, length do
1185 p.x = p.x + tailvec.x
1186 p.z = p.z + tailvec.z
1187 minetest.set_node(p, {name = "default:nyancat_rainbow", param2 = facedir})
1191 function default.generate_nyancats(minp, maxp, seed)
1192 local height_min = -31000
1193 local height_max = -32
1194 if maxp.y < height_min or minp.y > height_max then
1197 local y_min = math.max(minp.y, height_min)
1198 local y_max = math.min(maxp.y, height_max)
1199 local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
1200 local pr = PseudoRandom(seed + 9324342)
1201 local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
1202 for i = 1, max_num_nyancats do
1203 if pr:next(0, 1000) == 0 then
1204 local x0 = pr:next(minp.x, maxp.x)
1205 local y0 = pr:next(minp.y, maxp.y)
1206 local z0 = pr:next(minp.z, maxp.z)
1207 local p0 = {x = x0, y = y0, z = z0}
1208 default.make_nyancat(p0, pr:next(0, 3), pr:next(3, 15))
1215 -- Detect mapgen to select functions
1218 -- Mods using singlenode mapgen can call these functions to enable
1219 -- the use of minetest.generate_ores or minetest.generate_decorations
1221 local mg_params = minetest.get_mapgen_params()
1222 if mg_params.mgname == "v6" then
1223 default.register_ores()
1224 default.register_mgv6_decorations()
1225 minetest.register_on_generated(default.generate_nyancats)
1226 elseif mg_params.mgname ~= "singlenode" then
1227 default.register_ores()
1228 default.register_biomes()
1229 default.register_decorations()
1230 minetest.register_on_generated(default.generate_nyancats)