diff --git a/src/item/Item.php b/src/item/Item.php index bef3adb86..103638c15 100644 --- a/src/item/Item.php +++ b/src/item/Item.php @@ -678,12 +678,13 @@ class Item implements \JsonSerializable{ if($idTag instanceof ShortTag){ $item = ItemFactory::getInstance()->get($idTag->getValue(), $meta, $count); }elseif($idTag instanceof StringTag){ //PC item save format - //TODO: this isn't a very good mapping source, we need a dedicated mapping for PC - $id = LegacyStringToItemParser::getInstance()->parseId($idTag->getValue()); - if($id === null){ + try{ + $item = LegacyStringToItemParser::getInstance()->parse($idTag->getValue() . ":$meta"); + }catch(\InvalidArgumentException $e){ + //TODO: improve error handling return ItemFactory::air(); } - $item = ItemFactory::getInstance()->get($id, $meta, $count); + $item->setCount($count); }else{ throw new \InvalidArgumentException("Item CompoundTag ID must be an instance of StringTag or ShortTag, " . get_class($idTag) . " given"); } diff --git a/src/item/LegacyStringToItemParser.php b/src/item/LegacyStringToItemParser.php index ca7559e64..d4d345b57 100644 --- a/src/item/LegacyStringToItemParser.php +++ b/src/item/LegacyStringToItemParser.php @@ -33,7 +33,6 @@ use function is_int; use function is_numeric; use function is_string; use function json_decode; -use function mb_strtolower; use function str_replace; use function strtolower; use function trim; @@ -80,10 +79,6 @@ final class LegacyStringToItemParser{ $this->map[$alias] = $id; } - public function parseId(string $input) : ?int{ - return $this->map[mb_strtolower($this->reprocess($input))] ?? null; - } - /** * Tries to parse the specified string into Item types. *