let SUGAR_WATER_ID = "the_bumblezone:sugar_water_block";
let WATER_BOTTLE_ID = "minecraft:potion";
let EMPTY_BOTTLE_ID = 'minecraft:glass_bottle';

onEvent('recipes', event => {
	event.shaped('8x the_bumblezone:sugar_water_bottle', [
		'BBB',
		'BSB',
		'BBB'
	  ], {
		S: 'the_bumblezone:sugar_water_bucket',
		B: 'minecraft:glass_bottle'
	  })
	  
	event.shaped('4x the_bumblezone:sugar_water_bottle', [
		' B ',
		'BSB',
		' B '
	  ], {
		S: 'the_bumblezone:sugar_water_bucket',
		B: 'minecraft:glass_bottle'
	  })
	  
	event.shapeless('1x the_bumblezone:sugar_water_bottle', ['the_bumblezone:sugar_water_bucket','minecraft:glass_bottle'])
})

const itemInventory = (item, player) => {
    let index = player.inventory.find(Item.of("minecraft:potion", '{Potion:"minecraft:water"}'));
    if (index != -1) {
        let item = player.inventory.get(index);
        return item;
    }
    return null;
}

onEvent('item.right_click', event => {
  let blockId = event.player.rayTrace()?.block?.id
  if (blockId != null && blockId == SUGAR_WATER_ID) {
	if (event.item.test(Item.of('minecraft:glass_bottle'))) {
		event.cancel();
		event.item.count -= 1
		event.player.giveInHand('1x the_bumblezone:sugar_water_bottle');
	}
  }
});