PlayerEvents.craftCompleted(event => {

    const player = event.player;
    const recipe = event.recipe;

    // Skontrolujeme, či recept obsahuje brush
    if (!recipe.ingredients.some(i => i.id === 'minecraft:brush')) return;

    // Crafting inventory (3x3 alebo 2x2)
    const grid = event.craftingInventory;

    for (let slot = 0; slot < grid.size(); slot++) {
        let item = grid.get(slot);

        if (item && item.id === 'minecraft:brush') {

            // Damage aktuálny
            let dmg = item.nbt?.Damage ?? 0;
            dmg++;

            // Max durability 64
            if (dmg >= 64) {
                // Brush sa zničí
                grid.set(slot, null);
            } else {
                // Brush ostane a získa damage
                const newBrush = Item.of('minecraft:brush');
                newBrush.nbt = { Damage: dmg };
                grid.set(slot, newBrush);
            }
        }
    }
});
