mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
fixed enitites being able to clip through 0 barrier
This commit is contained in:
parent
fc2e104c41
commit
bbe9e0ee13
3 changed files with 17 additions and 6 deletions
|
|
@ -586,7 +586,7 @@ class Entity extends Position
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function move($dx, $dy, $dz){
|
||||
$movX = $this->x;
|
||||
$movY = $this->y;
|
||||
|
|
@ -610,6 +610,7 @@ class Entity extends Position
|
|||
|
||||
|
||||
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||
|
||||
foreach($aaBBs as $bb){
|
||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||
}
|
||||
|
|
@ -618,14 +619,13 @@ class Entity extends Position
|
|||
foreach($aaBBs as $bb){
|
||||
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
||||
}
|
||||
$this->boundingBox->offset($dx, 0, 0);
|
||||
$this->boundingBox->offset($dx, 0, 0);
|
||||
|
||||
foreach($aaBBs as $bb){
|
||||
$dz = $bb->calculateZOffset($this->boundingBox, $dz);
|
||||
}
|
||||
$this->boundingBox->offset(0, 0, $dz);
|
||||
|
||||
|
||||
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
||||
|
||||
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
||||
|
|
@ -666,6 +666,7 @@ class Entity extends Position
|
|||
$this->modifySpeedY = true;
|
||||
$this->modifedSpeedY = 0.5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
|
||||
|
|
@ -677,7 +678,6 @@ class Entity extends Position
|
|||
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
||||
$this->updateFallState($this->speedY);
|
||||
|
||||
|
||||
if($savedDX != $dx) $this->speedX = 0;
|
||||
if($savedDY != $dy) $this->speedY = 0;
|
||||
if($savedDZ != $dz) $this->speedZ = 0;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,14 @@ class AxisAlignedBB{
|
|||
$this->maxX += $x;
|
||||
$this->maxY += $y;
|
||||
$this->maxZ += $z;
|
||||
|
||||
|
||||
if($this->minX < 1e-6 && $this->minX > -1e-6)$this->minX = 0;
|
||||
if($this->minY < 1e-6 && $this->minY > -1e-6)$this->minY = 0;
|
||||
if($this->minZ < 1e-6 && $this->minZ > -1e-6)$this->minZ = 0;
|
||||
if($this->maxX < 1e-6 && $this->maxX > -1e-6)$this->maxX = 0;
|
||||
if($this->maxY < 1e-6 && $this->maxY > -1e-6)$this->maxY = 0;
|
||||
if($this->maxZ < 1e-6 && $this->maxZ > -1e-6)$this->maxZ = 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +177,10 @@ class AxisAlignedBB{
|
|||
return $z;
|
||||
}
|
||||
|
||||
public function intersectsWith_(AxisAlignedBB $bb){
|
||||
return $bb->maxX > $this->minX && $bb->minX < $this->maxX && $bb->maxY > $this->minY && $bb->minY < $this->maxY && $bb->maxZ > $this->minZ && $bb->minZ < $this->maxZ;
|
||||
}
|
||||
|
||||
public function intersectsWith(AxisAlignedBB $bb){
|
||||
return $bb->maxX >= $this->minX && $bb->minX <= $this->maxX && $bb->maxZ >= $this->minZ && $bb->minZ <= $this->maxZ && $bb->maxY >= $this->minY && $bb->minY <= $this->maxY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ class Level{
|
|||
$blockBounds = StaticBlock::$prealloc[$bid]::getCollisionBoundingBoxes($this, $x, $y, $z, $e); //StaticBlock::getBoundingBoxForBlockCoords($b, $x, $y, $z);
|
||||
|
||||
foreach($blockBounds as $blockBound){
|
||||
if($aABB->intersectsWith($blockBound)) $aABBs[] = $blockBound;
|
||||
if($aABB->intersectsWith_($blockBound)) $aABBs[] = $blockBound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue