80 lines
1.9 KiB
Markdown
80 lines
1.9 KiB
Markdown
# 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);
|
||
```
|