diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index a2b828e091..7efc5d29e8 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -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 diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index a899b3234c..b70b5b75e8 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -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)