Fixed keepMovement logic

This commit is contained in:
Dylan K. Taylor 2017-11-19 19:28:04 +00:00
parent 00a9ae6c95
commit a8ad956b29

View File

@ -1455,15 +1455,15 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return true; return true;
} }
if($this->keepMovement){
$this->boundingBox->offset($dx, $dy, $dz);
$this->setPosition($this->temporalVector->setComponents(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));
$this->onGround = $this->isPlayer ? true : false;
return true;
}else{
Timings::$entityMoveTimer->startTiming(); Timings::$entityMoveTimer->startTiming();
$movX = $dx;
$movY = $dy;
$movZ = $dz;
if($this->keepMovement){
$this->boundingBox->offset($dx, $dy, $dz);
}else{
$this->ySize *= 0.4; $this->ySize *= 0.4;
/* /*
@ -1478,10 +1478,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
} }
*/ */
$movX = $dx;
$movY = $dy;
$movZ = $dz;
$axisalignedbb = clone $this->boundingBox; $axisalignedbb = clone $this->boundingBox;
/*$sneakFlag = $this->onGround and $this instanceof Player; /*$sneakFlag = $this->onGround and $this instanceof Player;
@ -1575,7 +1571,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}else{ }else{
$this->ySize += 0.5; //FIXME: this should be the height of the block it walked up, not fixed 0.5 $this->ySize += 0.5; //FIXME: this should be the height of the block it walked up, not fixed 0.5
} }
}
} }
$this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2; $this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
@ -1599,14 +1595,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->motionZ = 0; $this->motionZ = 0;
} }
//TODO: vehicle collision events (first we need to spawn them!) //TODO: vehicle collision events (first we need to spawn them!)
Timings::$entityMoveTimer->stopTiming(); Timings::$entityMoveTimer->stopTiming();
return true; return true;
} }
}
protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz){ protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz){
$this->isCollidedVertically = $movY != $dy; $this->isCollidedVertically = $movY != $dy;