diff --git a/src/pocketmine/tile/Bed.php b/src/pocketmine/tile/Bed.php index 4299ec9fb..fb1351f72 100644 --- a/src/pocketmine/tile/Bed.php +++ b/src/pocketmine/tile/Bed.php @@ -35,7 +35,7 @@ class Bed extends Spawnable{ const TAG_COLOR = "color"; public function __construct(Level $level, CompoundTag $nbt){ - if(!($nbt->getTag(self::TAG_COLOR) instanceof ByteTag)){ + if(!$nbt->hasTag(self::TAG_COLOR, ByteTag::class)){ $nbt->setTag(new ByteTag(self::TAG_COLOR, 14)); //default to old red } parent::__construct($level, $nbt); diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index 84d5b6e51..a2f31931d 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -51,7 +51,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ parent::__construct($level, $nbt); $this->inventory = new ChestInventory($this); - if(!($this->namedtag->getTag("Items") instanceof ListTag)){ + if(!$this->namedtag->hasTag("Items", ListTag::class)){ $this->namedtag->setTag(new ListTag("Items", [], NBT::TAG_Compound)); } diff --git a/src/pocketmine/tile/FlowerPot.php b/src/pocketmine/tile/FlowerPot.php index 79dba4145..0ae6a58dd 100644 --- a/src/pocketmine/tile/FlowerPot.php +++ b/src/pocketmine/tile/FlowerPot.php @@ -37,10 +37,10 @@ class FlowerPot extends Spawnable{ const TAG_ITEM_DATA = "mData"; public function __construct(Level $level, CompoundTag $nbt){ - if(!($nbt->getTag(self::TAG_ITEM) instanceof ShortTag)){ + if(!$nbt->hasTag(self::TAG_ITEM, ShortTag::class)){ $nbt->setTag(new ShortTag(self::TAG_ITEM, 0)); } - if(!($nbt->getTag(self::TAG_ITEM_DATA) instanceof IntTag)){ + if(!$nbt->hasTag(self::TAG_ITEM_DATA, IntTag::class)){ $nbt->setTag(new IntTag(self::TAG_ITEM_DATA, 0)); } parent::__construct($level, $nbt); diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index ffe4112a7..4730d7da8 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -53,24 +53,24 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{ protected $inventory; public function __construct(Level $level, CompoundTag $nbt){ - if(!($nbt->getTag(self::TAG_BURN_TIME) instanceof ShortTag) or $nbt->getShort(self::TAG_BURN_TIME) < 0){ + if(!$nbt->hasTag(self::TAG_BURN_TIME, ShortTag::class) or $nbt->getShort(self::TAG_BURN_TIME) < 0){ $nbt->setTag(new ShortTag(self::TAG_BURN_TIME, 0)); } - if(! - ($nbt->getTag(self::TAG_COOK_TIME) instanceof ShortTag) or + if( + !$nbt->hasTag(self::TAG_COOK_TIME, ShortTag::class) or $nbt->getShort(self::TAG_COOK_TIME) < 0 or ($nbt->getShort(self::TAG_BURN_TIME) === 0 and $nbt->getShort(self::TAG_COOK_TIME) > 0) ){ $nbt->setTag(new ShortTag(self::TAG_COOK_TIME, 0)); } - if(!($nbt->getTag(self::TAG_MAX_TIME) instanceof ShortTag)){ + if(!$nbt->hasTag(self::TAG_MAX_TIME, ShortTag::class)){ $nbt->setTag(new ShortTag(self::TAG_MAX_TIME, $nbt->getShort(self::TAG_BURN_TIME))); $nbt->removeTag(self::TAG_BURN_TICKS); } - if(!($nbt->getTag(self::TAG_BURN_TICKS) instanceof ShortTag)){ + if(!$nbt->getTag(self::TAG_BURN_TICKS, ShortTag::class)){ $nbt->setTag(new ShortTag(self::TAG_BURN_TICKS, 0)); } diff --git a/src/pocketmine/tile/ItemFrame.php b/src/pocketmine/tile/ItemFrame.php index dc5902cf8..5c6e3396e 100644 --- a/src/pocketmine/tile/ItemFrame.php +++ b/src/pocketmine/tile/ItemFrame.php @@ -38,11 +38,11 @@ class ItemFrame extends Spawnable{ const TAG_ITEM = "Item"; public function __construct(Level $level, CompoundTag $nbt){ - if(!($nbt->getTag(self::TAG_ITEM_ROTATION) instanceof ByteTag)){ + if(!$nbt->hasTag(self::TAG_ITEM_ROTATION, ByteTag::class)){ $nbt->setTag(new ByteTag(self::TAG_ITEM_ROTATION, 0)); } - if(!($nbt->getTag(self::TAG_ITEM_DROP_CHANCE) instanceof FloatTag)){ + if(!$nbt->hasTag(self::TAG_ITEM_DROP_CHANCE, FloatTag::class)){ $nbt->setTag(new FloatTag(self::TAG_ITEM_DROP_CHANCE, 1.0)); } diff --git a/src/pocketmine/tile/Sign.php b/src/pocketmine/tile/Sign.php index 65c7a59be..5c4f13106 100644 --- a/src/pocketmine/tile/Sign.php +++ b/src/pocketmine/tile/Sign.php @@ -41,14 +41,14 @@ class Sign extends Spawnable{ protected $text = ["", "", "", ""]; public function __construct(Level $level, CompoundTag $nbt){ - if($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format + if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ //MCPE 1.2 save format $this->text = explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)); assert(count($this->text) === 4, "Too many lines!"); $nbt->removeTag(self::TAG_TEXT_BLOB); }else{ for($i = 1; $i <= 4; ++$i){ $textKey = sprintf(self::TAG_TEXT_LINE, $i); - if($nbt->getTag($textKey) instanceof StringTag){ + if($nbt->hasTag($textKey, StringTag::class)){ $this->text[$i - 1] = $nbt->getString($textKey); $nbt->removeTag($textKey); } @@ -140,8 +140,8 @@ class Sign extends Spawnable{ return false; } - if(($blob = $nbt->getString(self::TAG_TEXT_BLOB)) !== null){ - $lines = array_pad(explode("\n", $blob), 4, ""); + if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ + $lines = array_pad(explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)), 4, ""); }else{ $lines = [ $nbt->getString(sprintf(self::TAG_TEXT_LINE, 1)), diff --git a/src/pocketmine/tile/Skull.php b/src/pocketmine/tile/Skull.php index 486008ad0..fa6b30c1e 100644 --- a/src/pocketmine/tile/Skull.php +++ b/src/pocketmine/tile/Skull.php @@ -42,10 +42,10 @@ class Skull extends Spawnable{ const TAG_ROT = "Rot"; public function __construct(Level $level, CompoundTag $nbt){ - if(!($nbt->getTag(self::TAG_SKULL_TYPE) instanceof ByteTag)){ + if(!$nbt->hasTag(self::TAG_SKULL_TYPE, ByteTag::class)){ $nbt->setTag(new ByteTag(self::TAG_SKULL_TYPE, 0)); } - if(!($nbt->getTag(self::TAG_ROT) instanceof ByteTag)){ + if(!$nbt->hasTag(self::TAG_ROT, ByteTag::class)){ $nbt->setTag(new ByteTag(self::TAG_ROT, 0)); } parent::__construct($level, $nbt);