Files

1.8 KiB
Raw Permalink Blame History

potion_rain.js — q() (satır 160)

← potion_rain.js · ← Master

Parça 4/11 · önceki · sonraki

function vanillaNbt(k, cfg, owner) {
    var motion = 'Motion:[' + fx3((Math.random() - 0.5) * 0.1) + 'd,' + fx3(-0.3 - Math.random() * 0.3) + 'd,' +
        fx3((Math.random() - 0.5) * 0.1) + 'd]';
    if (k.key === "potion") {
        return '{Potion:{id:"minecraft:splash_potion",Count:1b,tag:{Potion:"' + potionAt(cfg.pot) + '"}},' +
            motion + ',ownerName:' + q(owner) + '}';
    }
    if (k.key === "arrow") {
        // yerden alinamaz; vanilla ok yerde 1200 tick sonra silinir, "life"
        // o sayacin baslangici: Kalma suresi kadar kalip kaybolur
        return '{' + motion + ',pickup:0b,damage:2.0d,life:' + Math.round(1200 - cfg.stay * 20) + 's}';
    }
    return '{' + motion + ',ownerName:' + q(owner) + '}';
}

// =====================================================================
//  ALAN: ESIT VE SIK DAGILIM
// =====================================================================
// Alani hucrelere bol (hucre boyu ~ alan / beklenen adet, en az 1 blok),
// karistir; her dusus siradaki hucreye (hucre icinde rastgele) gider.
function buildCells(cfg, safe, expected) {
    var area = cfg.shape === 1 ? cfg.width * cfg.depth : Math.PI * cfg.radius * cfg.radius;
    var cell = Math.max(1, Math.sqrt(area / Math.max(1, expected)));
    var cells = [];
    var hw, hd, x, z;
    if (cfg.shape === 1) {
        hw = cfg.width / 2; hd = cfg.depth / 2;
        for (x = -hw + cell / 2; x < hw; x += cell) {
            for (z = -hd + cell / 2; z < hd; z += cell) {
                if (safe > 0 && x * x + z * z < safe * safe) continue;
                cells.push([x, z]);
            }
        }
    } else {
        var r = cfg.radius;