diff --git a/src/classes/Player.php b/src/classes/Player.php index 1247b00a7..9bab81e01 100644 --- a/src/classes/Player.php +++ b/src/classes/Player.php @@ -55,7 +55,7 @@ class Player{ $this->CID = $this->server->clientID($ip, $port); $this->ip = $ip; $this->port = $port; - $this->timeout = microtime(true) + 25; + $this->timeout = microtime(true) + 20; $this->inventory = array_fill(0, 36, array(0, 0, 0)); $this->evid[] = $this->server->event("server.tick", array($this, "onTick")); $this->evid[] = $this->server->event("server.close", array($this, "close")); @@ -297,7 +297,7 @@ class Player{ public function handle($pid, $data){ if($this->connected === true){ - $this->timeout = microtime(true) + 25; + $this->timeout = microtime(true) + 20; switch($pid){ case 0xa0: //NACK if(isset($this->buffer[$data[2]])){ @@ -368,6 +368,10 @@ class Player{ } $this->send(0xc0, array(1, true, $data[0])); } + + if(!isset($data["id"])){ + break; + } switch($data["id"]){ case MC_KEEP_ALIVE: @@ -399,6 +403,10 @@ class Player{ if($this->loggedIn === true){ break; } + if($data["protocol1"] !== CURRENT_PROTOCOL){ + $this->close("protocol", false); + break; + } $this->loggedIn = true; $this->username = str_replace(array("\x00", "/", " ", "\r", "\n", '"', "'"), array("", "-", "_", "", "", "", ""), $data["username"]); if($this->username == ""){ diff --git a/src/classes/PocketMinecraftServer.php b/src/classes/PocketMinecraftServer.php index 9cc2a2540..ece1e5bc5 100644 --- a/src/classes/PocketMinecraftServer.php +++ b/src/classes/PocketMinecraftServer.php @@ -541,7 +541,7 @@ class PocketMinecraftServer{ } $version = $data[1]; $size = strlen($data[2]); - if($version !== CURRENT_PROTOCOL){ + if($version !== 5){ console("[DEBUG] Incorrect protocol #$version from ".$packet["ip"].":".$packet["port"], true, true, 2); $this->send(0x1a, array( CURRENT_PROTOCOL, diff --git a/src/classes/network/CustomPacketHandler.php b/src/classes/network/CustomPacketHandler.php index 7db3f2da5..64ede8010 100644 --- a/src/classes/network/CustomPacketHandler.php +++ b/src/classes/network/CustomPacketHandler.php @@ -91,7 +91,7 @@ class CustomPacketHandler{ $this->raw .= "\xcd"; $this->raw .= Utils::writeShort($this->data["port"]); $this->raw .= Utils::writeDataArray(array( - "\xff\xff\xff\xff", + "\xf5\xff\xff\xf5", "\xff\xff\xff\xff", "\xff\xff\xff\xff", "\xff\xff\xff\xff", @@ -140,11 +140,11 @@ class CustomPacketHandler{ case MC_LOGIN: if($this->c === false){ $this->data["username"] = $this->get(Utils::readShort($this->get(2), false)); - $this->data["maxX"] = Utils::readInt($this->get(4)); - $this->data["maxY"] = Utils::readInt($this->get(4)); + $this->data["protocol1"] = Utils::readInt($this->get(4)); + $this->data["protocol2"] = Utils::readInt($this->get(4)); }else{ $this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"]; - $this->raw .= "\x00\x00\x00\x08\x00\x00\x00\x08"; + $this->raw .= Utils::writeInt(CURRENT_PROTOCOL).Utils::writeInt(CURRENT_PROTOCOL); } break; case MC_LOGIN_STATUS: diff --git a/src/common/config.php b/src/common/config.php index 82cea46b3..5d3115a2a 100644 --- a/src/common/config.php +++ b/src/common/config.php @@ -39,5 +39,5 @@ define("LOG", true); define("MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78"); define("TEST_MD5", "d0ca3786e53b615bb4fb9f5094d5c9a7"); define("MAJOR_VERSION", "Alpha_1.1dev"); -define("CURRENT_PROTOCOL", 5); +define("CURRENT_PROTOCOL", 9); define("CURRENT_MINECRAFT_VERSION", "v0.6.0 alpha"); \ No newline at end of file diff --git a/src/protocol/current.php b/src/protocol/current.php index 0d0752333..fc892521c 100644 --- a/src/protocol/current.php +++ b/src/protocol/current.php @@ -68,20 +68,20 @@ define("MC_CHUNK_DATA", 0x9e); define("MC_PLAYER_EQUIPMENT", 0x9f); -define("MC_INTERACT", 0xa0); -define("MC_USE_ITEM", 0xa1); -define("MC_PLAYER_ACTION", 0xa2); -define("MC_SET_ENTITY_DATA", 0xa3); -define("MC_SET_ENTITY_MOTION", 0xa4); -define("MC_SET_HEALTH", 0xa5); -define("MC_SET_SPAWN_POSITION", 0xa6); -define("MC_ANIMATE", 0xa7); -define("MC_RESPAWN", 0xa8); +define("MC_INTERACT", 0xa1); +define("MC_USE_ITEM", 0xa2); +define("MC_PLAYER_ACTION", 0xa3); +define("MC_SET_ENTITY_DATA", 0xa4); +define("MC_SET_ENTITY_MOTION", 0xa5); +define("MC_SET_HEALTH", 0xa6); +define("MC_SET_SPAWN_POSITION", 0xa7); +define("MC_ANIMATE", 0xa8); +define("MC_RESPAWN", 0xa9); -define("MC_DROP_ITEM", 0xaa); -define("MC_CONTAINER_OPEN", 0xab); -define("MC_CONTAINER_CLOSE", 0xac); -define("MC_CONTAINER_SET_SLOT", 0xad); +define("MC_DROP_ITEM", 0xab); +define("MC_CONTAINER_OPEN", 0xac); +define("MC_CONTAINER_CLOSE", 0xad); +define("MC_CONTAINER_SET_SLOT", 0xae); define("MC_CLIENT_MESSAGE", 0xb1); define("MC_SIGN_UPDATE", 0xb2);