@@ -51,17 +51,17 @@ class MCStructure
5151 public const LAYER_BLOCKS = 0 ;
5252 public const LAYER_LIQUIDS = 1 ;
5353 /** @var Vector3 */
54- private $ structure_world_origin ;
54+ private Vector3 $ structure_world_origin ;
5555 /** @var int */
56- private $ format_version ;
56+ private int $ format_version ;
5757 /** @var Vector3 */
58- private $ size ;
58+ private Vector3 $ size ;
5959 /** @var PalettedBlockArray[] */
60- private $ blockLayers = [];
60+ private array $ blockLayers = [];
6161 /** @var array|CompoundTag[] */
62- private $ entities = [];
62+ private array $ entities = [];
6363 /** @var array|CompoundTag[] */
64- private $ blockEntities = [];
64+ private array $ blockEntities = [];
6565
6666 /**
6767 * Parses a *.mcstructure file
@@ -123,7 +123,7 @@ private static function parseVec3(CompoundTag $nbt, string $tagName, bool $optio
123123 private function parseStructure (CompoundTag $ structure ): void
124124 {
125125 $ blockIndicesList = $ structure ->getListTag ('block_indices ' );//list<list<int>>
126- $ entitiesList = $ structure ->getListTag ('entities ' );
126+ # $entitiesList = $structure->getListTag('entities');
127127 #var_dump($entitiesList->toString(2));
128128 $ paletteCompound = $ structure ->getCompoundTag ('palette ' );
129129 #$this->parseEntities($entitiesList);//TODO
@@ -170,10 +170,12 @@ private function parseBlockLayers(?CompoundTag $paletteCompound, ?ListTag $block
170170// }
171171// }
172172 $ offset = (int )(($ x * $ l * $ h ) + ($ y * $ l ) + $ z );
173+ /** @var ListTag<IntTag> $tag */
174+ if (!$ tag instanceof ListTag) continue ;
173175
174176 //block layer
175- /** @var ListTag<IntTag> $tag */
176- $ tag = $ blockIndicesList ->get (0 );
177+ if ( $ blockIndicesList -> isset ( 0 )){
178+ $ tag = $ blockIndicesList ->get (0 );
177179 $ blockLayer = $ tag ->getAllValues ();
178180 if (($ i = $ blockLayer [$ offset ] ?? -1 ) !== -1 ) {
179181 if (($ statesEntry = $ paletteArray [$ i ] ?? null ) !== null ) {
@@ -184,8 +186,9 @@ private function parseBlockLayers(?CompoundTag $paletteCompound, ?ListTag $block
184186 GlobalLogger::get ()->logException ($ e );
185187 }
186188 }
187- }
189+ }}
188190 //liquid layer
191+ if ($ blockIndicesList ->isset (1 )){
189192 $ tag = $ blockIndicesList ->get (1 );
190193 $ liquidLayer = $ tag ->getAllValues ();
191194 if (($ i = $ liquidLayer [$ offset ] ?? -1 ) !== -1 ) {
@@ -197,7 +200,7 @@ private function parseBlockLayers(?CompoundTag $paletteCompound, ?ListTag $block
197200 GlobalLogger::get ()->logException ($ e );
198201 }
199202 }
200- }
203+ }}
201204 //nbt
202205 if ($ blockPositionData ->getTag ((string )$ offset ) !== null ) {
203206 /** @var CompoundTag<CompoundTag> $tag1 */
@@ -225,7 +228,7 @@ public function blocks(int $layer = 0): Generator
225228 for ($ z = 0 ; $ z < $ this ->size ->getZ (); $ z ++) {
226229 $ fullState = $ this ->blockLayers [$ layer ]->get ($ x , $ y , $ z );
227230 $ block = BlockFactory::getInstance ()->fromFullBlock ($ fullState );
228- [$ block ->getPos ()->x , $ block ->getPos ()->y , $ block ->getPos ()->z ] = [$ x , $ y , $ z ];
231+ [$ block ->getPosition ()->x , $ block ->getPosition ()->y , $ block ->getPosition ()->z ] = [$ x , $ y , $ z ];
229232 yield $ block ;
230233 }
231234 }
@@ -248,9 +251,9 @@ public function translateBlockEntity(Position $position, Vector3 $origin): ?Tile
248251 foreach ($ inventoryTag as $ itemNBT ) {
249252 $ itemNBT ->setString ("id " , $ itemNBT ->getString ("Name " , "minecraft:air " ));
250253 $ itemNBT ->removeTag ("Name " );
251- if ($ itemNBT ->getTag ("tag " , CompoundTag::class ) !== null ) {
254+ if ($ itemNBT ->getCompoundTag ("tag " ) !== null ) {
252255 /** @var CompoundTag $tag */
253- $ tag = $ itemNBT ->getTag ("tag " , CompoundTag::class );
256+ $ tag = $ itemNBT ->getCompoundTag ("tag " );
254257 if ($ tag ->getTag ("Damage " ) !== null ) $ tag ->removeTag ("Damage " );
255258 }
256259 }
@@ -283,7 +286,7 @@ public function translateBlockEntity(Position $position, Vector3 $origin): ?Tile
283286 * @param string $property
284287 * @return mixed
285288 */
286- public static function &readAnyValue (object $ object , string $ property )
289+ public static function &readAnyValue (object $ object , string $ property ): mixed
287290 {
288291 $ invoke = Closure::bind (function & () use ($ property ) {
289292 return $ this ->$ property ;
0 commit comments