Files

55 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.
# KlonlanmaLal.js — updateClone() (satır 340)
[← KlonlanmaLal.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](updateClone-2.md)
```javascript
function updateClone(c, owner, clone, index, count, tick, ownerMoving) {
var world = c.getWorld();
var op = owner.getPosition();
var cp = clone.getPosition();
var sprintBoost = owner.isSprinting() ? 0.55 : 0.0;
var radius = CLONE_RADIUS + sprintBoost;
var off = offsetFor(owner, index, count, radius, tick, ownerMoving);
var wave = ownerMoving ? Math.sin((tick + index * 13) * 0.18) * 0.05 : 0;
var tx = op.x + off.x;
var tz = op.z + off.z;
var ty = groundY(world, tx, op.y, tz);
if (owner.isSneaking()) {
tx *= 0.985;
tx += op.x * 0.015;
tz *= 0.985;
tz += op.z * 0.015;
}
ty = groundY(world, tx, op.y, tz);
var dx = tx - cp.x;
var dy = clamp(ty - cp.y, -0.75, 0.75);
var dz = tz - cp.z;
var far = (dx * dx + (ty - cp.y) * (ty - cp.y) + dz * dz) > 36;
var flatClose = (dx * dx + dz * dz) < 0.035 && Math.abs(ty - cp.y) < 0.12;
if (!ownerMoving && flatClose) {
clone.setMotion(0, 0, 0);
clone.setPosition(cp.x, ty, cp.z);
} else if (far) {
clone.setPosition(tx, ty, tz);
clone.setMotion(0, 0, 0);
} else {
var smooth = ownerMoving ? FOLLOW_SMOOTH : IDLE_SMOOTH;
clone.setMotion(dx * 0.55, 0, dz * 0.55);
clone.setPosition(cp.x + dx * smooth, cp.y + dy * 0.55, cp.z + dz * smooth);
}
var yaw = owner.getYaw() + (ownerMoving ? Math.sin((tick + index * 9) * 0.12) * 2.0 : idleYawOffset(index));
var pitch = owner.getPitch() + wave * 8.0;
clone.setRotations(jfloat(pitch), jfloat(yaw), jfloat(yaw));
applyHiddenName(clone, owner.getName());
copyFlags(owner, clone);
```