2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"village:entity_spawner",
|
|
|
|
{
|
|
|
|
description = "Chunk defs may choose which entities to spawn here",
|
|
|
|
tiles = {"default_brick.png^default_book.png"},
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {dig_immediate = 2},
|
2015-09-02 00:13:34 +02:00
|
|
|
sounds = default.node_sound_wood_defaults()
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"village:grassland_village",
|
|
|
|
{
|
2015-09-07 00:10:27 +02:00
|
|
|
description = "Village spawner",
|
|
|
|
tiles = {"default_grass.png^default_book.png"},
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {dig_immediate = 2},
|
|
|
|
sounds = default.node_sound_wood_defaults()
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-02 00:13:34 +02:00
|
|
|
"village:grassland_village_mg",
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
2015-09-02 00:13:34 +02:00
|
|
|
description = "Mapgen village spawner(Has chance of not spawning village)",
|
2015-09-07 00:09:12 +02:00
|
|
|
drawtype = "airlike",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
pointable = false,
|
|
|
|
diggable = false,
|
|
|
|
buildable_to = false,
|
|
|
|
is_ground_content = true,
|
|
|
|
air_equivalent = true,
|
|
|
|
drop = "",
|
|
|
|
groups = {not_in_craftingguide = 1},
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_abm(
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
2015-09-02 00:13:34 +02:00
|
|
|
nodenames = {"village:grassland_village", "village:grassland_village_mg"},
|
2015-09-01 17:15:24 +02:00
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node)
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.remove_node(pos)
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
if minetest.setting_getbool("mapgen_disable_villages") == true then
|
2017-05-11 23:12:40 +02:00
|
|
|
return
|
|
|
|
end
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
local pr = PseudoRandom(minetest.get_mapgen_params().seed+pos.x+pos.y+pos.z)
|
2017-05-11 23:10:00 +02:00
|
|
|
|
|
|
|
if node.name == "village:grassland_village_mg" then
|
2017-05-12 04:29:55 +02:00
|
|
|
if ((minetest.get_mapgen_params().seed+pos.x+pos.y+pos.z) % 30) == 1 then
|
2017-05-11 23:10:00 +02:00
|
|
|
local nearest = village.get_nearest_village(pos)
|
|
|
|
|
|
|
|
if nearest.dist > village.min_spawn_dist then
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.log("Spawning a (Mapgen)Grassland village at "..dump(pos))
|
2017-05-11 23:10:00 +02:00
|
|
|
|
|
|
|
-- a short delay to (hopefully) ensure that the surrounding terrain is generated
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.after(3.0, function() village.spawn_village(pos, pr) end)
|
2017-05-11 23:10:00 +02:00
|
|
|
else
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.log("Cannot spawn village, too near another village")
|
2017-05-11 23:10:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.log("Spawning a Grassland village at "..dump(pos))
|
2017-05-11 23:10:00 +02:00
|
|
|
|
|
|
|
village.spawn_village(pos, pr)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_decoration(
|
2015-09-02 00:13:34 +02:00
|
|
|
{
|
|
|
|
deco_type = "simple",
|
|
|
|
place_on = "default:dirt_with_grass",
|
|
|
|
sidelen = 16,
|
|
|
|
fill_ratio = 0.005,
|
|
|
|
biomes = {"Grassland", "Forest"},
|
|
|
|
decoration = {"village:grassland_village_mg"},
|
|
|
|
y_min = 1,
|
|
|
|
y_max = 1000,
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|