mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Skins, protocol changes, handle split packets
This commit is contained in:
@ -24,6 +24,8 @@ namespace pocketmine\network\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
class AddEntityPacket extends DataPacket{
|
||||
public static $pool = [];
|
||||
public static $next = 0;
|
||||
@ -33,10 +35,13 @@ class AddEntityPacket extends DataPacket{
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $did;
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
public $yaw;
|
||||
public $pitch;
|
||||
public $metadata;
|
||||
public $links = [];
|
||||
|
||||
public function pid(){
|
||||
return Info::ADD_ENTITY_PACKET;
|
||||
@ -53,11 +58,17 @@ class AddEntityPacket extends DataPacket{
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putLong($this->did);
|
||||
if($this->did > 0){
|
||||
$this->putFloat($this->speedX);
|
||||
$this->putFloat($this->speedY);
|
||||
$this->putFloat($this->speedZ);
|
||||
$this->putFloat($this->speedX);
|
||||
$this->putFloat($this->speedY);
|
||||
$this->putFloat($this->speedZ);
|
||||
$this->putFloat($this->yaw);
|
||||
$this->putFloat($this->pitch);
|
||||
$this->put(Binary::writeMetadata($this->metadata));
|
||||
$this->putShort(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putLong($link[0]);
|
||||
$this->putLong($link[1]);
|
||||
$this->putByte($link[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ class AddPlayerPacket extends DataPacket{
|
||||
public static $pool = [];
|
||||
public static $next = 0;
|
||||
|
||||
|
||||
|
||||
public $clientID;
|
||||
public $username;
|
||||
public $eid;
|
||||
@ -44,6 +46,9 @@ class AddPlayerPacket extends DataPacket{
|
||||
public $meta;
|
||||
public $metadata;
|
||||
|
||||
public $slim = false;
|
||||
public $skin = null;
|
||||
|
||||
public function pid(){
|
||||
return Info::ADD_PLAYER_PACKET;
|
||||
}
|
||||
@ -61,9 +66,12 @@ class AddPlayerPacket extends DataPacket{
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->yaw);
|
||||
$this->putFloat($this->yaw); //TODO headrot
|
||||
$this->putFloat($this->pitch);
|
||||
$this->putShort($this->item);
|
||||
$this->putShort($this->meta);
|
||||
$this->putByte($this->slim ? 1 : 0);
|
||||
$this->putString($this->skin);
|
||||
$this->put(Binary::writeMetadata($this->metadata));
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,10 @@ abstract class DataPacket extends \stdClass{
|
||||
$this->offset = 0;
|
||||
}
|
||||
|
||||
public function getOffset(){
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
public function getBuffer(){
|
||||
return $this->buffer;
|
||||
}
|
||||
|
@ -31,66 +31,65 @@ interface Info{
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
const CURRENT_PROTOCOL = 21;
|
||||
|
||||
|
||||
const LOGIN_PACKET = 0x82;
|
||||
const PLAY_STATUS_PACKET = 0x83;
|
||||
|
||||
|
||||
const DISCONNECT_PACKET = 0x84;
|
||||
|
||||
|
||||
const TEXT_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 = 0x8b;
|
||||
const REMOVE_ENTITY_PACKET = 0x8c;
|
||||
const ADD_ITEM_ENTITY_PACKET = 0x8d;
|
||||
const TAKE_ITEM_ENTITY_PACKET = 0x8e;
|
||||
|
||||
const MOVE_ENTITY_PACKET = 0x8f;
|
||||
const MOVE_PLAYER_PACKET = 0x90;
|
||||
|
||||
const REMOVE_BLOCK_PACKET = 0x91;
|
||||
const UPDATE_BLOCK_PACKET = 0x92;
|
||||
|
||||
const ADD_PAINTING_PACKET = 0x93;
|
||||
|
||||
const EXPLODE_PACKET = 0x94;
|
||||
|
||||
const LEVEL_EVENT_PACKET = 0x95;
|
||||
const TILE_EVENT_PACKET = 0x96;
|
||||
const ENTITY_EVENT_PACKET = 0x97;
|
||||
const MOB_EFFECT_PACKET = 0x98;
|
||||
|
||||
const PLAYER_EQUIPMENT_PACKET = 0x99;
|
||||
const PLAYER_ARMOR_EQUIPMENT_PACKET = 0x9a;
|
||||
const INTERACT_PACKET = 0x9b;
|
||||
const USE_ITEM_PACKET = 0x9c;
|
||||
const PLAYER_ACTION_PACKET = 0x9d;
|
||||
const HURT_ARMOR_PACKET = 0x9e;
|
||||
const SET_ENTITY_DATA_PACKET = 0x9f;
|
||||
const SET_ENTITY_MOTION_PACKET = 0xa0;
|
||||
//const SET_ENTITY_LINK_PACKET = 0xa1;
|
||||
const SET_HEALTH_PACKET = 0xa2;
|
||||
const SET_SPAWN_POSITION_PACKET = 0xa3;
|
||||
const ANIMATE_PACKET = 0xa4;
|
||||
const RESPAWN_PACKET = 0xa5;
|
||||
const DROP_ITEM_PACKET = 0xa6;
|
||||
const CONTAINER_OPEN_PACKET = 0xa7;
|
||||
const CONTAINER_CLOSE_PACKET = 0xa8;
|
||||
const CONTAINER_SET_SLOT_PACKET = 0xa9;
|
||||
const CONTAINER_SET_DATA_PACKET = 0xaa;
|
||||
const CONTAINER_SET_CONTENT_PACKET = 0xab;
|
||||
//const CONTAINER_ACK_PACKET = 0xac;
|
||||
const ADVENTURE_SETTINGS_PACKET = 0xad;
|
||||
const TILE_ENTITY_DATA_PACKET = 0xae;
|
||||
//const PLAYER_INPUT_PACKET = 0xaf;
|
||||
const FULL_CHUNK_DATA_PACKET = 0xb0;
|
||||
const SET_DIFFICULTY_PACKET = 0xb1;
|
||||
const BATCH_PACKET = 0xb2;
|
||||
|
||||
const ADD_PLAYER_PACKET = 0x88;
|
||||
const REMOVE_PLAYER_PACKET = 0x89;
|
||||
|
||||
const ADD_ENTITY_PACKET = 0x8a;
|
||||
const REMOVE_ENTITY_PACKET = 0x8b;
|
||||
const ADD_ITEM_ENTITY_PACKET = 0x8c;
|
||||
const TAKE_ITEM_ENTITY_PACKET = 0x8d;
|
||||
|
||||
const MOVE_ENTITY_PACKET = 0x8e;
|
||||
const MOVE_PLAYER_PACKET = 0x8f;
|
||||
|
||||
const REMOVE_BLOCK_PACKET = 0x90;
|
||||
const UPDATE_BLOCK_PACKET = 0x91;
|
||||
|
||||
const ADD_PAINTING_PACKET = 0x92;
|
||||
|
||||
const EXPLODE_PACKET = 0x93;
|
||||
|
||||
const LEVEL_EVENT_PACKET = 0x94;
|
||||
const TILE_EVENT_PACKET = 0x95;
|
||||
const ENTITY_EVENT_PACKET = 0x96;
|
||||
const MOB_EFFECT_PACKET = 0x97;
|
||||
|
||||
const PLAYER_EQUIPMENT_PACKET = 0x98;
|
||||
const PLAYER_ARMOR_EQUIPMENT_PACKET = 0x99;
|
||||
const INTERACT_PACKET = 0x9a;
|
||||
const USE_ITEM_PACKET = 0x9b;
|
||||
const PLAYER_ACTION_PACKET = 0x9c;
|
||||
const HURT_ARMOR_PACKET = 0x9d;
|
||||
const SET_ENTITY_DATA_PACKET = 0x9e;
|
||||
const SET_ENTITY_MOTION_PACKET = 0x9f;
|
||||
const SET_ENTITY_LINK_PACKET = 0xa0;
|
||||
const SET_HEALTH_PACKET = 0xa1;
|
||||
const SET_SPAWN_POSITION_PACKET = 0xa2;
|
||||
const ANIMATE_PACKET = 0xa3;
|
||||
const RESPAWN_PACKET = 0xa4;
|
||||
const DROP_ITEM_PACKET = 0xa5;
|
||||
const CONTAINER_OPEN_PACKET = 0xa6;
|
||||
const CONTAINER_CLOSE_PACKET = 0xa7;
|
||||
const CONTAINER_SET_SLOT_PACKET = 0xa8;
|
||||
const CONTAINER_SET_DATA_PACKET = 0xa9;
|
||||
const CONTAINER_SET_CONTENT_PACKET = 0xaa;
|
||||
//const CONTAINER_ACK_PACKET = 0xab;
|
||||
const ADVENTURE_SETTINGS_PACKET = 0xac;
|
||||
const TILE_ENTITY_DATA_PACKET = 0xad;
|
||||
//const PLAYER_INPUT_PACKET = 0xae;
|
||||
const FULL_CHUNK_DATA_PACKET = 0xaf;
|
||||
const SET_DIFFICULTY_PACKET = 0xb0;
|
||||
const BATCH_PACKET = 0xb1;
|
||||
|
||||
}
|
||||
|
@ -38,14 +38,12 @@ class InteractPacket extends DataPacket{
|
||||
|
||||
public function decode(){
|
||||
$this->action = $this->getByte();
|
||||
$this->eid = $this->getLong();
|
||||
$this->target = $this->getLong();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->action);
|
||||
$this->putLong($this->eid);
|
||||
$this->putLong($this->target);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,9 @@ class LoginPacket extends DataPacket{
|
||||
public $protocol1;
|
||||
public $protocol2;
|
||||
public $clientId;
|
||||
public $loginData;
|
||||
|
||||
public $slim = false;
|
||||
public $skin = null;
|
||||
|
||||
public function pid(){
|
||||
return Info::LOGIN_PACKET;
|
||||
@ -42,8 +44,12 @@ class LoginPacket extends DataPacket{
|
||||
$this->username = $this->getString();
|
||||
$this->protocol1 = $this->getInt();
|
||||
$this->protocol2 = $this->getInt();
|
||||
if(Info::CURRENT_PROTOCOL != $this->protocol1){
|
||||
return;
|
||||
}
|
||||
$this->clientId = $this->getInt();
|
||||
$this->loginData = $this->getString();
|
||||
$this->slim = $this->getByte() > 0;
|
||||
$this->skin = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
@ -35,7 +35,7 @@ class MovePlayerPacket extends DataPacket{
|
||||
public $yaw;
|
||||
public $pitch;
|
||||
public $bodyYaw;
|
||||
public $teleport = false;
|
||||
public $mode = 0;
|
||||
|
||||
public function pid(){
|
||||
return Info::MOVE_PLAYER_PACKET;
|
||||
@ -52,10 +52,9 @@ class MovePlayerPacket extends DataPacket{
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
$this->yaw = $this->getFloat();
|
||||
$this->pitch = $this->getFloat();
|
||||
$this->bodyYaw = $this->getFloat();
|
||||
$flags = $this->getByte();
|
||||
$this->teleport = (($flags & 0x80) > 0);
|
||||
$this->pitch = $this->getFloat();
|
||||
$this->mode = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
@ -65,9 +64,9 @@ class MovePlayerPacket extends DataPacket{
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->yaw);
|
||||
$this->putFloat($this->bodyYaw); //TODO
|
||||
$this->putFloat($this->pitch);
|
||||
$this->putFloat($this->bodyYaw);
|
||||
$this->putByte($this->teleport == true ? 0x80 : 0x00);
|
||||
$this->putByte($this->mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ class RespawnPacket extends DataPacket{
|
||||
public static $pool = [];
|
||||
public static $next = 0;
|
||||
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
@ -38,7 +37,6 @@ class RespawnPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->x = $this->getFloat();
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
@ -46,7 +44,6 @@ class RespawnPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
|
@ -23,26 +23,17 @@ namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
#ifndef COMPILE
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
#endif
|
||||
|
||||
class AddMobPacket extends DataPacket{
|
||||
class SetEntityLinkPacket extends DataPacket{
|
||||
public static $pool = [];
|
||||
public static $next = 0;
|
||||
|
||||
public $eid;
|
||||
public $from;
|
||||
public $to;
|
||||
public $type;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $pitch;
|
||||
public $yaw;
|
||||
public $metadata;
|
||||
|
||||
public function pid(){
|
||||
return Info::ADD_MOB_PACKET;
|
||||
return Info::SET_ENTITY_LINK_PACKET;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
@ -51,14 +42,9 @@ class AddMobPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putInt($this->type);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->yaw);
|
||||
$this->putFloat($this->pitch);
|
||||
$this->put(Binary::writeMetadata($this->metadata));
|
||||
$this->putLong($this->from);
|
||||
$this->putLong($this->to);
|
||||
$this->putByte($this->type);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user