mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Some packets
This commit is contained in:
parent
22965e0acf
commit
123f988017
@ -71,8 +71,11 @@ class MinecraftInterface{
|
|||||||
if($data[3] === false){
|
if($data[3] === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pid = $data[0]{0};
|
$pid = ord($data[0]);
|
||||||
$pid = ord($pid);
|
if($pid === 0x84){
|
||||||
|
$data[0] = substr($data[0], 10);
|
||||||
|
$pid = ord($data[0]);
|
||||||
|
}
|
||||||
$struct = $this->getStruct($pid);
|
$struct = $this->getStruct($pid);
|
||||||
if($struct === false){
|
if($struct === false){
|
||||||
$p = "[".microtime(true)."] [SERVER->CLIENT]: Error, bad packet id 0x".Utils::strToHex(chr($pid)).PHP_EOL;
|
$p = "[".microtime(true)."] [SERVER->CLIENT]: Error, bad packet id 0x".Utils::strToHex(chr($pid)).PHP_EOL;
|
||||||
|
@ -32,7 +32,7 @@ class PocketMinecraftServer{
|
|||||||
$this->version = (int) $version;
|
$this->version = (int) $version;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->cnt = 1;
|
$this->cnt = 1;
|
||||||
$this->serverID = Utils::readDouble(substr(Utils::generateKey(), 0, 8));
|
$this->serverID = substr(Utils::generateKey(), 0, 8);
|
||||||
$this->events = array("disabled" => array());
|
$this->events = array("disabled" => array());
|
||||||
$this->protocol = (int) $protocol;
|
$this->protocol = (int) $protocol;
|
||||||
$this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true);
|
$this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true);
|
||||||
@ -65,26 +65,20 @@ class PocketMinecraftServer{
|
|||||||
$this->send(0x06, array(
|
$this->send(0x06, array(
|
||||||
MAGIC,
|
MAGIC,
|
||||||
$this->serverID,
|
$this->serverID,
|
||||||
$this->version,
|
0,
|
||||||
$size,
|
strlen($packet["raw"]),
|
||||||
), false, $packet["ip"], $packet["port"]);
|
), false, $packet["ip"], $packet["port"]);
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case 0x07:
|
||||||
$bytes = $data[1];
|
|
||||||
$port = $data[2];
|
$port = $data[2];
|
||||||
$size = $data[3];
|
$MTU = $data[3];
|
||||||
$x = $data[4];
|
$clientID = $data[4];
|
||||||
$sess = $data[5];
|
|
||||||
//console("[DEBUG] ".$packet["ip"].":".$packet["port"]." v".$version." response (".$size.")", true, true, 2);
|
//console("[DEBUG] ".$packet["ip"].":".$packet["port"]." v".$version." response (".$size.")", true, true, 2);
|
||||||
$sess2 = Utils::readInt(substr(Utils::generateKey(), 0, 4));
|
$sess2 = Utils::readInt(substr(Utils::generateKey(), 0, 4));
|
||||||
$this->send(0x08, array(
|
$this->send(0x08, array(
|
||||||
MAGIC,
|
MAGIC,
|
||||||
$x,
|
$clientID,
|
||||||
$sess2,
|
$data[1],
|
||||||
$bytes,
|
|
||||||
$packet["port"],
|
|
||||||
$size,
|
|
||||||
0x00
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
), false, $packet["ip"], $packet["port"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -102,8 +96,9 @@ class PocketMinecraftServer{
|
|||||||
if($packet !== false){
|
if($packet !== false){
|
||||||
$this->trigger("onReceivedPacket", $packet);
|
$this->trigger("onReceivedPacket", $packet);
|
||||||
$this->trigger($packet["pid"], $packet);
|
$this->trigger($packet["pid"], $packet);
|
||||||
|
}else{
|
||||||
|
usleep(10000);
|
||||||
}
|
}
|
||||||
usleep(10000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
$pstruct = array(
|
$pstruct = array(
|
||||||
0x02 => array(
|
0x02 => array(
|
||||||
"double",
|
8,
|
||||||
"magic",
|
"magic",
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ $pstruct = array(
|
|||||||
|
|
||||||
0x06 => array(
|
0x06 => array(
|
||||||
"magic",
|
"magic",
|
||||||
"double",
|
8,
|
||||||
"byte",
|
"byte",
|
||||||
"short",
|
"short",
|
||||||
),
|
),
|
||||||
@ -49,42 +49,38 @@ $pstruct = array(
|
|||||||
5,
|
5,
|
||||||
"short",
|
"short",
|
||||||
"short",
|
"short",
|
||||||
"int",
|
8,
|
||||||
"int",
|
|
||||||
),
|
),
|
||||||
|
|
||||||
0x08 => array(
|
0x08 => array(
|
||||||
"magic",
|
"magic",
|
||||||
"int",
|
8,
|
||||||
"int",
|
|
||||||
5,
|
5,
|
||||||
"short",
|
),
|
||||||
"short",
|
|
||||||
|
0x09 => array(
|
||||||
|
8,
|
||||||
|
8,
|
||||||
"byte",
|
"byte",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
0x10 => array(
|
||||||
|
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
0x1c => array(
|
0x1c => array(
|
||||||
"double",
|
8,
|
||||||
"double",
|
8,
|
||||||
"magic",
|
"magic",
|
||||||
"string",
|
"string",
|
||||||
),
|
),
|
||||||
|
|
||||||
0x1d => array(
|
0x1d => array(
|
||||||
"double",
|
8,
|
||||||
"double",
|
8,
|
||||||
"magic",
|
"magic",
|
||||||
"string",
|
"string",
|
||||||
),
|
),
|
||||||
|
|
||||||
0x84 => array(
|
|
||||||
"byte",
|
|
||||||
9,
|
|
||||||
"int",
|
|
||||||
"int",
|
|
||||||
5,
|
|
||||||
3,
|
|
||||||
"byte",
|
|
||||||
),
|
|
||||||
|
|
||||||
);
|
);
|
@ -31,7 +31,8 @@ $packetName = array(
|
|||||||
0x06 => "ID_OPEN_CONNECTION_REPLY_1",
|
0x06 => "ID_OPEN_CONNECTION_REPLY_1",
|
||||||
0x07 => "ID_OPEN_CONNECTION_REQUEST_2",
|
0x07 => "ID_OPEN_CONNECTION_REQUEST_2",
|
||||||
0x08 => "ID_OPEN_CONNECTION_REPLY_2",
|
0x08 => "ID_OPEN_CONNECTION_REPLY_2",
|
||||||
|
0x09 => "ID_CONNECTION_REQUEST",
|
||||||
|
0x10 => "ID_CONNECTION_REQUEST_ACCEPTED",
|
||||||
0x1c => "ID_UNCONNECTED_PONG",
|
0x1c => "ID_UNCONNECTED_PONG",
|
||||||
0x1d => "ID_ADVERTISE_SYSTEM",
|
0x1d => "ID_ADVERTISE_SYSTEM",
|
||||||
|
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user