From a83cf553f998f3f7c7bbca185bf27847cff22fc0 Mon Sep 17 00:00:00 2001 From: kotyara Date: Thu, 15 Sep 2022 22:28:36 +0500 Subject: [PATCH 1/5] fix --- src/utils/Utils.php | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 80499b6e..7d70a65b 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -644,27 +644,28 @@ class Utils{ public static function writeLong($value){ $x = ""; - if(strval($value[0] == null ? '' : $value[0]) === "-"){ - $negative = true; - $value = bcadd($value, "1"); - if(strval($value[0]) === "-"){ - $value = substr($value, 1); - } - }else{ - $negative = false; - } - while(bccomp($value, "0", 0) > 0){ - $temp = bcmod($value, "16777216"); - $x = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $x; - $value = bcdiv($value, "16777216", 0); - } - $x = str_pad(substr($x, 0, 8), 8, "\x00", STR_PAD_LEFT); - if($negative === true){ - $x = ~$x; - } - return $x; + if(!is_float($value)){ + if(strval($value[0] == null ? '' : $value[0]) === "-"){ + $negative = true; + $value = bcadd($value, "1"); + if(strval($value[0]) === "-"){ + $value = substr($value, 1); + } + }else{ + $negative = false; + } + while(bccomp($value, "0", 0) > 0){ + $temp = bcmod($value, "16777216"); + $x = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $x; + $value = bcdiv($value, "16777216", 0); + } + $x = str_pad(substr($x, 0, 8), 8, "\x00", STR_PAD_LEFT); + if($negative === true){ + $x = ~$x; + } + return $x; + } } - } //if(Utils::isOnline() === false){ From e1e4ec13b6cb1a0fec696fc31a196cfa27613e3c Mon Sep 17 00:00:00 2001 From: kotyara Date: Thu, 15 Sep 2022 22:50:34 +0500 Subject: [PATCH 2/5] Update PocketMinecraftServer.php --- src/PocketMinecraftServer.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 69aece05..b80953f7 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -21,6 +21,7 @@ class PocketMinecraftServer{ $this->serverip = $serverip; $this->load(); } + private function load(){ global $dolog; @@ -94,18 +95,20 @@ class PocketMinecraftServer{ } }elseif($this->extraprops->get("version") == null){ console("[WARNING] Your extra.properties file is corrupted!"); - console("To fix it - just remove it! Server will generate it again automatically."); + console("[WARNING] To fix it - just remove it! Server will generate it again automatically."); } $dolog = $this->extraprops->get("save-console-data"); } + public function onShutdown(){ - console("Saving..."); + console("[INFO] Saving..."); $save = $this->saveEnabled; $this->saveEnabled = true; $this->api->level->saveAll(); $this->saveEnabled = $save; - console("Shutting Down..."); + $this->send2Discord('[INFO] Server stopped!'); } + public function startDatabase(){ $this->preparedSQL = new stdClass(); $this->preparedSQL->entity = new stdClass(); @@ -146,12 +149,11 @@ class PocketMinecraftServer{ $this->serverType = "MCCPP;MINECON;"; break; } - } public function titleTick(){ $time = microtime(true); - if(defined("DEBUG") and DEBUG >= 0 and ENABLE_ANSI === true){ + if(defined("DEBUG") and DEBUG >= 0){ echo "\x1b]0;NostalgiaCore " . MAJOR_VERSION . " | Online " . count($this->clients) . "/" . $this->maxClients . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "MB | U " . round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " D " . round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07"; } @@ -181,7 +183,6 @@ class PocketMinecraftServer{ * @param string $reason */ public function close($reason = "server stop"){ - $this->send2Discord('[INFO] Server stopped!'); usleep(2); $this->onShutdown(); if($this->stop !== true){ From 9c6cbaaae1d9526105434ff7989796dce3e89e2c Mon Sep 17 00:00:00 2001 From: kotyara Date: Thu, 15 Sep 2022 22:54:49 +0500 Subject: [PATCH 3/5] Update ServerAPI.php --- src/API/ServerAPI.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 13625f0a..8556aca0 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -89,6 +89,7 @@ class ServerAPI{ $version = new VersionString(); console("[INFO] Starting Minecraft PE server version " . FORMAT_AQUA . CURRENT_MINECRAFT_VERSION); + $this->server->send2Discord("[INFO] Starting Minecraft PE server version " . CURRENT_MINECRAFT_VERSION); console("[INFO] Loading properties..."); $this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, [ @@ -139,13 +140,11 @@ class ServerAPI{ $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"); $this->server->api = $this; self::$serverRequest = $this->server; - $this->server->send2Discord("[INFO] Starting Minecraft PE server version " . CURRENT_MINECRAFT_VERSION); console("[INFO] This server is running NostalgiaCore version " . ($version->isDev() ? FORMAT_YELLOW : "") . MAJOR_VERSION . FORMAT_RESET . " \"" . CODENAME . "\" (MCPE: " . CURRENT_MINECRAFT_VERSION . ") (API " . CURRENT_API_VERSION . ") (PHP " . PHP_VERSION . ")", true, true, 0); console("[INFO] NostalgiaCore is distributed under the LGPL License", true, true, 0); $this->loadProperties(); - $this->loadAPI("console", "ConsoleAPI"); $this->loadAPI("level", "LevelAPI"); $this->loadAPI("block", "BlockAPI"); From 360e160b82ef9ee56b845844e912413aa8fb37da Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Sat, 24 Sep 2022 12:28:17 +0300 Subject: [PATCH 4/5] Update ServerAPI.php fix --- src/API/ServerAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 8556aca0..2361285d 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -89,7 +89,6 @@ class ServerAPI{ $version = new VersionString(); console("[INFO] Starting Minecraft PE server version " . FORMAT_AQUA . CURRENT_MINECRAFT_VERSION); - $this->server->send2Discord("[INFO] Starting Minecraft PE server version " . CURRENT_MINECRAFT_VERSION); console("[INFO] Loading properties..."); $this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, [ @@ -140,6 +139,7 @@ class ServerAPI{ $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"); $this->server->api = $this; self::$serverRequest = $this->server; + $this->server->send2Discord("[INFO] Starting Minecraft PE server version " . CURRENT_MINECRAFT_VERSION); console("[INFO] This server is running NostalgiaCore version " . ($version->isDev() ? FORMAT_YELLOW : "") . MAJOR_VERSION . FORMAT_RESET . " \"" . CODENAME . "\" (MCPE: " . CURRENT_MINECRAFT_VERSION . ") (API " . CURRENT_API_VERSION . ") (PHP " . PHP_VERSION . ")", true, true, 0); console("[INFO] NostalgiaCore is distributed under the LGPL License", true, true, 0); From 0c75cf8473b1e13c45fed3dd80171a4392e1bd1e Mon Sep 17 00:00:00 2001 From: GameHerobrine <55945072+GameHerobrine@users.noreply.github.com> Date: Sat, 24 Sep 2022 20:11:40 +0300 Subject: [PATCH 5/5] manual adding of missing file from my commit *i forgot to use git add src/ =\* --- .../protocol/packet/PlayerInputPacket.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/network/protocol/packet/PlayerInputPacket.php diff --git a/src/network/protocol/packet/PlayerInputPacket.php b/src/network/protocol/packet/PlayerInputPacket.php new file mode 100644 index 00000000..21037eb7 --- /dev/null +++ b/src/network/protocol/packet/PlayerInputPacket.php @@ -0,0 +1,24 @@ +unk1 = $this->getFloat(); + $this->unk2 = $this->getFloat(); + $this->unk3 = $this->getByte(); + $this->unk4 = $this->getByte(); + console("values: {$this->unk1}, {$this->unk2}, {$this->unk3}, {$this->unk4}"); + } + +} +