Don't pick up near player, add more breeding stuff

This commit is contained in:
cora 2022-05-20 01:52:20 +02:00
parent 873e018faf
commit 53df441c1b
3 changed files with 11 additions and 4 deletions

@ -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

@ -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

@ -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