Further cleanup on NBT dynamic field access

not sure how I missed so many of these... there are probably lots more besides :(
This commit is contained in:
Dylan K. Taylor
2017-11-17 11:19:36 +00:00
parent 48a7627b96
commit 665130561e
3 changed files with 32 additions and 32 deletions

View File

@ -73,8 +73,11 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
protected $baseOffset = 1.62;
public function __construct(Level $level, CompoundTag $nbt){
if($this->skin === null and (!isset($nbt->Skin) or !isset($nbt->Skin->Data) or !Player::isValidSkin($nbt->Skin->Data->getValue()))){
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
if($this->skin === null){
$skinTag = $nbt->getCompoundTag("Skin");
if($skinTag === null or !self::isValidSkin($skinTag->getString("Data", "", true))){
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
}
}
parent::__construct($level, $nbt);