mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
better custom packet handling
This commit is contained in:
parent
95b78a90ac
commit
0205880f99
@ -78,7 +78,24 @@ class CustomPacketHandler{
|
||||
$this->data["time"] = Utils::readInt($this->get(4));
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["time"]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x87:
|
||||
if($this->c === false){
|
||||
$this->data["seed"] = $this->get(8);
|
||||
$this->data["unknown1"] = $this->get(4);
|
||||
$this->data["unknown2"] = $this->get(4);
|
||||
$this->data["spawnX"] = Utils::readFloat($this->get(4));
|
||||
$this->data["spawnY"] = Utils::readFloat($this->get(4));
|
||||
$this->data["spawnZ"] = Utils::readFloat($this->get(4));
|
||||
}else{
|
||||
$this->raw .= $this->data["seed"];
|
||||
$this->raw .= "\x00\x00\x00\x01\x00\x00\x00\x05";
|
||||
$this->raw .= "\x43\x00\x80\x00\x42\x82\x00\x00\x43\x00\x80\x00";
|
||||
/*$this->raw .= Utils::writeFloat($this->data["spawnX"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["spawnY"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["spawnZ"]);*/
|
||||
}
|
||||
break;
|
||||
case 0x09:
|
||||
if($this->c === false){
|
||||
|
@ -71,11 +71,21 @@ class Packet{
|
||||
}
|
||||
break;
|
||||
case "customData":
|
||||
$reply = new CustomPacketHandler($this->data[$field]["id"], "", $this->data[$field], true);
|
||||
$this->addRaw(Utils::writeShort((strlen($reply->raw) + 1) << 3));
|
||||
$this->addRaw(Utils::writeTriad($this->data[$field]["count"]));
|
||||
$this->addRaw(chr($this->data[$field]["id"]));
|
||||
$this->addRaw($reply->raw);
|
||||
switch($this->data[1]){
|
||||
case 0x40:
|
||||
$reply = new CustomPacketHandler($this->data[$field]["id"], "", $this->data[$field], true);
|
||||
$this->addRaw(Utils::writeShort((strlen($reply->raw) + 1) << 3));
|
||||
$this->addRaw(Utils::writeTriad($this->data[$field]["count"]));
|
||||
$this->addRaw(chr($this->data[$field]["id"]));
|
||||
$this->addRaw($reply->raw);
|
||||
break;
|
||||
case 0x00:
|
||||
$reply = new CustomPacketHandler($this->data[$field]["id"], "", $this->data[$field], true);
|
||||
$this->addRaw(Utils::writeShort((strlen($reply->raw) + 1) << 3));
|
||||
$this->addRaw(chr($this->data[$field]["id"]));
|
||||
$this->addRaw($reply->raw);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "magic":
|
||||
$this->addRaw(MAGIC);
|
||||
|
@ -114,7 +114,7 @@ class PocketMinecraftClient{
|
||||
$serverID = $data[1];
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x09,
|
||||
"clientID" => $this->clientID,
|
||||
@ -132,7 +132,7 @@ class PocketMinecraftClient{
|
||||
case 0x00:
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x00,
|
||||
"payload" => $data["payload"],
|
||||
@ -143,7 +143,7 @@ class PocketMinecraftClient{
|
||||
case 0x10:
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x13,
|
||||
"port" => 19132,
|
||||
@ -154,7 +154,7 @@ class PocketMinecraftClient{
|
||||
++$this->counter[0];
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x82,
|
||||
"username" => $this->username,
|
||||
|
@ -28,13 +28,15 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
require_once("classes/Session.class.php");
|
||||
|
||||
class PocketMinecraftServer{
|
||||
protected $interface, $protocol, $entities, $player, $cnt, $events, $username, $version, $clients, $serverType;
|
||||
var $seed, $protocol;
|
||||
protected $interface, $entities, $player, $cnt, $events, $username, $version, $clients, $serverType;
|
||||
function __construct($username, $protocol = CURRENT_PROTOCOL, $version = CURRENT_VERSION){
|
||||
//$this->player = new Player($username);
|
||||
$this->version = (int) $version;
|
||||
$this->username = $username;
|
||||
$this->cnt = 1;
|
||||
$this->serverID = substr(Utils::generateKey(), 0, 8);
|
||||
$this->seed = "\x4f\xf0\x2d\x84\x00\x00\x00\x00";
|
||||
$this->events = array("disabled" => array());
|
||||
$this->actions = array();
|
||||
$this->clients = array();
|
||||
|
@ -77,12 +77,6 @@ class SerializedPacketHandler{
|
||||
}
|
||||
$pk->data["packetName"] = $pk->name;
|
||||
$this->data["packets"][] = array($pid, $pk->data, $raw);
|
||||
/*if($pid === 0x60 and $i === 0){
|
||||
$l = $this->get(3);
|
||||
if(strlen($l) === 3){
|
||||
$this->data["unknown2"] = $this->get(Utils::readTriad($l));
|
||||
}
|
||||
}*/
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ class Session{
|
||||
$this->close("client disconnect");
|
||||
break;
|
||||
case 0x09:
|
||||
$this->send(0x84, array(
|
||||
$this->send(0x88, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x10,
|
||||
"count" => 0,
|
||||
@ -98,10 +98,24 @@ class Session{
|
||||
));
|
||||
++$this->counter[0];
|
||||
break;
|
||||
|
||||
case 0x82:
|
||||
$this->username = $data["username"];
|
||||
console("[INFO] User ".$this->username." connected from ".$this->ip.":".$this->port);
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x00,
|
||||
array(
|
||||
"id" => 0x87,
|
||||
"seed" => $this->server->seed,
|
||||
"spawnX" => 0,
|
||||
"spawnY" => 100,
|
||||
"spawnZ" => 0,
|
||||
),
|
||||
));
|
||||
++$this->counter[0];
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x8c:
|
||||
|
@ -35,7 +35,8 @@ $dataName = array(
|
||||
0x83 => "LoginStatus",
|
||||
0x84 => "Ready",
|
||||
0x85 => "Message",
|
||||
0x66 => "SetTime",
|
||||
0x86 => "SetTime",
|
||||
0x87 => "StartGame",
|
||||
|
||||
0x93 => "MoveEntity_PosRot",
|
||||
|
||||
|
@ -34,10 +34,10 @@ $packetName = array(
|
||||
0x1a => "ID_INCOMPATIBLE_PROTOCOL_VERSION", //RakNet
|
||||
0x1c => "ID_UNCONNECTED_PONG", //RakNet
|
||||
0x1d => "ID_ADVERTISE_SYSTEM", //RakNet
|
||||
0x80 => "Unknown", //Minecraft Implementation
|
||||
0x84 => "Data Packet", //Minecraft Implementation
|
||||
0x88 => "Unknown", //Minecraft Implementation
|
||||
0x8c => "Unknown", //Minecraft Implementation
|
||||
0x80 => "Custom Packet", //Minecraft Implementation
|
||||
0x84 => "Custom Packet", //Minecraft Implementation
|
||||
0x88 => "Custom Packet", //Minecraft Implementation
|
||||
0x8c => "Custom Packet", //Minecraft Implementation
|
||||
0xa0 => "Unknown", //Minecraft Implementation
|
||||
0xc0 => "ACK", //Minecraft Implementation
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user