From dfb74cf9e9cbd5987c2fe19c4a04832afd346189 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 19 May 2022 14:13:59 +0200 Subject: [PATCH] mobs: add nofollow option so v. dont follow bread --- mods/ENTITIES/mcl_mobs/api.lua | 6 ++++-- mods/ENTITIES/mobs_mc/villager.lua | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index c5d5916acc..e5e3063a22 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1438,7 +1438,8 @@ end -- should mob follow what I'm holding ? local follow_holding = function(self, clicker) - + if self.nofollow then return false end + if mobs.invis[clicker:get_player_name()] then return false end @@ -3913,6 +3914,7 @@ minetest.register_entity(name, { sounds = def.sounds or {}, animation = def.animation, follow = def.follow, + nofollow = def.nofollow, jump = def.jump ~= false, walk_chance = def.walk_chance or 50, attacks_monsters = def.attacks_monsters or false, @@ -4321,7 +4323,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame) end -- can eat/tame with item in hand - if follow_holding(self, clicker) then + if self.nofollow or follow_holding(self, clicker) then -- if not in creative then take item if not mobs.is_creative(clicker:get_player_name()) then diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index f0a3ca0882..07126db979 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -1231,6 +1231,7 @@ mobs:register_mob("mobs_mc:villager", { die_loop = false, }, follow = mobs_mc.follow.villager, + nofollow = true, view_range = 16, fear_height = 4, jump = true, @@ -1247,7 +1248,6 @@ mobs:register_mob("mobs_mc:villager", { 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