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->setHealth(1);
$this->damage = $this->namedtag->getDouble("damage", $this->damage); $this->damage = $this->namedtag->getDouble("damage", $this->damage);
do{ (function() : void{
$blockHit = null;
$blockId = null;
$blockData = null;
if($this->namedtag->hasTag("tileX", IntTag::class) and $this->namedtag->hasTag("tileY", IntTag::class) and $this->namedtag->hasTag("tileZ", IntTag::class)){ 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")); $blockHit = new Vector3($this->namedtag->getInt("tileX"), $this->namedtag->getInt("tileY"), $this->namedtag->getInt("tileZ"));
}else{ }else{
break; return;
} }
if($this->namedtag->hasTag("blockId", IntTag::class)){ if($this->namedtag->hasTag("blockId", IntTag::class)){
$blockId = $this->namedtag->getInt("blockId"); $blockId = $this->namedtag->getInt("blockId");
}else{ }else{
break; return;
} }
if($this->namedtag->hasTag("blockData", ByteTag::class)){ if($this->namedtag->hasTag("blockData", ByteTag::class)){
$blockData = $this->namedtag->getByte("blockData"); $blockData = $this->namedtag->getByte("blockData");
}else{ }else{
break; return;
} }
$this->blockHit = $blockHit; $this->blockHit = $blockHit;
$this->blockHitId = $blockId; $this->blockHitId = $blockId;
$this->blockHitData = $blockData; $this->blockHitData = $blockData;
}while(false); })();
} }
public function canCollideWith(Entity $entity) : bool{ public function canCollideWith(Entity $entity) : bool{