import { ItemStack, } from '@minecraft/server';
import { decreaseItemAmountInHand, getItemInSlot } from '../../util/utils';
export default class BloomingWiltComponent {
    onTick(e) {
        e.dimension.getEntities({ location: e.block.location, maxDistance: 1 }).forEach((entity) => entity.addEffect('wither', 20, { amplifier: 2 }));
    }
    onPlayerInteract(e) {
        if (!e.player)
            return;
        const heldItem = getItemInSlot(e.player);
        if (heldItem?.typeId === 'minecraft:bone_meal') {
            const loc = e.block.center();
            const itemStack = new ItemStack('twb_wisu:blooming_wilt', 1);
            e.dimension.spawnItem(itemStack, loc);
            e.dimension.spawnParticle('minecraft:crop_growth_emitter', loc);
            e.dimension.playSound('item.bone_meal.use', e.block);
            decreaseItemAmountInHand(e.player);
        }
    }
}
