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_threshhold = 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_threshhold = 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_threshhold = 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_threshhold = 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_ocean",
458 node_top = "default:sand",
460 node_filler = "default:sand",
463 --node_water_top = "",
464 --depth_water_top = ,
466 --node_river_water = "",
474 minetest.register_biome({
475 name = "coniferous_forest",
477 node_top = "default:dirt_with_grass",
479 node_filler = "default:dirt",
482 --node_water_top = "",
483 --depth_water_top = ,
485 --node_river_water = "",
492 minetest.register_biome({
493 name = "coniferous_forest_ocean",
495 node_top = "default:sand",
497 node_filler = "default:sand",
500 --node_water_top = "",
501 --depth_water_top = ,
503 --node_river_water = "",
511 minetest.register_biome({
512 name = "sandstone_grassland",
514 node_top = "default:dirt_with_grass",
516 node_filler = "default:dirt",
518 node_stone = "default:sandstone",
519 --node_water_top = "",
520 --depth_water_top = ,
522 --node_river_water = "",
529 minetest.register_biome({
530 name = "sandstone_grassland_ocean",
532 node_top = "default:sand",
534 node_filler = "default:sand",
536 node_stone = "default:sandstone",
537 --node_water_top = "",
538 --depth_water_top = ,
540 --node_river_water = "",
548 minetest.register_biome({
549 name = "deciduous_forest",
551 node_top = "default:dirt_with_grass",
553 node_filler = "default:dirt",
556 --node_water_top = "",
557 --depth_water_top = ,
559 --node_river_water = "",
566 minetest.register_biome({
567 name = "deciduous_forest_swamp",
569 node_top = "default:dirt",
571 node_filler = "default:dirt",
574 --node_water_top = "",
575 --depth_water_top = ,
577 --node_river_water = "",
584 minetest.register_biome({
585 name = "deciduous_forest_ocean",
587 node_top = "default:sand",
589 node_filler = "default:sand",
592 --node_water_top = "",
593 --depth_water_top = ,
595 --node_river_water = "",
604 minetest.register_biome({
607 node_top = "default:desert_sand",
609 node_filler = "default:desert_sand",
611 node_stone = "default:desert_stone",
612 --node_water_top = "",
613 --depth_water_top = ,
615 --node_river_water = "",
622 minetest.register_biome({
623 name = "desert_ocean",
625 node_top = "default:sand",
627 node_filler = "default:sand",
629 node_stone = "default:desert_stone",
630 --node_water_top = "",
631 --depth_water_top = ,
633 --node_river_water = "",
641 minetest.register_biome({
644 node_top = "default:dirt_with_dry_grass",
646 node_filler = "default:dirt",
649 --node_water_top = "",
650 --depth_water_top = ,
652 --node_river_water = "",
659 minetest.register_biome({
660 name = "savanna_swamp",
662 node_top = "default:dirt",
664 node_filler = "default:dirt",
667 --node_water_top = "",
668 --depth_water_top = ,
670 --node_river_water = "",
677 minetest.register_biome({
678 name = "savanna_ocean",
680 node_top = "default:sand",
682 node_filler = "default:sand",
685 --node_water_top = "",
686 --depth_water_top = ,
688 --node_river_water = "",
696 minetest.register_biome({
699 node_top = "default:dirt_with_grass",
701 node_filler = "default:dirt",
704 --node_water_top = "",
705 --depth_water_top = ,
707 --node_river_water = "",
714 minetest.register_biome({
715 name = "rainforest_swamp",
717 node_top = "default:dirt",
719 node_filler = "default:dirt",
722 --node_water_top = "",
723 --depth_water_top = ,
725 --node_river_water = "",
732 minetest.register_biome({
733 name = "rainforest_ocean",
735 node_top = "default:sand",
737 node_filler = "default:sand",
740 --node_water_top = "",
741 --depth_water_top = ,
743 --node_river_water = "",
752 minetest.register_biome({
753 name = "underground",
760 --node_water_top = "",
761 --depth_water_top = ,
763 --node_river_water = "",
773 -- Register decorations
778 function default.register_mgv6_decorations()
779 minetest.clear_registered_decorations()
783 minetest.register_decoration({
784 deco_type = "simple",
785 place_on = {"default:dirt_with_grass"},
790 spread = {x = 100, y = 100, z = 100},
797 decoration = "default:papyrus",
800 spawn_by = "default:water_source",
806 minetest.register_decoration({
807 deco_type = "simple",
808 place_on = {"default:desert_sand"},
813 spread = {x = 100, y = 100, z = 100},
820 decoration = "default:cactus",
828 minetest.register_decoration({
829 deco_type = "simple",
830 place_on = {"default:dirt_with_grass"},
835 spread = {x = 100, y = 100, z = 100},
842 decoration = "default:grass_"..length,
848 minetest.register_decoration({
849 deco_type = "simple",
850 place_on = {"default:desert_sand", "default:dirt_with_snow"},
855 spread = {x = 100, y = 100, z = 100},
862 decoration = "default:dry_shrub",
866 -- All mapgens except mgv6 and singlenode
868 local function register_grass_decoration(offset, scale, length)
869 minetest.register_decoration({
870 deco_type = "simple",
871 place_on = {"default:dirt_with_grass", "default:sand"},
876 spread = {x = 200, y = 200, z = 200},
881 biomes = {"stone_grassland", "sandstone_grassland",
882 "deciduous_forest", "coniferous_forest"},
885 decoration = "default:grass_"..length,
889 local function register_dry_grass_decoration(offset, scale, length)
890 minetest.register_decoration({
891 deco_type = "simple",
892 place_on = {"default:dirt_with_dry_grass"},
897 spread = {x = 200, y = 200, z = 200},
902 biomes = {"savanna"},
905 decoration = "default:dry_grass_"..length,
909 function default.register_decorations()
910 minetest.clear_registered_decorations()
914 minetest.register_decoration({
915 deco_type = "schematic",
916 place_on = {"default:dirt_with_grass"},
921 spread = {x = 250, y = 250, z = 250},
926 biomes = {"deciduous_forest"},
929 schematic = minetest.get_modpath("default").."/schematics/apple_tree.mts",
930 flags = "place_center_x, place_center_z",
935 minetest.register_decoration({
936 deco_type = "schematic",
937 place_on = {"default:dirt_with_grass", "default:dirt"},
940 biomes = {"rainforest", "rainforest_swamp"},
943 schematic = minetest.get_modpath("default").."/schematics/jungle_tree.mts",
944 flags = "place_center_x, place_center_z",
948 -- Taiga and temperate forest pine tree
950 minetest.register_decoration({
951 deco_type = "schematic",
952 place_on = {"default:snowblock", "default:dirt_with_grass"},
957 spread = {x = 250, y = 250, z = 250},
962 biomes = {"taiga", "coniferous_forest"},
965 schematic = minetest.get_modpath("default").."/schematics/pine_tree.mts",
966 flags = "place_center_x, place_center_z",
971 minetest.register_decoration({
972 deco_type = "schematic",
973 place_on = {"default:dirt_with_dry_grass"},
978 spread = {x = 250, y = 250, z = 250},
983 biomes = {"savanna"},
986 schematic = minetest.get_modpath("default").."/schematics/acacia_tree.mts",
987 flags = "place_center_x, place_center_z",
993 minetest.register_decoration({
994 deco_type = "schematic",
995 place_on = {"default:desert_sand"},
1000 spread = {x = 200, y = 200, z = 200},
1005 biomes = {"desert"},
1008 schematic = minetest.get_modpath("default").."/schematics/large_cactus.mts",
1009 flags = "place_center_x",
1010 rotation = "random",
1015 minetest.register_decoration({
1016 deco_type = "simple",
1017 place_on = {"default:desert_sand"},
1022 spread = {x = 200, y = 200, z = 200},
1027 biomes = {"desert"},
1030 decoration = "default:cactus",
1037 minetest.register_decoration({
1038 deco_type = "schematic",
1039 place_on = {"default:dirt"},
1044 spread = {x = 200, y = 200, z = 200},
1049 biomes = {"savanna_swamp"},
1052 schematic = minetest.get_modpath("default").."/schematics/papyrus.mts",
1057 register_grass_decoration(-0.03, 0.09, 5)
1058 register_grass_decoration(-0.015, 0.075, 4)
1059 register_grass_decoration(0, 0.06, 3)
1060 register_grass_decoration(0.015, 0.045, 2)
1061 register_grass_decoration(0.03, 0.03, 1)
1065 register_dry_grass_decoration(0.01, 0.05, 5)
1066 register_dry_grass_decoration(0.03, 0.03, 4)
1067 register_dry_grass_decoration(0.05, 0.01, 3)
1068 register_dry_grass_decoration(0.07, -0.01, 2)
1069 register_dry_grass_decoration(0.09, -0.03, 1)
1073 minetest.register_decoration({
1074 deco_type = "simple",
1075 place_on = {"default:dirt_with_grass"},
1078 biomes = {"rainforest"},
1081 decoration = "default:junglegrass",
1086 minetest.register_decoration({
1087 deco_type = "simple",
1088 place_on = {"default:desert_sand", "default:dirt_with_snow"},
1093 spread = {x = 200, y = 200, z = 200},
1098 biomes = {"desert", "tundra"},
1101 decoration = "default:dry_shrub",
1107 -- Generate nyan cats
1110 -- All mapgens except singlenode
1112 function default.make_nyancat(pos, facedir, length)
1113 local tailvec = {x = 0, y = 0, z = 0}
1114 if facedir == 0 then
1116 elseif facedir == 1 then
1118 elseif facedir == 2 then
1120 elseif facedir == 3 then
1126 local p = {x = pos.x, y = pos.y, z = pos.z}
1127 minetest.set_node(p, {name = "default:nyancat", param2 = facedir})
1128 for i = 1, length do
1129 p.x = p.x + tailvec.x
1130 p.z = p.z + tailvec.z
1131 minetest.set_node(p, {name = "default:nyancat_rainbow", param2 = facedir})
1135 function default.generate_nyancats(minp, maxp, seed)
1136 local height_min = -31000
1137 local height_max = -32
1138 if maxp.y < height_min or minp.y > height_max then
1141 local y_min = math.max(minp.y, height_min)
1142 local y_max = math.min(maxp.y, height_max)
1143 local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
1144 local pr = PseudoRandom(seed + 9324342)
1145 local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
1146 for i = 1, max_num_nyancats do
1147 if pr:next(0, 1000) == 0 then
1148 local x0 = pr:next(minp.x, maxp.x)
1149 local y0 = pr:next(minp.y, maxp.y)
1150 local z0 = pr:next(minp.z, maxp.z)
1151 local p0 = {x = x0, y = y0, z = z0}
1152 default.make_nyancat(p0, pr:next(0, 3), pr:next(3, 15))
1159 -- Detect mapgen to select functions
1162 -- Mods using singlenode mapgen can call these functions to enable
1163 -- the use of minetest.generate_ores or minetest.generate_decorations
1165 local mg_params = minetest.get_mapgen_params()
1166 if mg_params.mgname == "v6" then
1167 default.register_ores()
1168 default.register_mgv6_decorations()
1169 minetest.register_on_generated(default.generate_nyancats)
1170 elseif mg_params.mgname ~= "singlenode" then
1171 default.register_ores()
1172 default.register_biomes()
1173 default.register_decorations()
1174 minetest.register_on_generated(default.generate_nyancats)