From 9d52fed357462e6d380fce24bb7c0c07774aeb1f Mon Sep 17 00:00:00 2001 From: SumianVoice Date: Tue, 19 Jul 2022 14:05:04 +1000 Subject: [PATCH] non-tamable mobs will not send tame param to feed_tame func, changed event flow so it tries in order: heal, tame, breed, grow child --- mods/ENTITIES/mcl_mobs/api.lua | 39 ++++++++++++------------- mods/ENTITIES/mobs_mc/chicken.lua | 2 +- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 4 +-- mods/ENTITIES/mobs_mc/pig.lua | 2 +- mods/ENTITIES/mobs_mc/rabbit.lua | 2 +- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index ae8fd25a3..9596d606a 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -4371,7 +4371,7 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake) -- increase health - if self.health < self.hp_max then + if not consume_food and self.health < self.hp_max then consume_food = true self.health = min(self.health + 4, self.hp_max) @@ -4381,41 +4381,40 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake) self.object:set_hp(self.health) end - - update_tag(self) - - -- make children grow quicker - if self.child == true then - consume_food = true - - -- deduct 10% of the time to adulthood - self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1) - end - -- feed and tame + self.food = (self.food or 0) + 1 - if not self.child and self.food >= feed_count then + if self.food >= feed_count then self.food = 0 - if breed and self.hornytimer == 0 and not self.horny then - self.horny = true - consume_food = true - end - if tame then - self.tamed = true - if not self.owner or self.owner == "" then self.owner = clicker:get_player_name() consume_food = true end end + if breed and not self.child and not consume_food + and self.hornytimer == 0 and not self.horny then + self.horny = true + consume_food = true + end -- make sound when fed so many times mob_sound(self, "random", true) end + + update_tag(self) + + -- make children grow quicker + if not consume_food and self.child == true then + consume_food = true + + -- deduct 10% of the time to adulthood + self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1) + end + -- if not in creative then take item if it was used if not minetest.is_creative_enabled(clicker:get_player_name()) and consume_food then diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 886a945b9..5dc417582 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -74,7 +74,7 @@ mcl_mobs:register_mob("mobs_mc:chicken", { fear_height = 4, on_rightclick = function(self, clicker) - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end end, diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index d72a6c0f9..fe04650cd 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -48,7 +48,7 @@ local cow_def = { run_end = 40, }, on_rightclick = function(self, clicker) - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end if mcl_mobs:protect(self, clicker) then return end if self.child then @@ -87,7 +87,7 @@ mooshroom_def.spawn_in_group_min = 4 mooshroom_def.spawn_in_group = 8 mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } } mooshroom_def.on_rightclick = function(self, clicker) - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end if mcl_mobs:protect(self, clicker) then return end if self.child then diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index b1958dc69..b88e88d49 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -99,7 +99,7 @@ mcl_mobs:register_mob("mobs_mc:pig", { local wielditem = clicker:get_wielded_item() -- Feed pig if wielditem:get_name() ~= "mcl_mobitems:carrot_on_a_stick" then - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end end if mcl_mobs:protect(self, clicker) then return end diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index c11167007..2d7bc5e7e 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -75,7 +75,7 @@ local rabbit = { }, on_rightclick = function(self, clicker) -- Feed, tame protect or capture - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end end, diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 412c0cbdb..3ab794c05 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -195,7 +195,7 @@ mcl_mobs:register_mob("mobs_mc:sheep", { on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() - if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end + if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end if mcl_mobs:protect(self, clicker) then return end if item:get_name() == "mcl_tools:shears" and not self.gotten and not self.child then