Further (major!) performance enhancements to entity ticking

This commit is contained in:
Dylan K. Taylor 2017-08-21 20:28:30 +01:00
parent b8ade18888
commit c32b75fa18

View File

@ -1097,7 +1097,6 @@ abstract class Entity extends Location implements Metadatable{
public function entityBaseTick(int $tickDiff = 1) : bool{ public function entityBaseTick(int $tickDiff = 1) : bool{
//TODO: check vehicles //TODO: check vehicles
$this->blocksAround = null;
$this->justCreated = false; $this->justCreated = false;
if(!$this->isAlive()){ if(!$this->isAlive()){
@ -1313,6 +1312,8 @@ abstract class Entity extends Location implements Metadatable{
final public function setForceMovementUpdate(bool $value = true){ final public function setForceMovementUpdate(bool $value = true){
$this->forceMovementUpdate = $value; $this->forceMovementUpdate = $value;
$this->onGround = false; $this->onGround = false;
$this->blocksAround = null;
} }
/** /**
@ -1473,6 +1474,8 @@ abstract class Entity extends Location implements Metadatable{
} }
public function fastMove(float $dx, float $dy, float $dz) : bool{ public function fastMove(float $dx, float $dy, float $dz) : bool{
$this->blocksAround = null;
if($dx == 0 and $dz == 0 and $dy == 0){ if($dx == 0 and $dz == 0 and $dy == 0){
return true; return true;
} }
@ -1512,13 +1515,12 @@ abstract class Entity extends Location implements Metadatable{
} }
public function move(float $dx, float $dy, float $dz) : bool{ public function move(float $dx, float $dy, float $dz) : bool{
$this->blocksAround = null;
if($dx == 0 and $dz == 0 and $dy == 0){ if($dx == 0 and $dz == 0 and $dy == 0){
return true; return true;
} }
$this->blocksAround = null;
if($this->keepMovement){ if($this->keepMovement){
$this->boundingBox->offset($dx, $dy, $dz); $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->setPosition($this->temporalVector->setComponents(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));