Files
MAPPET-ULTIMATE-WIKI/scripts/Ae/transparentOwnerMorphNbt-8.md

1.9 KiB
Raw Permalink Blame History

Ae.js — transparentOwnerMorphNbt() (satır 808)

← Ae.js · ← Master

Parça 8/38 · önceki · sonraki

    if (maps.morphs[name] === undefined)
    {
        saveSideOriginalMorph(player, state, side);
    }

    var wanted = maps.morphs[name];
    var had = maps.had[name];
    var current = morphNbtText(player);

    if (had && wanted !== "" && current !== wanted)
    {
        applyTargetMorph(player, wanted);
    }
    else if (!had && current !== "")
    {
        try { player.setMorph(null); } catch (e) {}
    }
}

function removePotionIfPresent(player, id)
{
    try
    {
        var potion = mappet.getPotion(id);
        if (potion != null && player.hasPotion(potion))
        {
            player.removePotion(potion);
        }
    }
    catch (e) {}
}

function clearBadPotions(player)
{
    for (var i = 0; i < BAD_POTIONS.length; i++)
    {
        removePotionIfPresent(player, BAD_POTIONS[i]);
    }
}

function applyPotionSafe(player, id, ticks, amplifier, particles)
{
    try
    {
        var potion = mappet.getPotion(id);
        if (potion != null)
        {
            player.applyPotion(potion, ticks, amplifier, particles);
            return true;
        }
    }
    catch (e) {}

    return false;
}

function applyOwnerResistance(player)
{
    if (applyPotionSafe(player, "resistance", RESISTANCE_TICKS, 4, false)) return;
    applyPotionSafe(player, "minecraft:resistance", RESISTANCE_TICKS, 4, false);
}

function protectOwner(c, owner, state)
{
    if (!owner || !isOwner(owner) || !state.active) return;

    try { owner.unlockPosition(); } catch (e1) {}
    try { owner.unlockRotation(); } catch (e2) {}

    clearBadPotions(owner);
    if (state.ownerVanished) applyOwnerVanishState(c, owner, state, false, false);