mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Remove all usages of CompoundTag->hasTag()
in pretty much every case, these usages really wanted to read the tag's contents anyway, which can be combined with a getTag() and instanceof call for more concise and static analysis friendly code. In the few cases where the tag contents wasn't needed, it still wanted to check the type, which, again, can be done in a more static analysis friendly way by just using getTag() and instanceof.
This commit is contained in:
@@ -481,12 +481,12 @@ abstract class Entity{
|
||||
|
||||
$this->fallDistance = $nbt->getFloat("FallDistance", 0.0);
|
||||
|
||||
if($nbt->hasTag("CustomName", StringTag::class)){
|
||||
$this->setNameTag($nbt->getString("CustomName"));
|
||||
if(($customNameTag = $nbt->getTag("CustomName")) instanceof StringTag){
|
||||
$this->setNameTag($customNameTag->getValue());
|
||||
|
||||
if($nbt->hasTag("CustomNameVisible", StringTag::class)){
|
||||
if(($customNameVisibleTag = $nbt->getTag("CustomNameVisible")) instanceof StringTag){
|
||||
//Older versions incorrectly saved this as a string (see 890f72dbf23a77f294169b79590770470041adc4)
|
||||
$this->setNameTagVisible($nbt->getString("CustomNameVisible") !== "");
|
||||
$this->setNameTagVisible($customNameVisibleTag->getValue() !== "");
|
||||
}else{
|
||||
$this->setNameTagVisible($nbt->getByte("CustomNameVisible", 1) !== 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user