mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
Added individual object timings to Entities / Tile Entities
This commit is contained in:
parent
f8378c09ba
commit
539fa232f8
@ -1167,6 +1167,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->timings->startTiming();
|
||||
|
||||
$this->processMovement();
|
||||
|
||||
$hasUpdate = $this->entityBaseTick();
|
||||
@ -1232,6 +1234,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
$this->timings->stopTiming();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,16 @@ class Arrow extends Projectile{
|
||||
}
|
||||
|
||||
public function onUpdate(){
|
||||
$this->entityBaseTick();
|
||||
|
||||
if($this->closed !== false){
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->timings->startTiming();
|
||||
|
||||
$this->entityBaseTick();
|
||||
|
||||
if(!$this->dead){
|
||||
|
||||
$movingObjectPosition = null;
|
||||
|
||||
$this->motionY -= $this->gravity;
|
||||
@ -85,7 +89,9 @@ class Arrow extends Projectile{
|
||||
$nearEntity = null;
|
||||
|
||||
foreach($list as $entity){
|
||||
if(/*!$entity->canCollideWith($this) or */($entity === $this->shootingEntity and $this->ticksLived < 5)){
|
||||
if(/*!$entity->canCollideWith($this) or */
|
||||
($entity === $this->shootingEntity and $this->ticksLived < 5)
|
||||
){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -147,6 +153,10 @@ class Arrow extends Projectile{
|
||||
}
|
||||
$this->updateMovement();
|
||||
|
||||
}
|
||||
|
||||
$this->timings->stopTiming();
|
||||
|
||||
return !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0);
|
||||
}
|
||||
|
||||
|
@ -66,12 +66,16 @@ class DroppedItem extends Entity{
|
||||
}
|
||||
|
||||
public function onUpdate(){
|
||||
$this->entityBaseTick();
|
||||
|
||||
if($this->closed !== false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->timings->startTiming();
|
||||
|
||||
$this->entityBaseTick();
|
||||
|
||||
if(!$this->dead){
|
||||
|
||||
if($this->pickupDelay > 0 and $this->pickupDelay < 32767){ //Infinite delay
|
||||
--$this->pickupDelay;
|
||||
}
|
||||
@ -100,6 +104,9 @@ class DroppedItem extends Entity{
|
||||
}
|
||||
|
||||
$this->updateMovement();
|
||||
}
|
||||
|
||||
$this->timings->stopTiming();
|
||||
|
||||
return !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0);
|
||||
}
|
||||
|
@ -152,12 +152,17 @@ abstract class Entity extends Position implements Metadatable{
|
||||
|
||||
public $closed = false;
|
||||
|
||||
/** @var \pocketmine\event\TimingsHandler */
|
||||
protected $timings;
|
||||
|
||||
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
if($chunk === null or $chunk->getProvider() === null){
|
||||
throw new \Exception("Invalid garbage Chunk given to Entity");
|
||||
}
|
||||
|
||||
$this->timings = Timings::getEntityTimings($this);
|
||||
|
||||
if($this->eyeHeight === null){
|
||||
$this->eyeHeight = $this->height;
|
||||
}
|
||||
@ -533,7 +538,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
}
|
||||
|
||||
foreach($this->hasSpawned as $player){
|
||||
$player->directDataPacket($pk);
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,11 +580,14 @@ abstract class Entity extends Position implements Metadatable{
|
||||
if($this->closed !== false){
|
||||
return false;
|
||||
}
|
||||
$this->timings->startTiming();
|
||||
|
||||
$hasUpdate = $this->entityBaseTick();
|
||||
|
||||
$this->updateMovement();
|
||||
|
||||
$this->timings->stopTiming();
|
||||
|
||||
//if($this->isStatic())
|
||||
return true;
|
||||
//return !($this instanceof Player);
|
||||
|
@ -63,12 +63,16 @@ class FallingBlock extends Entity{
|
||||
}
|
||||
|
||||
public function onUpdate(){
|
||||
$this->entityBaseTick();
|
||||
|
||||
if($this->closed or $this->dead){
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->timings->startTiming();
|
||||
|
||||
$this->entityBaseTick();
|
||||
|
||||
if(!$this->dead){
|
||||
if($this->ticksLived === 1){
|
||||
$block = $this->level->getBlock($this->floor());
|
||||
if($block->getID() != $this->blockId){
|
||||
@ -102,6 +106,8 @@ class FallingBlock extends Entity{
|
||||
}
|
||||
|
||||
$this->updateMovement();
|
||||
}
|
||||
|
||||
|
||||
return !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0);
|
||||
}
|
||||
|
@ -742,7 +742,11 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return bool
|
||||
*/
|
||||
public function isFullBlock(Vector3 $pos){
|
||||
if($pos instanceof Block){
|
||||
$bb = $pos->getBoundingBox();
|
||||
}else{
|
||||
$bb = $this->getBlock($pos)->getBoundingBox();
|
||||
}
|
||||
|
||||
return $bb instanceof AxisAlignedBB and $bb->getAverageEdgeLength() >= 1;
|
||||
}
|
||||
|
@ -170,6 +170,8 @@ class Furnace extends Tile implements InventoryHolder, Container{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->timings->startTiming();
|
||||
|
||||
$ret = false;
|
||||
|
||||
$fuel = $this->inventory->getFuel();
|
||||
@ -248,6 +250,8 @@ class Furnace extends Tile implements InventoryHolder, Container{
|
||||
|
||||
$this->lastUpdate = microtime(true);
|
||||
|
||||
$this->timings->stopTiming();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ abstract class Tile extends Position{
|
||||
public $namedtag;
|
||||
protected $lastUpdate;
|
||||
protected $server;
|
||||
protected $timings;
|
||||
|
||||
/** @var \pocketmine\event\TimingsHandler */
|
||||
public $tickTimer;
|
||||
@ -63,6 +64,8 @@ abstract class Tile extends Position{
|
||||
throw new \Exception("Invalid garbage Chunk given to Tile");
|
||||
}
|
||||
|
||||
$this->timings = Timings::getTileEntityTimings($this);
|
||||
|
||||
$this->server = $chunk->getProvider()->getLevel()->getServer();
|
||||
$this->chunk = $chunk;
|
||||
$this->setLevel($chunk->getProvider()->getLevel());
|
||||
|
Loading…
x
Reference in New Issue
Block a user