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

80 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Ae.js — transparentOwnerMorphNbt() (satır 808)
[← Ae.js](index.md) · [← Master](../../wiki.md)
Parça 8/38 · [önceki](transparentOwnerMorphNbt-7.md) · [sonraki](transparentOwnerMorphNbt-9.md)
```javascript
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);
```