local mod_name = minetest.get_current_modname()
local mod_path = minetest.get_modpath(mod_name)
local S = minetest.get_translator(mod_name)


aom_creative = {}
aom_creative.disable_take_item = false

-- don't take items when in creative if it's the last item
local core_item_place = minetest.item_place_node
minetest.item_place_node = function(itemstack, placer, pointed_thing, param2, prevent_after_place, ...)
    local ret, pos = core_item_place(ItemStack(itemstack), placer, pointed_thing, param2, prevent_after_place, ...)
    local is_creative = core.is_player(placer) and minetest.is_creative_enabled(placer:get_player_name())
    -- don't take the last item in the stack
    if is_creative then
        return ((aom_creative.disable_take_item or ret:is_empty()) and itemstack or ret), pos
    else
        return ret, pos
    end
end
