Files

51 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.
# Grim2.js — spreadStep() (satır 291)
[← Grim2.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](spreadStep-2.md)
```javascript
function spreadStep(c) {
if (String(mappet.get(STATE_KEY)) !== "1") return;
if (String(mappet.get(PHASE_KEY)) !== "spreading") return;
var world = c.getWorld();
var buckets = c.getValue("acil_buckets");
var step = Number(c.getValue("acil_step"));
var targetId = String(c.getValue("acil_target_id"));
var targetMeta = Number(c.getValue("acil_target_meta"));
var cx = Number(c.getValue("acil_cx"));
var cy = Number(c.getValue("acil_cy"));
var cz = Number(c.getValue("acil_cz"));
if (String(mappet.get(PULL_KEY)) === "1") {
var restoreFrom = step - 1;
if (restoreFrom < 0) restoreFrom = 0;
if (restoreFrom > SPREAD_TICKS) restoreFrom = SPREAD_TICKS;
c.setValue("acil_restore_step", restoreFrom);
beginRestore(c, world, cx, cy, cz, true);
return;
}
if (!buckets || step > SPREAD_TICKS) {
mappet.set(PHASE_KEY, "holding");
world.playSound(SOUND_DONE, cx, cy + 1, cz, 3.0, 1.2);
c.setValue("acil_hold_ticks", 0);
c.scheduleScript("holdStep", HOLD_CHECK_INTERVAL);
return;
}
var target = mappet.createBlockState(targetId, targetMeta);
var list = buckets[step] || [];
for (var i = 0; i < list.length; i += 6) {
world.setBlock(target, list[i], list[i + 1], list[i + 2]);
}
if (list.length > 0) {
var t = step / SPREAD_TICKS;
world.playSound(SOUND_GROW, cx, cy + 1, cz, 1.2, 0.65 + t * 0.8);
if (step % 8 === 0) world.playSound(SOUND_PLACE, cx, cy + 1, cz, 0.8, 0.75 + t * 0.6);
spawnRingParticles(world, cx, cy, cz, Math.max(1, t * RADIUS));
}
```