53 public function map(
string $id, \Closure $deserializer) : void{
54 if(isset($this->deserializers[$id])){
55 throw new \InvalidArgumentException(
"Deserializer is already assigned for \"$id\"");
57 $this->deserializers[$id] = $deserializer;
71 if(($blockData = $data->getBlock()) !== null){
74 $block = $this->blockStateDeserializer->deserialize($blockData);
82 return RuntimeBlockStateRegistry::getInstance()->fromStateId($block)->asItem();
84 $id = $data->getName();
85 if(!isset($this->deserializers[$id])){
89 return ($this->deserializers[$id])($data);
96 $itemStack = $this->deserializeType($data->getTypeData());
98 $itemStack->
setCount($data->getCount());
99 if(($tagTag = $data->getTypeData()->getTag()) !==
null){
101 $itemStack->setNamedTag(clone $tagTag);
103 throw new ItemTypeDeserializeException(
"Invalid item saved NBT: " . $e->getMessage(), 0, $e);
108 if($itemStack instanceof
Durable && $itemStack->getDamage() === 0 && ($damage = $data->getTypeData()->getMeta()) > 0){
109 $itemStack->setDamage(min($damage, $itemStack->getMaxDurability()));