mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
collision tweaks, autojump tweaks
This commit is contained in:
parent
fe78ac4ee6
commit
ab03a1883f
4 changed files with 22 additions and 16 deletions
|
|
@ -566,11 +566,11 @@ class Entity extends Position
|
||||||
$this->inWater = false;
|
$this->inWater = false;
|
||||||
if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT)){
|
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);
|
$aABB = $this->boundingBox->getOffsetBoundingBox($this->speedX, $this->speedY, $this->speedZ);
|
||||||
$x0 = floor($aABB->minX);
|
$x0 = floor($aABB->minX - 1);
|
||||||
$x1 = ceil($aABB->maxX);
|
$x1 = ceil($aABB->maxX);
|
||||||
$y0 = floor($aABB->minY);
|
$y0 = floor($aABB->minY);
|
||||||
$y1 = ceil($aABB->maxY);
|
$y1 = ceil($aABB->maxY);
|
||||||
$z0 = floor($aABB->minZ);
|
$z0 = floor($aABB->minZ - 1);
|
||||||
$z1 = ceil($aABB->maxZ);
|
$z1 = ceil($aABB->maxZ);
|
||||||
$x0 = $x0 < 0 ? 0 : $x0;
|
$x0 = $x0 < 0 ? 0 : $x0;
|
||||||
$y0 = $y0 < 0 ? 0 : $y0;
|
$y0 = $y0 < 0 ? 0 : $y0;
|
||||||
|
|
@ -1352,7 +1352,7 @@ class Entity extends Position
|
||||||
public function moveEntityWithOffset($oX, $oY, $oZ)
|
public function moveEntityWithOffset($oX, $oY, $oZ)
|
||||||
{
|
{
|
||||||
$oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed());
|
$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());
|
$oZ = $oZ === 0 ? $this->speedZ : ($this->getSpeedModifer() * $oZ * $this->getSpeed());
|
||||||
$this->setVelocity($oX, $oY, $oZ);
|
$this->setVelocity($oX, $oY, $oZ);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,23 @@ class MobController
|
||||||
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
|
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
|
||||||
$xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed());
|
$xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed());
|
||||||
$zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed());
|
$zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed());
|
||||||
$bs = [ //TODO simplify(somehow)
|
if($this->entity->onGround){
|
||||||
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), ceil($zf)),
|
$bs = [ //TODO simplify(somehow)
|
||||||
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
|
$this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), ceil($zf)),
|
||||||
$this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
|
$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), ceil($zf)),
|
$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){
|
foreach($bs as $b){
|
||||||
if(!$b->getSide(1)->isSolid){
|
if($b->isSolid){
|
||||||
$oy = 1;
|
if(!$b->getSide(1)->isSolid){
|
||||||
break;
|
$oy = 1;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->entity->knockbackTime <= 0){
|
if($this->entity->knockbackTime <= 0){
|
||||||
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@ class TransparentBlock extends GenericBlock{
|
||||||
$this->isReplaceable = false;
|
$this->isReplaceable = false;
|
||||||
$this->isPlaceable = true;
|
$this->isPlaceable = true;
|
||||||
$this->isSolid = true;
|
$this->isSolid = true;
|
||||||
|
$this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1.2, $this->z + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,4 +7,6 @@ class FenceBlock extends TransparentBlock{
|
||||||
$this->hardness = 15;
|
$this->hardness = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue