59 lines
1.2 KiB
Markdown
59 lines
1.2 KiB
Markdown
# NullObey.js — main() (satır 14)
|
||
|
||
[← NullObey.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
```javascript
|
||
function main(c)
|
||
{
|
||
var source = c.getSubject();
|
||
|
||
if (!source)
|
||
{
|
||
return;
|
||
}
|
||
|
||
var result = source.rayTrace(32);
|
||
|
||
if (!result || !result.isEntity())
|
||
{
|
||
return;
|
||
}
|
||
|
||
var target = result.getEntity();
|
||
|
||
if (!target || !target.isPlayer())
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (target.isSame(source))
|
||
{
|
||
return;
|
||
}
|
||
|
||
var sourcePos = source.getPosition();
|
||
var targetPos = target.getPosition();
|
||
|
||
var sourceEyes = {
|
||
x: sourcePos.x,
|
||
y: sourcePos.y + source.getEyeHeight(),
|
||
z: sourcePos.z
|
||
};
|
||
|
||
var targetEyes = {
|
||
x: targetPos.x,
|
||
y: targetPos.y + target.getEyeHeight(),
|
||
z: targetPos.z
|
||
};
|
||
|
||
var look = calculateLookRotation(targetEyes, sourceEyes);
|
||
|
||
// sadece kafayı aşağı eğ
|
||
look.pitch = look.pitch + 35;
|
||
|
||
target.setRotations(look.pitch, look.yaw, 0);
|
||
target.lockRotation(look.yaw, look.pitch, 0);
|
||
target.lockPosition(targetPos.x, targetPos.y, targetPos.z);
|
||
}
|
||
```
|