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_pinetree", "default:pinetree")
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 = 24 * 24 * 24,
64 spread = {x = 5, y = 5, z = 5},
73 minetest.register_ore({
76 wherein = {"default:stone"},
77 clust_scarcity = 24 * 24 * 24,
85 spread = {x = 5, y = 5, z = 5},
94 minetest.register_ore({
97 wherein = {"default:stone"},
98 clust_scarcity = 24 * 24 * 24,
102 noise_threshhold = 0,
106 spread = {x = 5, y = 5, z = 5},
115 minetest.register_ore({
117 ore = "default:gravel",
118 wherein = {"default:stone"},
119 clust_scarcity = 24 * 24 * 24,
123 noise_threshhold = 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,
341 minetest.register_biome({
342 name = "glacier_ocean",
343 node_dust = "default:snowblock",
344 node_top = "default:gravel",
346 node_filler = "default:gravel",
349 --node_water_top = "",
350 --depth_water_top = ,
360 minetest.register_biome({
362 node_dust = "default:snow",
363 node_top = "default:dirt_with_snow",
365 node_filler = "default:dirt",
368 --node_water_top = "",
369 --depth_water_top = ,
377 minetest.register_biome({
378 name = "tundra_ocean",
380 node_top = "default:sand",
382 node_filler = "default:sand",
385 --node_water_top = "",
386 --depth_water_top = ,
394 minetest.register_biome({
396 node_dust = "default:snow",
397 node_top = "default:snowblock",
399 node_filler = "default:dirt",
402 --node_water_top = "",
403 --depth_water_top = ,
411 minetest.register_biome({
412 name = "taiga_ocean",
414 node_top = "default:sand",
416 node_filler = "default:sand",
419 --node_water_top = "",
420 --depth_water_top = ,
430 minetest.register_biome({
431 name = "stone_grassland",
433 node_top = "default:dirt_with_grass",
435 node_filler = "default:dirt",
438 --node_water_top = "",
439 --depth_water_top = ,
447 minetest.register_biome({
448 name = "stone_grassland_ocean",
450 node_top = "default:sand",
452 node_filler = "default:sand",
455 --node_water_top = "",
456 --depth_water_top = ,
464 minetest.register_biome({
465 name = "coniferous_forest",
467 node_top = "default:dirt_with_grass",
469 node_filler = "default:dirt",
472 --node_water_top = "",
473 --depth_water_top = ,
481 minetest.register_biome({
482 name = "coniferous_forest_ocean",
484 node_top = "default:sand",
486 node_filler = "default:sand",
489 --node_water_top = "",
490 --depth_water_top = ,
500 minetest.register_biome({
501 name = "sandstone_grassland",
503 node_top = "default:dirt_with_grass",
505 node_filler = "default:dirt",
507 node_stone = "default:sandstone",
508 --node_water_top = "",
509 --depth_water_top = ,
517 minetest.register_biome({
518 name = "sandstone_grassland_ocean",
520 node_top = "default:sand",
522 node_filler = "default:sand",
524 node_stone = "default:sandstone",
525 --node_water_top = "",
526 --depth_water_top = ,
534 minetest.register_biome({
535 name = "deciduous_forest",
537 node_top = "default:dirt_with_grass",
539 node_filler = "default:dirt",
542 --node_water_top = "",
543 --depth_water_top = ,
551 minetest.register_biome({
552 name = "deciduous_forest_ocean",
554 node_top = "default:sand",
556 node_filler = "default:sand",
559 --node_water_top = "",
560 --depth_water_top = ,
570 minetest.register_biome({
573 node_top = "default:desert_sand",
575 node_filler = "default:desert_sand",
577 node_stone = "default:desert_stone",
578 --node_water_top = "",
579 --depth_water_top = ,
587 minetest.register_biome({
588 name = "desert_ocean",
590 node_top = "default:sand",
592 node_filler = "default:sand",
594 node_stone = "default:desert_stone",
595 --node_water_top = "",
596 --depth_water_top = ,
604 minetest.register_biome({
607 node_top = "default:dirt_with_dry_grass",
609 node_filler = "default:dirt",
612 --node_water_top = "",
613 --depth_water_top = ,
621 minetest.register_biome({
622 name = "savanna_ocean",
624 node_top = "default:sand",
626 node_filler = "default:sand",
629 --node_water_top = "",
630 --depth_water_top = ,
638 minetest.register_biome({
641 node_top = "default:dirt_with_grass",
643 node_filler = "default:dirt",
646 --node_water_top = "",
647 --depth_water_top = ,
655 minetest.register_biome({
656 name = "rainforest_swamp",
658 node_top = "default:dirt",
660 node_filler = "default:dirt",
663 --node_water_top = "",
664 --depth_water_top = ,
672 minetest.register_biome({
673 name = "rainforest_ocean",
675 node_top = "default:sand",
677 node_filler = "default:sand",
680 --node_water_top = "",
681 --depth_water_top = ,
691 minetest.register_biome({
692 name = "underground",
699 --node_water_top = "",
700 --depth_water_top = ,
711 -- Register decorations
716 function default.register_mgv6_decorations()
717 minetest.clear_registered_decorations()
721 minetest.register_decoration({
722 deco_type = "simple",
723 place_on = {"default:dirt_with_grass"},
728 spread = {x = 100, y = 100, z = 100},
735 decoration = "default:papyrus",
738 spawn_by = "default:water_source",
744 minetest.register_decoration({
745 deco_type = "simple",
746 place_on = {"default:desert_sand"},
751 spread = {x = 100, y = 100, z = 100},
758 decoration = "default:cactus",
766 minetest.register_decoration({
767 deco_type = "simple",
768 place_on = {"default:dirt_with_grass"},
773 spread = {x = 100, y = 100, z = 100},
780 decoration = "default:grass_"..length,
786 minetest.register_decoration({
787 deco_type = "simple",
788 place_on = {"default:desert_sand", "default:dirt_with_snow"},
793 spread = {x = 100, y = 100, z = 100},
800 decoration = "default:dry_shrub",
804 -- All mapgens except mgv6 and singlenode
806 local function register_grass_decoration(offset, scale, length)
807 minetest.register_decoration({
808 deco_type = "simple",
809 place_on = {"default:dirt_with_grass", "default:sand"},
814 spread = {x=200, y=200, z=200},
820 "stone_grassland", "stone_grassland_ocean",
821 "sandstone_grassland", "sandstone_grassland_ocean",
822 "deciduous_forest", "deciduous_forest_ocean",
823 "coniferous_forest", "coniferous_forest_ocean",
827 decoration = "default:grass_"..length,
831 local function register_dry_grass_decoration(offset, scale, length)
832 minetest.register_decoration({
833 deco_type = "simple",
834 place_on = {"default:dirt_with_dry_grass"},
839 spread = {x=200, y=200, z=200},
844 biomes = {"savanna"},
847 decoration = "default:dry_grass_"..length,
851 function default.register_decorations()
852 minetest.clear_registered_decorations()
856 minetest.register_decoration({
857 deco_type = "schematic",
858 place_on = {"default:dirt_with_grass"},
863 spread = {x=250, y=250, z=250},
868 biomes = {"deciduous_forest"},
871 schematic = minetest.get_modpath("default").."/schematics/apple_tree.mts",
872 flags = "place_center_x, place_center_z",
877 minetest.register_decoration({
878 deco_type = "schematic",
879 place_on = {"default:dirt_with_grass", "default:dirt"},
882 biomes = {"rainforest", "rainforest_swamp"},
885 schematic = minetest.get_modpath("default").."/schematics/jungle_tree.mts",
886 flags = "place_center_x, place_center_z",
889 -- Taiga and temperate forest pine tree
891 minetest.register_decoration({
892 deco_type = "schematic",
893 place_on = {"default:snowblock", "default:dirt_with_grass"},
898 spread = {x=250, y=250, z=250},
903 biomes = {"taiga", "coniferous_forest"},
906 schematic = minetest.get_modpath("default").."/schematics/pine_tree.mts",
907 flags = "place_center_x, place_center_z",
912 minetest.register_decoration({
913 deco_type = "schematic",
914 place_on = {"default:dirt_with_dry_grass"},
919 spread = {x=250, y=250, z=250},
924 biomes = {"savanna"},
927 schematic = minetest.get_modpath("default").."/schematics/acacia_tree.mts",
928 flags = "place_center_x, place_center_z",
934 minetest.register_decoration({
935 deco_type = "schematic",
936 place_on = {"default:desert_sand"},
941 spread = {x=200, y=200, z=200},
949 schematic = minetest.get_modpath("default").."/schematics/large_cactus.mts",
950 flags = "place_center_x",
956 minetest.register_decoration({
957 deco_type = "simple",
958 place_on = {"default:desert_sand"},
963 spread = {x=200, y=200, z=200},
971 decoration = "default:cactus",
978 minetest.register_decoration({
979 deco_type = "schematic",
980 place_on = {"default:sand"},
985 spread = {x=200, y=200, z=200},
990 biomes = {"savanna_ocean", "desert_ocean"},
993 schematic = minetest.get_modpath("default").."/schematics/papyrus.mts",
998 register_grass_decoration(-0.03, 0.09, 5)
999 register_grass_decoration(-0.015, 0.075, 4)
1000 register_grass_decoration(0, 0.06, 3)
1001 register_grass_decoration(0.015, 0.045, 2)
1002 register_grass_decoration(0.03, 0.03, 1)
1006 register_dry_grass_decoration(0.01, 0.05, 5)
1007 register_dry_grass_decoration(0.03, 0.03, 4)
1008 register_dry_grass_decoration(0.05, 0.01, 3)
1009 register_dry_grass_decoration(0.07, -0.01, 2)
1010 register_dry_grass_decoration(0.09, -0.03, 1)
1014 minetest.register_decoration({
1015 deco_type = "simple",
1016 place_on = {"default:dirt_with_grass"},
1019 biomes = {"rainforest"},
1022 decoration = "default:junglegrass",
1027 minetest.register_decoration({
1028 deco_type = "simple",
1029 place_on = {"default:desert_sand", "default:dirt_with_snow"},
1034 spread = {x=200, y=200, z=200},
1039 biomes = {"desert", "tundra"},
1042 decoration = "default:dry_shrub",
1048 -- Generate nyan cats
1051 -- All mapgens except singlenode
1053 function default.make_nyancat(pos, facedir, length)
1054 local tailvec = {x = 0, y = 0, z = 0}
1055 if facedir == 0 then
1057 elseif facedir == 1 then
1059 elseif facedir == 2 then
1061 elseif facedir == 3 then
1067 local p = {x = pos.x, y = pos.y, z = pos.z}
1068 minetest.set_node(p, {name = "default:nyancat", param2 = facedir})
1069 for i = 1, length do
1070 p.x = p.x + tailvec.x
1071 p.z = p.z + tailvec.z
1072 minetest.set_node(p, {name = "default:nyancat_rainbow", param2 = facedir})
1076 function default.generate_nyancats(minp, maxp, seed)
1077 local height_min = -31000
1078 local height_max = -32
1079 if maxp.y < height_min or minp.y > height_max then
1082 local y_min = math.max(minp.y, height_min)
1083 local y_max = math.min(maxp.y, height_max)
1084 local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
1085 local pr = PseudoRandom(seed + 9324342)
1086 local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
1087 for i = 1, max_num_nyancats do
1088 if pr:next(0, 1000) == 0 then
1089 local x0 = pr:next(minp.x, maxp.x)
1090 local y0 = pr:next(minp.y, maxp.y)
1091 local z0 = pr:next(minp.z, maxp.z)
1092 local p0 = {x = x0, y = y0, z = z0}
1093 default.make_nyancat(p0, pr:next(0, 3), pr:next(3, 15))
1100 -- Detect mapgen to select functions
1103 -- Mods using singlenode mapgen can call these functions to enable
1104 -- the use of minetest.generate_ores or minetest.generate_decorations
1106 local mg_params = minetest.get_mapgen_params()
1107 if mg_params.mgname == "v6" then
1108 default.register_ores()
1109 default.register_mgv6_decorations()
1110 minetest.register_on_generated(default.generate_nyancats)
1111 elseif mg_params.mgname ~= "singlenode" then
1112 default.register_ores()
1113 default.register_biomes()
1114 default.register_decorations()
1115 minetest.register_on_generated(default.generate_nyancats)