Implemented scheduled and partial entity updates

This commit is contained in:
Shoghi Cervantes
2014-10-14 22:49:35 +02:00
parent fbe548c611
commit 18f6bad48d
8 changed files with 81 additions and 44 deletions

View File

@ -1192,16 +1192,18 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
public function onUpdate(){
public function onUpdate($currentTick){
if($this->spawned === false or $this->dead === true){
return true;
}
$this->timings->startTiming();
$this->lastUpdate = $currentTick;
$this->processMovement();
$this->entityBaseTick();
$this->entityBaseTick(1);
if($this->onGround){
$this->inAirTicks = 0;
@ -1215,6 +1217,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 1, 1), $this) as $entity){
if(($currentTick - $entity->lastUpdate) > 1){
$entity->scheduleUpdate();
}
if($entity instanceof Arrow and $entity->onGround and $this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0){
if($entity->dead !== true){
$item = Item::get(Item::ARROW, 0, 1);