mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Wall: separate connection calculation into its own method
we'll need this once wall connections start actually being stored instead of just being recalculated on every read.
This commit is contained in:
parent
8bf1fb7b1d
commit
9f4418e01d
@ -35,16 +35,31 @@ class Wall extends Transparent{
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
|
||||
$this->recalculateConnections();
|
||||
}
|
||||
|
||||
protected function recalculateConnections() : bool{
|
||||
$changed = 0;
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$block = $this->getSide($facing);
|
||||
if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){
|
||||
$this->connections[$facing] = $facing;
|
||||
}else{
|
||||
if(!isset($this->connections[$facing])){
|
||||
$this->connections[$facing] = $facing;
|
||||
$changed++;
|
||||
}
|
||||
}elseif(isset($this->connections[$facing])){
|
||||
unset($this->connections[$facing]);
|
||||
$changed++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->up = $this->getSide(Facing::UP)->getId() !== BlockLegacyIds::AIR;
|
||||
$up = $this->getSide(Facing::UP)->getId() !== BlockLegacyIds::AIR;
|
||||
if($up !== $this->up){
|
||||
$this->up = $up;
|
||||
$changed++;
|
||||
}
|
||||
|
||||
return $changed > 0;
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
|
Loading…
x
Reference in New Issue
Block a user