deserializer = new ItemDeserializer(GlobalBlockStateHandlers::getDeserializer()); $this->serializer = new ItemSerializer(GlobalBlockStateHandlers::getSerializer()); } public function testAllVanillaItemsSerializableAndDeserializable() : void{ foreach(VanillaItems::getAll() as $item){ if($item->isNull()){ continue; } try{ $itemData = $this->serializer->serializeType($item); }catch(ItemTypeSerializeException $e){ self::fail($e->getMessage()); } try{ $newItem = $this->deserializer->deserializeType($itemData); }catch(ItemTypeDeserializeException $e){ self::fail($e->getMessage()); } self::assertTrue($item->equalsExact($newItem)); } } public function testAllVanillaBlocksSerializableAndDeserializable() : void{ foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $block){ $item = $block->asItem(); if($item->isNull()){ continue; } try{ $itemData = $this->serializer->serializeType($item); }catch(ItemTypeSerializeException $e){ self::fail($e->getMessage()); } try{ $newItem = $this->deserializer->deserializeType($itemData); }catch(ItemTypeDeserializeException $e){ self::fail($e->getMessage()); } self::assertTrue($item->equalsExact($newItem)); } } }