Skip to content

LegacyStringToItemParser ​

final class · pocketmine\item\LegacyStringToItemParser · source

Deprecated

This class is deprecated.

This class replaces the functionality that used to be provided by ItemFactory::fromString(), but in a more dynamic way. Avoid using this wherever possible. Unless you need to parse item strings containing meta (e.g. "dye:4", "351:4") or item IDs (e.g. "351"), you should prefer the newer StringToItemParser, which is much more user-friendly, more flexible, and also supports registering custom aliases for any item in any state.

WARNING: This class does NOT support items added during or after PocketMine-MP 5.0.0. Use StringToItemParser for modern items.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\data\bedrock\item\upgrade\ItemDataUpgrader $itemDataUpgrader, \pocketmine\data\bedrock\item\ItemDeserializer $itemDeserializer)

addMapping() ​

php
public function addMapping(string $alias, string $id) : void

getMappings() ​

php
public function getMappings() : array

parse() ​

php
public function parse(string $input) : \pocketmine\item\Item

Tries to parse the specified string into Item types.

Example accepted formats:

  • diamond_pickaxe:5
  • minecraft:string
  • 351:4 (lapis lazuli ID:meta)

reprocess() protected ​

php
protected function reprocess(string $input) : string

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.