1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00

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.
This commit is contained in:
coil 2019-08-17 22:23:13 -04:00
parent d17ec1d978
commit c871e0d388
No known key found for this signature in database
GPG Key ID: 2BCEED3C1F732DE0

View File

@ -164,18 +164,7 @@ homedecor.register("beer_mug", {
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local inv = user:get_inventory() local inv = user:get_inventory()
if not creative.is_enabled_for(user:get_player_name()) then if not creative.is_enabled_for(user:get_player_name()) then
if inv:room_for_item("main", "vessels:drinking_glass 1") then minetest.do_item_eat(2, "vessels:drinking_glass 1", itemstack, user, pointed_thing)
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)
return itemstack return itemstack
end end
end end