Cleaned up some bad code in DataPacket, added encode/decodeHeader and made encode/decodePayload protected

This commit is contained in:
Dylan K. Taylor 2017-08-05 11:40:14 +01:00
parent 8a151dc373
commit 7886918140
110 changed files with 249 additions and 237 deletions

View File

@ -33,11 +33,11 @@ class AddBehaviorTreePacket extends DataPacket{
/** @var string */
public $unknownString1;
public function decodePayload(){
protected function decodePayload(){
$this->unknownString1 = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->unknownString1);
}

View File

@ -49,7 +49,7 @@ class AddEntityPacket extends DataPacket{
public $metadata = [];
public $links = [];
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->type = $this->getUnsignedVarInt();
@ -83,7 +83,7 @@ class AddEntityPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putUnsignedVarInt($this->type);

View File

@ -37,14 +37,14 @@ class AddHangingEntityPacket extends DataPacket{
public $z;
public $unknown; //TODO (rotation?)
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->unknown = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -44,7 +44,7 @@ class AddItemEntityPacket extends DataPacket{
public $speedZ = 0.0;
public $metadata = [];
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot();
@ -53,7 +53,7 @@ class AddItemEntityPacket extends DataPacket{
$this->metadata = $this->getEntityMetadata();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item);

View File

@ -41,7 +41,7 @@ class AddPaintingPacket extends DataPacket{
public $direction;
public $title;
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
@ -49,7 +49,7 @@ class AddPaintingPacket extends DataPacket{
$this->title = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -60,7 +60,7 @@ class AddPlayerPacket extends DataPacket{
public $uvarint4 = 0;
public $long1 = 0;
public function decodePayload(){
protected function decodePayload(){
$this->uuid = $this->getUUID();
$this->username = $this->getString();
$this->entityUniqueId = $this->getEntityUniqueId();
@ -80,7 +80,7 @@ class AddPlayerPacket extends DataPacket{
$this->long1 = $this->getLLong();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUUID($this->uuid);
$this->putString($this->username);
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);

View File

@ -71,7 +71,7 @@ class AdventureSettingsPacket extends DataPacket{
public $playerPermission = PlayerPermissions::MEMBER;
public $long1 = 0;
public function decodePayload(){
protected function decodePayload(){
$this->flags = $this->getUnsignedVarInt();
$this->commandPermission = $this->getUnsignedVarInt();
$this->flags2 = $this->getUnsignedVarInt();
@ -79,7 +79,7 @@ class AdventureSettingsPacket extends DataPacket{
$this->long1 = $this->getLLong();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->flags);
$this->putUnsignedVarInt($this->commandPermission);
$this->putUnsignedVarInt($this->flags2);

View File

@ -40,7 +40,7 @@ class AnimatePacket extends DataPacket{
public $entityRuntimeId;
public $float = 0.0; //TODO (Boat rowing time?)
public function decodePayload(){
protected function decodePayload(){
$this->action = $this->getVarInt();
$this->entityRuntimeId = $this->getEntityRuntimeId();
if($this->action & 0x80){
@ -48,7 +48,7 @@ class AnimatePacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->action);
$this->putEntityRuntimeId($this->entityRuntimeId);
if($this->action & 0x80){

View File

@ -33,12 +33,12 @@ class AvailableCommandsPacket extends DataPacket{
public $commands; //JSON-encoded command data
public $unknown = "";
public function decodePayload(){
protected function decodePayload(){
$this->commands = $this->getString();
$this->unknown = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->commands);
$this->putString($this->unknown);
}

View File

@ -48,23 +48,12 @@ class BatchPacket extends DataPacket{
return true;
}
public function decode(){
$this->offset = 1;
$this->decodePayload();
protected function decodeHeader(){
$pid = $this->getByte();
assert($pid === static::NETWORK_ID);
}
public function encode(){
$this->reset();
$this->encodePayload();
$this->isEncoded = true;
}
public function reset(){
$this->buffer = "\xfe";
$this->offset = 0;
}
public function decodePayload(){
protected function decodePayload(){
$data = $this->getRemaining();
try{
$this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB
@ -73,7 +62,11 @@ class BatchPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodeHeader(){
$this->putByte(static::NETWORK_ID);
}
protected function encodePayload(){
$this->put(zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $this->compressionLevel));
}

View File

@ -36,12 +36,12 @@ class BlockEntityDataPacket extends DataPacket{
public $z;
public $namedtag;
public function decodePayload(){
protected function decodePayload(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->namedtag = $this->getRemaining();
}
public function encodePayload(){
protected function encodePayload(){
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->put($this->namedtag);
}

View File

@ -37,13 +37,13 @@ class BlockEventPacket extends DataPacket{
public $case1;
public $case2;
public function decodePayload(){
protected function decodePayload(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->case1 = $this->getVarInt();
$this->case2 = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->case1);
$this->putVarInt($this->case2);

View File

@ -38,13 +38,13 @@ class BlockPickRequestPacket extends DataPacket{
public $addUserData = false;
public $hotbarSlot;
public function decodePayload(){
protected function decodePayload(){
$this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->addUserData = $this->getBool();
$this->hotbarSlot = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->putBool($this->addUserData);
$this->putByte($this->hotbarSlot);

View File

@ -55,7 +55,7 @@ class BookEditPacket extends DataPacket{
/** @var string */
public $author;
public function decodePayload(){
protected function decodePayload(){
$this->type = $this->getByte();
$this->inventorySlot = $this->getByte();
@ -82,7 +82,7 @@ class BookEditPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->type);
$this->putByte($this->inventorySlot);

View File

@ -64,7 +64,7 @@ class BossEventPacket extends DataPacket{
/** @var int */
public $overlay;
public function decodePayload(){
protected function decodePayload(){
$this->bossEid = $this->getEntityUniqueId();
$this->eventType = $this->getUnsignedVarInt();
switch($this->eventType){
@ -94,7 +94,7 @@ class BossEventPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->bossEid);
$this->putUnsignedVarInt($this->eventType);
switch($this->eventType){

View File

@ -35,12 +35,12 @@ class CameraPacket extends DataPacket{
/** @var int */
public $playerUniqueId;
public function decodePayload(){
protected function decodePayload(){
$this->cameraUniqueId = $this->getEntityUniqueId();
$this->playerUniqueId = $this->getEntityUniqueId();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->cameraUniqueId);
$this->putEntityUniqueId($this->playerUniqueId);
}

View File

@ -42,13 +42,13 @@ class ChangeDimensionPacket extends DataPacket{
/** @var bool */
public $respawn = false;
public function decodePayload(){
protected function decodePayload(){
$this->dimension = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z);
$this->respawn = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->dimension);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putBool($this->respawn);

View File

@ -33,11 +33,11 @@ class ChunkRadiusUpdatedPacket extends DataPacket{
public $radius;
public function decodePayload(){
protected function decodePayload(){
$this->radius = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->radius);
}

View File

@ -35,11 +35,11 @@ class ClientToServerHandshakePacket extends DataPacket{
return true;
}
public function decodePayload(){
protected function decodePayload(){
//No payload
}
public function encodePayload(){
protected function encodePayload(){
//No payload
}

View File

@ -50,7 +50,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
/** @var Color[][] */
public $colors = [];
public function decodePayload(){
protected function decodePayload(){
$this->mapId = $this->getEntityUniqueId();
$this->type = $this->getUnsignedVarInt();
@ -93,7 +93,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->mapId);
$type = 0;

View File

@ -49,7 +49,7 @@ class CommandBlockUpdatePacket extends DataPacket{
public $shouldTrackOutput;
public function decodePayload(){
protected function decodePayload(){
$this->isBlock = $this->getBool();
if($this->isBlock){
@ -69,7 +69,7 @@ class CommandBlockUpdatePacket extends DataPacket{
$this->shouldTrackOutput = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putBool($this->isBlock);
if($this->isBlock){

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class CommandOutputPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
public function decodePayload(){
protected function decodePayload(){
//TODO
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

View File

@ -32,12 +32,12 @@ class CommandRequestPacket extends DataPacket{
public $command;
public function decodePayload(){
protected function decodePayload(){
$this->command = $this->getString();
//TODO: everything else
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->command);
//TODO
}

View File

@ -33,11 +33,11 @@ class ContainerClosePacket extends DataPacket{
public $windowid;
public function decodePayload(){
protected function decodePayload(){
$this->windowid = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->windowid);
}

View File

@ -38,14 +38,14 @@ class ContainerOpenPacket extends DataPacket{
public $z;
public $entityUniqueId = -1;
public function decodePayload(){
protected function decodePayload(){
$this->windowid = $this->getByte();
$this->type = $this->getByte();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->entityUniqueId = $this->getEntityUniqueId();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->windowid);
$this->putByte($this->type);
$this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -35,13 +35,13 @@ class ContainerSetDataPacket extends DataPacket{
public $property;
public $value;
public function decodePayload(){
protected function decodePayload(){
$this->windowid = $this->getByte();
$this->property = $this->getVarInt();
$this->value = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->windowid);
$this->putVarInt($this->property);
$this->putVarInt($this->value);

View File

@ -41,7 +41,7 @@ class ContainerSetSlotPacket extends DataPacket{
public $item;
public $selectSlot = 0;
public function decodePayload(){
protected function decodePayload(){
$this->windowid = $this->getByte();
$this->slot = $this->getVarInt();
$this->hotbarSlot = $this->getVarInt();
@ -49,7 +49,7 @@ class ContainerSetSlotPacket extends DataPacket{
$this->selectSlot = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->windowid);
$this->putVarInt($this->slot);
$this->putVarInt($this->hotbarSlot);

View File

@ -52,7 +52,7 @@ class CraftingDataPacket extends DataPacket{
return parent::clean();
}
public function decodePayload(){
protected function decodePayload(){
$entries = [];
$recipeCount = $this->getUnsignedVarInt();
for($i = 0; $i < $recipeCount; ++$i){
@ -182,7 +182,7 @@ class CraftingDataPacket extends DataPacket{
$this->entries[] = $recipe;
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt(count($this->entries));
$writer = new BinaryStream();

View File

@ -47,7 +47,7 @@ class CraftingEventPacket extends DataPacket{
return parent::clean();
}
public function decodePayload(){
protected function decodePayload(){
$this->windowId = $this->getByte();
$this->type = $this->getVarInt();
$this->id = $this->getUUID();
@ -63,7 +63,7 @@ class CraftingEventPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->windowId);
$this->putVarInt($this->type);
$this->putUUID($this->id);

View File

@ -41,6 +41,9 @@ abstract class DataPacket extends BinaryStream{
public $isEncoded = false;
public $extraByte1 = 0;
public $extraByte2 = 0;
public function pid(){
return $this::NETWORK_ID;
}
@ -58,28 +61,44 @@ abstract class DataPacket extends BinaryStream{
}
public function decode(){
$this->offset = 3;
$this->offset = 0;
$this->decodeHeader();
$this->decodePayload();
}
protected function decodeHeader(){
$pid = $this->getUnsignedVarInt();
assert($pid === static::NETWORK_ID);
$this->extraByte1 = $this->getByte();
$this->extraByte2 = $this->getByte();
assert($this->extraByte1 === 0 and $this->extraByte2 === 0, "Got unexpected non-zero split-screen bytes (byte1: $this->extraByte1, byte2: $this->extraByte2");
}
/**
* Note for plugin developers: If you're adding your own packets, you should perform decoding in here.
*/
public function decodePayload(){
protected function decodePayload(){
}
public function encode(){
$this->reset();
$this->put("\x00\x00");
$this->encodePayload();
$this->isEncoded = true;
}
protected function encodeHeader(){
$this->putUnsignedVarInt(static::NETWORK_ID);
$this->putByte($this->extraByte1);
$this->putByte($this->extraByte2);
}
/**
* Note for plugin developers: If you're adding your own packets, you should perform encoding in here.
*/
public function encodePayload(){
protected function encodePayload(){
}
@ -96,7 +115,7 @@ abstract class DataPacket extends BinaryStream{
abstract public function handle(NetworkSession $session) : bool;
public function reset(){
$this->buffer = Binary::writeUnsignedVarInt(static::NETWORK_ID);
$this->encodeHeader();
$this->offset = 0;
}

View File

@ -38,12 +38,12 @@ class DisconnectPacket extends DataPacket{
return true;
}
public function decodePayload(){
protected function decodePayload(){
$this->hideDisconnectionScreen = $this->getBool();
$this->message = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putBool($this->hideDisconnectionScreen);
if(!$this->hideDisconnectionScreen){
$this->putString($this->message);

View File

@ -39,12 +39,12 @@ class DropItemPacket extends DataPacket{
/** @var Item */
public $item;
public function decodePayload(){
protected function decodePayload(){
$this->type = $this->getByte();
$this->item = $this->getSlot();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->type);
$this->putSlot($this->item);
}

View File

@ -54,13 +54,13 @@ class EntityEventPacket extends DataPacket{
public $event;
public $data = 0;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->event = $this->getByte();
$this->data = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->event);
$this->putVarInt($this->data);

View File

@ -35,13 +35,13 @@ class EntityFallPacket extends DataPacket{
public $fallDistance;
public $bool1;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->fallDistance = $this->getLFloat();
$this->bool1 = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putLFloat($this->fallDistance);
$this->putBool($this->bool1);

View File

@ -33,12 +33,12 @@ class EntityPickRequestPacket extends DataPacket{
public $entityTypeId;
public $hotbarSlot;
public function decodePayload(){
protected function decodePayload(){
$this->entityTypeId = $this->getLLong();
$this->hotbarSlot = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putLLong($this->entityTypeId);
$this->putByte($this->hotbarSlot);
}

View File

@ -45,7 +45,7 @@ class EventPacket extends DataPacket{
public $eventData;
public $type;
public function decodePayload(){
protected function decodePayload(){
$this->playerRuntimeId = $this->getEntityRuntimeId();
$this->eventData = $this->getVarInt();
$this->type = $this->getByte();
@ -53,7 +53,7 @@ class EventPacket extends DataPacket{
//TODO: nice confusing mess
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->playerRuntimeId);
$this->putVarInt($this->eventData);
$this->putByte($this->type);

View File

@ -45,7 +45,7 @@ class ExplodePacket extends DataPacket{
return parent::clean();
}
public function decodePayload(){
protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z);
$this->radius = (float) ($this->getVarInt() / 32);
$count = $this->getUnsignedVarInt();
@ -56,7 +56,7 @@ class ExplodePacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt((int) ($this->radius * 32));
$this->putUnsignedVarInt(count($this->records));

View File

@ -35,13 +35,13 @@ class FullChunkDataPacket extends DataPacket{
public $chunkZ;
public $data;
public function decodePayload(){
protected function decodePayload(){
$this->chunkX = $this->getVarInt();
$this->chunkZ = $this->getVarInt();
$this->data = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->chunkX);
$this->putVarInt($this->chunkZ);
$this->putString($this->data);

View File

@ -32,11 +32,11 @@ class GameRulesChangedPacket extends DataPacket{
public $gameRules = [];
public function decodePayload(){
protected function decodePayload(){
$this->gameRules = $this->getGameRules();
}
public function encodePayload(){
protected function encodePayload(){
$this->putGameRules($this->gameRules);
}

View File

@ -33,11 +33,11 @@ class GuiDataPickItemPacket extends DataPacket{
/** @var int */
public $hotbarSlot;
public function decodePayload(){
protected function decodePayload(){
$this->hotbarSlot = $this->getLInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putLInt($this->hotbarSlot);
}

View File

@ -33,11 +33,11 @@ class HurtArmorPacket extends DataPacket{
public $health;
public function decodePayload(){
protected function decodePayload(){
$this->health = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->health);
}

View File

@ -59,7 +59,7 @@ class InteractPacket extends DataPacket{
/** @var float */
public $z;
public function decodePayload(){
protected function decodePayload(){
$this->action = $this->getByte();
$this->target = $this->getEntityRuntimeId();
@ -70,7 +70,7 @@ class InteractPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->action);
$this->putEntityRuntimeId($this->target);

View File

@ -36,7 +36,7 @@ class InventoryContentPacket extends DataPacket{
/** @var Item[] */
public $items = [];
public function decodePayload(){
protected function decodePayload(){
$this->windowId = $this->getUnsignedVarInt();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
@ -44,7 +44,7 @@ class InventoryContentPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->windowId);
$this->putUnsignedVarInt(count($this->items));
foreach($this->items as $item){

View File

@ -38,13 +38,13 @@ class InventorySlotPacket extends DataPacket{
/** @var Item */
public $item;
public function decodePayload(){
protected function decodePayload(){
$this->windowId = $this->getUnsignedVarInt();
$this->inventorySlot = $this->getUnsignedVarInt();
$this->item = $this->getSlot();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->windowId);
$this->putUnsignedVarInt($this->inventorySlot);
$this->putSlot($this->item);

View File

@ -85,7 +85,7 @@ class InventoryTransactionPacket extends DataPacket{
public $transactionData;
public function decodePayload(){
protected function decodePayload(){
$type = $this->getUnsignedVarInt();
$actionCount = $this->getUnsignedVarInt();
@ -133,7 +133,7 @@ class InventoryTransactionPacket extends DataPacket{
//TODO
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

View File

@ -35,11 +35,11 @@ class ItemFrameDropItemPacket extends DataPacket{
public $y;
public $z;
public function decodePayload(){
protected function decodePayload(){
$this->getBlockPosition($this->x, $this->y, $this->z);
}
public function encodePayload(){
protected function encodePayload(){
$this->putBlockPosition($this->x, $this->y, $this->z);
}

View File

@ -106,13 +106,13 @@ class LevelEventPacket extends DataPacket{
public $z = 0;
public $data;
public function decodePayload(){
protected function decodePayload(){
$this->evid = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z);
$this->data = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->evid);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->data);

View File

@ -201,7 +201,7 @@ class LevelSoundEventPacket extends DataPacket{
public $unknownBool = false;
public $disableRelativeVolume = false;
public function decodePayload(){
protected function decodePayload(){
$this->sound = $this->getByte();
$this->getVector3f($this->x, $this->y, $this->z);
$this->extraData = $this->getVarInt();
@ -210,7 +210,7 @@ class LevelSoundEventPacket extends DataPacket{
$this->disableRelativeVolume = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->sound);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->extraData);

View File

@ -55,7 +55,7 @@ class LoginPacket extends DataPacket{
return true;
}
public function decodePayload(){
protected function decodePayload(){
$this->protocol = $this->getInt();
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
@ -93,7 +93,7 @@ class LoginPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

View File

@ -34,11 +34,11 @@ class MapInfoRequestPacket extends DataPacket{
public $mapId;
public function decodePayload(){
protected function decodePayload(){
$this->mapId = $this->getEntityUniqueId();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->mapId);
}

View File

@ -36,7 +36,7 @@ class MobArmorEquipmentPacket extends DataPacket{
/** @var Item[] */
public $slots = [];
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->slots[0] = $this->getSlot();
$this->slots[1] = $this->getSlot();
@ -44,7 +44,7 @@ class MobArmorEquipmentPacket extends DataPacket{
$this->slots[3] = $this->getSlot();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->slots[0]);
$this->putSlot($this->slots[1]);

View File

@ -42,7 +42,7 @@ class MobEffectPacket extends DataPacket{
public $particles = true;
public $duration = 0;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->eventId = $this->getByte();
$this->effectId = $this->getVarInt();
@ -51,7 +51,7 @@ class MobEffectPacket extends DataPacket{
$this->duration = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->eventId);
$this->putVarInt($this->effectId);

View File

@ -37,7 +37,7 @@ class MobEquipmentPacket extends DataPacket{
public $hotbarSlot;
public $windowId = 0;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot();
$this->inventorySlot = $this->getByte();
@ -45,7 +45,7 @@ class MobEquipmentPacket extends DataPacket{
$this->windowId = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item);
$this->putByte($this->inventorySlot);

View File

@ -35,12 +35,12 @@ class ModalFormRequestPacket extends DataPacket{
/** @var string */
public $formData; //json
public function decodePayload(){
protected function decodePayload(){
$this->formId = $this->getUnsignedVarInt();
$this->formData = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->formId);
$this->putString($this->formData);
}

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class ModalFormResponsePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET;
public function decodePayload(){
protected function decodePayload(){
//TODO
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

View File

@ -41,7 +41,7 @@ class MoveEntityPacket extends DataPacket{
public $onGround = false;
public $teleported = false;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getByteRotation();
@ -51,7 +51,7 @@ class MoveEntityPacket extends DataPacket{
$this->teleported = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putByteRotation($this->pitch);

View File

@ -49,7 +49,7 @@ class MovePlayerPacket extends DataPacket{
public $int1 = 0;
public $int2 = 0;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getLFloat();
@ -64,7 +64,7 @@ class MovePlayerPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putLFloat($this->pitch);

View File

@ -39,14 +39,14 @@ class NpcRequestPacket extends DataPacket{
/** @var int */
public $actionType;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->requestType = $this->getByte();
$this->commandString = $this->getString();
$this->actionType = $this->getByte();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->requestType);
$this->putString($this->commandString);

View File

@ -37,13 +37,13 @@ class PhotoTransferPacket extends DataPacket{
/** @var string */
public $string3;
public function decodePayload(){
protected function decodePayload(){
$this->string1 = $this->getString();
$this->string2 = $this->getString();
$this->string3 = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->string1);
$this->putString($this->string2);
$this->putString($this->string3);

View File

@ -39,14 +39,14 @@ class PlaySoundPacket extends DataPacket{
public $volume;
public $pitch;
public function decodePayload(){
protected function decodePayload(){
$this->soundName = $this->getString();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->volume = $this->getLFloat();
$this->pitch = $this->getLFloat();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->soundName);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putLFloat($this->volume);

View File

@ -41,7 +41,7 @@ class PlayStatusPacket extends DataPacket{
public $status;
public function decodePayload(){
protected function decodePayload(){
$this->status = $this->getInt();
}
@ -49,7 +49,7 @@ class PlayStatusPacket extends DataPacket{
return true;
}
public function encodePayload(){
protected function encodePayload(){
$this->putInt($this->status);
}

View File

@ -61,14 +61,14 @@ class PlayerActionPacket extends DataPacket{
public $z;
public $face;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->action = $this->getVarInt();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->face = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->action);
$this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -38,7 +38,7 @@ class PlayerHotbarPacket extends DataPacket{
/** @var int[] */
public $slots = [];
public function decodePayload(){
protected function decodePayload(){
$this->selectedSlot = $this->getUnsignedVarInt();
$this->windowId = $this->getByte();
$count = $this->getUnsignedVarInt();
@ -47,7 +47,7 @@ class PlayerHotbarPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->selectedSlot);
$this->putByte($this->windowId);
$this->putUnsignedVarInt(count($this->slots));

View File

@ -36,14 +36,14 @@ class PlayerInputPacket extends DataPacket{
public $unknownBool1;
public $unknownBool2;
public function decodePayload(){
protected function decodePayload(){
$this->motionX = $this->getLFloat();
$this->motionY = $this->getLFloat();
$this->unknownBool1 = $this->getBool();
$this->unknownBool2 = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putLFloat($this->motionX);
$this->putLFloat($this->motionY);
$this->putBool($this->unknownBool1);

View File

@ -44,7 +44,7 @@ class PlayerListPacket extends DataPacket{
return parent::clean();
}
public function decodePayload(){
protected function decodePayload(){
$this->type = $this->getByte();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
@ -63,7 +63,7 @@ class PlayerListPacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->type);
$this->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $d){

View File

@ -49,7 +49,7 @@ class PlayerSkinPacket extends DataPacket{
public $geometryData;
public function decodePayload(){
protected function decodePayload(){
$this->uuid = $this->getUUID();
$this->skinId = $this->getString();
$this->skinName = $this->getString();
@ -60,7 +60,7 @@ class PlayerSkinPacket extends DataPacket{
$this->geometryData = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUUID($this->uuid);
$this->putString($this->skinId);
$this->putString($this->skinName);

View File

@ -33,14 +33,14 @@ class PurchaseReceiptPacket extends DataPacket{
/** @var string[] */
public $entries = [];
public function decodePayload(){
protected function decodePayload(){
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->entries[] = $this->getString();
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$this->putString($entry);

View File

@ -38,11 +38,11 @@ class RemoveBlockPacket extends DataPacket{
public $y;
public $z;
public function decodePayload(){
protected function decodePayload(){
$this->getBlockPosition($this->x, $this->y, $this->z);
}
public function encodePayload(){
protected function encodePayload(){
$this->putBlockPosition($this->x, $this->y, $this->z);
}

View File

@ -33,11 +33,11 @@ class RemoveEntityPacket extends DataPacket{
public $entityUniqueId;
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId);
}

View File

@ -33,11 +33,11 @@ class RequestChunkRadiusPacket extends DataPacket{
public $radius;
public function decodePayload(){
protected function decodePayload(){
$this->radius = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->radius);
}

View File

@ -37,14 +37,14 @@ class ResourcePackChunkDataPacket extends DataPacket{
public $progress;
public $data;
public function decodePayload(){
protected function decodePayload(){
$this->packId = $this->getString();
$this->chunkIndex = $this->getLInt();
$this->progress = $this->getLLong();
$this->data = $this->get($this->getLInt());
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->packId);
$this->putLInt($this->chunkIndex);
$this->putLLong($this->progress);

View File

@ -35,12 +35,12 @@ class ResourcePackChunkRequestPacket extends DataPacket{
public $packId;
public $chunkIndex;
public function decodePayload(){
protected function decodePayload(){
$this->packId = $this->getString();
$this->chunkIndex = $this->getLInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->packId);
$this->putLInt($this->chunkIndex);
}

View File

@ -39,7 +39,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
public $status;
public $packIds = [];
public function decodePayload(){
protected function decodePayload(){
$this->status = $this->getByte();
$entryCount = $this->getLShort();
while($entryCount-- > 0){
@ -47,7 +47,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
}
}
public function encodePayload(){
protected function encodePayload(){
$this->putByte($this->status);
$this->putLShort(count($this->packIds));
foreach($this->packIds as $id){

View File

@ -38,7 +38,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
public $compressedPackSize;
public $sha256;
public function decodePayload(){
protected function decodePayload(){
$this->packId = $this->getString();
$this->maxChunkSize = $this->getLInt();
$this->chunkCount = $this->getLInt();
@ -46,7 +46,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
$this->sha256 = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->packId);
$this->putLInt($this->maxChunkSize);
$this->putLInt($this->chunkCount);

View File

@ -41,7 +41,7 @@ class ResourcePackStackPacket extends DataPacket{
/** @var ResourcePack[] */
public $resourcePackStack = [];
public function decodePayload(){
protected function decodePayload(){
/*$this->mustAccept = $this->getBool();
$behaviorPackCount = $this->getUnsignedVarInt();
while($behaviorPackCount-- > 0){
@ -58,7 +58,7 @@ class ResourcePackStackPacket extends DataPacket{
}*/
}
public function encodePayload(){
protected function encodePayload(){
$this->putBool($this->mustAccept);
$this->putUnsignedVarInt(count($this->behaviorPackStack));

View File

@ -39,7 +39,7 @@ class ResourcePacksInfoPacket extends DataPacket{
/** @var ResourcePack[] */
public $resourcePackEntries = [];
public function decodePayload(){
protected function decodePayload(){
/*$this->mustAccept = $this->getBool();
$behaviorPackCount = $this->getLShort();
while($behaviorPackCount-- > 0){
@ -60,7 +60,7 @@ class ResourcePacksInfoPacket extends DataPacket{
}*/
}
public function encodePayload(){
protected function encodePayload(){
$this->putBool($this->mustAccept);
$this->putLShort(count($this->behaviorPackEntries));

View File

@ -35,11 +35,11 @@ class RespawnPacket extends DataPacket{
public $y;
public $z;
public function decodePayload(){
protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z);
}
public function encodePayload(){
protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z);
}

View File

@ -34,11 +34,11 @@ class RiderJumpPacket extends DataPacket{
public $unknown;
public function decodePayload(){
protected function decodePayload(){
$this->unknown = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->unknown);
}

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class ServerSettingsRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET;
public function decodePayload(){
protected function decodePayload(){
//No payload
}
public function encodePayload(){
protected function encodePayload(){
//No payload
}

View File

@ -35,12 +35,12 @@ class ServerSettingsResponsePacket extends DataPacket{
/** @var string */
public $formData; //json
public function decodePayload(){
protected function decodePayload(){
$this->formId = $this->getUnsignedVarInt();
$this->formData = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->formId);
$this->putString($this->formData);
}

View File

@ -41,11 +41,11 @@ class ServerToClientHandshakePacket extends DataPacket{
return true;
}
public function decodePayload(){
protected function decodePayload(){
$this->jwt = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->jwt);
}

View File

@ -33,11 +33,11 @@ class SetCommandsEnabledPacket extends DataPacket{
public $enabled;
public function decodePayload(){
protected function decodePayload(){
$this->enabled = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putBool($this->enabled);
}

View File

@ -33,11 +33,11 @@ class SetDifficultyPacket extends DataPacket{
public $difficulty;
public function decodePayload(){
protected function decodePayload(){
$this->difficulty = $this->getUnsignedVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putUnsignedVarInt($this->difficulty);
}

View File

@ -34,12 +34,12 @@ class SetEntityDataPacket extends DataPacket{
public $entityRuntimeId;
public $metadata;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->metadata = $this->getEntityMetadata();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putEntityMetadata($this->metadata);
}

View File

@ -34,11 +34,11 @@ class SetEntityLinkPacket extends DataPacket{
/** @var array [from, to, type, unknown byte] */
public $link = [];
public function decodePayload(){
protected function decodePayload(){
$this->link = $this->getEntityLink();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityLink($this->link);
}

View File

@ -36,12 +36,12 @@ class SetEntityMotionPacket extends DataPacket{
public $motionY;
public $motionZ;
public function decodePayload(){
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->motionX, $this->motionY, $this->motionZ);
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
}

View File

@ -33,11 +33,11 @@ class SetHealthPacket extends DataPacket{
public $health;
public function decodePayload(){
protected function decodePayload(){
$this->health = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->health);
}

View File

@ -32,11 +32,11 @@ class SetLastHurtByPacket extends DataPacket{
public $entityTypeId;
public function decodePayload(){
protected function decodePayload(){
$this->entityTypeId = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->entityTypeId);
}

View File

@ -33,11 +33,11 @@ class SetPlayerGameTypePacket extends DataPacket{
public $gamemode;
public function decodePayload(){
protected function decodePayload(){
$this->gamemode = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->gamemode);
}

View File

@ -40,13 +40,13 @@ class SetSpawnPositionPacket extends DataPacket{
public $z;
public $spawnForced;
public function decodePayload(){
protected function decodePayload(){
$this->spawnType = $this->getVarInt();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->spawnForced = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->spawnType);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putBool($this->spawnForced);

View File

@ -32,11 +32,11 @@ class SetTimePacket extends DataPacket{
public $time;
public function decodePayload(){
protected function decodePayload(){
$this->time = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->time);
}

View File

@ -45,7 +45,7 @@ class SetTitlePacket extends DataPacket{
public $stayTime = 0;
public $fadeOutTime = 0;
public function decodePayload(){
protected function decodePayload(){
$this->type = $this->getVarInt();
$this->text = $this->getString();
$this->fadeInTime = $this->getVarInt();
@ -53,7 +53,7 @@ class SetTitlePacket extends DataPacket{
$this->fadeOutTime = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVarInt($this->type);
$this->putString($this->text);
$this->putVarInt($this->fadeInTime);

View File

@ -38,12 +38,12 @@ class ShowCreditsPacket extends DataPacket{
public $playerEid;
public $status;
public function decodePayload(){
protected function decodePayload(){
$this->playerEid = $this->getEntityRuntimeId();
$this->status = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityRuntimeId($this->playerEid);
$this->putVarInt($this->status);
}

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class ShowProfilePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SHOW_PROFILE_PACKET;
public function decodePayload(){
protected function decodePayload(){
//TODO
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

View File

@ -32,11 +32,11 @@ class ShowStoreOfferPacket extends DataPacket{
public $offerId;
public function decodePayload(){
protected function decodePayload(){
$this->offerId = $this->getString();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->offerId);
}

View File

@ -32,11 +32,11 @@ class SimpleEventPacket extends DataPacket{
public $unknownShort1;
public function decodePayload(){
protected function decodePayload(){
$this->unknownShort1 = $this->getLShort();
}
public function encodePayload(){
protected function encodePayload(){
$this->putLShort($this->unknownShort1);
}

View File

@ -36,12 +36,12 @@ class SpawnExperienceOrbPacket extends DataPacket{
public $z;
public $amount;
public function decodePayload(){
protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z);
$this->amount = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->amount);
}

View File

@ -75,7 +75,7 @@ class StartGamePacket extends DataPacket{
public $unknownVarInt = 0;
public function decodePayload(){
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->playerGamemode = $this->getVarInt();
@ -117,7 +117,7 @@ class StartGamePacket extends DataPacket{
$this->unknownVarInt = $this->getVarInt();
}
public function encodePayload(){
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->playerGamemode);

View File

@ -35,12 +35,12 @@ class StopSoundPacket extends DataPacket{
public $soundName;
public $stopAll;
public function decodePayload(){
protected function decodePayload(){
$this->soundName = $this->getString();
$this->stopAll = $this->getBool();
}
public function encodePayload(){
protected function encodePayload(){
$this->putString($this->soundName);
$this->putBool($this->stopAll);
}

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class StructureBlockUpdatePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::STRUCTURE_BLOCK_UPDATE_PACKET;
public function decodePayload(){
protected function decodePayload(){
//TODO
}
public function encodePayload(){
protected function encodePayload(){
//TODO
}

Some files were not shown because too many files have changed in this diff Show More