mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
more stuff uses StaticBlock class now
This commit is contained in:
parent
9cb7fbafaa
commit
e70c501df8
12 changed files with 49 additions and 86 deletions
|
|
@ -42,12 +42,11 @@ class TileNavigator implements ITileNavigator
|
|||
$current = $open->top();
|
||||
$open->next();
|
||||
if ($current == $to){
|
||||
|
||||
return $this->reconstructPath($path, $current);
|
||||
}
|
||||
foreach($this->neighborProvider->getNeighbors($current) as $neighbor)
|
||||
{
|
||||
if(!Utils::in_range(Utils::distance_noroot($neighbor->asArray(), $from->asArray()), -$maxDist, $maxDist)){
|
||||
if(!Utils::in_range(($from->x - $neighbor->x)*($from->x - $neighbor->x) + ($from->y - $neighbor->y)*($from->y - $neighbor->y) + ($from->z - $neighbor->z)*($from->z - $neighbor->z), -$maxDist, $maxDist)){ //Utils::distance_noroot($neighbor->asArray(), $from->asArray())
|
||||
continue;
|
||||
}
|
||||
if(isset($visited[(string)$neighbor])){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Pythagoras3D implements IDistanceAlgorithm
|
|||
public function calculate(PathTile $from, PathTile $to)
|
||||
{
|
||||
if($from instanceof PathTileXYZ && $to instanceof PathTileXYZ){
|
||||
return Utils::distance_noroot($from->asArray(), $to->asArray());
|
||||
return sqrt(($to->x - $from->x) * ($to->x - $from->x) + ($to->y - $from->y) * ($to->y - $from->y) + ($to->z - $from->z) * ($to->z - $from->z));
|
||||
}
|
||||
return INF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,7 @@ class MCBlockedProvider implements IBlockedProvider
|
|||
{
|
||||
public function isBlocked(PathTile $tile)
|
||||
{
|
||||
if($tile instanceof PathTileXYZ){
|
||||
$b = $tile->level->getBlockWithoutVector($tile->x, $tile->y, $tile->z);
|
||||
return $b instanceof Block && $b->isSolid;
|
||||
}
|
||||
return false;
|
||||
return $tile instanceof PathTileXYZ && StaticBlock::getIsSolid($tile->level->level->getBlockID($tile->x, $tile->y, $tile->z));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,17 @@ class MCDiagonalProvider implements INeighborProvider
|
|||
private static $moveDownOffset = [0, -1, 0];
|
||||
public function getNeighbors(PathTile $tile)
|
||||
{
|
||||
|
||||
if($tile instanceof PathTileXYZ){
|
||||
$pnts = [];
|
||||
foreach(MCDiagonalProvider::$neighbors as $offset){
|
||||
$pnt = $tile->addOffset($offset);
|
||||
if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y, $pnt->z, false)->isSolid){
|
||||
if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y - 1, $pnt->z, false)->isSolid){
|
||||
if(!StaticBlock::getIsSolid($tile->level->level->getBlockID($pnt->x, $pnt->y, $pnt->z))){
|
||||
if(!StaticBlock::getIsSolid($tile->level->level->getBlockID($pnt->x, $pnt->y - 1, $pnt->z, false))){
|
||||
--$pnt->y;
|
||||
}
|
||||
$pnts[] = $pnt;
|
||||
}else{
|
||||
if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){
|
||||
if(!StaticBlock::getIsSolid($tile->level->level->getBlockID($pnt->x, $pnt->y + 1, $pnt->z, false))){
|
||||
++$pnt->y;
|
||||
$pnts[] = $pnt;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue