1
0
Fork 0

Update api.lua

wood_api
SumianVoice 2022-07-18 23:30:46 +10:00 committed by cora
parent 69d1c26a15
commit c626c977d1
1 changed files with 20 additions and 20 deletions

View File

@ -4365,40 +4365,28 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake)
if not self.follow then if not self.follow then
return false return false
end end
-- can eat/tame with item in hand -- can eat/tame with item in hand
if self.nofollow or follow_holding(self, clicker) then if self.nofollow or follow_holding(self, clicker) then
local consume_food = false
-- if not in creative then take item
if not minetest.is_creative_enabled(clicker:get_player_name()) then
local item = clicker:get_wielded_item()
if not notake then item:take_item() end
clicker:set_wielded_item(item)
end
mob_sound(self, "eat", nil, true)
-- increase health -- increase health
self.health = self.health + 4
if self.health >= self.hp_max then if self.health < self.hp_max then
consume_food = true
self.health = self.hp_max self.health = min(self.health + 4, self.hp_max)
if self.htimer < 1 then if self.htimer < 1 then
self.htimer = 5 self.htimer = 5
end end
self.object:set_hp(self.health)
end end
self.object:set_hp(self.health)
update_tag(self) update_tag(self)
-- make children grow quicker -- make children grow quicker
if self.child == true then if self.child == true then
consume_food = true
-- deduct 10% of the time to adulthood -- deduct 10% of the time to adulthood
self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1) self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1)
@ -4412,8 +4400,9 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake)
self.food = 0 self.food = 0
if breed and self.hornytimer == 0 then if breed and self.hornytimer == 0 and not self.horny then
self.horny = true self.horny = true
consume_food = true
end end
if tame then if tame then
@ -4422,16 +4411,27 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake)
if not self.owner or self.owner == "" then if not self.owner or self.owner == "" then
self.owner = clicker:get_player_name() self.owner = clicker:get_player_name()
consume_food = true
end end
end end
-- make sound when fed so many times -- make sound when fed so many times
mob_sound(self, "random", true) mob_sound(self, "random", true)
end end
-- if not in creative then take item
if not minetest.is_creative_enabled(clicker:get_player_name()) and consume_food then
local item = clicker:get_wielded_item()
if not notake then
item:take_item()
mob_sound(self, "eat", nil, true)
end
clicker:set_wielded_item(item)
end
return true return true
end end
return false return false
end end