armor rewrite

This commit is contained in:
GameHerobrine 2023-01-23 17:39:57 +03:00
parent 45b36cb034
commit bae0d4618e
34 changed files with 143 additions and 67 deletions

View file

@ -1,9 +1,9 @@
<?php
class TileNavigator implements ITileNavigator
{
private $blockedProvider, $neighborProvider, $distanceAlgorithm;
private $blockedProvider, $neighborProvider, $distanceAlgorithm;
public static $pathfinderAccessed = 0;
public static $pathfinderAccessed = 0;
public function __construct(IBlockedProvider $blockedProvider, INeighborProvider $neighborProvider, IDistanceAlgorithm $distanceAlgorithm){
$this->blockedProvider = $blockedProvider;

View file

@ -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 Utils::distance_noroot($from->asArray(), $to->asArray());
}
return INF;
}

View file

@ -13,12 +13,12 @@ class MCDiagonalProvider implements INeighborProvider
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(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y - 1, $pnt->z, false)->isSolid){
--$pnt->y;
}
$pnts[] = $pnt;
}else{
if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){
if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){
++$pnt->y;
$pnts[] = $pnt;
}