diff --git a/src/data/bedrock/item/upgrade/ItemDataUpgrader.php b/src/data/bedrock/item/upgrade/ItemDataUpgrader.php index 7b34ffcb6e0..7d654a88893 100644 --- a/src/data/bedrock/item/upgrade/ItemDataUpgrader.php +++ b/src/data/bedrock/item/upgrade/ItemDataUpgrader.php @@ -36,7 +36,7 @@ use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\network\mcpe\convert\BlockStateDictionary; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\utils\Binary; use function assert; @@ -48,8 +48,7 @@ public function __construct( private LegacyItemIdToStringIdMap $legacyIntToStringIdMap, private R12ItemIdToBlockIdMap $r12ItemIdToBlockIdMap, private BlockDataUpgrader $blockDataUpgrader, - private BlockItemIdMap $blockItemIdMap, - private BlockStateDictionary $blockStateDictionary + private BlockItemIdMap $blockItemIdMap ){} /** @@ -154,13 +153,14 @@ private function upgradeItemTypeNbt(CompoundTag $tag) : ?SavedItemData{ //TODO: Dirty hack to load old skulls from disk: Put this into item upgrade schema's before Mojang makes something with a non 0 default state if($blockStateData === null && ($blockId = $this->blockItemIdMap->lookupBlockId($newNameId)) !== null){ - $networkRuntimeId = $this->blockStateDictionary->lookupStateIdFromIdMeta($blockId, 0); + $blockStateDictionary = TypeConverter::getInstance()->getBlockTranslator()->getBlockStateDictionary(); + $networkRuntimeId = $blockStateDictionary->lookupStateIdFromIdMeta($blockId, 0); if($networkRuntimeId === null){ throw new SavedDataLoadingException("Failed to find blockstate for blockitem $newNameId"); } - $blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkRuntimeId); + $blockStateData = $blockStateDictionary->generateDataFromStateId($networkRuntimeId); } //TODO: this won't account for spawn eggs from before 1.16.100 - perhaps we're lucky and they just left the meta in there anyway? diff --git a/src/world/format/io/GlobalItemDataHandlers.php b/src/world/format/io/GlobalItemDataHandlers.php index f622584784a..7561bd0397d 100644 --- a/src/world/format/io/GlobalItemDataHandlers.php +++ b/src/world/format/io/GlobalItemDataHandlers.php @@ -31,7 +31,6 @@ use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgradeSchemaUtils; use pocketmine\data\bedrock\item\upgrade\LegacyItemIdToStringIdMap; use pocketmine\data\bedrock\item\upgrade\R12ItemIdToBlockIdMap; -use pocketmine\network\mcpe\convert\TypeConverter; use Symfony\Component\Filesystem\Path; use const PHP_INT_MAX; use const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH; @@ -58,7 +57,6 @@ public static function getUpgrader() : ItemDataUpgrader{ R12ItemIdToBlockIdMap::getInstance(), GlobalBlockStateHandlers::getUpgrader(), BlockItemIdMap::getInstance(), - TypeConverter::getInstance()->getBlockTranslator()->getBlockStateDictionary() ); } }