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

@ -566,11 +566,11 @@ class Entity extends Position
$this->inWater = false;
if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT)){
$aABB = $this->boundingBox->getOffsetBoundingBox($this->speedX, $this->speedY, $this->speedZ);
$x0 = floor($aABB->minX);
$x0 = floor($aABB->minX - 1);
$x1 = ceil($aABB->maxX);
$y0 = floor($aABB->minY);
$y1 = ceil($aABB->maxY);
$z0 = floor($aABB->minZ);
$z0 = floor($aABB->minZ - 1);
$z1 = ceil($aABB->maxZ);
$x0 = $x0 < 0 ? 0 : $x0;
$y0 = $y0 < 0 ? 0 : $y0;
@ -1352,7 +1352,7 @@ class Entity extends Position
public function moveEntityWithOffset($oX, $oY, $oZ)
{
$oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed());
$oY = $oY <= 0 ? $this->speedY : (0.5);
$oY = $oY <= 0 ? $this->speedY : (0.45);
$oZ = $oZ === 0 ? $this->speedZ : ($this->getSpeedModifer() * $oZ * $this->getSpeed());
$this->setVelocity($oX, $oY, $oZ);
}

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);
}

View file

@ -15,5 +15,6 @@ class TransparentBlock extends GenericBlock{
$this->isReplaceable = false;
$this->isPlaceable = true;
$this->isSolid = true;
$this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1.2, $this->z + 1);
}
}

View file

@ -7,4 +7,6 @@ class FenceBlock extends TransparentBlock{
$this->hardness = 15;
}
}