collision tweaks, autojump tweaks

This commit is contained in:
GameHerobrine 2023-01-23 19:54:35 +03:00
parent fe78ac4ee6
commit ab03a1883f
4 changed files with 22 additions and 16 deletions

View file

@ -20,20 +20,23 @@ class MobController
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
$xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed());
$zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed());
$bs = [ //TODO simplify(somehow)
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), ceil($zf)),
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
$this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
$this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), ceil($zf)),
];
foreach($bs as $b){
if($b->isSolid){
if(!$b->getSide(1)->isSolid){
$oy = 1;
break;
}
}
if($this->entity->onGround){
$bs = [ //TODO simplify(somehow)
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), ceil($zf)),
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
$this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
$this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), ceil($zf)),
];
foreach($bs as $b){
if($b->isSolid){
if(!$b->getSide(1)->isSolid){
$oy = 1;
break;
}
}
}
}
if($this->entity->knockbackTime <= 0){
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
}