mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
* Fixed #32 * StringTag check, throw exception for other types * Short, not int * Fix misleading exception message
This commit is contained in:
parent
e7e476b65e
commit
3ddfb97921
@ -107,7 +107,15 @@ class NBT{
|
||||
return Item::get(0);
|
||||
}
|
||||
|
||||
$item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
|
||||
if($tag->id instanceof ShortTag){
|
||||
$item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
|
||||
}elseif($tag->id instanceof StringTag){ //PC item save format
|
||||
$item = Item::fromString($tag->id->getValue());
|
||||
$item->setDamage(!isset($tag->Damage) ? 0 : $tag->Damage->getValue());
|
||||
$item->setCount($tag->Count->getValue());
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Item CompoundTag ID must be an instance of StringTag or ShortTag, " . get_class($tag->id) . " given");
|
||||
}
|
||||
|
||||
if(isset($tag->tag) and $tag->tag instanceof CompoundTag){
|
||||
$item->setNamedTag($tag->tag);
|
||||
|
Loading…
x
Reference in New Issue
Block a user