protected function checkObstruction($x, $y, $z)
{
$i = Math::floorFloat($x);
$j = Math::floorFloat($y);
$k = Math::floorFloat($z);
$diffX = $x - $i;
$diffY = $y - $j;
$diffZ = $z - $k;
if (Block::$solid[$this->level->getBlockIdAt($i, $j, $k)]) {
$flag = !Block::$solid[$this->level->getBlockIdAt($i - 1, $j, $k)];
$flag1 = !Block::$solid[$this->level->getBlockIdAt($i + 1, $j, $k)];
$flag2 = !Block::$solid[$this->level->getBlockIdAt($i, $j - 1, $k)];
$flag3 = !Block::$solid[$this->level->getBlockIdAt($i, $j + 1, $k)];
$flag4 = !Block::$solid[$this->level->getBlockIdAt($i, $j, $k - 1)];
$flag5 = !Block::$solid[$this->level->getBlockIdAt($i, $j, $k + 1)];
$direction = -1;
$limit = 9999;
if ($flag) {
$limit = $diffX;
$direction = 0;
}
if ($flag1 and 1 - $diffX < $limit) {
$limit = 1 - $diffX;
$direction = 1;
}
if ($flag2 and $diffY < $limit) {
$limit = $diffY;
$direction = 2;
}
if ($flag3 and 1 - $diffY < $limit) {
$limit = 1 - $diffY;
$direction = 3;
}
if ($flag4 and $diffZ < $limit) {
$limit = $diffZ;
$direction = 4;
}
if ($flag5 and 1 - $diffZ < $limit) {
$direction = 5;
}
$force = lcg_value() * 0.2 + 0.1;
if ($direction === 0) {
$this->motionX = -$force;
return true;
}
if ($direction === 1) {
$this->motionX = $force;
return true;
}
if ($direction === 2) {
$this->motionY = -$force;
return true;
}
if ($direction === 3) {
$this->motionY = $force;
return true;
}
if ($direction === 4) {
$this->motionZ = -$force;
return true;
}
if ($direction === 5) {
$this->motionZ = $force;
return true;
}
}
return false;
}