mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Do not sleep on main Thread when actions are being done
This commit is contained in:
parent
980ee223d0
commit
bf412b1c20
@ -473,8 +473,9 @@ class MainServer{
|
||||
$this->tickMeasure[] = $this->lastTick = $time;
|
||||
unset($this->tickMeasure[key($this->tickMeasure)]);
|
||||
++$this->ticks;
|
||||
$this->tickerFunction($time);
|
||||
return $this->tickerFunction($time);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function clientID($ip, $port){
|
||||
@ -565,6 +566,8 @@ class MainServer{
|
||||
if($packet instanceof Packet){
|
||||
$this->packetHandler($packet);
|
||||
$lastLoop = 0;
|
||||
}elseif($this->tick() > 0){
|
||||
$lastLoop = 0;
|
||||
}else{
|
||||
++$lastLoop;
|
||||
if($lastLoop < 16){
|
||||
@ -620,6 +623,7 @@ class MainServer{
|
||||
$this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
|
||||
$actions = $this->preparedSQL->selectActions->execute();
|
||||
|
||||
$actionCount = 0;
|
||||
if($actions instanceof SQLite3Result){
|
||||
while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$cid = $action["ID"];
|
||||
@ -630,6 +634,7 @@ class MainServer{
|
||||
if(!@is_callable($this->schedule[$cid][0])){
|
||||
$return = false;
|
||||
}else{
|
||||
++$actionCount;
|
||||
$return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]);
|
||||
}
|
||||
|
||||
@ -641,6 +646,7 @@ class MainServer{
|
||||
}
|
||||
$actions->finalize();
|
||||
}
|
||||
return $actionCount;
|
||||
}
|
||||
|
||||
public function event($event,callable $func){
|
||||
|
@ -216,7 +216,7 @@ class HumanEntity extends CreatureEntity implements ProjectileSourceEntity, Inve
|
||||
|
||||
public function getSlot($slot){
|
||||
$slot = (int) $slot;
|
||||
if(!($this->inventory[$slot] instanceof Item)){
|
||||
if(!isset($this->inventory[$slot])){
|
||||
$this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0);
|
||||
}
|
||||
return $this->inventory[$slot];
|
||||
|
Loading…
x
Reference in New Issue
Block a user