Files

55 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.
# Lal2.js — restoreStep() (satır 359)
[← Lal2.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](restoreStep-2.md)
```javascript
function restoreStep(c) {
if (String(mappet.get(STATE_KEY)) !== "1") return;
if (String(mappet.get(PHASE_KEY)) !== "restoring") return;
mappet.set(PHASE_KEY, "restoring");
var world = c.getWorld();
var buckets = c.getValue("kapla_buckets");
var idList = c.getValue("kapla_id_list");
var tileList = c.getValue("kapla_tile_list");
var step = Number(c.getValue("kapla_restore_step"));
var cx = Number(c.getValue("kapla_cx"));
var cy = Number(c.getValue("kapla_cy"));
var cz = Number(c.getValue("kapla_cz"));
if (!buckets || !idList || step < 0) {
mappet.set(STATE_KEY, "0");
mappet.set(PHASE_KEY, "idle");
mappet.set(PULL_KEY, "0");
world.playSound("minecraft:entity.player.levelup", cx, cy + 1, cz, 2.5, 1.25);
world.playSound(SOUND_RESTORE, cx, cy + 1, cz, 2.0, 1.1);
return;
}
var list = buckets[step] || [];
for (var i = 0; i < list.length; i += 6) {
var x = list[i];
var y = list[i + 1];
var z = list[i + 2];
var id = idList[list[i + 3]];
var meta = list[i + 4];
var tileIdx = list[i + 5];
var state = mappet.createBlockState(id, meta);
if (tileIdx >= 0 && tileList && tileList[tileIdx]) {
try {
world.setTileEntity(x, y, z, state, mappet.createCompound(String(tileList[tileIdx])));
} catch (e1) {
world.setBlock(state, x, y, z);
}
} else {
world.setBlock(state, x, y, z);
}
}
if (list.length > 0) {
var t = step / SPREAD_TICKS;
```