mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Solved packet encode/decode boilerplate code issue
Something as simple as forgetting the reset() when encoding would cause lots of problems which could go unnoticed. This should be fully backwards-compatible but needs more tests.
This commit is contained in:
parent
1a5e3b2ad0
commit
2726f2a011
@ -49,7 +49,7 @@ class AddEntityPacket extends DataPacket{
|
||||
public $metadata = [];
|
||||
public $links = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->type = $this->getUnsignedVarInt();
|
||||
@ -85,8 +85,7 @@ class AddEntityPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putUnsignedVarInt($this->type);
|
||||
|
@ -37,15 +37,14 @@ class AddHangingEntityPacket extends DataPacket{
|
||||
public $z;
|
||||
public $unknown; //TODO (rotation?)
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
|
@ -44,7 +44,7 @@ class AddItemEntityPacket extends DataPacket{
|
||||
public $speedZ = 0.0;
|
||||
public $metadata = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->item = $this->getSlot();
|
||||
@ -53,8 +53,7 @@ class AddItemEntityPacket extends DataPacket{
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->item);
|
||||
|
@ -33,12 +33,11 @@ class AddItemPacket extends DataPacket{
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class AddPaintingPacket extends DataPacket{
|
||||
public $direction;
|
||||
public $title;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
@ -49,8 +49,7 @@ class AddPaintingPacket extends DataPacket{
|
||||
$this->title = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
|
@ -53,7 +53,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
public $item;
|
||||
public $metadata = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->uuid = $this->getUUID();
|
||||
$this->username = $this->getString();
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
@ -67,8 +67,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUUID($this->uuid);
|
||||
$this->putString($this->username);
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
|
@ -52,7 +52,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
public $flags = 0;
|
||||
public $userPermission;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->userPermission = $this->getUnsignedVarInt();
|
||||
|
||||
@ -69,9 +69,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
$this->muted = (bool) ($this->flags & (1 << 10));
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
|
||||
public function encodePayload(){
|
||||
$this->flags |= ((int) $this->worldImmutable);
|
||||
$this->flags |= ((int) $this->noPvp) << 1;
|
||||
$this->flags |= ((int) $this->noPvm) << 2;
|
||||
|
@ -35,7 +35,7 @@ class AnimatePacket extends DataPacket{
|
||||
public $entityRuntimeId;
|
||||
public $float; //TODO (Boat rowing time?)
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->action = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
if($this->action & 0x80){
|
||||
@ -43,8 +43,7 @@ class AnimatePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->action);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if($this->action & 0x80){
|
||||
|
@ -33,13 +33,12 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
public $commands; //JSON-encoded command data
|
||||
public $unknown = "";
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->commands = $this->getString();
|
||||
$this->unknown = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->commands);
|
||||
$this->putString($this->unknown);
|
||||
}
|
||||
|
@ -45,12 +45,11 @@ class BatchPacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->payload = $this->getRemaining();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
assert($this->compressed);
|
||||
$this->put($this->payload);
|
||||
}
|
||||
|
@ -36,13 +36,12 @@ class BlockEntityDataPacket extends DataPacket{
|
||||
public $z;
|
||||
public $namedtag;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->getRemaining();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->put($this->namedtag);
|
||||
}
|
||||
|
@ -37,14 +37,13 @@ class BlockEventPacket extends DataPacket{
|
||||
public $case1;
|
||||
public $case2;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->case1 = $this->getVarInt();
|
||||
$this->case2 = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->case1);
|
||||
$this->putVarInt($this->case2);
|
||||
|
@ -37,13 +37,12 @@ class BlockPickRequestPacket extends DataPacket{
|
||||
public $tileZ;
|
||||
public $hotbarSlot;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class BossEventPacket extends DataPacket{
|
||||
/** @var int */
|
||||
public $overlay;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->bossEid = $this->getEntityUniqueId();
|
||||
$this->eventType = $this->getUnsignedVarInt();
|
||||
switch($this->eventType){
|
||||
@ -91,8 +91,7 @@ class BossEventPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->bossEid);
|
||||
$this->putUnsignedVarInt($this->eventType);
|
||||
switch($this->eventType){
|
||||
|
@ -40,14 +40,13 @@ class ChangeDimensionPacket extends DataPacket{
|
||||
public $z;
|
||||
public $respawn = false;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->dimension = $this->getVarInt();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->respawn = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->respawn);
|
||||
|
@ -33,12 +33,11 @@ class ChunkRadiusUpdatedPacket extends DataPacket{
|
||||
|
||||
public $radius;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->radius = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,11 @@ class ClientToServerHandshakePacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
//No payload
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
//No payload
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
/** @var Color[][] */
|
||||
public $colors = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
$this->type = $this->getUnsignedVarInt();
|
||||
|
||||
@ -93,8 +93,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->mapId);
|
||||
|
||||
$type = 0;
|
||||
|
@ -49,7 +49,7 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
|
||||
public $shouldTrackOutput;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->isBlock = $this->getBool();
|
||||
|
||||
if($this->isBlock){
|
||||
@ -69,8 +69,7 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
$this->shouldTrackOutput = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBool($this->isBlock);
|
||||
|
||||
if($this->isBlock){
|
||||
|
@ -39,7 +39,7 @@ class CommandStepPacket extends DataPacket{
|
||||
public $inputJson;
|
||||
public $outputJson;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->command = $this->getString();
|
||||
$this->overload = $this->getString();
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
@ -52,8 +52,7 @@ class CommandStepPacket extends DataPacket{
|
||||
$this->getRemaining(); //TODO: read command origin data
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->command);
|
||||
$this->putString($this->overload);
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
|
@ -33,12 +33,11 @@ class ContainerClosePacket extends DataPacket{
|
||||
|
||||
public $windowid;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowid = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowid);
|
||||
}
|
||||
|
||||
|
@ -38,15 +38,14 @@ class ContainerOpenPacket extends DataPacket{
|
||||
public $z;
|
||||
public $entityUniqueId = -1;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowid = $this->getByte();
|
||||
$this->type = $this->getByte();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowid);
|
||||
$this->putByte($this->type);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
|
@ -49,7 +49,7 @@ class ContainerSetContentPacket extends DataPacket{
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowid = $this->getUnsignedVarInt();
|
||||
$this->targetEid = $this->getEntityUniqueId();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
@ -63,8 +63,7 @@ class ContainerSetContentPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt($this->windowid);
|
||||
$this->putEntityUniqueId($this->targetEid);
|
||||
$this->putUnsignedVarInt(count($this->slots));
|
||||
|
@ -35,14 +35,13 @@ class ContainerSetDataPacket extends DataPacket{
|
||||
public $property;
|
||||
public $value;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowid = $this->getByte();
|
||||
$this->property = $this->getVarInt();
|
||||
$this->value = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowid);
|
||||
$this->putVarInt($this->property);
|
||||
$this->putVarInt($this->value);
|
||||
|
@ -38,7 +38,7 @@ class ContainerSetSlotPacket extends DataPacket{
|
||||
public $item;
|
||||
public $selectSlot = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowid = $this->getByte();
|
||||
$this->slot = $this->getVarInt();
|
||||
$this->hotbarSlot = $this->getVarInt();
|
||||
@ -46,8 +46,7 @@ class ContainerSetSlotPacket extends DataPacket{
|
||||
$this->selectSlot = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowid);
|
||||
$this->putVarInt($this->slot);
|
||||
$this->putVarInt($this->hotbarSlot);
|
||||
|
@ -52,7 +52,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$entries = [];
|
||||
$recipeCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $recipeCount; ++$i){
|
||||
@ -182,8 +182,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
|
||||
$writer = new BinaryStream();
|
||||
|
@ -47,7 +47,7 @@ class CraftingEventPacket extends DataPacket{
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowId = $this->getByte();
|
||||
$this->type = $this->getVarInt();
|
||||
$this->id = $this->getUUID();
|
||||
@ -63,8 +63,7 @@ class CraftingEventPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowId);
|
||||
$this->putVarInt($this->type);
|
||||
$this->putUUID($this->id);
|
||||
|
@ -55,9 +55,29 @@ abstract class DataPacket extends BinaryStream{
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract public function encode();
|
||||
public function decode(){
|
||||
$this->offset = 1;
|
||||
$this->decodePayload();
|
||||
}
|
||||
|
||||
abstract public function decode();
|
||||
/**
|
||||
* Note for plugin developers: If you're adding your own packets, you should perform decoding in here.
|
||||
*/
|
||||
public function decodePayload(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->encodePayload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Note for plugin developers: If you're adding your own packets, you should perform encoding in here.
|
||||
*/
|
||||
public function encodePayload(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs handling for this packet. Usually you'll want an appropriately named method in the NetworkSession for this.
|
||||
|
@ -38,13 +38,12 @@ class DisconnectPacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->hideDisconnectionScreen = $this->getBool();
|
||||
$this->message = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBool($this->hideDisconnectionScreen);
|
||||
if(!$this->hideDisconnectionScreen){
|
||||
$this->putString($this->message);
|
||||
|
@ -36,13 +36,12 @@ class DropItemPacket extends DataPacket{
|
||||
/** @var Item */
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->type = $this->getByte();
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->type);
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
@ -54,14 +54,13 @@ class EntityEventPacket extends DataPacket{
|
||||
public $event;
|
||||
public $data = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->event = $this->getByte();
|
||||
$this->data = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->event);
|
||||
$this->putVarInt($this->data);
|
||||
|
@ -35,14 +35,13 @@ class EntityFallPacket extends DataPacket{
|
||||
public $fallDistance;
|
||||
public $bool1;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->fallDistance = $this->getLFloat();
|
||||
$this->bool1 = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putLFloat($this->fallDistance);
|
||||
$this->putBool($this->bool1);
|
||||
|
@ -45,7 +45,7 @@ class ExplodePacket extends DataPacket{
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->radius = (float) ($this->getVarInt() / 32);
|
||||
$count = $this->getUnsignedVarInt();
|
||||
@ -56,8 +56,7 @@ class ExplodePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt((int) ($this->radius * 32));
|
||||
$this->putUnsignedVarInt(count($this->records));
|
||||
|
@ -35,14 +35,13 @@ class FullChunkDataPacket extends DataPacket{
|
||||
public $chunkZ;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->chunkX = $this->getVarInt();
|
||||
$this->chunkZ = $this->getVarInt();
|
||||
$this->data = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->chunkX);
|
||||
$this->putVarInt($this->chunkZ);
|
||||
$this->putString($this->data);
|
||||
|
@ -32,12 +32,11 @@ class GameRulesChangedPacket extends DataPacket{
|
||||
|
||||
public $gameRules = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->gameRules = $this->getGameRules();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putGameRules($this->gameRules);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class HurtArmorPacket extends DataPacket{
|
||||
|
||||
public $health;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->health = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,12 @@ class InteractPacket extends DataPacket{
|
||||
public $action;
|
||||
public $target;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->action = $this->getByte();
|
||||
$this->target = $this->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->action);
|
||||
$this->putEntityRuntimeId($this->target);
|
||||
}
|
||||
|
@ -38,15 +38,14 @@ class InventoryActionPacket extends DataPacket{
|
||||
public $enchantmentId = 0;
|
||||
public $enchantmentLevel = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->actionId = $this->getUnsignedVarInt();
|
||||
$this->item = $this->getSlot();
|
||||
$this->enchantmentId = $this->getVarInt();
|
||||
$this->enchantmentLevel = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt($this->actionId);
|
||||
$this->putSlot($this->item);
|
||||
$this->putVarInt($this->enchantmentId);
|
||||
|
@ -35,12 +35,11 @@ class ItemFrameDropItemPacket extends DataPacket{
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
|
@ -106,14 +106,13 @@ class LevelEventPacket extends DataPacket{
|
||||
public $z = 0;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->evid = $this->getVarInt();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->data = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->evid);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->data);
|
||||
|
@ -148,7 +148,7 @@ class LevelSoundEventPacket extends DataPacket{
|
||||
public $unknownBool = false;
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->sound = $this->getByte();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->extraData = $this->getVarInt();
|
||||
@ -157,8 +157,7 @@ class LevelSoundEventPacket extends DataPacket{
|
||||
$this->disableRelativeVolume = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->sound);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->extraData);
|
||||
|
@ -50,7 +50,7 @@ class LoginPacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->protocol = $this->getInt();
|
||||
|
||||
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
||||
@ -89,7 +89,7 @@ class LoginPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
public function encodePayload(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,11 @@ class MapInfoRequestPacket extends DataPacket{
|
||||
|
||||
public $mapId;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->mapId);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
/** @var Item[] */
|
||||
public $slots = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->slots[0] = $this->getSlot();
|
||||
$this->slots[1] = $this->getSlot();
|
||||
@ -44,8 +44,7 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
$this->slots[3] = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->slots[0]);
|
||||
$this->putSlot($this->slots[1]);
|
||||
|
@ -42,7 +42,7 @@ class MobEffectPacket extends DataPacket{
|
||||
public $particles = true;
|
||||
public $duration = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->eventId = $this->getByte();
|
||||
$this->effectId = $this->getVarInt();
|
||||
@ -51,8 +51,7 @@ class MobEffectPacket extends DataPacket{
|
||||
$this->duration = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->eventId);
|
||||
$this->putVarInt($this->effectId);
|
||||
|
@ -37,7 +37,7 @@ class MobEquipmentPacket extends DataPacket{
|
||||
public $hotbarSlot;
|
||||
public $windowId = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->item = $this->getSlot();
|
||||
$this->inventorySlot = $this->getByte();
|
||||
@ -45,8 +45,7 @@ class MobEquipmentPacket extends DataPacket{
|
||||
$this->windowId = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->item);
|
||||
$this->putByte($this->inventorySlot);
|
||||
|
@ -41,7 +41,7 @@ class MoveEntityPacket extends DataPacket{
|
||||
public $onGround = false;
|
||||
public $teleported = false;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->pitch = $this->getByteRotation();
|
||||
@ -51,8 +51,7 @@ class MoveEntityPacket extends DataPacket{
|
||||
$this->teleported = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putByteRotation($this->pitch);
|
||||
|
@ -49,7 +49,7 @@ class MovePlayerPacket extends DataPacket{
|
||||
public $int1 = 0;
|
||||
public $int2 = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->pitch = $this->getLFloat();
|
||||
@ -64,8 +64,7 @@ class MovePlayerPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->pitch);
|
||||
|
@ -39,15 +39,14 @@ class PlaySoundPacket extends DataPacket{
|
||||
public $volume;
|
||||
public $pitch;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->soundName = $this->getString();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->volume = $this->getLFloat();
|
||||
$this->pitch = $this->getLFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->soundName);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->volume);
|
||||
|
@ -41,16 +41,15 @@ class PlayStatusPacket extends DataPacket{
|
||||
|
||||
public $status;
|
||||
|
||||
public function decode(){
|
||||
|
||||
public function decodePayload(){
|
||||
$this->status = $this->getInt();
|
||||
}
|
||||
|
||||
public function canBeSentBeforeLogin() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putInt($this->status);
|
||||
}
|
||||
|
||||
|
@ -58,15 +58,14 @@ class PlayerActionPacket extends DataPacket{
|
||||
public $z;
|
||||
public $face;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->action = $this->getVarInt();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVarInt($this->action);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
|
@ -36,15 +36,14 @@ class PlayerInputPacket extends DataPacket{
|
||||
public $unknownBool1;
|
||||
public $unknownBool2;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->motionX = $this->getLFloat();
|
||||
$this->motionY = $this->getLFloat();
|
||||
$this->unknownBool1 = $this->getBool();
|
||||
$this->unknownBool2 = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putLFloat($this->motionX);
|
||||
$this->putLFloat($this->motionY);
|
||||
$this->putBool($this->unknownBool1);
|
||||
|
@ -44,7 +44,7 @@ class PlayerListPacket extends DataPacket{
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->type = $this->getByte();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
@ -60,8 +60,7 @@ class PlayerListPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->type);
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $d){
|
||||
|
@ -35,12 +35,11 @@ class RemoveBlockPacket extends DataPacket{
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class RemoveEntityPacket extends DataPacket{
|
||||
|
||||
public $entityUniqueId;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class ReplaceItemInSlotPacket extends DataPacket{
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class RequestChunkRadiusPacket extends DataPacket{
|
||||
|
||||
public $radius;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->radius = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
|
@ -37,15 +37,14 @@ class ResourcePackChunkDataPacket extends DataPacket{
|
||||
public $progress;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->packId = $this->getString();
|
||||
$this->chunkIndex = $this->getLInt();
|
||||
$this->progress = $this->getLLong();
|
||||
$this->data = $this->get($this->getLInt());
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->chunkIndex);
|
||||
$this->putLLong($this->progress);
|
||||
|
@ -35,13 +35,12 @@ class ResourcePackChunkRequestPacket extends DataPacket{
|
||||
public $packId;
|
||||
public $chunkIndex;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->packId = $this->getString();
|
||||
$this->chunkIndex = $this->getLInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->chunkIndex);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
|
||||
public $status;
|
||||
public $packIds = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->status = $this->getByte();
|
||||
$entryCount = $this->getLShort();
|
||||
while($entryCount-- > 0){
|
||||
@ -47,8 +47,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->status);
|
||||
$this->putLShort(count($this->packIds));
|
||||
foreach($this->packIds as $id){
|
||||
|
@ -38,7 +38,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
|
||||
public $compressedPackSize;
|
||||
public $sha256;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->packId = $this->getString();
|
||||
$this->maxChunkSize = $this->getLInt();
|
||||
$this->chunkCount = $this->getLInt();
|
||||
@ -46,8 +46,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
|
||||
$this->sha256 = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->maxChunkSize);
|
||||
$this->putLInt($this->chunkCount);
|
||||
|
@ -41,7 +41,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
/** @var ResourcePack[] */
|
||||
public $resourcePackStack = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
/*$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getUnsignedVarInt();
|
||||
while($behaviorPackCount-- > 0){
|
||||
@ -58,8 +58,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
}*/
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBool($this->mustAccept);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
|
@ -39,7 +39,7 @@ class ResourcePacksInfoPacket extends DataPacket{
|
||||
/** @var ResourcePack[] */
|
||||
public $resourcePackEntries = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
/*$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getLShort();
|
||||
while($behaviorPackCount-- > 0){
|
||||
@ -60,8 +60,7 @@ class ResourcePacksInfoPacket extends DataPacket{
|
||||
}*/
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
|
||||
$this->putBool($this->mustAccept);
|
||||
$this->putLShort(count($this->behaviorPackEntries));
|
||||
|
@ -35,12 +35,11 @@ class RespawnPacket extends DataPacket{
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,11 @@ class RiderJumpPacket extends DataPacket{
|
||||
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,12 @@ class ServerToClientHandshakePacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->publicKey = $this->getString();
|
||||
$this->serverToken = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->publicKey);
|
||||
$this->putString($this->serverToken);
|
||||
}
|
||||
|
@ -33,12 +33,11 @@ class SetCommandsEnabledPacket extends DataPacket{
|
||||
|
||||
public $enabled;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->enabled = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBool($this->enabled);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class SetDifficultyPacket extends DataPacket{
|
||||
|
||||
public $difficulty;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->difficulty = $this->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt($this->difficulty);
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,12 @@ class SetEntityDataPacket extends DataPacket{
|
||||
public $entityRuntimeId;
|
||||
public $metadata;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
}
|
||||
|
@ -35,14 +35,13 @@ class SetEntityLinkPacket extends DataPacket{
|
||||
public $to;
|
||||
public $type;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->from = $this->getEntityUniqueId();
|
||||
$this->to = $this->getEntityUniqueId();
|
||||
$this->type = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->from);
|
||||
$this->putEntityUniqueId($this->to);
|
||||
$this->putByte($this->type);
|
||||
|
@ -36,13 +36,12 @@ class SetEntityMotionPacket extends DataPacket{
|
||||
public $motionY;
|
||||
public $motionZ;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getVector3f($this->motionX, $this->motionY, $this->motionZ);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
|
||||
}
|
||||
|
@ -33,12 +33,11 @@ class SetHealthPacket extends DataPacket{
|
||||
|
||||
public $health;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->health = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,11 @@ class SetPlayerGameTypePacket extends DataPacket{
|
||||
|
||||
public $gamemode;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->gamemode = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->gamemode);
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,13 @@ class SetSpawnPositionPacket extends DataPacket{
|
||||
public $z;
|
||||
public $spawnForced;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->spawnType = $this->getVarInt();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->spawnForced = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->spawnType);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->spawnForced);
|
||||
|
@ -32,12 +32,11 @@ class SetTimePacket extends DataPacket{
|
||||
|
||||
public $time;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->time = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->time);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class SetTitlePacket extends DataPacket{
|
||||
public $stayTime = 0;
|
||||
public $fadeOutTime = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->type = $this->getVarInt();
|
||||
$this->text = $this->getString();
|
||||
$this->fadeInTime = $this->getVarInt();
|
||||
@ -53,8 +53,7 @@ class SetTitlePacket extends DataPacket{
|
||||
$this->fadeOutTime = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVarInt($this->type);
|
||||
$this->putString($this->text);
|
||||
$this->putVarInt($this->fadeInTime);
|
||||
|
@ -38,13 +38,12 @@ class ShowCreditsPacket extends DataPacket{
|
||||
public $playerEid;
|
||||
public $status;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->playerEid = $this->getEntityRuntimeId();
|
||||
$this->status = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->playerEid);
|
||||
$this->putVarInt($this->status);
|
||||
}
|
||||
|
@ -36,13 +36,12 @@ class SpawnExperienceOrbPacket extends DataPacket{
|
||||
public $z;
|
||||
public $amount;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->amount = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->amount);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class StartGamePacket extends DataPacket{
|
||||
public $unknownBool = false;
|
||||
public $currentTick = 0;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->playerGamemode = $this->getVarInt();
|
||||
@ -90,8 +90,7 @@ class StartGamePacket extends DataPacket{
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVarInt($this->playerGamemode);
|
||||
|
@ -35,13 +35,12 @@ class StopSoundPacket extends DataPacket{
|
||||
public $soundName;
|
||||
public $stopAll;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->soundName = $this->getString();
|
||||
$this->stopAll = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->soundName);
|
||||
$this->putBool($this->stopAll);
|
||||
}
|
||||
|
@ -34,12 +34,11 @@ class TakeItemEntityPacket extends DataPacket{
|
||||
public $target;
|
||||
public $eid;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->target);
|
||||
$this->putEntityRuntimeId($this->eid);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class TextPacket extends DataPacket{
|
||||
public $message;
|
||||
public $parameters = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->type = $this->getByte();
|
||||
switch($this->type){
|
||||
case self::TYPE_POPUP:
|
||||
@ -69,8 +69,7 @@ class TextPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->type);
|
||||
switch($this->type){
|
||||
case self::TYPE_POPUP:
|
||||
|
@ -33,13 +33,12 @@ class TransferPacket extends DataPacket{
|
||||
public $address;
|
||||
public $port = 19132;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->address = $this->getString();
|
||||
$this->port = $this->getLShort();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putString($this->address);
|
||||
$this->putLShort($this->port);
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ class UnknownPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
$this->offset -= 1; //Rewind one byte so we can read the PID
|
||||
$this->payload = $this->getRemaining();
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,12 @@ class UpdateAttributesPacket extends DataPacket{
|
||||
/** @var Attribute[] */
|
||||
public $entries = [];
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->entries = $this->getAttributeList();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putAttributeList(...$this->entries);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class UpdateBlockPacket extends DataPacket{
|
||||
public $blockData;
|
||||
public $flags;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->blockId = $this->getUnsignedVarInt();
|
||||
$aux = $this->getUnsignedVarInt();
|
||||
@ -55,8 +55,7 @@ class UpdateBlockPacket extends DataPacket{
|
||||
$this->flags = $aux >> 4;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->blockId);
|
||||
$this->putUnsignedVarInt(($this->flags << 4) | $this->blockData);
|
||||
|
@ -44,7 +44,7 @@ class UpdateTradePacket extends DataPacket{
|
||||
public $displayName;
|
||||
public $offers;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->windowId = $this->getByte();
|
||||
$this->windowType = $this->getByte();
|
||||
$this->varint1 = $this->getVarInt();
|
||||
@ -56,8 +56,7 @@ class UpdateTradePacket extends DataPacket{
|
||||
$this->offers = $this->getRemaining();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowId);
|
||||
$this->putByte($this->windowType);
|
||||
$this->putVarInt($this->varint1);
|
||||
|
@ -47,7 +47,7 @@ class UseItemPacket extends DataPacket{
|
||||
/** @var Item */
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->blockId = $this->getUnsignedVarInt();
|
||||
$this->face = $this->getVarInt();
|
||||
@ -57,8 +57,7 @@ class UseItemPacket extends DataPacket{
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt($this->blockId);
|
||||
$this->putUnsignedVarInt($this->face);
|
||||
$this->putVector3f($this->fx, $this->fy, $this->fz);
|
||||
|
Loading…
x
Reference in New Issue
Block a user