From c871e0d388818e96134708c49b0777200d2e9c50 Mon Sep 17 00:00:00 2001 From: coil <4219797-coil0@users.noreply.gitlab.com> Date: Sat, 17 Aug 2019 22:23:13 -0400 Subject: [PATCH] Use API to replace beer mug Mods overriding minetest.do_item_eat can ensure that an empty glass is given only if the item was actually used. Fixes #18. --- homedecor_gastronomy/init.lua | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/homedecor_gastronomy/init.lua b/homedecor_gastronomy/init.lua index 2d0a3996..68262e40 100644 --- a/homedecor_gastronomy/init.lua +++ b/homedecor_gastronomy/init.lua @@ -164,18 +164,7 @@ homedecor.register("beer_mug", { on_use = function(itemstack, user, pointed_thing) local inv = user:get_inventory() if not creative.is_enabled_for(user:get_player_name()) then - if inv:room_for_item("main", "vessels:drinking_glass 1") then - inv:add_item("main", "vessels:drinking_glass 1") - else - local pos = user:get_pos() - local dir = user:get_look_dir() - local fdir = minetest.dir_to_facedir(dir) - local pos_fwd = { x = pos.x + homedecor.fdir_to_fwd[fdir+1][1], - y = pos.y + 1, - z = pos.z + homedecor.fdir_to_fwd[fdir+1][2] } - minetest.add_item(pos_fwd, "vessels:drinking_glass 1") - end - minetest.do_item_eat(2, nil, itemstack, user, pointed_thing) + minetest.do_item_eat(2, "vessels:drinking_glass 1", itemstack, user, pointed_thing) return itemstack end end