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_snow", "default:snow")
18 minetest.register_alias("mapgen_snowblock", "default:snowblock")
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")
40 -- Blob ore first to avoid other ores inside blobs
42 function default.register_ores()
43 minetest.register_ore({
46 wherein = {"default:sand"},
47 clust_scarcity = 24*24*24,
55 spread={x=5, y=5, z=5},
62 minetest.register_ore({
65 wherein = {"default:stone"},
66 clust_scarcity = 24*24*24,
74 spread={x=5, y=5, z=5},
81 minetest.register_ore({
84 wherein = {"default:stone"},
85 clust_scarcity = 24*24*24,
93 spread={x=5, y=5, z=5},
100 minetest.register_ore({
102 ore = "default:gravel",
103 wherein = {"default:stone"},
104 clust_scarcity = 24*24*24,
108 noise_threshhold = 0,
112 spread={x=5, y=5, z=5},
119 minetest.register_ore({
120 ore_type = "scatter",
121 ore = "default:stone_with_coal",
122 wherein = "default:stone",
123 clust_scarcity = 8*8*8,
130 minetest.register_ore({
131 ore_type = "scatter",
132 ore = "default:stone_with_coal",
133 wherein = "default:stone",
134 clust_scarcity = 24*24*24,
141 minetest.register_ore({
142 ore_type = "scatter",
143 ore = "default:stone_with_iron",
144 wherein = "default:stone",
145 clust_scarcity = 12*12*12,
152 minetest.register_ore({
153 ore_type = "scatter",
154 ore = "default:stone_with_iron",
155 wherein = "default:stone",
156 clust_scarcity = 9*9*9,
163 minetest.register_ore({
164 ore_type = "scatter",
165 ore = "default:stone_with_iron",
166 wherein = "default:stone",
167 clust_scarcity = 7*7*7,
174 minetest.register_ore({
175 ore_type = "scatter",
176 ore = "default:stone_with_iron",
177 wherein = "default:stone",
178 clust_scarcity = 24*24*24,
185 minetest.register_ore({
186 ore_type = "scatter",
187 ore = "default:stone_with_mese",
188 wherein = "default:stone",
189 clust_scarcity = 18*18*18,
196 minetest.register_ore({
197 ore_type = "scatter",
198 ore = "default:stone_with_mese",
199 wherein = "default:stone",
200 clust_scarcity = 14*14*14,
207 minetest.register_ore({
208 ore_type = "scatter",
209 ore = "default:mese",
210 wherein = "default:stone",
211 clust_scarcity = 36*36*36,
218 minetest.register_ore({
219 ore_type = "scatter",
220 ore = "default:stone_with_gold",
221 wherein = "default:stone",
222 clust_scarcity = 15*15*15,
229 minetest.register_ore({
230 ore_type = "scatter",
231 ore = "default:stone_with_gold",
232 wherein = "default:stone",
233 clust_scarcity = 13*13*13,
240 minetest.register_ore({
241 ore_type = "scatter",
242 ore = "default:stone_with_diamond",
243 wherein = "default:stone",
244 clust_scarcity = 17*17*17,
251 minetest.register_ore({
252 ore_type = "scatter",
253 ore = "default:stone_with_diamond",
254 wherein = "default:stone",
255 clust_scarcity = 15*15*15,
262 minetest.register_ore({
263 ore_type = "scatter",
264 ore = "default:stone_with_copper",
265 wherein = "default:stone",
266 clust_scarcity = 12*12*12,
273 minetest.register_ore({
274 ore_type = "scatter",
275 ore = "default:stone_with_copper",
276 wherein = "default:stone",
277 clust_scarcity = 9*9*9,
291 function default.register_biomes()
292 minetest.clear_registered_biomes()
294 minetest.register_biome({
295 name = "default:grassland",
297 node_top = "default:dirt_with_grass",
299 node_filler = "default:dirt",
302 --node_water_top = "",
303 --depth_water_top = ,
311 minetest.register_biome({
312 name = "default:grassland_ocean",
314 node_top = "default:sand",
316 node_filler = "default:sand",
319 --node_water_top = "",
320 --depth_water_top = ,
331 -- Register mgv6 decorations
335 function default.register_mgv6_decorations()
339 minetest.register_decoration({
340 deco_type = "simple",
341 place_on = {"default:dirt_with_grass"},
346 spread = {x=100, y=100, z=100},
353 decoration = "default:papyrus",
356 spawn_by = "default:water_source",
362 minetest.register_decoration({
363 deco_type = "simple",
364 place_on = {"default:desert_sand"},
369 spread = {x=100, y=100, z=100},
376 decoration = "default:cactus",
384 minetest.register_decoration({
385 deco_type = "simple",
386 place_on = {"default:dirt_with_grass"},
391 spread = {x=100, y=100, z=100},
398 decoration = "default:grass_"..length,
404 minetest.register_decoration({
405 deco_type = "simple",
406 place_on = {"default:desert_sand", "default:dirt_with_snow"},
411 spread = {x=100, y=100, z=100},
418 decoration = "default:dry_shrub",
424 -- Register decorations
428 function default.register_decorations()
432 minetest.register_decoration({
433 deco_type = "simple",
434 place_on = {"default:dirt_with_grass"},
439 spread = {x=200, y=200, z=200},
444 biomes = {"default:grassland"},
447 decoration = "flowers:rose",
450 minetest.register_decoration({
451 deco_type = "simple",
452 place_on = {"default:dirt_with_grass"},
457 spread = {x=200, y=200, z=200},
462 biomes = {"default:grassland"},
465 decoration = "flowers:tulip",
468 minetest.register_decoration({
469 deco_type = "simple",
470 place_on = {"default:dirt_with_grass"},
475 spread = {x=200, y=200, z=200},
480 biomes = {"default:grassland"},
483 decoration = "flowers:dandelion_yellow",
486 minetest.register_decoration({
487 deco_type = "simple",
488 place_on = {"default:dirt_with_grass"},
493 spread = {x=200, y=200, z=200},
498 biomes = {"default:grassland"},
501 decoration = "flowers:geranium",
504 minetest.register_decoration({
505 deco_type = "simple",
506 place_on = {"default:dirt_with_grass"},
511 spread = {x=200, y=200, z=200},
516 biomes = {"default:grassland"},
519 decoration = "flowers:viola",
522 minetest.register_decoration({
523 deco_type = "simple",
524 place_on = {"default:dirt_with_grass"},
529 spread = {x=200, y=200, z=200},
534 biomes = {"default:grassland"},
537 decoration = "flowers:dandelion_white",
542 minetest.register_decoration({
543 deco_type = "simple",
544 place_on = {"default:dirt_with_grass"},
549 spread = {x=200, y=200, z=200},
554 biomes = {"default:grassland"},
557 decoration = "default:grass_1",
560 minetest.register_decoration({
561 deco_type = "simple",
562 place_on = {"default:dirt_with_grass"},
567 spread = {x=200, y=200, z=200},
572 biomes = {"default:grassland"},
575 decoration = "default:grass_2",
578 minetest.register_decoration({
579 deco_type = "simple",
580 place_on = {"default:dirt_with_grass"},
585 spread = {x=200, y=200, z=200},
590 biomes = {"default:grassland"},
593 decoration = "default:grass_3",
596 minetest.register_decoration({
597 deco_type = "simple",
598 place_on = {"default:dirt_with_grass"},
603 spread = {x=200, y=200, z=200},
608 biomes = {"default:grassland"},
611 decoration = "default:grass_4",
614 minetest.register_decoration({
615 deco_type = "simple",
616 place_on = {"default:dirt_with_grass"},
621 spread = {x=200, y=200, z=200},
626 biomes = {"default:grassland"},
629 decoration = "default:grass_5",
635 -- Detect mapgen to select functions
639 -- Mods using singlenode mapgen can call these functions to enable
640 -- the use of minetest.generate_ores or minetest.generate_decorations
642 local mg_params = minetest.get_mapgen_params()
643 if mg_params.mgname == "v6" then
644 default.register_ores()
645 default.register_mgv6_decorations()
646 elseif mg_params.mgname ~= "singlenode" then
647 default.register_ores()
648 default.register_biomes()
649 default.register_decorations()
654 -- Generate nyan cats in all mapgens
658 -- facedir: 0/1/2/3 (head node facedir value)
659 -- length: length of rainbow tail
660 function default.make_nyancat(pos, facedir, length)
661 local tailvec = {x=0, y=0, z=0}
664 elseif facedir == 1 then
666 elseif facedir == 2 then
668 elseif facedir == 3 then
671 --print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
675 local p = {x=pos.x, y=pos.y, z=pos.z}
676 minetest.set_node(p, {name="default:nyancat", param2=facedir})
678 p.x = p.x + tailvec.x
679 p.z = p.z + tailvec.z
680 minetest.set_node(p, {name="default:nyancat_rainbow", param2=facedir})
685 function default.generate_nyancats(minp, maxp, seed)
686 local height_min = -31000
687 local height_max = -32
688 if maxp.y < height_min or minp.y > height_max then
691 local y_min = math.max(minp.y, height_min)
692 local y_max = math.min(maxp.y, height_max)
693 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
694 local pr = PseudoRandom(seed + 9324342)
695 local max_num_nyancats = math.floor(volume / (16*16*16))
696 for i=1,max_num_nyancats do
697 if pr:next(0, 1000) == 0 then
698 local x0 = pr:next(minp.x, maxp.x)
699 local y0 = pr:next(minp.y, maxp.y)
700 local z0 = pr:next(minp.z, maxp.z)
701 local p0 = {x=x0, y=y0, z=z0}
702 default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
708 minetest.register_on_generated(default.generate_nyancats)
712 -- Deprecated ore generation code
716 function default.generate_ore(name, wherein, minp, maxp, seed,
717 chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
718 minetest.log('action', "WARNING: default.generate_ore is deprecated")
720 if maxp.y < height_min or minp.y > height_max then
723 local y_min = math.max(minp.y, height_min)
724 local y_max = math.min(maxp.y, height_max)
725 if chunk_size >= y_max - y_min + 1 then
728 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
729 local pr = PseudoRandom(seed)
730 local num_chunks = math.floor(chunks_per_volume * volume)
731 local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
732 --print("generate_ore num_chunks: "..dump(num_chunks))
733 for i=1,num_chunks do
734 local y0 = pr:next(y_min, y_max-chunk_size+1)
735 if y0 >= height_min and y0 <= height_max then
736 local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
737 local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
738 local p0 = {x=x0, y=y0, z=z0}
739 for x1=0,chunk_size-1 do
740 for y1=0,chunk_size-1 do
741 for z1=0,chunk_size-1 do
742 if pr:next(1,inverse_chance) == 1 then
746 local p2 = {x=x2, y=y2, z=z2}
747 if minetest.get_node(p2).name == wherein then
748 minetest.set_node(p2, {name=name})
756 --print("generate_ore done")