mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
ChorusPlant: fixed recalculateCollisionBoxes() depending on the world
This commit is contained in:
parent
fc86d3a44e
commit
70fb9bbdfd
@ -34,11 +34,16 @@ use function mt_rand;
|
|||||||
final class ChorusPlant extends Flowable{
|
final class ChorusPlant extends Flowable{
|
||||||
use StaticSupportTrait;
|
use StaticSupportTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var true[]
|
||||||
|
* @phpstan-var array<int, true>
|
||||||
|
*/
|
||||||
|
protected array $connections = [];
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
$bb = AxisAlignedBB::one();
|
$bb = AxisAlignedBB::one();
|
||||||
foreach($this->getAllSides() as $facing => $block){
|
foreach(Facing::ALL as $facing){
|
||||||
$id = $block->getTypeId();
|
if(!isset($this->connections[$facing])){
|
||||||
if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->hasSameTypeId($this)){
|
|
||||||
$bb->trim($facing, 2 / 16);
|
$bb->trim($facing, 2 / 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,6 +51,26 @@ final class ChorusPlant extends Flowable{
|
|||||||
return [$bb];
|
return [$bb];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function readStateFromWorld() : Block{
|
||||||
|
parent::readStateFromWorld();
|
||||||
|
|
||||||
|
$this->collisionBoxes = null;
|
||||||
|
|
||||||
|
foreach(Facing::ALL as $facing){
|
||||||
|
$block = $this->getSide($facing);
|
||||||
|
if(match($block->getTypeId()){
|
||||||
|
BlockTypeIds::END_STONE, BlockTypeIds::CHORUS_FLOWER, $this->getTypeId() => true,
|
||||||
|
default => false
|
||||||
|
}){
|
||||||
|
$this->connections[$facing] = true;
|
||||||
|
}else{
|
||||||
|
unset($this->connections[$facing]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
private function canBeSupportedBy(Block $block) : bool{
|
private function canBeSupportedBy(Block $block) : bool{
|
||||||
return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user