-- Right-clicking this node with a bare hand and no diamonds in the inventory will not give you anything
-- Right-clicking with any item or diamonds in your inventory, however, gives you three diamonds as expected.
minetest.register_node("bug_test:bug_test", {
	description = "Bug Test",
	on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
		local item = ItemStack("default:diamond 3")
		local inv = clicker:get_inventory()

		if inv:room_for_item("main", item) then
			inv:add_item("main", item)
		end

		return itemstack
	end
})