From 9a866e873eead4baafea6ad796586ccf2d11f5d3 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 19 May 2022 13:58:59 +0200 Subject: [PATCH] breed by throwing bread at villagers --- mods/ENTITIES/mobs_mc/villager.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 463a62d80..f0a3ca088 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -1241,7 +1241,18 @@ mobs:register_mob("mobs_mc:villager", { look_at_player = true, pick_up = {"mcl_farming:bread"}, on_pick_up = function(self,itementity) - minetest.log("picked up "..itementity.itemstring) + local clicker + for _,p in pairs(minetest.get_connected_players()) do + if vector.distance(p:get_pos(),self.object:get_pos()) < 10 then + clicker = p + end + end + if not clicker then minetest.log("no clicker") end + if clicker then + mobs:feed_tame(self, clicker, 1, true, true) + return + end + return true --do not pick up end, on_rightclick = function(self, clicker) local trg=vector.new(0,9,0) @@ -1250,10 +1261,6 @@ mobs:register_mob("mobs_mc:villager", { --minetest.log("arrived at jobsite") end) end - if clicker:get_wielded_item():get_name() == "mcl_farming:bread" then - if mobs:feed_tame(self, clicker, 1, true, true) then return end - if mobs:protect(self, clicker) then return end - end if self.child or self._profession == "unemployed" then return end