diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index cb421b78b..77d831e79 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -33,6 +33,7 @@ local PLAYER_SCAN_RADIUS = 4 -- scan radius for looking for nearby players local RESETTLE_DISTANCE = 100 -- If a mob is transported this far from home, it gives up bed and job and resettles local PATHFINDING = "gowp" +local VILLAGER_SEARCH_RADIUS = tonumber(minetest.settings:get("mcl_mobs_villager_search_radius")) or 20 --[=======[ TRADING ]=======] @@ -793,13 +794,13 @@ local function find_closest_bed (self) --local spawnable_bed={} --table.insert(spawnable_bed, "mcl_beds:bed_red_bottom") - --local nn = minetest.find_nodes_in_area(vector.offset(p,-48,-48,-48),vector.offset(p,48,48,48), spawnable_bed) + --local nn = minetest.find_nodes_in_area(vector.offset(p,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS),vector.offset(p,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS), spawnable_bed) --if nn then -- mcl_log("Red beds: " .. #nn) --end local unclaimed_beds = {} - local nn2 = minetest.find_nodes_in_area(vector.offset(p,-48,-48,-48),vector.offset(p,48,48,48), {"group:bed"}) + local nn2 = minetest.find_nodes_in_area(vector.offset(p,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS),vector.offset(p,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS), {"group:bed"}) if nn2 then --mcl_log("All bed parts: " .. #nn2) @@ -878,7 +879,7 @@ local function find_closest_bed (self) end local function find_closest_unclaimed_block (p, requested_block_types) - local nn = minetest.find_nodes_in_area(vector.offset(p,-48,-48,-48),vector.offset(p,48,48,48), requested_block_types) + local nn = minetest.find_nodes_in_area(vector.offset(p,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS),vector.offset(p,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS), requested_block_types) local distance_to_closest_block = nil local closest_block = nil @@ -1372,7 +1373,7 @@ local function go_to_town_bell(self) table.insert(looking_for_type, "mcl_bells:bell") local p = self.object:get_pos() - local nn = minetest.find_nodes_in_area(vector.offset(p,-48,-48,-48),vector.offset(p,48,48,48), looking_for_type) + local nn = minetest.find_nodes_in_area(vector.offset(p,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS,-VILLAGER_SEARCH_RADIUS),vector.offset(p,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS,VILLAGER_SEARCH_RADIUS), looking_for_type) --Ideally should check for closest available. It'll make pathing easier. for _,n in pairs(nn) do diff --git a/settingtypes.txt b/settingtypes.txt index f5743bc1d..f4213c8b6 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -214,6 +214,10 @@ mcl_mobs_overworld_threshold (Artificial light threshold to stop monster spawns mcl_mobs_overworld_sky_threshold (Skylight threshold to stop monster spawns in the Overworld) int 7 0 14 mcl_mobs_overworld_passive_threshold (Combined light threshold to stop animal and npc spawns in the Overworld) int 7 0 14 +# How far should villagers search for jobs, beds and bell +# Larger values will have a larger performance impact (default:20) +mcl_mobs_villager_search_radius (Villager job/bed/bell search radius) int 10 0 60 + [Audio] # Enable flame sound. flame_sound (Flame sound) bool true