22declare(strict_types=1);
24namespace pocketmine\data\bedrock\item\upgrade;
28use pocketmine\utils\SingletonTrait;
30use Symfony\Component\Filesystem\Path;
32use
function is_string;
33use
function json_decode;
34use
function mb_strtolower;
35use
const JSON_THROW_ON_ERROR;
36use
const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH;
48 private static function make() :
self{
52 flags: JSON_THROW_ON_ERROR
59 foreach($map as $itemId => $blockId){
60 if(!is_string($itemId)){
63 if(!is_string($blockId)){
66 $builtMap[$itemId] = $blockId;
69 return new self($builtMap);
76 private array $itemToBlock = [];
81 private array $blockToItem = [];
89 $this->itemToBlock[mb_strtolower($itemId,
'US-ASCII')] = $blockId;
90 $this->blockToItem[mb_strtolower($blockId,
'US-ASCII')] = $itemId;
94 public function itemIdToBlockId(
string $itemId) : ?string{
95 return $this->itemToBlock[mb_strtolower($itemId,
'US-ASCII')] ?? null;
98 public function blockIdToItemId(
string $blockId) : ?string{
100 return $this->blockToItem[mb_strtolower($blockId,
'US-ASCII')] ?? null;
__construct(array $itemToBlock)
static fileGetContents(string $fileName, bool $useIncludePath=false, $context=null, int $offset=0, ?int $length=null)
static stringifyKeys(array $array)