Fix fake milk drinking before end of eat delay

This commit is contained in:
Wuzzy 2017-05-23 02:14:43 +02:00
parent fa3cd83f5a
commit be79ade294
1 changed files with 11 additions and 8 deletions

View File

@ -132,6 +132,15 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
stack_max = 64, stack_max = 64,
}) })
local drink_milk = function(itemstack, player, pointed_thing)
local bucket = minetest.do_item_eat(0, "bucket:bucket_empty", itemstack, player, pointed_thing)
-- Check if we were allowed to drink this (eat delay check)
if bucket:get_name() ~= "mcl_mobitems:milk_bucket" then
mcl_hunger.stop_poison(player)
end
return bucket
end
-- TODO: Clear *all* status effects -- TODO: Clear *all* status effects
minetest.register_craftitem("mcl_mobitems:milk_bucket", { minetest.register_craftitem("mcl_mobitems:milk_bucket", {
description = "Milk", description = "Milk",
@ -140,14 +149,8 @@ minetest.register_craftitem("mcl_mobitems:milk_bucket", {
inventory_image = "mcl_mobitems_bucket_milk.png", inventory_image = "mcl_mobitems_bucket_milk.png",
wield_image = "mcl_mobitems_bucket_milk.png", wield_image = "mcl_mobitems_bucket_milk.png",
-- Clear poisoning when used -- Clear poisoning when used
on_place = function(itemstack, player, pointed_thing) on_place = drink_milk,
mcl_hunger.stop_poison(player) on_secondary_use = drink_milk,
return minetest.do_item_eat(0, "bucket:bucket_empty", itemstack, player, pointed_thing)
end,
on_secondary_use = function(itemstack, player, pointed_thing)
mcl_hunger.stop_poison(player)
return minetest.do_item_eat(0, "bucket:bucket_empty", itemstack, player, pointed_thing)
end,
stack_max = 1, stack_max = 1,
groups = { food = 3, can_eat_when_full = 1 }, groups = { food = 3, can_eat_when_full = 1 },
}) })