1
0
Fork 0

mcl_hunger: core.* → minetest.*

This commit is contained in:
Wuzzy 2019-02-05 21:14:28 +01:00
parent 0068508968
commit d9b6bae320
1 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
local org_eat = core.do_item_eat local org_eat = minetest.do_item_eat
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
-- Call on_rightclick if the pointed node defines it -- Call on_rightclick if the pointed node defines it
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
@ -28,7 +28,7 @@ core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, point
-- Don't allow eating when player has full hunger bar (some exceptional items apply) -- Don't allow eating when player has full hunger bar (some exceptional items apply)
if can_eat_when_full or (mcl_hunger.get_hunger(user) < 20) then if can_eat_when_full or (mcl_hunger.get_hunger(user) < 20) then
itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
for _, callback in pairs(core.registered_on_item_eats) do for _, callback in pairs(minetest.registered_on_item_eats) do
local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack) local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack)
if result then if result then
return result return result
@ -63,7 +63,7 @@ function mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_t
def = {} def = {}
if type(hp_change) ~= "number" then if type(hp_change) ~= "number" then
hp_change = 1 hp_change = 1
core.log("error", "Wrong on_use() definition for item '" .. item .. "'") minetest.log("error", "Wrong on_use() definition for item '" .. item .. "'")
end end
def.saturation = hp_change def.saturation = hp_change
def.replace = replace_with_item def.replace = replace_with_item