mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
fixed entity collisions with blocks (hopefully really fixed)
This commit is contained in:
parent
5208611d38
commit
f7cf750ce1
1 changed files with 16 additions and 24 deletions
|
|
@ -613,32 +613,24 @@ class Entity extends Position
|
||||||
|
|
||||||
$oldBB = clone $this->boundingBox;
|
$oldBB = clone $this->boundingBox;
|
||||||
|
|
||||||
$aABB = $this->boundingBox->addCoord($dx, $dy, $dz);
|
|
||||||
$x0 = floor($aABB->minX);
|
|
||||||
$x1 = floor($aABB->maxX + 1);
|
|
||||||
$y0 = floor($aABB->minY);
|
|
||||||
$y1 = floor($aABB->maxY + 1);
|
|
||||||
$z0 = floor($aABB->minZ);
|
|
||||||
$z1 = floor($aABB->maxZ + 1);
|
|
||||||
|
|
||||||
for($x = $x0; $x < $x1; ++$x){
|
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||||
for($z = $z0; $z < $z1; ++$z){
|
foreach($aaBBs as $bb){
|
||||||
for($y = $y0 - 1; $y < $y1; ++$y){
|
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||||
$b = $this->level->level->getBlockID($x, $y, $z);
|
|
||||||
if($b != 0){
|
|
||||||
$blockBounds = Block::$class[$b]::getCollisionBoundingBoxes($this->level, $x, $y, $z, $this);
|
|
||||||
foreach($blockBounds as $blockBound){
|
|
||||||
if($aABB->intersectsWith($blockBound)){
|
|
||||||
$dy = $blockBound->calculateYOffset($this->boundingBox, $dy);
|
|
||||||
$dx = $blockBound->calculateXOffset($this->boundingBox, $dx);
|
|
||||||
$dz = $blockBound->calculateZOffset($this->boundingBox, $dz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->boundingBox->offset($dx, $dy, $dz);
|
$this->boundingBox->offset(0, $dy, 0);
|
||||||
|
|
||||||
|
foreach($aaBBs as $bb){
|
||||||
|
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
||||||
|
}
|
||||||
|
$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;
|
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
||||||
|
|
||||||
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue