Skip to content

Commit

Permalink
Fix #502
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Oct 27, 2024
1 parent e5ed50a commit ee0fe4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/data/bedrock/item/upgrade/ItemDataUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
){}

/**
Expand Down Expand Up @@ -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?
Expand Down
2 changes: 0 additions & 2 deletions src/world/format/io/GlobalItemDataHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,7 +57,6 @@ public static function getUpgrader() : ItemDataUpgrader{
R12ItemIdToBlockIdMap::getInstance(),
GlobalBlockStateHandlers::getUpgrader(),
BlockItemIdMap::getInstance(),
TypeConverter::getInstance()->getBlockTranslator()->getBlockStateDictionary()
);
}
}

0 comments on commit ee0fe4f

Please sign in to comment.