import { Player } from "@minecraft/server";
import { EntityHelper } from "../../entities/utils/entityHelper";

export const HEALTH_ESSENCE = {
    _healthEssenceItemId: "piki_beyondsurvival:health_essence",
    _offhandEffect: [
        EntityHelper.createEntityEffect("regeneration", 15, 0, true),
        EntityHelper.createEntityEffect("resistance", 15, 0, true)
    ],

    /**
     * 
     * @param {Player} player 
     */
    applyOffhandEffect: function(player) {
        for (const effect of this._offhandEffect) {
            const {effectType, duration, amplifier, showParticles} = effect
            if (player.getEffect(effectType)) continue
            player.addEffect(effectType, duration, {amplifier: amplifier, showParticles: showParticles})
        }
    },
    /**
     * 
     * @param {Player} player 
     */
    isOffhandEquipped: function(itemStackId) {
        return itemStackId == this._healthEssenceItemId;
    }
    
}