Files

53 lines
1.8 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.
# klon_siluet.js — startLoop() (satır 549)
[← klon_siluet.js](index.md) · [← Master](../../wiki.md)
Parça 1/4 · [sonraki](startLoop-2.md)
```javascript
function startLoop(c, p, runId)
{
var name = String(p.getName());
var pos = p.getPosition();
var prevX = pos.x, prevY = pos.y, prevZ = pos.z;
var tick = 0;
var morph = null; // ham siluet morph'u (kendi morphun veya menuden secilen)
var ghost = null; // saydamlik uygulanmis kopya (displayMorph'a giden)
var ghostKey = -1; // ghost hangi saydamlik icin uretildi
var kilikKey = null; // en son uygulanan kilik NBT'si
var peak = PEAK_BASE; // olculen tavan hiz (Essentials /speed'e gore kendini ayarlar)
function loop(ctx)
{
var pl = resolvePlayer(ctx, name);
if (!pl) return; // oyuncu cikti -> dongu biter
var st = pl.getStates();
if (st.getNumber(ST_ON) !== 1) return; // kapatildi
if (st.getNumber(ST_RUN) !== runId) return; // yeni dongu basladi, bu eski
tick++;
if (tick % 5 === 0) st.setNumber(ST_ALIVE, nowMs());
// --- morph tazeleme (menuden secilen kilik veya kendi morphun) ---
if (morph === null || tick % MORPH_SYNC === 0)
{
var custom = customNbt(st);
var fresh = null;
if (custom !== "")
{
// secili kilik: sadece degistiginde yeniden kur
if (custom !== kilikKey) { try { fresh = mappet.createMorph(custom); } catch (eM) {} }
}
else
{
fresh = visualMorph(pl);
}
kilikKey = custom;
if (!fresh && morph === null) fresh = visualMorph(pl); // kilik parse edilemediyse
```