89 lines
1.9 KiB
Markdown
89 lines
1.9 KiB
Markdown
# Ae.js — transparentOwnerMorphNbt() (satır 808)
|
||
|
||
[← Ae.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 17/38 · [önceki](transparentOwnerMorphNbt-16.md) · [sonraki](transparentOwnerMorphNbt-18.md)
|
||
|
||
```javascript
|
||
var max = state.radius - 1.0;
|
||
var y = pos.y;
|
||
|
||
if (Math.abs(pos.y - state.centerY) > 5.0)
|
||
{
|
||
y = state.centerY;
|
||
}
|
||
|
||
if (d <= max && y === pos.y) return;
|
||
|
||
var dx = pos.x - state.centerX;
|
||
var dz = pos.z - state.centerZ;
|
||
if (d < 0.01)
|
||
{
|
||
dx = 1.0;
|
||
dz = 0.0;
|
||
d = 1.0;
|
||
}
|
||
|
||
var x = state.centerX + (dx / d) * max;
|
||
var z = state.centerZ + (dz / d) * max;
|
||
entity.setPosition(x, y, z);
|
||
}
|
||
|
||
function forceIntoDomain(c, entity, state, anchor)
|
||
{
|
||
if (!entity) return;
|
||
|
||
try
|
||
{
|
||
if (anchor && entity.getDimension && entity.getDimension() !== state.dimension)
|
||
{
|
||
c.executeCommand("/tp " + entity.getName() + " " + anchor.getName());
|
||
}
|
||
}
|
||
catch (e1) {}
|
||
|
||
try
|
||
{
|
||
entity.unlockPosition();
|
||
}
|
||
catch (e2) {}
|
||
|
||
try
|
||
{
|
||
entity.setPosition(state.centerX, state.centerY, state.centerZ);
|
||
}
|
||
catch (e3) {}
|
||
|
||
try
|
||
{
|
||
entity.setMotion(0, 0, 0);
|
||
}
|
||
catch (e4) {}
|
||
}
|
||
|
||
function keepTargetTrapped(c, target, state, owner)
|
||
{
|
||
if (!target) return;
|
||
|
||
try
|
||
{
|
||
if (target.getDimension && target.getDimension() !== state.dimension)
|
||
{
|
||
forceIntoDomain(c, target, state, owner);
|
||
return;
|
||
}
|
||
}
|
||
catch (e1) {}
|
||
|
||
var pos = target.getPosition();
|
||
if (horizontalDistance(pos, state) > state.radius - 1.0 || Math.abs(pos.y - state.centerY) > 5.0)
|
||
{
|
||
forceIntoDomain(c, target, state, owner);
|
||
if (state.tick % 10 === 0)
|
||
{
|
||
target.send(TAG + "\u00a7cKacamazsin.");
|
||
}
|
||
return;
|
||
}
|
||
```
|