mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
Merge branch 'master' into multiversion
This commit is contained in:
commit
3e438cf8ac
49 changed files with 2123 additions and 1161 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content
|
NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content
|
||||||
|
|
||||||
Supported MCPE versions: 0.8.0, 0.8.1 (maybe 0.8.2)
|
Supported MCPE versions: 0.7.4, 0.7.6, 0.8.0, 0.8.1 (maybe 0.8.2)
|
||||||
|
|
||||||
(Special thx to GullCraft Network and DartMiner43)
|
(Special thx to GullCraft Network and DartMiner43)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -327,6 +327,17 @@ class PlayerAPI{
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function decodeProtocol($ip){
|
||||||
|
foreach(ServerAPI::request()->clients as $p) {
|
||||||
|
if($p->ip == $ip){
|
||||||
|
return $p->PROTOCOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function add($CID){
|
public function add($CID){
|
||||||
if(isset($this->server->clients[$CID])){
|
if(isset($this->server->clients[$CID])){
|
||||||
$player = $this->server->clients[$CID];
|
$player = $this->server->clients[$CID];
|
||||||
|
|
|
||||||
205
src/Player.php
205
src/Player.php
|
|
@ -78,6 +78,8 @@ class Player{
|
||||||
public $blockUpdateQueue;
|
public $blockUpdateQueue;
|
||||||
public $blockUpdateQueueLength = 0;
|
public $blockUpdateQueueLength = 0;
|
||||||
|
|
||||||
|
public $PROTOCOL = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent by a client while it is linked to some entity.
|
* Sent by a client while it is linked to some entity.
|
||||||
* @var boolean $isJumping
|
* @var boolean $isJumping
|
||||||
|
|
@ -354,6 +356,8 @@ class Player{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
|
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$len = strlen($packet->buffer) + 1;
|
$len = strlen($packet->buffer) + 1;
|
||||||
$MTU = $this->MTU - 24;
|
$MTU = $this->MTU - 24;
|
||||||
|
|
@ -1216,6 +1220,7 @@ class Player{
|
||||||
}
|
}
|
||||||
$this->received[$p->messageIndex] = true;
|
$this->received[$p->messageIndex] = true;
|
||||||
}
|
}
|
||||||
|
$p->PROTOCOL = $this->PROTOCOL;
|
||||||
$p->decode();
|
$p->decode();
|
||||||
$this->handleDataPacket($p);
|
$this->handleDataPacket($p);
|
||||||
}
|
}
|
||||||
|
|
@ -1281,6 +1286,7 @@ class Player{
|
||||||
$packet->z = $z;
|
$packet->z = $z;
|
||||||
$packet->block = $id;
|
$packet->block = $id;
|
||||||
$packet->meta = $meta;
|
$packet->meta = $meta;
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
|
|
||||||
$len = 1 + strlen($packet->buffer);
|
$len = 1 + strlen($packet->buffer);
|
||||||
|
|
@ -1313,6 +1319,7 @@ class Player{
|
||||||
$motion->speedX = $e->speedX;
|
$motion->speedX = $e->speedX;
|
||||||
$motion->speedY = $e->speedY;
|
$motion->speedY = $e->speedY;
|
||||||
$motion->speedZ = $e->speedZ;
|
$motion->speedZ = $e->speedZ;
|
||||||
|
$motion->PROTOCOL = $this->PROTOCOL;
|
||||||
$motion->encode();
|
$motion->encode();
|
||||||
$len += 1 + strlen($motion->buffer);
|
$len += 1 + strlen($motion->buffer);
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -1334,6 +1341,7 @@ class Player{
|
||||||
$move->yaw = $e->yaw;
|
$move->yaw = $e->yaw;
|
||||||
$move->pitch = $e->pitch;
|
$move->pitch = $e->pitch;
|
||||||
$move->bodyYaw = $e->headYaw;
|
$move->bodyYaw = $e->headYaw;
|
||||||
|
$move->PROTOCOL = $this->PROTOCOL;
|
||||||
$move->encode();
|
$move->encode();
|
||||||
}else{
|
}else{
|
||||||
$move = new MoveEntityPacket_PosRot();
|
$move = new MoveEntityPacket_PosRot();
|
||||||
|
|
@ -1343,16 +1351,18 @@ class Player{
|
||||||
$move->z = $e->z;
|
$move->z = $e->z;
|
||||||
$move->yaw = $e->yaw;
|
$move->yaw = $e->yaw;
|
||||||
$move->pitch = $e->pitch;
|
$move->pitch = $e->pitch;
|
||||||
|
$move->PROTOCOL = $this->PROTOCOL;
|
||||||
$move->encode();
|
$move->encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
$len += strlen($move->buffer) + 1;
|
$len += strlen($move->buffer) + 1;
|
||||||
++$packets;
|
++$packets;
|
||||||
$moveSent = true;
|
$moveSent = true;
|
||||||
}else if($e->headYaw != $e->lastHeadYaw){
|
}else if($this->PROTOCOL > ProtocolInfo12::CURRENT_PROTOCOL_12 && $e->headYaw != $e->lastHeadYaw){
|
||||||
$headyaw = new RotateHeadPacket();
|
$headyaw = new RotateHeadPacket();
|
||||||
$headyaw->eid = $e->eid;
|
$headyaw->eid = $e->eid;
|
||||||
$headyaw->yaw = $e->headYaw;
|
$headyaw->yaw = $e->headYaw;
|
||||||
|
$headyaw->PROTOCOL = $this->PROTOCOL;
|
||||||
$headyaw->encode();
|
$headyaw->encode();
|
||||||
$len += strlen($headyaw->buffer) + 1;
|
$len += strlen($headyaw->buffer) + 1;
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -1469,6 +1479,7 @@ class Player{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function directDataPacket(RakNetDataPacket $packet, $reliability = 0, $recover = true){
|
public function directDataPacket(RakNetDataPacket $packet, $reliability = 0, $recover = true){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1478,6 +1489,7 @@ class Player{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
$pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
||||||
$pk->data[] = $packet;
|
$pk->data[] = $packet;
|
||||||
|
|
@ -1498,7 +1510,6 @@ class Player{
|
||||||
$this->entity->setHealth(min(20, $this->entity->health + 1), "regeneration");
|
$this->entity->setHealth(min(20, $this->entity->health + 1), "regeneration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendPing() {
|
public function sendPing() {
|
||||||
|
|
@ -1511,7 +1522,8 @@ class Player{
|
||||||
return $this->lastPing;
|
return $this->lastPing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleDataPacket(RakNetDataPacket $packet){
|
public function handleDataPacket(RakNetDataPacket $packet)
|
||||||
|
{
|
||||||
if ($this->connected === false) {
|
if ($this->connected === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1520,7 +1532,186 @@ class Player{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($packet->pid()){
|
if ($packet->pid() == ProtocolInfo::LOGIN_PACKET) {
|
||||||
|
if ($this->loggedIn === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->username = $packet->username;
|
||||||
|
$this->iusername = strtolower($this->username);
|
||||||
|
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
||||||
|
$this->PROTOCOL = $packet->PROTOCOL;
|
||||||
|
if (count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)) {
|
||||||
|
$this->close("server is full!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($packet->protocol1 < ProtocolInfo7::CURRENT_PROTOCOL_5 && $packet->protocol1 > ProtocolInfo::CURRENT_PROTOCOL) {
|
||||||
|
if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 1;
|
||||||
|
$this->directDataPacket($pk);
|
||||||
|
} else {
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 2;
|
||||||
|
$this->directDataPacket($pk);
|
||||||
|
}
|
||||||
|
$this->close("Incorrect protocol #" . $packet->protocol1, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (preg_match('#[^a-zA-Z0-9_]#', $this->username) > 0 || $this->username === "" || $this->iusername === "rcon" || $this->iusername === "console" || $this->iusername === "server" || strlen($this->iusername) > 16) {
|
||||||
|
$this->close("Bad username", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->server->api->handle("player.connect", $this) === false) {
|
||||||
|
$this->close("Unknown reason", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)) {
|
||||||
|
$this->close("Server is white-listed", false);
|
||||||
|
return;
|
||||||
|
} elseif ($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)) {
|
||||||
|
$this->close("You are banned!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->loggedIn = true;
|
||||||
|
|
||||||
|
if (!isset($this->CID) or $this->CID == null) {
|
||||||
|
console("[DEBUG] Player " . $this->username . " does not have a CID", true, true, 2);
|
||||||
|
$this->CID = Utils::readLong(Utils::getRandomBytes(8, false));
|
||||||
|
}
|
||||||
|
$u = $this->server->api->player->get($this->iusername, false);
|
||||||
|
if ($u !== false) {
|
||||||
|
$u = $this->server->clients[$this->CID];
|
||||||
|
$u->close("this player already in game");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->server->api->player->add($this->CID);
|
||||||
|
if ($this->server->api->handle("player.join", $this) === false) {
|
||||||
|
$this->close("join cancelled", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!($this->data instanceof Config)) {
|
||||||
|
$this->close("no config created", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->auth = true;
|
||||||
|
if (!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01) {
|
||||||
|
if (($this->gamemode & 0x01) === 0x01) {
|
||||||
|
$inv = [];
|
||||||
|
if (($this->gamemode & 0x02) === 0x02) {
|
||||||
|
foreach (BlockAPI::$creative as $item) {
|
||||||
|
$inv[] = [0, 0, 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach (BlockAPI::$creative as $item) {
|
||||||
|
$inv[] = [$item[0], $item[1], 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->data->set("inventory", $inv);
|
||||||
|
}
|
||||||
|
$this->achievements = $this->data->get("achievements");
|
||||||
|
$this->data->set("caseusername", $this->username);
|
||||||
|
$this->inventory = [];
|
||||||
|
foreach ($this->data->get("inventory") as $slot => $item) {
|
||||||
|
if (!is_array($item) or count($item) < 3) {
|
||||||
|
$item = [AIR, 0, 0];
|
||||||
|
}
|
||||||
|
$this->inventory[$slot] = BlockAPI::getItem($item[0], $item[1], $item[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->armor = [];
|
||||||
|
foreach ($this->data->get("armor") as $slot => $item) {
|
||||||
|
$this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], $item[0] === 0 ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data->set("lastIP", $this->ip);
|
||||||
|
$this->data->set("lastID", $this->clientID);
|
||||||
|
|
||||||
|
$this->server->api->player->saveOffline($this->data);
|
||||||
|
|
||||||
|
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 0;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
$pk = new StartGamePacket;
|
||||||
|
$pk->seed = $this->level->getSeed();
|
||||||
|
$pk->x = $this->data->get("position")["x"];
|
||||||
|
$pk->y = $this->data->get("position")["y"];
|
||||||
|
$pk->z = $this->data->get("position")["z"];
|
||||||
|
$pk->generator = 0;
|
||||||
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
|
$pk->eid = 0;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
if (($this->gamemode & 0x01) === 0x01) {
|
||||||
|
$this->slot = 0;
|
||||||
|
$this->hotbar = [];
|
||||||
|
} elseif ($this->data->exists("hotbar")) {
|
||||||
|
$this->hotbar = $this->data->get("hotbar");
|
||||||
|
$this->slot = $this->hotbar[0];
|
||||||
|
} else {
|
||||||
|
$this->slot = 0;
|
||||||
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < count($this->hotbar); ++$i) {
|
||||||
|
if ($this->hotbar[$i] > 36) $this->hotbar[$i] = -1; //XXX unsafe?
|
||||||
|
if ($this->hotbar[$i] < -1) $this->hotbar[$i] = -1;
|
||||||
|
}
|
||||||
|
if ($this->data->exists("slot-count")) {
|
||||||
|
$this->slotCount = $this->data->get("slot-count");
|
||||||
|
} else {
|
||||||
|
$this->data->set("slot-count", $this->slotCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, ["player" => $this]);
|
||||||
|
$this->eid = $this->entity->eid;
|
||||||
|
$this->server->query("UPDATE players SET EID = " . $this->eid . " WHERE CID = " . $this->CID . ";");
|
||||||
|
$this->entity->x = $this->data->get("position")["x"];
|
||||||
|
$this->entity->y = $this->data->get("position")["y"];
|
||||||
|
$this->entity->z = $this->data->get("position")["z"];
|
||||||
|
if (($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false) {
|
||||||
|
$this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level);
|
||||||
|
|
||||||
|
$pk = new SetSpawnPositionPacket;
|
||||||
|
$pk->x = (int)$this->spawnPosition->x;
|
||||||
|
$pk->y = (int)$this->spawnPosition->y;
|
||||||
|
$pk->z = (int)$this->spawnPosition->z;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
}
|
||||||
|
$this->entity->check = false;
|
||||||
|
$this->entity->setName($this->username);
|
||||||
|
$this->entity->data["CID"] = $this->CID;
|
||||||
|
$this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.motion", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.animate", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.event", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.metadata", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.link", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.equipment.change", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.armor", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.pickup", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("tile.container.slot", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("tile.update", [$this, "eventHandler"]);
|
||||||
|
$this->lastMeasure = microtime(true);
|
||||||
|
$this->server->schedule(50, [$this, "measureLag"], [], true);
|
||||||
|
|
||||||
|
$pk = new SetTimePacket;
|
||||||
|
$pk->time = $this->level->getTime();
|
||||||
|
$pk->started = !$this->level->isTimeStopped();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
|
||||||
|
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$internalPid = $packet->getInternalPid();
|
||||||
|
|
||||||
|
switch ($internalPid) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::PONG_PACKET:
|
case ProtocolInfo::PONG_PACKET:
|
||||||
|
|
@ -1560,6 +1751,7 @@ class Player{
|
||||||
$this->username = $packet->username;
|
$this->username = $packet->username;
|
||||||
$this->iusername = strtolower($this->username);
|
$this->iusername = strtolower($this->username);
|
||||||
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
||||||
|
$this->PROTOCOL = $packet->PROTOCOL;
|
||||||
if (count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)) {
|
if (count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)) {
|
||||||
$this->close("server is full!", false);
|
$this->close("server is full!", false);
|
||||||
return;
|
return;
|
||||||
|
|
@ -2293,12 +2485,12 @@ class Player{
|
||||||
$this->toCraft[] = $prevItem; //vanilla drops only result?
|
$this->toCraft[] = $prevItem; //vanilla drops only result?
|
||||||
$this->lastCraft = microtime(true);
|
$this->lastCraft = microtime(true);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
inv_desync_on_drop:
|
inv_desync_on_drop:
|
||||||
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
||||||
$sendOnDrop = true;
|
$sendOnDrop = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->craftingItems = [];
|
$this->craftingItems = [];
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
|
|
@ -2490,7 +2682,6 @@ class Player{
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getID() !== AIR and $slot->getID() == $item->getID()) {
|
if ($item->getID() !== AIR and $slot->getID() == $item->getID()) {
|
||||||
if ($slot->count < $item->count) {
|
if ($slot->count < $item->count) {
|
||||||
if ($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false) {
|
if ($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false) {
|
||||||
|
|
@ -2731,7 +2922,7 @@ class Player{
|
||||||
$s = $this->getSlot($slot);
|
$s = $this->getSlot($slot);
|
||||||
if($s->count <= 0 or $s->getID() === AIR){
|
if($s->count <= 0 or $s->getID() === AIR){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
||||||
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->getMaxStackSize()){
|
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->maxStackSize){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
||||||
}else{
|
}else{
|
||||||
$f1 = 0.3;
|
$f1 = 0.3;
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ class PocketMinecraftServer{
|
||||||
$this->saveEnabled = true;
|
$this->saveEnabled = true;
|
||||||
$this->tickMeasure = array_fill(0, 40, 0);
|
$this->tickMeasure = array_fill(0, 40, 0);
|
||||||
$this->setType("normal");
|
$this->setType("normal");
|
||||||
|
PacketPool::init();
|
||||||
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
|
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
|
||||||
$this->stop = false;
|
$this->stop = false;
|
||||||
$this->ticks = 0;
|
$this->ticks = 0;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class MinecraftInterface{
|
||||||
$pid = ord($buffer[0]);
|
$pid = ord($buffer[0]);
|
||||||
|
|
||||||
if(RakNetInfo::isValid($pid)){
|
if(RakNetInfo::isValid($pid)){
|
||||||
$parser = new RakNetParser($buffer);
|
$parser = new RakNetParser($buffer, $source);
|
||||||
if($parser->packet !== false){
|
if($parser->packet !== false){
|
||||||
$parser->packet->ip = $source;
|
$parser->packet->ip = $source;
|
||||||
$parser->packet->port = $port;
|
$parser->packet->port = $port;
|
||||||
|
|
|
||||||
117
src/network/PacketPool.php
Normal file
117
src/network/PacketPool.php
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PacketPool{
|
||||||
|
|
||||||
|
public const ACCEPTED_PROTOCOLS = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
||||||
|
|
||||||
|
public static bool $isInit = false;
|
||||||
|
/** @var RakNetDataPacket[][] */
|
||||||
|
private static array $packetPool = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param class-string<RakNetDataPacket> $class
|
||||||
|
*/
|
||||||
|
private static function registerPacket(string $class, $protocols = self::ACCEPTED_PROTOCOLS): void{
|
||||||
|
/** @var RakNetDataPacket $pk */
|
||||||
|
$pk = new $class;
|
||||||
|
foreach ($protocols as $protocol) {
|
||||||
|
$pk->PROTOCOL = $protocol;
|
||||||
|
$pid = $pk->pid();
|
||||||
|
if(isset(self::$packetPool[$protocol][$pid])) {
|
||||||
|
$oldPk = self::$packetPool[$protocol][$pid];
|
||||||
|
console("[WARNING] 协议$protocol 中 PID:$pid (0x".dechex($pid).")包".get_class($oldPk)."与包".get_class($pk)."冲突");
|
||||||
|
}
|
||||||
|
self::$packetPool[$protocol][$pid] = clone $pk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPacket(int $pid, int $protocol) : RakNetDataPacket{
|
||||||
|
if(isset(self::$packetPool[$protocol][$pid])) {
|
||||||
|
return clone self::$packetPool[$protocol][$pid];
|
||||||
|
}
|
||||||
|
$pk = new UnknownPacket();
|
||||||
|
$pk->packetID = $pid;
|
||||||
|
$pk->PROTOCOL = $protocol;
|
||||||
|
return $pk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function init() : void{
|
||||||
|
if(self::$isInit){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::registerPacket(AddEntityPacket::class);
|
||||||
|
self::registerPacket(AddItemEntityPacket::class);
|
||||||
|
self::registerPacket(AddMobPacket::class);
|
||||||
|
self::registerPacket(AddPaintingPacket::class);
|
||||||
|
self::registerPacket(AddPlayerPacket::class);
|
||||||
|
self::registerPacket(AdventureSettingsPacket::class);
|
||||||
|
self::registerPacket(AnimatePacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(ChatPacket::class);
|
||||||
|
self::registerPacket(ChunkDataPacket::class);
|
||||||
|
self::registerPacket(ClientConnectPacket::class);
|
||||||
|
self::registerPacket(ClientHandshakePacket::class);
|
||||||
|
self::registerPacket(ContainerClosePacket::class);
|
||||||
|
self::registerPacket(ContainerOpenPacket::class);
|
||||||
|
self::registerPacket(ContainerSetContentPacket::class);
|
||||||
|
self::registerPacket(ContainerSetDataPacket::class);
|
||||||
|
self::registerPacket(ContainerSetSlotPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(DisconnectPacket::class);
|
||||||
|
self::registerPacket(DropItemPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(EntityDataPacket::class);
|
||||||
|
self::registerPacket(EntityEventPacket::class);
|
||||||
|
self::registerPacket(ExplodePacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(HurtArmorPacket::class, [9, 10, 11, 12, 13, 14]);
|
||||||
|
|
||||||
|
self::registerPacket(InteractPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(LevelEventPacket::class);
|
||||||
|
self::registerPacket(LoginPacket::class);
|
||||||
|
self::registerPacket(LoginStatusPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(MessagePacket::class);
|
||||||
|
self::registerPacket(MoveEntityPacket::class);
|
||||||
|
self::registerPacket(MoveEntityPacket_PosRot::class);
|
||||||
|
self::registerPacket(MovePlayerPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(PingPacket::class);
|
||||||
|
self::registerPacket(PlaceBlockPacket::class);
|
||||||
|
self::registerPacket(PlayerActionPacket::class);
|
||||||
|
self::registerPacket(PlayerArmorEquipmentPacket::class, [9, 10, 11, 12, 13, 14]);
|
||||||
|
self::registerPacket(PlayerEquipmentPacket::class);
|
||||||
|
self::registerPacket(PlayerInputPacket::class);
|
||||||
|
self::registerPacket(PongPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(ReadyPacket::class);
|
||||||
|
self::registerPacket(RemoveBlockPacket::class);
|
||||||
|
self::registerPacket(RemoveEntityPacket::class);
|
||||||
|
self::registerPacket(RemovePlayerPacket::class);
|
||||||
|
self::registerPacket(RequestChunkPacket::class);
|
||||||
|
self::registerPacket(RespawnPacket::class);
|
||||||
|
self::registerPacket(RotateHeadPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(SendInventoryPacket::class);
|
||||||
|
self::registerPacket(ServerHandshakePacket::class);
|
||||||
|
self::registerPacket(SetEntityDataPacket::class);
|
||||||
|
self::registerPacket(SetEntityLinkPacket::class, [12, 13, 14]);
|
||||||
|
self::registerPacket(SetEntityMotionPacket::class);
|
||||||
|
self::registerPacket(SetHealthPacket::class);
|
||||||
|
self::registerPacket(SetSpawnPositionPacket::class);
|
||||||
|
self::registerPacket(SetTimePacket::class);
|
||||||
|
self::registerPacket(StartGamePacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(TakeItemEntityPacket::class);
|
||||||
|
self::registerPacket(TileEventPacket::class);
|
||||||
|
|
||||||
|
self::registerPacket(UpdateBlockPacket::class);
|
||||||
|
self::registerPacket(UseItemPacket::class);
|
||||||
|
|
||||||
|
//self::registerPacket(UnknownPacket::class); //DO NOT REGISTER THIS
|
||||||
|
|
||||||
|
self::$isInit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -34,7 +34,7 @@ abstract class ProtocolInfo{
|
||||||
const MOVE_ENTITY_PACKET_POSROT = 0x93;
|
const MOVE_ENTITY_PACKET_POSROT = 0x93;
|
||||||
const ROTATE_HEAD_PACKET = 0x94;
|
const ROTATE_HEAD_PACKET = 0x94;
|
||||||
const MOVE_PLAYER_PACKET = 0x95;
|
const MOVE_PLAYER_PACKET = 0x95;
|
||||||
//const PLACE_BLOCK_PACKET = 0x96;
|
const PLACE_BLOCK_PACKET = 0x96;
|
||||||
const REMOVE_BLOCK_PACKET = 0x97;
|
const REMOVE_BLOCK_PACKET = 0x97;
|
||||||
const UPDATE_BLOCK_PACKET = 0x98;
|
const UPDATE_BLOCK_PACKET = 0x98;
|
||||||
const ADD_PAINTING_PACKET = 0x99;
|
const ADD_PAINTING_PACKET = 0x99;
|
||||||
|
|
@ -65,7 +65,7 @@ abstract class ProtocolInfo{
|
||||||
const CONTAINER_SET_SLOT_PACKET = 0xb2;
|
const CONTAINER_SET_SLOT_PACKET = 0xb2;
|
||||||
const CONTAINER_SET_DATA_PACKET = 0xb3;
|
const CONTAINER_SET_DATA_PACKET = 0xb3;
|
||||||
const CONTAINER_SET_CONTENT_PACKET = 0xb4;
|
const CONTAINER_SET_CONTENT_PACKET = 0xb4;
|
||||||
//const CONTAINER_ACK_PACKET = 0xb5;
|
const CONTAINER_ACK_PACKET = 0xb5;
|
||||||
const CHAT_PACKET = 0xb6;
|
const CHAT_PACKET = 0xb6;
|
||||||
const ADVENTURE_SETTINGS_PACKET = 0xb7;
|
const ADVENTURE_SETTINGS_PACKET = 0xb7;
|
||||||
const ENTITY_DATA_PACKET = 0xb8;
|
const ENTITY_DATA_PACKET = 0xb8;
|
||||||
|
|
@ -78,6 +78,215 @@ abstract class ProtocolInfo{
|
||||||
* 0x17
|
* 0x17
|
||||||
* 0x14
|
* 0x14
|
||||||
*/
|
*/
|
||||||
|
abstract class ProtocolInfo12{
|
||||||
|
|
||||||
|
const CURRENT_PROTOCOL_12 = 12;
|
||||||
|
|
||||||
|
const PING_PACKET = 0x00;
|
||||||
|
|
||||||
|
const PONG_PACKET = 0x03;
|
||||||
|
|
||||||
|
const CLIENT_CONNECT_PACKET = 0x09;
|
||||||
|
const SERVER_HANDSHAKE_PACKET = 0x10;
|
||||||
|
|
||||||
|
const CLIENT_HANDSHAKE_PACKET = 0x13;
|
||||||
|
//const SERVER_FULL_PACKET = 0x14;
|
||||||
|
const DISCONNECT_PACKET = 0x15;
|
||||||
|
const LOGIN_PACKET = 0x82;
|
||||||
|
const LOGIN_STATUS_PACKET = 0x83;
|
||||||
|
const READY_PACKET = 0x84;
|
||||||
|
const MESSAGE_PACKET = 0x85;
|
||||||
|
const SET_TIME_PACKET = 0x86;
|
||||||
|
const START_GAME_PACKET = 0x87;
|
||||||
|
const ADD_MOB_PACKET = 0x88;
|
||||||
|
const ADD_PLAYER_PACKET = 0x89;
|
||||||
|
const REMOVE_PLAYER_PACKET = 0x8a;
|
||||||
|
|
||||||
|
const ADD_ENTITY_PACKET = 0x8c;
|
||||||
|
const REMOVE_ENTITY_PACKET = 0x8d;
|
||||||
|
const ADD_ITEM_ENTITY_PACKET = 0x8e;
|
||||||
|
const TAKE_ITEM_ENTITY_PACKET = 0x8f;
|
||||||
|
const MOVE_ENTITY_PACKET = 0x90;
|
||||||
|
|
||||||
|
const MOVE_ENTITY_PACKET_POSROT = 0x93;
|
||||||
|
const ROTATE_HEAD_PACKET = 0xff;
|
||||||
|
const MOVE_PLAYER_PACKET = 0x94;
|
||||||
|
const PLACE_BLOCK_PACKET = 0x95;
|
||||||
|
const REMOVE_BLOCK_PACKET = 0x96;
|
||||||
|
const UPDATE_BLOCK_PACKET = 0x97;
|
||||||
|
const ADD_PAINTING_PACKET = 0x98;
|
||||||
|
const EXPLODE_PACKET = 0x99;
|
||||||
|
const LEVEL_EVENT_PACKET = 0x9a;
|
||||||
|
const TILE_EVENT_PACKET = 0x9b;
|
||||||
|
const ENTITY_EVENT_PACKET = 0x9c;
|
||||||
|
const REQUEST_CHUNK_PACKET = 0x9d;
|
||||||
|
const CHUNK_DATA_PACKET = 0x9e;
|
||||||
|
const PLAYER_EQUIPMENT_PACKET = 0x9f;
|
||||||
|
const PLAYER_ARMOR_EQUIPMENT_PACKET = 0xa0;
|
||||||
|
const INTERACT_PACKET = 0xa1;
|
||||||
|
const USE_ITEM_PACKET = 0xa2;
|
||||||
|
const PLAYER_ACTION_PACKET = 0xa3;
|
||||||
|
|
||||||
|
const HURT_ARMOR_PACKET = 0xa5;
|
||||||
|
const SET_ENTITY_DATA_PACKET = 0xa6;
|
||||||
|
const SET_ENTITY_MOTION_PACKET = 0xa7;
|
||||||
|
const SET_ENTITY_LINK_PACKET = 0xa8;
|
||||||
|
const SET_HEALTH_PACKET = 0xa9;
|
||||||
|
const SET_SPAWN_POSITION_PACKET = 0xaa;
|
||||||
|
const ANIMATE_PACKET = 0xab;
|
||||||
|
const RESPAWN_PACKET = 0xac;
|
||||||
|
const SEND_INVENTORY_PACKET = 0xad;
|
||||||
|
const DROP_ITEM_PACKET = 0xae;
|
||||||
|
const CONTAINER_OPEN_PACKET = 0xaf;
|
||||||
|
const CONTAINER_CLOSE_PACKET = 0xb0;
|
||||||
|
const CONTAINER_SET_SLOT_PACKET = 0xb1;
|
||||||
|
const CONTAINER_SET_DATA_PACKET = 0xb2;
|
||||||
|
const CONTAINER_SET_CONTENT_PACKET = 0xb3;
|
||||||
|
const CONTAINER_ACK_PACKET = 0xb5; //Bruh
|
||||||
|
const CHAT_PACKET = 0xb5;
|
||||||
|
const ADVENTURE_SETTINGS_PACKET = 0xb6;
|
||||||
|
const ENTITY_DATA_PACKET = 0xb7;
|
||||||
|
const PLAYER_INPUT_PACKET = 0xb9;
|
||||||
|
}
|
||||||
|
abstract class ProtocolInfo9{
|
||||||
|
|
||||||
|
const CURRENT_PROTOCOL_9 = 9;
|
||||||
|
|
||||||
|
const PING_PACKET = 0x00;
|
||||||
|
|
||||||
|
const PONG_PACKET = 0x03;
|
||||||
|
|
||||||
|
const CLIENT_CONNECT_PACKET = 0x09;
|
||||||
|
const SERVER_HANDSHAKE_PACKET = 0x10;
|
||||||
|
|
||||||
|
const CLIENT_HANDSHAKE_PACKET = 0x13;
|
||||||
|
//const SERVER_FULL_PACKET = 0x14;
|
||||||
|
const DISCONNECT_PACKET = 0x15;
|
||||||
|
const LOGIN_PACKET = 0x82;
|
||||||
|
const LOGIN_STATUS_PACKET = 0x83;
|
||||||
|
const READY_PACKET = 0x84;
|
||||||
|
const MESSAGE_PACKET = 0x85;
|
||||||
|
const SET_TIME_PACKET = 0x86;
|
||||||
|
const START_GAME_PACKET = 0x87;
|
||||||
|
const ADD_MOB_PACKET = 0x88;
|
||||||
|
const ADD_PLAYER_PACKET = 0x89;
|
||||||
|
const REMOVE_PLAYER_PACKET = 0x8a;
|
||||||
|
|
||||||
|
const ADD_ENTITY_PACKET = 0x8c;
|
||||||
|
const REMOVE_ENTITY_PACKET = 0x8d;
|
||||||
|
const ADD_ITEM_ENTITY_PACKET = 0x8e;
|
||||||
|
const TAKE_ITEM_ENTITY_PACKET = 0x8f;
|
||||||
|
const MOVE_ENTITY_PACKET = 0x90;
|
||||||
|
|
||||||
|
const MOVE_ENTITY_PACKET_POSROT = 0x93;
|
||||||
|
const MOVE_PLAYER_PACKET = 0x94;
|
||||||
|
const PLACE_BLOCK_PACKET = 0x95;
|
||||||
|
const REMOVE_BLOCK_PACKET = 0x96;
|
||||||
|
const UPDATE_BLOCK_PACKET = 0x97;
|
||||||
|
const ADD_PAINTING_PACKET = 0x98;
|
||||||
|
const EXPLODE_PACKET = 0x99;
|
||||||
|
const LEVEL_EVENT_PACKET = 0x9a;
|
||||||
|
const TILE_EVENT_PACKET = 0x9b;
|
||||||
|
const ENTITY_EVENT_PACKET = 0x9c;
|
||||||
|
const REQUEST_CHUNK_PACKET = 0x9d;
|
||||||
|
const CHUNK_DATA_PACKET = 0x9e;
|
||||||
|
const PLAYER_EQUIPMENT_PACKET = 0x9f;
|
||||||
|
const PLAYER_ARMOR_EQUIPMENT_PACKET = 0xa0;
|
||||||
|
const INTERACT_PACKET = 0xa1;
|
||||||
|
const USE_ITEM_PACKET = 0xa2;
|
||||||
|
const PLAYER_ACTION_PACKET = 0xa3;
|
||||||
|
|
||||||
|
const HURT_ARMOR_PACKET = 0xa5;
|
||||||
|
const SET_ENTITY_DATA_PACKET = 0xa6;
|
||||||
|
const SET_ENTITY_MOTION_PACKET = 0xa7;
|
||||||
|
//const SET_ENTITY_LINK_PACKET = 0xa?;// Change
|
||||||
|
const SET_HEALTH_PACKET = 0xa8;// Change
|
||||||
|
const SET_SPAWN_POSITION_PACKET = 0xa9;
|
||||||
|
const ANIMATE_PACKET = 0xaa;
|
||||||
|
const RESPAWN_PACKET = 0xab;
|
||||||
|
const SEND_INVENTORY_PACKET = 0xac;
|
||||||
|
const DROP_ITEM_PACKET = 0xad;
|
||||||
|
const CONTAINER_OPEN_PACKET = 0xae;
|
||||||
|
const CONTAINER_CLOSE_PACKET = 0xaf;
|
||||||
|
const CONTAINER_SET_SLOT_PACKET = 0xb0;
|
||||||
|
const CONTAINER_SET_DATA_PACKET = 0xb1;
|
||||||
|
const CONTAINER_SET_CONTENT_PACKET = 0xb2;
|
||||||
|
const CONTAINER_ACK_PACKET = 0xb3;
|
||||||
|
const CHAT_PACKET = 0xb4;//12 change
|
||||||
|
const ADVENTURE_SETTINGS_PACKET = 0xb6;
|
||||||
|
const ENTITY_DATA_PACKET = 0xb7;
|
||||||
|
const PLAYER_INPUT_PACKET = 0xb9;
|
||||||
|
|
||||||
|
}
|
||||||
|
abstract class ProtocolInfo7{ // MCPE 0.3 - 0.5 seem using same packet id
|
||||||
|
|
||||||
|
const CURRENT_PROTOCOL_5 = 5;
|
||||||
|
|
||||||
|
const CURRENT_PROTOCOL_7 = 7;
|
||||||
|
|
||||||
|
const PING_PACKET = 0x00;
|
||||||
|
|
||||||
|
const PONG_PACKET = 0x03;
|
||||||
|
|
||||||
|
const CLIENT_CONNECT_PACKET = 0x09;
|
||||||
|
const SERVER_HANDSHAKE_PACKET = 0x10;
|
||||||
|
|
||||||
|
const CLIENT_HANDSHAKE_PACKET = 0x13;
|
||||||
|
//const SERVER_FULL_PACKET = 0x14;
|
||||||
|
const DISCONNECT_PACKET = 0x15;
|
||||||
|
const LOGIN_PACKET = 0x82;
|
||||||
|
const LOGIN_STATUS_PACKET = 0x83;
|
||||||
|
const READY_PACKET = 0x84;
|
||||||
|
const MESSAGE_PACKET = 0x85;
|
||||||
|
const SET_TIME_PACKET = 0x86;
|
||||||
|
const START_GAME_PACKET = 0x87;
|
||||||
|
const ADD_MOB_PACKET = 0x88;
|
||||||
|
const ADD_PLAYER_PACKET = 0x89;
|
||||||
|
const REMOVE_PLAYER_PACKET = 0x8a;//Maybe Exist
|
||||||
|
|
||||||
|
const ADD_ENTITY_PACKET = 0x8c;
|
||||||
|
const REMOVE_ENTITY_PACKET = 0x8d;
|
||||||
|
const ADD_ITEM_ENTITY_PACKET = 0x8e;
|
||||||
|
const TAKE_ITEM_ENTITY_PACKET = 0x8f;
|
||||||
|
const MOVE_ENTITY_PACKET = 0x90;
|
||||||
|
|
||||||
|
const MOVE_ENTITY_PACKET_POSROT = 0x93;
|
||||||
|
const MOVE_PLAYER_PACKET = 0x94;
|
||||||
|
const PLACE_BLOCK_PACKET = 0x95;
|
||||||
|
const REMOVE_BLOCK_PACKET = 0x96;
|
||||||
|
const UPDATE_BLOCK_PACKET = 0x97;
|
||||||
|
const ADD_PAINTING_PACKET = 0x98;// Maybe exist
|
||||||
|
const EXPLODE_PACKET = 0x99;
|
||||||
|
const LEVEL_EVENT_PACKET = 0x9a;
|
||||||
|
const TILE_EVENT_PACKET = 0x9b;//Maybe exist
|
||||||
|
const ENTITY_EVENT_PACKET = 0x9c;
|
||||||
|
const REQUEST_CHUNK_PACKET = 0x9d;
|
||||||
|
const CHUNK_DATA_PACKET = 0x9e;
|
||||||
|
const PLAYER_EQUIPMENT_PACKET = 0x9f;
|
||||||
|
// const PLAYER_ARMOR_EQUIPMENT_PACKET = 0xa0;
|
||||||
|
const INTERACT_PACKET = 0xa0;//Change
|
||||||
|
const USE_ITEM_PACKET = 0xa1;
|
||||||
|
const PLAYER_ACTION_PACKET = 0xa2;
|
||||||
|
const SET_ENTITY_DATA_PACKET = 0xa3;
|
||||||
|
const SET_ENTITY_MOTION_PACKET = 0xa4;
|
||||||
|
//const SET_ENTITY_LINK_PACKET = 0xa?;
|
||||||
|
const SET_HEALTH_PACKET = 0xa5;
|
||||||
|
const SET_SPAWN_POSITION_PACKET = 0xa6;
|
||||||
|
const ANIMATE_PACKET = 0xa7;
|
||||||
|
const RESPAWN_PACKET = 0xa8;
|
||||||
|
const SEND_INVENTORY_PACKET = 0xa9;//Maybe exist
|
||||||
|
const DROP_ITEM_PACKET = 0xaa;
|
||||||
|
const CONTAINER_OPEN_PACKET = 0xab;
|
||||||
|
const CONTAINER_CLOSE_PACKET = 0xac;
|
||||||
|
const CONTAINER_SET_SLOT_PACKET = 0xad;
|
||||||
|
const CONTAINER_SET_DATA_PACKET = 0xae;
|
||||||
|
const CONTAINER_SET_CONTENT_PACKET = 0xaf;
|
||||||
|
const CONTAINER_ACK_PACKET = 0xb;
|
||||||
|
const CHAT_PACKET = 0xb1;//12 change
|
||||||
|
const ADVENTURE_SETTINGS_PACKET = 0xb3;
|
||||||
|
const ENTITY_DATA_PACKET = 0xb2;
|
||||||
|
const PLAYER_INPUT_PACKET = 0xb9;
|
||||||
|
}
|
||||||
/***REM_START***/
|
/***REM_START***/
|
||||||
require_once(FILE_PATH . "src/network/raknet/RakNetDataPacket.php");
|
require_once(FILE_PATH . "src/network/raknet/RakNetDataPacket.php");
|
||||||
/***REM_END***/
|
/***REM_END***/
|
||||||
|
|
@ -9,6 +9,9 @@ class AddPaintingPacket extends RakNetDataPacket{
|
||||||
public $title;
|
public $title;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ADD_PAINTING_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ADD_PAINTING_PACKET;
|
return ProtocolInfo::ADD_PAINTING_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ class AdventureSettingsPacket extends RakNetDataPacket{
|
||||||
public $flags;
|
public $flags;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::ADVENTURE_SETTINGS_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::ADVENTURE_SETTINGS_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ADVENTURE_SETTINGS_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
|
return ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@ class AnimatePacket extends RakNetDataPacket{
|
||||||
public $eid;
|
public $eid;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::ANIMATE_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::ANIMATE_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ANIMATE_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ANIMATE_PACKET;
|
return ProtocolInfo::ANIMATE_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ class ChatPacket extends RakNetDataPacket{
|
||||||
public $message;
|
public $message;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CHAT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CHAT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CHAT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CHAT_PACKET;
|
return ProtocolInfo::CHAT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ class ChunkDataPacket extends RakNetDataPacket{
|
||||||
public $data;
|
public $data;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CHUNK_DATA_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CHUNK_DATA_PACKET;
|
return ProtocolInfo::CHUNK_DATA_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ class ContainerClosePacket extends RakNetDataPacket{
|
||||||
public $windowid;
|
public $windowid;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CONTAINER_CLOSE_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CONTAINER_CLOSE_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CONTAINER_CLOSE_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CONTAINER_CLOSE_PACKET;
|
return ProtocolInfo::CONTAINER_CLOSE_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,13 @@ class ContainerOpenPacket extends RakNetDataPacket{
|
||||||
public $z;
|
public $z;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CONTAINER_OPEN_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CONTAINER_OPEN_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CONTAINER_OPEN_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CONTAINER_OPEN_PACKET;
|
return ProtocolInfo::CONTAINER_OPEN_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +28,7 @@ class ContainerOpenPacket extends RakNetDataPacket{
|
||||||
$this->putByte($this->windowid);
|
$this->putByte($this->windowid);
|
||||||
$this->putByte($this->type);
|
$this->putByte($this->type);
|
||||||
$this->putByte($this->slots);
|
$this->putByte($this->slots);
|
||||||
$this->putInt($this->x);
|
$this->putInt($this->x);//String
|
||||||
$this->putInt($this->y);
|
$this->putInt($this->y);
|
||||||
$this->putInt($this->z);
|
$this->putInt($this->z);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ class ContainerSetContentPacket extends RakNetDataPacket{
|
||||||
public $hotbar = array();
|
public $hotbar = array();
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CONTAINER_SET_CONTENT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CONTAINER_SET_CONTENT_PACKET;
|
||||||
|
}else if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CONTAINER_SET_CONTENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
|
return ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,7 +38,7 @@ class ContainerSetContentPacket extends RakNetDataPacket{
|
||||||
$this->putSlot($slot);
|
$this->putSlot($slot);
|
||||||
}
|
}
|
||||||
if($this->windowid === 0 and count($this->hotbar) > 0){
|
if($this->windowid === 0 and count($this->hotbar) > 0){
|
||||||
$this->putShort(count($this->hotbar));
|
$this->putShort(count($this->hotbar));//null
|
||||||
foreach($this->hotbar as $slot){
|
foreach($this->hotbar as $slot){
|
||||||
$this->putInt($slot);
|
$this->putInt($slot);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ class ContainerSetDataPacket extends RakNetDataPacket{
|
||||||
public $value;
|
public $value;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CONTAINER_SET_DATA_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CONTAINER_SET_DATA_PACKET;
|
||||||
|
}else if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CONTAINER_SET_DATA_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CONTAINER_SET_DATA_PACKET;
|
return ProtocolInfo::CONTAINER_SET_DATA_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ class ContainerSetSlotPacket extends RakNetDataPacket{
|
||||||
public $item;
|
public $item;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::CONTAINER_SET_SLOT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::CONTAINER_SET_SLOT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::CONTAINER_SET_SLOT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::CONTAINER_SET_SLOT_PACKET;
|
return ProtocolInfo::CONTAINER_SET_SLOT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ class DropItemPacket extends RakNetDataPacket{
|
||||||
public $item;
|
public $item;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::DROP_ITEM_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::DROP_ITEM_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::DROP_ITEM_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::DROP_ITEM_PACKET;
|
return ProtocolInfo::DROP_ITEM_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ class EntityDataPacket extends RakNetDataPacket{
|
||||||
public $namedtag;
|
public $namedtag;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::ENTITY_DATA_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::ENTITY_DATA_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ENTITY_DATA_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ENTITY_DATA_PACKET;
|
return ProtocolInfo::ENTITY_DATA_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ class EntityEventPacket extends RakNetDataPacket{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ENTITY_EVENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ENTITY_EVENT_PACKET;
|
return ProtocolInfo::ENTITY_EVENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ class ExplodePacket extends RakNetDataPacket{
|
||||||
public $records;
|
public $records;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::EXPLODE_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::EXPLODE_PACKET;
|
return ProtocolInfo::EXPLODE_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ class HurtArmorPacket extends RakNetDataPacket{
|
||||||
public $health;
|
public $health;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::HURT_ARMOR_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::HURT_ARMOR_PACKET;
|
return ProtocolInfo::HURT_ARMOR_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ class InteractPacket extends RakNetDataPacket{
|
||||||
public $target;
|
public $target;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::INTERACT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::INTERACT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::INTERACT_PACKET;
|
return ProtocolInfo::INTERACT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ class LevelEventPacket extends RakNetDataPacket{
|
||||||
public $data;
|
public $data;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::LEVEL_EVENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::LEVEL_EVENT_PACKET;
|
return ProtocolInfo::LEVEL_EVENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@ class LoginPacket extends RakNetDataPacket{
|
||||||
$this->username = $this->getString();
|
$this->username = $this->getString();
|
||||||
$this->protocol1 = $this->getInt();
|
$this->protocol1 = $this->getInt();
|
||||||
$this->protocol2 = $this->getInt();
|
$this->protocol2 = $this->getInt();
|
||||||
$this->clientId = $this->getInt();
|
$this->clientId = $this->getInt();//null
|
||||||
$this->loginData = $this->getString();
|
$this->loginData = $this->getString();
|
||||||
|
$this->PROTOCOL = $this->protocol1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,17 @@ class MessagePacket extends RakNetDataPacket{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
|
if($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9){ //0.6.1 and below From NostalgiaCore-BackPort Author:Gameherobrine
|
||||||
$this->source = $this->getString();
|
$this->source = $this->getString();
|
||||||
|
}
|
||||||
$this->message = $this->getString();
|
$this->message = $this->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
if($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9){ //0.6.1 and below From NostalgiaCore-BackPort Author:Gameherobrine
|
||||||
$this->putString($this->source);
|
$this->putString($this->source);
|
||||||
|
}
|
||||||
$this->putString($this->message);
|
$this->putString($this->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ class MovePlayerPacket extends RakNetDataPacket{
|
||||||
public $bodyYaw;
|
public $bodyYaw;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::MOVE_PLAYER_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::MOVE_PLAYER_PACKET;
|
return ProtocolInfo::MOVE_PLAYER_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,8 +23,10 @@ class MovePlayerPacket extends RakNetDataPacket{
|
||||||
$this->z = $this->getFloat();
|
$this->z = $this->getFloat();
|
||||||
$this->yaw = $this->getFloat();
|
$this->yaw = $this->getFloat();
|
||||||
$this->pitch = $this->getFloat();
|
$this->pitch = $this->getFloat();
|
||||||
|
if($this->PROTOCOL > 13){
|
||||||
$this->bodyYaw = $this->getFloat();
|
$this->bodyYaw = $this->getFloat();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
|
@ -31,7 +36,9 @@ class MovePlayerPacket extends RakNetDataPacket{
|
||||||
$this->putFloat($this->z);
|
$this->putFloat($this->z);
|
||||||
$this->putFloat($this->yaw);
|
$this->putFloat($this->yaw);
|
||||||
$this->putFloat($this->pitch);
|
$this->putFloat($this->pitch);
|
||||||
|
if($this->PROTOCOL > 13){
|
||||||
$this->putFloat($this->bodyYaw);
|
$this->putFloat($this->bodyYaw);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
54
src/network/protocol/packet/PlaceBlockPacket.php
Normal file
54
src/network/protocol/packet/PlaceBlockPacket.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PlaceBlockPacket extends RakNetDataPacket{
|
||||||
|
public $unknown1 = 0;
|
||||||
|
public $unknown2 = 0;
|
||||||
|
public $unknown3 = 0;
|
||||||
|
public $unknown4 = 0;
|
||||||
|
public $unknown5 = 0;
|
||||||
|
public $unknown6 = 0;
|
||||||
|
public $unknown7 = 0;
|
||||||
|
|
||||||
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL) {
|
||||||
|
return ProtocolInfo12::PLACE_BLOCK_PACKET;
|
||||||
|
}
|
||||||
|
return ProtocolInfo::PLACE_BLOCK_PACKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decode(){
|
||||||
|
$this->unknown1 = $this->getInt();
|
||||||
|
$this->unknown2 = $this->getInt();
|
||||||
|
$this->unknown3 = $this->getInt();
|
||||||
|
$this->unknown4 = $this->getByte();
|
||||||
|
$this->unknown5 = $this->getByte();
|
||||||
|
$this->unknown6 = $this->getByte();
|
||||||
|
$this->unknown7 = $this->getByte();
|
||||||
|
ConsoleAPI::info("Int1:".$this->unknown1);
|
||||||
|
ConsoleAPI::info("Int2:".$this->unknown2);
|
||||||
|
ConsoleAPI::info("Int3:".$this->unknown3);
|
||||||
|
ConsoleAPI::info("Byte4:".$this->unknown4);
|
||||||
|
ConsoleAPI::info("Byte5:".$this->unknown5);
|
||||||
|
ConsoleAPI::info("Byte6:".$this->unknown6);
|
||||||
|
ConsoleAPI::info("Byte7:".$this->unknown7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function encode(){
|
||||||
|
$this->reset();
|
||||||
|
$this->putInt($this->unknown1);
|
||||||
|
$this->putInt($this->unknown2);
|
||||||
|
$this->putInt($this->unknown3);
|
||||||
|
$this->putByte($this->unknown4);
|
||||||
|
$this->putByte($this->unknown5);
|
||||||
|
$this->putByte($this->unknown6);
|
||||||
|
$this->putByte($this->unknown7);
|
||||||
|
ConsoleAPI::info("Int1:".$this->unknown1);
|
||||||
|
ConsoleAPI::info("Int2:".$this->unknown2);
|
||||||
|
ConsoleAPI::info("Int3:".$this->unknown3);
|
||||||
|
ConsoleAPI::info("Byte4:".$this->unknown4);
|
||||||
|
ConsoleAPI::info("Byte5:".$this->unknown5);
|
||||||
|
ConsoleAPI::info("Byte6:".$this->unknown6);
|
||||||
|
ConsoleAPI::info("Byte7:".$this->unknown7);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,11 @@ class PlayerActionPacket extends RakNetDataPacket{
|
||||||
public $eid;
|
public $eid;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::PLAYER_ACTION_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::PLAYER_ACTION_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::PLAYER_ACTION_PACKET;
|
return ProtocolInfo::PLAYER_ACTION_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ class PlayerArmorEquipmentPacket extends RakNetDataPacket{
|
||||||
public $slots = array();
|
public $slots = array();
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::PLAYER_ARMOR_EQUIPMENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET;
|
return ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
||||||
public $slot;
|
public $slot;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::PLAYER_EQUIPMENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::PLAYER_EQUIPMENT_PACKET;
|
return ProtocolInfo::PLAYER_EQUIPMENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +17,7 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
||||||
$this->eid = $this->getInt();
|
$this->eid = $this->getInt();
|
||||||
$this->item = $this->getShort();
|
$this->item = $this->getShort();
|
||||||
$this->meta = $this->getShort();
|
$this->meta = $this->getShort();
|
||||||
$this->slot = $this->getSignedByte();
|
if($this->PROTOCOL === ProtocolInfo::CURRENT_PROTOCOL){$this->slot = $this->getSignedByte();}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
|
|
@ -22,7 +25,7 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
||||||
$this->putInt($this->eid);
|
$this->putInt($this->eid);
|
||||||
$this->putShort($this->item);
|
$this->putShort($this->item);
|
||||||
$this->putShort($this->meta);
|
$this->putShort($this->meta);
|
||||||
$this->putByte($this->slot);
|
if($this->PROTOCOL === ProtocolInfo::CURRENT_PROTOCOL){$this->putByte($this->slot);}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
class PlayerInputPacket extends RakNetDataPacket{
|
class PlayerInputPacket extends RakNetDataPacket{
|
||||||
|
|
||||||
public $moveStrafe, $moveForward, $isJumping, $isSneaking;
|
public $moveStrafe, $moveForward, $isJumping, $isSneaking;
|
||||||
public function encode()
|
|
||||||
{
|
public function encode(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pid()
|
public function pid(){
|
||||||
{
|
if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::PLAYER_INPUT_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::PLAYER_INPUT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::PLAYER_INPUT_PACKET;
|
return ProtocolInfo::PLAYER_INPUT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ class RemoveBlockPacket extends RakNetDataPacket{
|
||||||
public $z;
|
public $z;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::REMOVE_BLOCK_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::REMOVE_BLOCK_PACKET;
|
return ProtocolInfo::REMOVE_BLOCK_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ class RequestChunkPacket extends RakNetDataPacket{
|
||||||
public $chunkZ;
|
public $chunkZ;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::REQUEST_CHUNK_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::REQUEST_CHUNK_PACKET;
|
return ProtocolInfo::REQUEST_CHUNK_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ class RespawnPacket extends RakNetDataPacket{
|
||||||
public $z;
|
public $z;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::RESPAWN_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::RESPAWN_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::RESPAWN_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::RESPAWN_PACKET;
|
return ProtocolInfo::RESPAWN_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ class RotateHeadPacket extends RakNetDataPacket{
|
||||||
*/
|
*/
|
||||||
public $rawYaw = false;
|
public $rawYaw = false;
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::ROTATE_HEAD_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::ROTATE_HEAD_PACKET;
|
return ProtocolInfo::ROTATE_HEAD_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ class SendInventoryPacket extends RakNetDataPacket{
|
||||||
public $armor = array();
|
public $armor = array();
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::SEND_INVENTORY_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::SEND_INVENTORY_PACKET;
|
||||||
|
}else if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SEND_INVENTORY_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SEND_INVENTORY_PACKET;
|
return ProtocolInfo::SEND_INVENTORY_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ class SetEntityDataPacket extends RakNetDataPacket{
|
||||||
public $metadata;
|
public $metadata;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::SET_ENTITY_DATA_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SET_ENTITY_DATA_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SET_ENTITY_DATA_PACKET;
|
return ProtocolInfo::SET_ENTITY_DATA_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,6 +19,7 @@ class SetEntityDataPacket extends RakNetDataPacket{
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
if($this->PROTOCOL >= ProtocolInfo7::CURRENT_PROTOCOL_7)
|
||||||
$this->putInt($this->eid);
|
$this->putInt($this->eid);
|
||||||
$this->put(Utils::writeMetadata($this->metadata));
|
$this->put(Utils::writeMetadata($this->metadata));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ class SetEntityLinkPacket extends RakNetDataPacket{
|
||||||
|
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SET_ENTITY_LINK_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SET_ENTITY_LINK_PACKET;
|
return ProtocolInfo::SET_ENTITY_LINK_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,11 @@ class SetEntityMotionPacket extends RakNetDataPacket{
|
||||||
public $speedZ;
|
public $speedZ;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::SET_ENTITY_MOTION_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SET_ENTITY_MOTION_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SET_ENTITY_MOTION_PACKET;
|
return ProtocolInfo::SET_ENTITY_MOTION_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ class SetHealthPacket extends RakNetDataPacket{
|
||||||
public $health;
|
public $health;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::SET_HEALTH_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::SET_HEALTH_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SET_HEALTH_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SET_HEALTH_PACKET;
|
return ProtocolInfo::SET_HEALTH_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ class SetSpawnPositionPacket extends RakNetDataPacket{
|
||||||
public $y;
|
public $y;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::SET_SPAWN_POSITION_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||||
|
return ProtocolInfo9::SET_SPAWN_POSITION_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::SET_SPAWN_POSITION_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::SET_SPAWN_POSITION_PACKET;
|
return ProtocolInfo::SET_SPAWN_POSITION_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class SetTimePacket extends RakNetDataPacket{
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
$this->putInt($this->time);
|
$this->putInt($this->time);//long
|
||||||
$this->putByte($this->started ? 0x80:0x00);
|
$this->putByte($this->started ? 0x80:0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class StartGamePacket extends RakNetDataPacket{
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
$this->putInt($this->seed);
|
$this->putInt($this->seed);//long
|
||||||
$this->putInt($this->generator);
|
$this->putInt($this->generator);
|
||||||
$this->putInt($this->gamemode);
|
$this->putInt($this->gamemode);
|
||||||
$this->putInt($this->eid);
|
$this->putInt($this->eid);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ class TileEventPacket extends RakNetDataPacket{
|
||||||
public $case2;
|
public $case2;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::TILE_EVENT_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::TILE_EVENT_PACKET;
|
return ProtocolInfo::TILE_EVENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ class UpdateBlockPacket extends RakNetDataPacket{
|
||||||
public $meta;
|
public $meta;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::UPDATE_BLOCK_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::UPDATE_BLOCK_PACKET;
|
return ProtocolInfo::UPDATE_BLOCK_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ class UseItemPacket extends RakNetDataPacket{
|
||||||
public $posZ;
|
public $posZ;
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
|
if($this->PROTOCOL < ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||||
|
return ProtocolInfo7::USE_ITEM_PACKET;
|
||||||
|
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
return ProtocolInfo12::USE_ITEM_PACKET;
|
||||||
|
}
|
||||||
return ProtocolInfo::USE_ITEM_PACKET;
|
return ProtocolInfo::USE_ITEM_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,10 +35,12 @@ class UseItemPacket extends RakNetDataPacket{
|
||||||
$this->fx = $this->getFloat();
|
$this->fx = $this->getFloat();
|
||||||
$this->fy = $this->getFloat();
|
$this->fy = $this->getFloat();
|
||||||
$this->fz = $this->getFloat();
|
$this->fz = $this->getFloat();
|
||||||
|
if ($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9) {
|
||||||
$this->posX = $this->getFloat();
|
$this->posX = $this->getFloat();
|
||||||
$this->posY = $this->getFloat();
|
$this->posY = $this->getFloat();
|
||||||
$this->posZ = $this->getFloat();
|
$this->posZ = $this->getFloat();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,11 @@ abstract class RakNetDataPacket extends stdClass{
|
||||||
public $splitCount;
|
public $splitCount;
|
||||||
public $splitID;
|
public $splitID;
|
||||||
public $splitIndex;
|
public $splitIndex;
|
||||||
|
|
||||||
private $offset = 0;
|
private $offset = 0;
|
||||||
|
|
||||||
|
public $PROTOCOL = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
|
|
||||||
abstract public function encode();
|
abstract public function encode();
|
||||||
|
|
||||||
abstract public function decode();
|
abstract public function decode();
|
||||||
|
|
@ -34,8 +37,22 @@ abstract class RakNetDataPacket extends stdClass{
|
||||||
$this->setBuffer(chr($this->pid()));
|
$this->setBuffer(chr($this->pid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isPacketExist(int $protocol) : int{
|
||||||
|
|
||||||
|
$exist = true;
|
||||||
|
return $exist;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public function pid();
|
abstract public function pid();
|
||||||
|
|
||||||
|
public function getInternalPid() : int{
|
||||||
|
$rawProtocol = $this->PROTOCOL;
|
||||||
|
$this->PROTOCOL = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
|
$pid = (int) $this->pid();
|
||||||
|
$this->PROTOCOL = $rawProtocol;
|
||||||
|
return $pid;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getLong($unsigned = false){
|
protected function getLong($unsigned = false){
|
||||||
return Utils::readLong($this->get(8), $unsigned);
|
return Utils::readLong($this->get(8), $unsigned);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@ class RakNetParser{
|
||||||
|
|
||||||
public $packet;
|
public $packet;
|
||||||
private $buffer;
|
private $buffer;
|
||||||
|
private $source;
|
||||||
private $offset;
|
private $offset;
|
||||||
|
private $isparse = false;
|
||||||
|
|
||||||
public function __construct(&$buffer){
|
public function __construct(&$buffer, $source){
|
||||||
|
$this->source =& $source;
|
||||||
$this->buffer =& $buffer;
|
$this->buffer =& $buffer;
|
||||||
$this->offset = 0;
|
$this->offset = 0;
|
||||||
if(strlen($this->buffer) > 0){
|
if(strlen($this->buffer) > 0){
|
||||||
|
|
@ -56,6 +59,9 @@ class RakNetParser{
|
||||||
case RakNetInfo::DATA_PACKET_F:
|
case RakNetInfo::DATA_PACKET_F:
|
||||||
$this->packet->seqNumber = $this->getLTriad();
|
$this->packet->seqNumber = $this->getLTriad();
|
||||||
$this->packet->data = [];
|
$this->packet->data = [];
|
||||||
|
$this->packet->ip = $this->source;
|
||||||
|
$PROTOCOL = PlayerAPI::decodeProtocol($this->packet->ip);
|
||||||
|
|
||||||
while(!$this->feof() and ($pk = $this->parseDataPacket()) instanceof RakNetDataPacket){
|
while(!$this->feof() and ($pk = $this->parseDataPacket()) instanceof RakNetDataPacket){
|
||||||
$this->packet->data[] = $pk;
|
$this->packet->data[] = $pk;
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +123,7 @@ class RakNetParser{
|
||||||
return !isset($this->buffer[$this->offset]);
|
return !isset($this->buffer[$this->offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseDataPacket(){
|
private function parseDataPacket(int $protocol = ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
$packetFlags = $this->getByte();
|
$packetFlags = $this->getByte();
|
||||||
$reliability = ($packetFlags & 0b11100000) >> 5;
|
$reliability = ($packetFlags & 0b11100000) >> 5;
|
||||||
$hasSplit = ($packetFlags & 0b00010000) > 0;
|
$hasSplit = ($packetFlags & 0b00010000) > 0;
|
||||||
|
|
@ -164,65 +170,236 @@ class RakNetParser{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = match($pid){
|
$data = PacketPool::getPacket($pid, $protocol);
|
||||||
ProtocolInfo::PING_PACKET => new PingPacket(),
|
$data->reliability = $reliability;
|
||||||
ProtocolInfo::PONG_PACKET => new PongPacket(),
|
$data->hasSplit = $hasSplit;
|
||||||
ProtocolInfo::CLIENT_CONNECT_PACKET => new ClientConnectPacket(),
|
$data->messageIndex = $messageIndex;
|
||||||
ProtocolInfo::SERVER_HANDSHAKE_PACKET => new ServerHandshakePacket(),
|
$data->orderIndex = $orderIndex;
|
||||||
ProtocolInfo::DISCONNECT_PACKET => new DisconnectPacket(),
|
$data->orderChannel = $orderChannel;
|
||||||
ProtocolInfo::LOGIN_PACKET => new LoginPacket(),
|
$data->splitCount = $splitCount;
|
||||||
ProtocolInfo::LOGIN_STATUS_PACKET => new LoginStatusPacket(),
|
$data->splitID = $splitID;
|
||||||
ProtocolInfo::READY_PACKET => new ReadyPacket(),
|
$data->splitIndex = $splitIndex;
|
||||||
ProtocolInfo::MESSAGE_PACKET => new MessagePacket(),
|
$data->setBuffer($buffer);
|
||||||
ProtocolInfo::SET_TIME_PACKET => new SetTimePacket(),
|
}
|
||||||
ProtocolInfo::START_GAME_PACKET => new StartGamePacket(),
|
return $data;
|
||||||
ProtocolInfo::ADD_MOB_PACKET => new AddMobPacket(),
|
}
|
||||||
ProtocolInfo::ADD_PLAYER_PACKET => new AddPlayerPacket(),
|
|
||||||
ProtocolInfo::REMOVE_PLAYER_PACKET => new RemovePlayerPacket(),
|
|
||||||
ProtocolInfo::ADD_ENTITY_PACKET => new AddEntityPacket(),
|
|
||||||
ProtocolInfo::REMOVE_ENTITY_PACKET => new RemoveEntityPacket(),
|
|
||||||
ProtocolInfo::ADD_ITEM_ENTITY_PACKET => new AddItemEntityPacket(),
|
|
||||||
ProtocolInfo::TAKE_ITEM_ENTITY_PACKET => new TakeItemEntityPacket(),
|
|
||||||
ProtocolInfo::MOVE_ENTITY_PACKET => new MoveEntityPacket(),
|
|
||||||
ProtocolInfo::MOVE_ENTITY_PACKET_POSROT => new MoveEntityPacket_PosRot(),
|
|
||||||
ProtocolInfo::ROTATE_HEAD_PACKET => new RotateHeadPacket(),
|
|
||||||
ProtocolInfo::MOVE_PLAYER_PACKET => new MovePlayerPacket(),
|
|
||||||
ProtocolInfo::REMOVE_BLOCK_PACKET => new RemoveBlockPacket(),
|
|
||||||
ProtocolInfo::UPDATE_BLOCK_PACKET => new UpdateBlockPacket(),
|
|
||||||
ProtocolInfo::ADD_PAINTING_PACKET => new AddPaintingPacket(),
|
|
||||||
ProtocolInfo::EXPLODE_PACKET => new ExplodePacket(),
|
|
||||||
ProtocolInfo::LEVEL_EVENT_PACKET => new LevelEventPacket(),
|
|
||||||
ProtocolInfo::TILE_EVENT_PACKET => new TileEventPacket(),
|
|
||||||
ProtocolInfo::ENTITY_EVENT_PACKET => new EntityEventPacket(),
|
|
||||||
ProtocolInfo::REQUEST_CHUNK_PACKET => new RequestChunkPacket(),
|
|
||||||
ProtocolInfo::CHUNK_DATA_PACKET => new ChunkDataPacket(),
|
|
||||||
ProtocolInfo::PLAYER_EQUIPMENT_PACKET => new PlayerEquipmentPacket(),
|
|
||||||
ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET => new PlayerArmorEquipmentPacket(),
|
|
||||||
ProtocolInfo::INTERACT_PACKET => new InteractPacket(),
|
|
||||||
ProtocolInfo::USE_ITEM_PACKET => new UseItemPacket(),
|
|
||||||
ProtocolInfo::PLAYER_ACTION_PACKET => new PlayerActionPacket(),
|
|
||||||
ProtocolInfo::HURT_ARMOR_PACKET => new HurtArmorPacket(),
|
|
||||||
ProtocolInfo::SET_ENTITY_DATA_PACKET => new SetEntityDataPacket(),
|
|
||||||
ProtocolInfo::SET_ENTITY_MOTION_PACKET => new SetEntityMotionPacket(),
|
|
||||||
ProtocolInfo::SET_HEALTH_PACKET => new SetHealthPacket(),
|
|
||||||
ProtocolInfo::SET_SPAWN_POSITION_PACKET => new SetSpawnPositionPacket(),
|
|
||||||
ProtocolInfo::ANIMATE_PACKET => new AnimatePacket(),
|
|
||||||
ProtocolInfo::RESPAWN_PACKET => new RespawnPacket(),
|
|
||||||
ProtocolInfo::SEND_INVENTORY_PACKET => new SendInventoryPacket(),
|
|
||||||
ProtocolInfo::DROP_ITEM_PACKET => new DropItemPacket(),
|
|
||||||
ProtocolInfo::CONTAINER_OPEN_PACKET => new ContainerOpenPacket(),
|
|
||||||
ProtocolInfo::CONTAINER_CLOSE_PACKET => new ContainerClosePacket(),
|
|
||||||
ProtocolInfo::CONTAINER_SET_SLOT_PACKET => new ContainerSetSlotPacket(),
|
|
||||||
ProtocolInfo::CONTAINER_SET_DATA_PACKET => new ContainerSetDataPacket(),
|
|
||||||
ProtocolInfo::CONTAINER_SET_CONTENT_PACKET => new ContainerSetContentPacket(),
|
|
||||||
ProtocolInfo::CHAT_PACKET => new ChatPacket(),
|
|
||||||
ProtocolInfo::ADVENTURE_SETTINGS_PACKET => new AdventureSettingsPacket(),
|
|
||||||
ProtocolInfo::ENTITY_DATA_PACKET => new EntityDataPacket(),
|
|
||||||
ProtocolInfo::SET_ENTITY_LINK_PACKET => new SetEntityLinkPacket(),
|
|
||||||
ProtocolInfo::PLAYER_INPUT_PACKET => new PlayerInputPacket(),
|
|
||||||
default => new UnknownPacket($pid)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private function parseDataPacket12(){
|
||||||
|
$packetFlags = $this->getByte();
|
||||||
|
$reliability = ($packetFlags & 0b11100000) >> 5;
|
||||||
|
$hasSplit = ($packetFlags & 0b00010000) > 0;
|
||||||
|
$length = (int) ceil($this->getShort() / 8);
|
||||||
|
if($reliability === 2
|
||||||
|
or $reliability === 3
|
||||||
|
or $reliability === 4
|
||||||
|
or $reliability === 6
|
||||||
|
or $reliability === 7){
|
||||||
|
$messageIndex = $this->getLTriad();
|
||||||
|
}else{
|
||||||
|
$messageIndex = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($reliability === 1
|
||||||
|
or $reliability === 3
|
||||||
|
or $reliability === 4
|
||||||
|
or $reliability === 7){
|
||||||
|
$orderIndex = $this->getLTriad();
|
||||||
|
$orderChannel = $this->getByte();
|
||||||
|
}else{
|
||||||
|
$orderIndex = false;
|
||||||
|
$orderChannel = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($hasSplit){
|
||||||
|
$splitCount = $this->getInt();
|
||||||
|
$splitID = $this->getShort();
|
||||||
|
$splitIndex = $this->getInt();
|
||||||
|
}else{
|
||||||
|
$splitCount = false;
|
||||||
|
$splitID = false;
|
||||||
|
$splitIndex = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($length <= 0
|
||||||
|
or $orderChannel >= 32
|
||||||
|
or ($hasSplit === true and $splitIndex >= $splitCount)){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
$pid = $this->getByte();
|
||||||
|
$buffer = $this->get($length - 1);
|
||||||
|
if(strlen($buffer) < ($length - 1)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch($pid){
|
||||||
|
case ProtocolInfo12::PING_PACKET:
|
||||||
|
$data = new PingPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::PONG_PACKET:
|
||||||
|
$data = new PongPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CLIENT_CONNECT_PACKET:
|
||||||
|
$data = new ClientConnectPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SERVER_HANDSHAKE_PACKET:
|
||||||
|
$data = new ServerHandshakePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::DISCONNECT_PACKET:
|
||||||
|
$data = new DisconnectPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::LOGIN_PACKET:
|
||||||
|
$data = new LoginPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::LOGIN_STATUS_PACKET:
|
||||||
|
$data = new LoginStatusPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::READY_PACKET:
|
||||||
|
$data = new ReadyPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::MESSAGE_PACKET:
|
||||||
|
$data = new MessagePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_TIME_PACKET:
|
||||||
|
$data = new SetTimePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::START_GAME_PACKET:
|
||||||
|
$data = new StartGamePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADD_MOB_PACKET:
|
||||||
|
$data = new AddMobPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADD_PLAYER_PACKET:
|
||||||
|
$data = new AddPlayerPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::REMOVE_PLAYER_PACKET:
|
||||||
|
$data = new RemovePlayerPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADD_ENTITY_PACKET:
|
||||||
|
$data = new AddEntityPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::REMOVE_ENTITY_PACKET:
|
||||||
|
$data = new RemoveEntityPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADD_ITEM_ENTITY_PACKET:
|
||||||
|
$data = new AddItemEntityPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::TAKE_ITEM_ENTITY_PACKET:
|
||||||
|
$data = new TakeItemEntityPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::MOVE_ENTITY_PACKET:
|
||||||
|
$data = new MoveEntityPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::MOVE_ENTITY_PACKET_POSROT:
|
||||||
|
$data = new MoveEntityPacket_PosRot;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ROTATE_HEAD_PACKET:
|
||||||
|
$data = new RotateHeadPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::MOVE_PLAYER_PACKET:
|
||||||
|
$data = new MovePlayerPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::REMOVE_BLOCK_PACKET:
|
||||||
|
$data = new RemoveBlockPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::UPDATE_BLOCK_PACKET:
|
||||||
|
$data = new UpdateBlockPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADD_PAINTING_PACKET:
|
||||||
|
$data = new AddPaintingPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::EXPLODE_PACKET:
|
||||||
|
$data = new ExplodePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::LEVEL_EVENT_PACKET:
|
||||||
|
$data = new LevelEventPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::TILE_EVENT_PACKET:
|
||||||
|
$data = new TileEventPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ENTITY_EVENT_PACKET:
|
||||||
|
$data = new EntityEventPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::REQUEST_CHUNK_PACKET:
|
||||||
|
$data = new RequestChunkPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CHUNK_DATA_PACKET:
|
||||||
|
$data = new ChunkDataPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::PLAYER_EQUIPMENT_PACKET:
|
||||||
|
$data = new PlayerEquipmentPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::PLAYER_ARMOR_EQUIPMENT_PACKET:
|
||||||
|
$data = new PlayerArmorEquipmentPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::INTERACT_PACKET:
|
||||||
|
$data = new InteractPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::USE_ITEM_PACKET:
|
||||||
|
$data = new UseItemPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::PLAYER_ACTION_PACKET:
|
||||||
|
$data = new PlayerActionPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::HURT_ARMOR_PACKET:
|
||||||
|
$data = new HurtArmorPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_ENTITY_DATA_PACKET:
|
||||||
|
$data = new SetEntityDataPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_ENTITY_MOTION_PACKET:
|
||||||
|
$data = new SetEntityMotionPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_HEALTH_PACKET:
|
||||||
|
$data = new SetHealthPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_SPAWN_POSITION_PACKET:
|
||||||
|
$data = new SetSpawnPositionPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ANIMATE_PACKET:
|
||||||
|
$data = new AnimatePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::RESPAWN_PACKET:
|
||||||
|
$data = new RespawnPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SEND_INVENTORY_PACKET:
|
||||||
|
$data = new SendInventoryPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::DROP_ITEM_PACKET:
|
||||||
|
$data = new DropItemPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CONTAINER_OPEN_PACKET:
|
||||||
|
$data = new ContainerOpenPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CONTAINER_CLOSE_PACKET:
|
||||||
|
$data = new ContainerClosePacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CONTAINER_SET_SLOT_PACKET:
|
||||||
|
$data = new ContainerSetSlotPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CONTAINER_SET_DATA_PACKET:
|
||||||
|
$data = new ContainerSetDataPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CONTAINER_SET_CONTENT_PACKET:
|
||||||
|
$data = new ContainerSetContentPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::CHAT_PACKET:
|
||||||
|
$data = new ChatPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ADVENTURE_SETTINGS_PACKET:
|
||||||
|
$data = new AdventureSettingsPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::ENTITY_DATA_PACKET:
|
||||||
|
$data = new EntityDataPacket;
|
||||||
|
break;
|
||||||
|
case ProtocolInfo12::SET_ENTITY_LINK_PACKET:
|
||||||
|
$data = new SetEntityLinkPacket;
|
||||||
|
case ProtocolInfo12::PLAYER_INPUT_PACKET:
|
||||||
|
$data = new PlayerInputPacket;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$data = new UnknownPacket();
|
||||||
|
$data->packetID = $pid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
$data->reliability = $reliability;
|
$data->reliability = $reliability;
|
||||||
$data->hasSplit = $hasSplit;
|
$data->hasSplit = $hasSplit;
|
||||||
$data->messageIndex = $messageIndex;
|
$data->messageIndex = $messageIndex;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue