/**
 * Not sure whether this should even be its own seperate file, but I guess better to have it here rather than a random spot. I'll maybe clean this up later on.
 */
import { world } from "@minecraft/server";
import { MinecraftEffectTypes } from "../data/vanilla-data";
export function initMedkit() {
    world.beforeEvents.worldInitialize.subscribe(result => {
        result.itemComponentRegistry.registerCustomComponent("oct_db:medkit", {
            onCompleteUse: (result) => {
                const player = result.source;
                player.resetLimbHealth(); // Set limbs to full hp
                // Reset effects
                const negativeEffectsArr = [MinecraftEffectTypes.Blindness, MinecraftEffectTypes.Darkness, MinecraftEffectTypes.FatalPoison, MinecraftEffectTypes.Hunger, MinecraftEffectTypes.Infested, MinecraftEffectTypes.MiningFatigue, MinecraftEffectTypes.Nausea, MinecraftEffectTypes.Oozing, MinecraftEffectTypes.Poison, MinecraftEffectTypes.Slowness, MinecraftEffectTypes.Weakness, MinecraftEffectTypes.Weaving, MinecraftEffectTypes.Wither];
                const playerCurrentEffects = player.getEffects();
                for (const effect of playerCurrentEffects) {
                    if (!negativeEffectsArr.includes((`minecraft:${effect.typeId}`)))
                        continue;
                    player.removeEffect(effect.typeId);
                }
                ;
                // VFX
                player.dimension.spawnParticle("oct_db:healing.root", player.location);
                player.playSound(`chime.amethyst_block`, { pitch: 1.5 });
            }
        });
    });
}
;
