public static function fromString(string $str, bool $multiple = false)
{
if ($multiple === true) {
$blocks = [];
foreach (explode(",", $str) as $b) {
$blocks[] = self::fromString($b, false);
}
return $blocks;
} else {
$b = explode(":", str_replace([" ", "minecraft:"], ["_", ""], trim($str)));
if (!isset($b[1])) {
$meta = 0;
} else {
$meta = $b[1] & 0xffff;
}
if (defined(Item::class . "::" . strtoupper($b[0]))) {
$item = self::get(constant(Item::class . "::" . strtoupper($b[0])), $meta);
if ($item->getId() === self::AIR and strtoupper($b[0]) !== "AIR") {
$item = self::get($b[0] & 0xffff, $meta);
}
} else {
$item = self::get($b[0] & 0xffff, $meta);
}
return $item;
}
}