diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index bdfe1c76f..4a6e41fd9 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -162,8 +162,7 @@ class Arrow extends Projectile{ } $this->updateMovement(); - //TODO: handle scheduled updates - return true; + return !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0); } public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ diff --git a/src/pocketmine/entity/DroppedItem.php b/src/pocketmine/entity/DroppedItem.php index c825e293d..c6892eefd 100644 --- a/src/pocketmine/entity/DroppedItem.php +++ b/src/pocketmine/entity/DroppedItem.php @@ -107,8 +107,7 @@ class DroppedItem extends Entity{ } $this->updateMovement(); - //TODO: handle scheduled updates - return true; + return !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0); } public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 7131e8d02..49f6bd23f 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -64,11 +64,6 @@ abstract class Entity extends Position implements Metadatable{ public static $entityCount = 1; - /** - * @var Entity[] - */ - public static $needUpdate = []; - /** * @var Player[] */ @@ -584,8 +579,7 @@ abstract class Entity extends Position implements Metadatable{ } public final function scheduleUpdate(){ - //TODO! - Entity::$needUpdate[$this->id] = $this; + $this->level->updateEntities[$this->id] = $this; } public function setOnFire($seconds){ @@ -1106,7 +1100,7 @@ abstract class Entity extends Position implements Metadatable{ if($this->closed === false){ $this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this)); $this->closed = true; - unset(Entity::$needUpdate[$this->id]); + unset($this->level->updateEntities[$this->id]); if($this->chunk instanceof FullChunk){ $this->chunk->removeEntity($this); } diff --git a/src/pocketmine/event/entity/EntityShootBowEvent.php b/src/pocketmine/event/entity/EntityShootBowEvent.php index b0644d30a..424bf3cb9 100644 --- a/src/pocketmine/event/entity/EntityShootBowEvent.php +++ b/src/pocketmine/event/entity/EntityShootBowEvent.php @@ -24,13 +24,12 @@ namespace pocketmine\event\entity; use pocketmine\entity\Living; use pocketmine\entity\Projectile; use pocketmine\event\Cancellable; -use pocketmine\item\Bow; use pocketmine\item\Item; class EntityShootBowEvent extends EntityEvent implements Cancellable{ public static $handlerList = null; - /** @var Bow */ + /** @var Item */ private $bow; /** @var Projectile */ private $projectile; @@ -39,11 +38,11 @@ class EntityShootBowEvent extends EntityEvent implements Cancellable{ /** * @param Living $shooter - * @param Bow $bow + * @param Item $bow * @param Projectile $projectile * @param float $force */ - public function __construct(Living $shooter, Bow $bow, Projectile $projectile, $force){ + public function __construct(Living $shooter, Item $bow, Projectile $projectile, $force){ $this->entity = $shooter; $this->bow = $bow; $this->projectile = $projectile; @@ -58,7 +57,7 @@ class EntityShootBowEvent extends EntityEvent implements Cancellable{ } /** - * @return Bow + * @return Item */ public function getBow(){ return $this->bow; diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 58c9761f1..9de055484 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -121,6 +121,11 @@ class Level implements ChunkManager, Metadatable{ /** @var Entity[] */ protected $entities = []; + /** @var Entity[] */ + public $updateEntities = []; + /** @var Tile[] */ + public $updateTiles = []; + /** @var Server */ protected $server; @@ -505,11 +510,11 @@ class Level implements ChunkManager, Metadatable{ $this->timings->entityTick->startTiming(); //Update entities that need update - if(count(Entity::$needUpdate) > 0){ + if(count($this->updateEntities) > 0){ //Timings::$tickEntityTimer->startTiming(); - foreach($this->entities as $id => $entity){ - if($entity->onUpdate() === false){ - //unset(Entity::$needUpdate[$id]); + foreach($this->updateEntities as $id => $entity){ + if($entity->onUpdate() !== true){ + unset($this->updateEntities[$id]); } } //Timings::$tickEntityTimer->stopTiming(); @@ -518,11 +523,11 @@ class Level implements ChunkManager, Metadatable{ $this->timings->tileEntityTick->startTiming(); //Update tiles that need update - if(count(Tile::$needUpdate) > 0){ + if(count($this->updateTiles) > 0){ //Timings::$tickTileEntityTimer->startTiming(); - foreach($this->tiles as $id => $tile){ - if($tile->onUpdate() === false){ - //unset(Tile::$needUpdate[$id]); + foreach($this->updateTiles as $id => $tile){ + if($tile->onUpdate() !== true){ + unset($this->updateTiles[$id]); } } //Timings::$tickTileEntityTimer->stopTiming(); diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 41871de02..39b5ac059 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -41,11 +41,6 @@ abstract class Tile extends Position{ public static $tileCount = 1; - /** - * @var Tile[] - */ - public static $needUpdate = []; - /** @var Chunk */ public $chunk; public $name; @@ -100,8 +95,7 @@ abstract class Tile extends Position{ } public final function scheduleUpdate(){ - //TODO! - Tile::$needUpdate[$this->id] = $this; + $this->level->updateTiles[$this->id] = $this; } public function __destruct(){ @@ -111,7 +105,7 @@ abstract class Tile extends Position{ public function close(){ if($this->closed === false){ $this->closed = true; - unset(Tile::$needUpdate[$this->id]); + unset($this->level->updateTiles[$this->id]); if($this->chunk instanceof FullChunk){ $this->chunk->removeTile($this); }