diff --git a/plugin.yml b/plugin.yml index 29efe23..e667177 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: MineReset main: minereset\MineReset -version: 2.0.1 +version: 2.0.2 author: Falk api: [1.0.0] load: POSTWORLD diff --git a/src/minereset/Mine.php b/src/minereset/Mine.php index 7e98927..d47b2b3 100644 --- a/src/minereset/Mine.php +++ b/src/minereset/Mine.php @@ -37,13 +37,14 @@ public function getData(){ } public function resetMine(){ $chunks = []; - for ($x = $this->getA()->getX() >> 4; $x <= $this->getB()->getX() >> 4; $x ++){ - for ($z = $this->getA()->getZ() >> 4; $z <= $this->getB()->getZ() >> 4; $z ++) { - $chunk = $this->level->getChunk($x, $z, true); + for ($x = $this->getA()->getX(); $x <= $this->getB()->getX(); $x += 16){ + for ($z = $this->getA()->getZ(); $z <= $this->getB()->getZ(); $z += 16) { + $chunk = $this->level->getChunk($x >> 4, $z >> 4, true); $chunkClass = get_class($chunk); - $chunks[Level::chunkHash($x, $z)] = $chunk->toBinary(); + $chunks[Level::chunkHash($x >> 4, $z >> 4)] = $chunk->toBinary(); } } + //var_dump($chunks); $resetTask = new MineResetTask($chunks, $this->a, $this->b, $this->data, $this->getLevel()->getId(), $this->base->getRegionBlocker()->blockZone($this->a, $this->b, $this->level), $chunkClass); $this->base->scheduleReset($resetTask); } diff --git a/src/minereset/MineResetTask.php b/src/minereset/MineResetTask.php index 9b16e7f..43e3912 100644 --- a/src/minereset/MineResetTask.php +++ b/src/minereset/MineResetTask.php @@ -47,7 +47,8 @@ public function onRun(){ $a = rand(0, end($sum)); for ($l = 0; $l < count($sum); $l++) { if ($a <= $sum[$l]) { - $chunks[Level::chunkHash($x >> 4, $z >> 4)]->setBlock($x & 0x0f, $y & 0x7f, $z & 0x0f, $id[$l] & 0xff, 0); + $hash = Level::chunkHash($x >> 4, $z >> 4); + if(isset($chunks[$hash])) $chunks[$hash]->setBlock($x & 0x0f, $y & 0x7f, $z & 0x0f, $id[$l] & 0xff, 0); $l = count($sum); } }