import { world } from '@minecraft/server';
import '../../spawn_loot/spawn_loot';

world.afterEvents.playerBreakBlock.subscribe(eventData => {
    const brokenBlock = eventData.brokenBlockPermutation;
    const block = eventData.block

    if (brokenBlock.type.id == "minecraft:short_grass" || brokenBlock.type.id == "minecraft:tall_grass"){
        block.dimension.spawnLoot(grassLootTable,block.center())
    }
    if (brokenBlock.type.id == "minecraft:vine"){
        block.dimension.spawnLoot(vinesLootTable,block.center())
    }

});



export const grassLootTable = {
    pools: [
    {
        rolls: 1,
        entries: [
            {
                item: 'rustic:chili_pepper_seeds',
                count: { min: 0, max: 1 },
                weight: 10
            },
            {
                item: 'rustic:tomato_seeds',
                count: { min: 0, max: 1 },
                weight: 10
            }
        ]
    }
    ]
}

export const vinesLootTable = {
    pools: [
    {
        rolls: 1,
        entries: [
            {
                item: 'rustic:grape_seeds',
                count: { min: 0, max: 1 },
                weight: 15
            }
        ]
    }
    ]
}