Fixed stew/bowl duplication bug (#3995)

Fixed #3991, copied some code over from mcl_potions

Reviewed-on: MineClone2/MineClone2#3995
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
This commit is contained in:
the-real-herowl 2023-11-03 22:39:21 +00:00 committed by the-real-herowl
parent 69dc013799
commit 262100be24
1 changed files with 18 additions and 4 deletions

View File

@ -53,13 +53,27 @@ local function get_random_effect()
return effects[keys[math.random(#keys)]] return effects[keys[math.random(#keys)]]
end end
local function eat_stew(itemstack, placer, pointed_thing) local function eat_stew(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
if user and not user:get_player_control().sneak then
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
end
elseif pointed_thing.type == "object" then
return itemstack
end
local e = itemstack:get_meta():get_string("effect") local e = itemstack:get_meta():get_string("effect")
local f = effects[e] local f = effects[e]
if not f then if not f then
f = get_random_effect() f = get_random_effect()
end end
if f(itemstack,placer,pointed_thing) then if f(itemstack, user, pointed_thing) then
return "mcl_core:bowl" return "mcl_core:bowl"
end end
end end