55 lines
1.8 KiB
Markdown
55 lines
1.8 KiB
Markdown
# Grim2.js — restoreStep() (satır 359)
|
||
|
||
[← Grim2.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("acil_buckets");
|
||
var idList = c.getValue("acil_id_list");
|
||
var tileList = c.getValue("acil_tile_list");
|
||
var step = Number(c.getValue("acil_restore_step"));
|
||
var cx = Number(c.getValue("acil_cx"));
|
||
var cy = Number(c.getValue("acil_cy"));
|
||
var cz = Number(c.getValue("acil_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;
|
||
```
|