mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-28 22:15:13 +00:00
62 lines
2.3 KiB
PHP
62 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\world\format\io;
|
|
|
|
use pocketmine\data\bedrock\item\ItemDeserializer;
|
|
use pocketmine\data\bedrock\item\ItemSerializer;
|
|
use pocketmine\data\bedrock\item\upgrade\ItemDataUpgrader;
|
|
use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgrader;
|
|
use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgradeSchemaUtils;
|
|
use pocketmine\data\bedrock\item\upgrade\LegacyItemIdToStringIdMap;
|
|
use pocketmine\data\bedrock\item\upgrade\R12ItemIdToBlockIdMap;
|
|
use Symfony\Component\Filesystem\Path;
|
|
use const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH;
|
|
|
|
final class GlobalItemDataHandlers{
|
|
public const MAX_ITEM_ID_UPGRADE_SCHEMA_ID = 81; //0081_1.18.30_to_1.19.30.34_beta.json
|
|
|
|
private static ?ItemSerializer $itemSerializer = null;
|
|
|
|
private static ?ItemDeserializer $itemDeserializer = null;
|
|
|
|
private static ?ItemDataUpgrader $itemDataUpgrader = null;
|
|
|
|
public static function getSerializer() : ItemSerializer{
|
|
return self::$itemSerializer ??= new ItemSerializer(GlobalBlockStateHandlers::getSerializer());
|
|
}
|
|
|
|
public static function getDeserializer() : ItemDeserializer{
|
|
return self::$itemDeserializer ??= new ItemDeserializer(GlobalBlockStateHandlers::getDeserializer());
|
|
}
|
|
|
|
public static function getUpgrader() : ItemDataUpgrader{
|
|
return self::$itemDataUpgrader ??= new ItemDataUpgrader(
|
|
new ItemIdMetaUpgrader(ItemIdMetaUpgradeSchemaUtils::loadSchemas(Path::join(BEDROCK_ITEM_UPGRADE_SCHEMA_PATH, 'id_meta_upgrade_schema'), self::MAX_ITEM_ID_UPGRADE_SCHEMA_ID)),
|
|
LegacyItemIdToStringIdMap::getInstance(),
|
|
R12ItemIdToBlockIdMap::getInstance(),
|
|
GlobalBlockStateHandlers::getUpgrader()
|
|
);
|
|
}
|
|
}
|