From d1ca012ea01b7a91cee846c742d5686c8966f199 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 27 Mar 2021 12:27:46 +0100 Subject: [PATCH] small API fix --- mods/ITEMS/mcl_cauldrons/api.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_cauldrons/api.lua b/mods/ITEMS/mcl_cauldrons/api.lua index ef77ae19a7..5383e15dc4 100644 --- a/mods/ITEMS/mcl_cauldrons/api.lua +++ b/mods/ITEMS/mcl_cauldrons/api.lua @@ -1,28 +1,29 @@ local has_doc = minetest.get_modpath(minetest.get_current_modname()) -local function survival_give(inv, itemstack) +local function survival_give(inv, original_item, itemstack) if inv:room_for_item("main", itemstack) then inv:add_item("main", itemstack) + return original_item:take_item() else minetest.add_item(user:get_pos(), itemstack) + return original_item end end -local function creative_give(inv, itemstack) - if inv:room_for_item("main", itemstack) then +local function creative_give(inv, original_item, itemstack) + if not inv:contains_item("main", itemstack) then inv:add_item("main", itemstack) - else - minetest.add_item(user:get_pos(), itemstack) + return original_item end end -local function give_item(user, itemstack) +local function give_item(user, original_item, itemstack) local inv = user:get_inventory() if inv then if minetest.is_creative_enabled(user:get_player_name()) then - creative_give(inv, itemstack) + creative_give(inv, original_item, itemstack) else - survival_give(inv, itemstack) + survival_give(inv, original_item, itemstack) end end return itemstack @@ -107,7 +108,7 @@ function mcl_cauldrons.take_cauldron(pos, itemstack, user, sounds) if user and not minetest.is_creative_enabled(user:get_player_name()) then minetest.set_node(pos, {name="mcl_cauldrons:cauldron"}) if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end - return give_item(user, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket)) + return give_item(user, original, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket)) else minetest.set_node(pos, {name="mcl_cauldrons:cauldron"}) if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end