import { ItemStack, system } from "@minecraft/server";
system.beforeEvents.startup.subscribe((event) => {
    const { blockComponentRegistry } = event;
    blockComponentRegistry.registerCustomComponent("rp_pr:collect_apricorn", {
        onPlayerInteract(arg0, arg1) {
            const { block } = arg0;
            const { params } = arg1;
            const itemStack = new ItemStack(params.drop, 1);
            block.dimension.spawnItem(itemStack, block.location);
            block.setPermutation(block.permutation.withState("pr:has_apricorn", false));
        }
    });
    blockComponentRegistry.registerCustomComponent("rp_pr:sprout_apricorn", {
        onRandomTick(arg0, arg1) {
            const { block } = arg0;
            const randomChance = Math.round(Math.random() * 100);
            if (randomChance < 20) {
                block.setPermutation(block.permutation.withState("pr:has_apricorn", true));
            }
        }
    });
});
