mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +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{
|
public function readStateFromWorld() : void{
|
||||||
parent::readStateFromWorld();
|
parent::readStateFromWorld();
|
||||||
|
|
||||||
|
$this->recalculateConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateConnections() : bool{
|
||||||
|
$changed = 0;
|
||||||
foreach(Facing::HORIZONTAL as $facing){
|
foreach(Facing::HORIZONTAL as $facing){
|
||||||
$block = $this->getSide($facing);
|
$block = $this->getSide($facing);
|
||||||
if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){
|
if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){
|
||||||
|
if(!isset($this->connections[$facing])){
|
||||||
$this->connections[$facing] = $facing;
|
$this->connections[$facing] = $facing;
|
||||||
}else{
|
$changed++;
|
||||||
|
}
|
||||||
|
}elseif(isset($this->connections[$facing])){
|
||||||
unset($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{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user