Spawn villagers on villagegen, stay in village
This spawns a villager per bed on village gen and saves the bed position in the entity. If it moves too far from the village it gets teleported (for now) back.mobs_head_rotation
parent
7c263c6a18
commit
46dbf8c0ab
|
@ -1029,6 +1029,9 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
_player_scan_timer = 0,
|
||||
_trading_players = {}, -- list of playernames currently trading with villager (open formspec)
|
||||
do_custom = function(self, dtime)
|
||||
if self.bed and vector.distance(self.object:get_pos(),self.bed) > 50 then
|
||||
self.object:set_pos(self.bed)
|
||||
end
|
||||
-- Stand still if player is nearby.
|
||||
if not self._player_scan_timer then
|
||||
self._player_scan_timer = 0
|
||||
|
|
|
@ -48,6 +48,17 @@ if minetest.get_modpath("mobs_mc") then
|
|||
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
|
||||
minetest.get_meta(bed):set_string("villagebed","true")
|
||||
local v=minetest.add_entity(bed,"mobs_mc:villager")
|
||||
if v then
|
||||
v:get_luaentity().bed = bed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- on map generation, try to build a settlement
|
||||
--
|
||||
|
@ -66,6 +77,10 @@ local function build_a_settlement(minp, maxp, blockseed)
|
|||
|
||||
-- evaluate settlement_info and place schematics
|
||||
settlements.place_schematics(settlement_info, pr)
|
||||
|
||||
minetest.after(20,function()
|
||||
spawn_villagers(minp,maxp)
|
||||
end) --give the village some time to fully generate
|
||||
end
|
||||
|
||||
local function ecb_village(blockpos, action, calls_remaining, param)
|
||||
|
|
Loading…
Reference in New Issue