From 53df441c1b3b03173dd3a55dd465e49ace0f587f Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 20 May 2022 01:52:20 +0200 Subject: [PATCH] Don't pick up near player, add more breeding stuff --- mods/ENTITIES/mcl_mobs/api.lua | 11 +++++++++-- mods/ENTITIES/mobs_mc/0_gameconfig.lua | 2 +- mods/ENTITIES/mobs_mc/villager.lua | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index c5340c472..7fb4e6a32 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2976,13 +2976,20 @@ function mobs:gopath(self,target,callback_arrived) end end +local function player_near(pos) + for _,o in pairs(minetest.get_objects_inside_radius(pos,2)) do + if o:is_player() then return true end + end +end + local function check_item_pickup(self) if self.pick_up and #self.pick_up > 0 then - for _,o in pairs(minetest.get_objects_inside_radius(self.object:get_pos(),2)) do + local p = self.object:get_pos() + for _,o in pairs(minetest.get_objects_inside_radius(p,2)) do local l=o:get_luaentity() if l and l.name == "__builtin:item" then for k,v in pairs(self.pick_up) do - if self.on_pick_up and l.itemstring:find(v) then + if not player_near(p) and self.on_pick_up and l.itemstring:find(v) then if self.on_pick_up(self,l) == nil then o:remove() end end end diff --git a/mods/ENTITIES/mobs_mc/0_gameconfig.lua b/mods/ENTITIES/mobs_mc/0_gameconfig.lua index 17451aeb6..c36b88475 100644 --- a/mods/ENTITIES/mobs_mc/0_gameconfig.lua +++ b/mods/ENTITIES/mobs_mc/0_gameconfig.lua @@ -169,7 +169,7 @@ mobs_mc.follow = { dog = { mobs_mc.items.rabbit_raw, mobs_mc.items.rabbit_cooked, mobs_mc.items.mutton_raw, mobs_mc.items.mutton_cooked, mobs_mc.items.beef_raw, mobs_mc.items.beef_cooked, mobs_mc.items.chicken_raw, mobs_mc.items.chicken_cooked, mobs_mc.items.rotten_flesh, -- Mobs Redo items "mobs:meat", "mobs:meat_raw" }, - villager = { "mcl_farming:bread" }, + villager = { "mcl_farming:bread", "mcl_farming:carrot_item", "mcl_farming:beetroot_item" , "mcl_farming:potato_item" }, } -- Contents for replace_what diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 68e6fb1e7..deaee72af 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -1253,7 +1253,7 @@ mobs:register_mob("mobs_mc:villager", { _id = nil, _profession = "unemployed", look_at_player = true, - pick_up = {"mcl_farming:bread"}, + pick_up = mobs_mc.follow.villager, can_open_doors = true, on_pick_up = function(self,itementity) local clicker