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