Skip to content

Commit

Permalink
use CompoundTag get functions for accessing NBT structures
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtThiemann committed Nov 26, 2021
1 parent b0cc379 commit 7611505
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Thanos.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Aternos\Thanos;

use Aternos\Nbt\Tag\CompoundTag;
use Aternos\Nbt\Tag\LongArrayTag;
use Aternos\Thanos\RegionDirectory\AnvilRegionDirectory;
use Aternos\Thanos\World\AnvilWorld;
Expand Down Expand Up @@ -79,15 +80,17 @@ public function snap(AnvilWorld $world): int
protected function getForceLoadedChunks(AnvilRegionDirectory $regionDirectory): array
{
$chunksDat = $regionDirectory->readDataFile("chunks.dat");
if(is_null($chunksDat)) {
if(!$chunksDat instanceof CompoundTag) {
return [];
}
if(!isset($chunksDat["data"]) || !isset($chunksDat["data"]["Forced"])) {

$data = $chunksDat->getCompound("data");
if($data === null) {
return [];
}

$list = $chunksDat["data"]["Forced"];
if(!($list instanceof LongArrayTag)) {
$list = $data->getLongArray("Forced");
if($list === null) {
return [];
}

Expand Down

0 comments on commit 7611505

Please sign in to comment.