1
0
Fork 0

spawn villagers (and golem) immediately after mg

This commit is contained in:
cora 2022-05-20 23:44:58 +02:00
parent 27d0d778e2
commit 2b63866c14
2 changed files with 36 additions and 22 deletions

View File

@ -188,6 +188,32 @@ local function construct_node(p1, p2, name)
end end
minetest.log("warning", "[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name) minetest.log("warning", "[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name)
end end
local function spawn_iron_golem(pos)
local p = minetest.find_node_near(pos,50,"mcl_core:grass_path")
if p then
local l=minetest.add_entity(p,"mobs_mc:iron_golem"):get_luaentity()
if l then
l._home = p
end
end
end
local function spawn_villagers(minp,maxp)
local beds=minetest.find_nodes_in_area(minp,maxp,{"mcl_beds:bed_red_bottom"})
for _,bed in pairs(beds) do
local m = minetest.get_meta(bed)
if m:get_string("villager") == "" then
local v=minetest.add_entity(bed,"mobs_mc:villager")
if v then
local l=v:get_luaentity()
l._bed = bed
m:set_string("villager",l._id)
end
end
end
end
local function init_nodes(p1, p2, size, rotation, pr) local function init_nodes(p1, p2, size, rotation, pr)
construct_node(p1, p2, "mcl_itemframes:item_frame") construct_node(p1, p2, "mcl_itemframes:item_frame")
construct_node(p1, p2, "mcl_furnaces:furnace") construct_node(p1, p2, "mcl_furnaces:furnace")
@ -205,9 +231,12 @@ local function init_nodes(p1, p2, size, rotation, pr)
end end
end end
end end
function settlements.place_schematics(settlement_info, pr) function settlements.place_schematics(settlement_info, pr)
local building_all_info local building_all_info
for i, built_house in ipairs(settlement_info) do for i, built_house in ipairs(settlement_info) do
local is_last = i == #settlement_info
for j, schem in ipairs(settlements.schematic_table) do for j, schem in ipairs(settlements.schematic_table) do
if settlement_info[i]["name"] == schem["name"] then if settlement_info[i]["name"] == schem["name"] then
building_all_info = schem building_all_info = schem
@ -275,7 +304,13 @@ function settlements.place_schematics(settlement_info, pr)
nil, nil,
true, true,
nil, nil,
init_nodes, function(p1, p2, size, rotation, pr)
init_nodes(p1, p2, size, rotation, pr)
spawn_villagers(p1,p2)
if is_last then
spawn_iron_golem(p1)
end
end,
pr pr
) )
end end

View File

@ -21,7 +21,6 @@ minetest.register_node("mcl_villages:stonebrickcarved", {
description = ("Chiseled Stone Village Bricks"), description = ("Chiseled Stone Village Bricks"),
_doc_items_longdesc = doc.sub.items.temp.build, _doc_items_longdesc = doc.sub.items.temp.build,
tiles = {"mcl_core_stonebrick_carved.png"}, tiles = {"mcl_core_stonebrick_carved.png"},
stack_max = 64,
drop = "mcl_core:stonebrickcarved", drop = "mcl_core:stonebrickcarved",
groups = {pickaxey=1, stone=1, stonebrick=1, building_block=1, material_stone=1}, groups = {pickaxey=1, stone=1, stonebrick=1, building_block=1, material_stone=1},
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
@ -50,26 +49,6 @@ if minetest.get_modpath("mobs_mc") then
end end
--]] --]]
local function spawn_villagers(minp,maxp)
local beds=minetest.find_nodes_in_area(minp,maxp,{"mcl_beds:bed_red_bottom"})
for _,bed in pairs(beds) do
local m = minetest.get_meta(bed)
if m:get_string("villager") == "" then
local v=minetest.add_entity(bed,"mobs_mc:villager")
if v then
local l=v:get_luaentity()
l._bed = bed
m:set_string("villager",l._id)
end
end
end
local p = minetest.find_node_near(minp,50,"mcl_core:grass_path")
if p then
minetest.add_entity(p,"mobs_mc:iron_golem")
end
end
-- --
-- on map generation, try to build a settlement -- on map generation, try to build a settlement
-- --