diff --git a/items.lua b/items.lua index b9a5179..5462c28 100644 --- a/items.lua +++ b/items.lua @@ -417,7 +417,6 @@ minetest.register_node("hell:apple", { groups = {fleshy=3, dig_immediate=3}, sounds = default.node_sound_defaults(), furnace_burntime = 6, - on_use = minetest.item_eat(-5, "hell:blood_extracted 2"), }) minetest.register_alias("nether:apple", "hell:apple") diff --git a/portal.lua b/portal.lua index 1ee1e4c..36d5cb0 100644 --- a/portal.lua +++ b/portal.lua @@ -372,22 +372,20 @@ local function hell_port(player, pos) return true end -minetest.register_on_item_eat(function(_, _, itemstack, user, _) - if not user or itemstack:is_empty() then - return - end - +minetest.override_item("hell:apple", { + on_use = function(itemstack, user, pointed_thing) local inv = user:get_inventory() if not inv then return end - if itemstack:get_name() == "hell:apple" then + if hell_port(user, vector.round(user:get_pos())) then itemstack:take_item() - if hell_port(user, vector.round(user:get_pos())) then - return itemstack - end + return itemstack + else + return minetest.do_item_eat(-5, "hell:blood_extracted 2", itemstack, user, pointed_thing) end -end) + end, +}) if hell.HELL_REALM_ENABLED then -- Use the Portal API to add a portal type which goes to the Hell