import { damageEntityHeldItem, spawnLootAtBlock } from '../../utils/utils.js';
import { FSTags } from '../../constants.js';
import { Keys as x } from '../../ftb_bedrock_bedrock_utils_dist_bedrock_utils.js';

const LOOT_AMOUNT = 2;
class TrowelItemComponent {
    onMineBlock(event) {
        damageEntityHeldItem(event.source, 1, event.itemStack);
    }
    onUseOn(event) {
        const block = event.block;
        const itemStack = event.itemStack;
        if (FSTags.DirtLikeBlocks.includes(block?.typeId)) {
            for (let i = 0; i < LOOT_AMOUNT; i++) {
                spawnLootAtBlock(event.block, x.SIEVES + "/world/rocks");
            }
            damageEntityHeldItem(event.source, 1, itemStack);
        }
    }
}

export { TrowelItemComponent };
