Projectile: use closure instead of do/while for reading id/data of block

not ideal, but whatever I guess... this at least provides scope isolation
This commit is contained in:
Dylan K. Taylor 2021-11-01 15:56:28 +00:00
parent 8865bb73ba
commit 9f5c16bc46
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -80,33 +80,29 @@ abstract class Projectile extends Entity{
$this->setHealth(1);
$this->damage = $this->namedtag->getDouble("damage", $this->damage);
do{
$blockHit = null;
$blockId = null;
$blockData = null;
(function() : void{
if($this->namedtag->hasTag("tileX", IntTag::class) and $this->namedtag->hasTag("tileY", IntTag::class) and $this->namedtag->hasTag("tileZ", IntTag::class)){
$blockHit = new Vector3($this->namedtag->getInt("tileX"), $this->namedtag->getInt("tileY"), $this->namedtag->getInt("tileZ"));
}else{
break;
return;
}
if($this->namedtag->hasTag("blockId", IntTag::class)){
$blockId = $this->namedtag->getInt("blockId");
}else{
break;
return;
}
if($this->namedtag->hasTag("blockData", ByteTag::class)){
$blockData = $this->namedtag->getByte("blockData");
}else{
break;
return;
}
$this->blockHit = $blockHit;
$this->blockHitId = $blockId;
$this->blockHitData = $blockData;
}while(false);
})();
}
public function canCollideWith(Entity $entity) : bool{