public function getHighestStrengthAround()
{
$strength = 0;
$hasChecked = [Vector3::SIDE_WEST => false, Vector3::SIDE_EAST => false, Vector3::SIDE_NORTH => false, Vector3::SIDE_SOUTH => false];
//check blocks around
foreach ($hasChecked as $side => $bool) {
/** @var RedstoneSource $block */
$block = $this->getSide($side);
if ($block instanceof RedstoneSource) {
if ($block->getStrength() > $strength and $block->isActivated($this)) {
$strength = $block->getStrength();
}
$hasChecked[$side] = true;
}
}
//check blocks above
$baseBlock = $this->add(0, 1, 0);
foreach ($hasChecked as $side => $bool) {
if (!$bool) {
$block = $this->getLevel()->getBlock($baseBlock->getSide($side));
if ($block->getId() == $this->id) {
if ($block->getStrength() > $strength) {
$strength = $block->getStrength();
}
$hasChecked[$side] = true;
}
}
}
//check blocks below
$baseBlock = $this->add(0, -1, 0);
foreach ($hasChecked as $side => $bool) {
if (!$bool) {
$block = $this->getLevel()->getBlock($baseBlock->getSide($side));
if ($block->getId() == $this->id) {
if ($block->getStrength() > $strength) {
$strength = $block->getStrength();
}
$hasChecked[$side] = true;
}
}
}
unset($block);
unset($hasChecked);
return $strength;
}