Skip to content

Commit

Permalink
Fixes for call on null errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Falkirks committed Jan 17, 2015
1 parent 3680ba2 commit d3f5dbe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/minereset/Mine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/minereset/MineResetTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit d3f5dbe

Please sign in to comment.