diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index ab0024ad5d..0053ba6f55 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -95,8 +95,8 @@ class ServerAPI{ $this->config->remove("invisible"); } $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), ($seed = $this->getProperty("level-seed")) != "" ? (int) $seed:false, $this->getProperty("server-port"), ($ip = $this->getProperty("server-ip")) != "" ? $ip:"0.0.0.0"); - self::$serverRequest = $this->server; $this->server->api = $this; + self::$serverRequest = $this->server; if($this->getProperty("upnp-forwarding") === true){ console("[INFO] [UPnP] Trying to port forward..."); diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 192b2bfc88..95fed8d379 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -124,10 +124,10 @@ class PocketMinecraftServer{ $this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);"); $this->query("CREATE TABLE blockUpdates (level TEXT, x INTEGER, y INTEGER, z INTEGER, type INTEGER, delay NUMERIC);"); $this->query("CREATE TABLE recipes (id INTEGER PRIMARY KEY, type NUMERIC, recipe TEXT);"); - //$this->query("PRAGMA synchronous = OFF;"); + $this->query("PRAGMA synchronous = OFF;"); $this->preparedSQL->selectHandlers = $this->database->prepare("SELECT DISTINCT ID FROM handlers WHERE name = :name ORDER BY priority DESC;"); $this->preparedSQL->selectActions = $this->database->prepare("SELECT ID,code,repeat FROM actions WHERE last <= (:time - interval);"); - $this->preparedSQL->updateActions = $this->database->prepare("UPDATE actions SET last = :time WHERE last <= (:time - interval);"); + $this->preparedSQL->updateAction = $this->database->prepare("UPDATE actions SET last = :time WHERE ID = :id;"); } public function query($sql, $fetch = false){ @@ -507,7 +507,6 @@ class PocketMinecraftServer{ public function tickerFunction($time){ //actions that repeat every x time will go here $this->preparedSQL->selectActions->reset(); - $this->preparedSQL->selectActions->clear(); $this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT); $actions = $this->preparedSQL->selectActions->execute(); @@ -516,11 +515,16 @@ class PocketMinecraftServer{ } while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){ $cid = $action["ID"]; + $this->preparedSQL->updateAction->reset(); + $this->preparedSQL->updateAction->bindValue(":time", $time, SQLITE3_FLOAT); + $this->preparedSQL->updateAction->bindValue(":id", $cid, SQLITE3_INTEGER); + $this->preparedSQL->updateAction->execute(); $schedule = $this->schedule[$cid]; if(!is_callable($schedule[0])){ $return = false; }else{ $return = call_user_func($schedule[0],$schedule[1],$schedule[2]); + console(get_class($schedule[0][0])."::".$schedule[0][1]); } if($action["repeat"] === 0 or $return === false){ @@ -530,10 +534,6 @@ class PocketMinecraftServer{ } } $actions->finalize(); - $this->preparedSQL->updateActions->reset(); - $this->preparedSQL->updateActions->clear(); - $this->preparedSQL->updateActions->bindValue(":time", $time, SQLITE3_FLOAT); - $this->preparedSQL->updateActions->execute(); } public function event($event,callable $func){ diff --git a/src/world/Entity.php b/src/world/Entity.php index fd345511d2..5ad8fdcf79 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -241,6 +241,11 @@ class Entity extends Position{ return false; } } + + if($this->class !== ENTITY_PLAYER and ($this->x <= 0 or $this->z <= 0 or $this->x >= 256 or $this->z >= 256 or $this->y >= 128 or $this->y <= 0)){ + $this->close(); + return false; + } if($this->dead === true){ $this->fire = 0; @@ -344,7 +349,7 @@ class Entity extends Position{ return; } $tdiff = $now - $this->lastUpdate; - + if($this->tickCounter === 0){ $this->tickCounter = 1; $hasUpdate = $this->environmentUpdate(); @@ -353,11 +358,11 @@ class Entity extends Position{ } if($this->isStatic === false){ - $startX = floor($this->x - 0.5 - $this->size); + $startX = floor($this->x - 0.5 - $this->size - 1); $y = (int) round($this->y - 1); - $startZ = floor($this->z - 0.5 - $this->size); - $endX = ceil($startX + $this->size); - $endZ = ceil($startZ + $this->size); + $startZ = floor($this->z - 0.5 - $this->size - 1); + $endX = ceil($this->x - 0.5 + $this->size + 1); + $endZ = ceil($this->z - 0.5 + $this->size + 1); $support = false; $isFlying = true; for($z = $startZ; $z <= $endZ; ++$z){