diff --git a/src/MainServer.php b/src/MainServer.php index 836bebd22..9ce51c2c0 100644 --- a/src/MainServer.php +++ b/src/MainServer.php @@ -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){ diff --git a/src/entity/HumanEntity.php b/src/entity/HumanEntity.php index 96c516978..f892c5c2e 100644 --- a/src/entity/HumanEntity.php +++ b/src/entity/HumanEntity.php @@ -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];