Apply typehints to pocketmine\network\mcpe\protocol namespace

this is pulled from network-nuke in order to reduce the size of the diff.
This commit is contained in:
Dylan K. Taylor 2018-07-05 13:19:15 +01:00
parent fbd4f4a849
commit 2bba3a0805
116 changed files with 255 additions and 255 deletions

View File

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

View File

@ -55,7 +55,7 @@ class AddEntityPacket extends DataPacket{
/** @var EntityLink[] */ /** @var EntityLink[] */
public $links = []; public $links = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->type = $this->getUnsignedVarInt(); $this->type = $this->getUnsignedVarInt();
@ -89,7 +89,7 @@ class AddEntityPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putUnsignedVarInt($this->type); $this->putUnsignedVarInt($this->type);

View File

@ -43,14 +43,14 @@ class AddHangingEntityPacket extends DataPacket{
/** @var int */ /** @var int */
public $direction; public $direction;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt(); $this->direction = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z); $this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -47,7 +47,7 @@ class AddItemEntityPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $isFromFishing = false; public $isFromFishing = false;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
@ -57,7 +57,7 @@ class AddItemEntityPacket extends DataPacket{
$this->isFromFishing = $this->getBool(); $this->isFromFishing = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item); $this->putSlot($this->item);

View File

@ -34,12 +34,12 @@ class AddPaintingPacket extends AddHangingEntityPacket{
/** @var string */ /** @var string */
public $title; public $title;
protected function decodePayload(){ protected function decodePayload() : void{
parent::decodePayload(); parent::decodePayload();
$this->title = $this->getString(); $this->title = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload() : void{
parent::encodePayload(); parent::encodePayload();
$this->putString($this->title); $this->putString($this->title);
} }

View File

@ -75,7 +75,7 @@ class AddPlayerPacket extends DataPacket{
/** @var EntityLink[] */ /** @var EntityLink[] */
public $links = []; public $links = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->uuid = $this->getUUID(); $this->uuid = $this->getUUID();
$this->username = $this->getString(); $this->username = $this->getString();
$this->thirdPartyName = $this->getString(); $this->thirdPartyName = $this->getString();
@ -105,7 +105,7 @@ class AddPlayerPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUUID($this->uuid); $this->putUUID($this->uuid);
$this->putString($this->username); $this->putString($this->username);
$this->putString($this->thirdPartyName); $this->putString($this->thirdPartyName);

View File

@ -76,7 +76,7 @@ class AdventureSettingsPacket extends DataPacket{
/** @var int */ /** @var int */
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang) public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
protected function decodePayload(){ protected function decodePayload() : void{
$this->flags = $this->getUnsignedVarInt(); $this->flags = $this->getUnsignedVarInt();
$this->commandPermission = $this->getUnsignedVarInt(); $this->commandPermission = $this->getUnsignedVarInt();
$this->flags2 = $this->getUnsignedVarInt(); $this->flags2 = $this->getUnsignedVarInt();
@ -85,7 +85,7 @@ class AdventureSettingsPacket extends DataPacket{
$this->entityUniqueId = $this->getLLong(); $this->entityUniqueId = $this->getLLong();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt($this->flags); $this->putUnsignedVarInt($this->flags);
$this->putUnsignedVarInt($this->commandPermission); $this->putUnsignedVarInt($this->commandPermission);
$this->putUnsignedVarInt($this->flags2); $this->putUnsignedVarInt($this->flags2);
@ -102,7 +102,7 @@ class AdventureSettingsPacket extends DataPacket{
return ($this->flags & $flag) !== 0; return ($this->flags & $flag) !== 0;
} }
public function setFlag(int $flag, bool $value){ public function setFlag(int $flag, bool $value) : void{
if($flag & self::BITFLAG_SECOND_SET){ if($flag & self::BITFLAG_SECOND_SET){
$flagSet =& $this->flags2; $flagSet =& $this->flags2;
}else{ }else{

View File

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

View File

@ -103,7 +103,7 @@ class AvailableCommandsPacket extends DataPacket{
*/ */
public $commandData = []; public $commandData = [];
protected function decodePayload(){ protected function decodePayload() : void{
for($i = 0, $this->enumValuesCount = $this->getUnsignedVarInt(); $i < $this->enumValuesCount; ++$i){ for($i = 0, $this->enumValuesCount = $this->getUnsignedVarInt(); $i < $this->enumValuesCount; ++$i){
$this->enumValues[] = $this->getString(); $this->enumValues[] = $this->getString();
} }
@ -133,7 +133,7 @@ class AvailableCommandsPacket extends DataPacket{
return $retval; return $retval;
} }
protected function putEnum(CommandEnum $enum){ protected function putEnum(CommandEnum $enum) : void{
$this->putString($enum->enumName); $this->putString($enum->enumName);
$this->putUnsignedVarInt(count($enum->enumValues)); $this->putUnsignedVarInt(count($enum->enumValues));
@ -157,7 +157,7 @@ class AvailableCommandsPacket extends DataPacket{
} }
} }
protected function putEnumValueIndex(int $index){ protected function putEnumValueIndex(int $index) : void{
if($this->enumValuesCount < 256){ if($this->enumValuesCount < 256){
$this->putByte($index); $this->putByte($index);
}elseif($this->enumValuesCount < 65536){ }elseif($this->enumValuesCount < 65536){
@ -201,7 +201,7 @@ class AvailableCommandsPacket extends DataPacket{
return $retval; return $retval;
} }
protected function putCommandData(CommandData $data){ protected function putCommandData(CommandData $data) : void{
$this->putString($data->commandName); $this->putString($data->commandName);
$this->putString($data->commandDescription); $this->putString($data->commandDescription);
$this->putByte($data->flags); $this->putByte($data->flags);
@ -278,7 +278,7 @@ class AvailableCommandsPacket extends DataPacket{
return "unknown ($argtype)"; return "unknown ($argtype)";
} }
protected function encodePayload(){ protected function encodePayload() : void{
$enumValuesMap = []; $enumValuesMap = [];
$postfixesMap = []; $postfixesMap = [];
$enumMap = []; $enumMap = [];

View File

@ -48,12 +48,12 @@ class BatchPacket extends DataPacket{
return true; return true;
} }
protected function decodeHeader(){ protected function decodeHeader() : void{
$pid = $this->getByte(); $pid = $this->getByte();
assert($pid === static::NETWORK_ID); assert($pid === static::NETWORK_ID);
} }
protected function decodePayload(){ protected function decodePayload() : void{
$data = $this->getRemaining(); $data = $this->getRemaining();
try{ try{
$this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB $this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB
@ -62,18 +62,18 @@ class BatchPacket extends DataPacket{
} }
} }
protected function encodeHeader(){ protected function encodeHeader() : void{
$this->putByte(static::NETWORK_ID); $this->putByte(static::NETWORK_ID);
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->put(zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $this->compressionLevel)); $this->put(zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $this->compressionLevel));
} }
/** /**
* @param DataPacket $packet * @param DataPacket $packet
*/ */
public function addPacket(DataPacket $packet){ public function addPacket(DataPacket $packet) : void{
if(!$packet->canBeBatched()){ if(!$packet->canBeBatched()){
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket"); throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
} }
@ -87,7 +87,7 @@ class BatchPacket extends DataPacket{
/** /**
* @return \Generator * @return \Generator
*/ */
public function getPackets(){ public function getPackets() : \Generator{
$stream = new NetworkBinaryStream($this->payload); $stream = new NetworkBinaryStream($this->payload);
while(!$stream->feof()){ while(!$stream->feof()){
yield $stream->getString(); yield $stream->getString();
@ -98,7 +98,7 @@ class BatchPacket extends DataPacket{
return $this->compressionLevel; return $this->compressionLevel;
} }
public function setCompressionLevel(int $level){ public function setCompressionLevel(int $level) : void{
$this->compressionLevel = $level; $this->compressionLevel = $level;
} }

View File

@ -40,12 +40,12 @@ class BlockEntityDataPacket extends DataPacket{
/** @var string */ /** @var string */
public $namedtag; public $namedtag;
protected function decodePayload(){ protected function decodePayload() : void{
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
$this->namedtag = $this->getRemaining(); $this->namedtag = $this->getRemaining();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putBlockPosition($this->x, $this->y, $this->z); $this->putBlockPosition($this->x, $this->y, $this->z);
$this->put($this->namedtag); $this->put($this->namedtag);
} }

View File

@ -42,13 +42,13 @@ class BlockEventPacket extends DataPacket{
/** @var int */ /** @var int */
public $eventData; public $eventData;
protected function decodePayload(){ protected function decodePayload() : void{
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
$this->eventType = $this->getVarInt(); $this->eventType = $this->getVarInt();
$this->eventData = $this->getVarInt(); $this->eventData = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putBlockPosition($this->x, $this->y, $this->z); $this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->eventType); $this->putVarInt($this->eventType);
$this->putVarInt($this->eventData); $this->putVarInt($this->eventData);

View File

@ -43,13 +43,13 @@ class BlockPickRequestPacket extends DataPacket{
/** @var int */ /** @var int */
public $hotbarSlot; public $hotbarSlot;
protected function decodePayload(){ protected function decodePayload() : void{
$this->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); $this->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
$this->addUserData = $this->getBool(); $this->addUserData = $this->getBool();
$this->hotbarSlot = $this->getByte(); $this->hotbarSlot = $this->getByte();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); $this->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
$this->putBool($this->addUserData); $this->putBool($this->addUserData);
$this->putByte($this->hotbarSlot); $this->putByte($this->hotbarSlot);

View File

@ -57,7 +57,7 @@ class BookEditPacket extends DataPacket{
/** @var string */ /** @var string */
public $xuid; public $xuid;
protected function decodePayload(){ protected function decodePayload() : void{
$this->type = $this->getByte(); $this->type = $this->getByte();
$this->inventorySlot = $this->getByte(); $this->inventorySlot = $this->getByte();
@ -85,7 +85,7 @@ class BookEditPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->type); $this->putByte($this->type);
$this->putByte($this->inventorySlot); $this->putByte($this->inventorySlot);

View File

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

View File

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

View File

@ -39,13 +39,13 @@ class ChangeDimensionPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $respawn = false; public $respawn = false;
protected function decodePayload(){ protected function decodePayload() : void{
$this->dimension = $this->getVarInt(); $this->dimension = $this->getVarInt();
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->respawn = $this->getBool(); $this->respawn = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->dimension); $this->putVarInt($this->dimension);
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putBool($this->respawn); $this->putBool($this->respawn);

View File

@ -34,11 +34,11 @@ class ChunkRadiusUpdatedPacket extends DataPacket{
/** @var int */ /** @var int */
public $radius; public $radius;
protected function decodePayload(){ protected function decodePayload() : void{
$this->radius = $this->getVarInt(); $this->radius = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->radius); $this->putVarInt($this->radius);
} }

View File

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

View File

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

View File

@ -60,7 +60,7 @@ class CommandBlockUpdatePacket extends DataPacket{
/** @var bool */ /** @var bool */
public $shouldTrackOutput; public $shouldTrackOutput;
protected function decodePayload(){ protected function decodePayload() : void{
$this->isBlock = $this->getBool(); $this->isBlock = $this->getBool();
if($this->isBlock){ if($this->isBlock){
@ -80,7 +80,7 @@ class CommandBlockUpdatePacket extends DataPacket{
$this->shouldTrackOutput = $this->getBool(); $this->shouldTrackOutput = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putBool($this->isBlock); $this->putBool($this->isBlock);
if($this->isBlock){ if($this->isBlock){

View File

@ -43,7 +43,7 @@ class CommandOutputPacket extends DataPacket{
/** @var string */ /** @var string */
public $unknownString; public $unknownString;
protected function decodePayload(){ protected function decodePayload() : void{
$this->originData = $this->getCommandOriginData(); $this->originData = $this->getCommandOriginData();
$this->outputType = $this->getByte(); $this->outputType = $this->getByte();
$this->successCount = $this->getUnsignedVarInt(); $this->successCount = $this->getUnsignedVarInt();
@ -70,7 +70,7 @@ class CommandOutputPacket extends DataPacket{
return $message; return $message;
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putCommandOriginData($this->originData); $this->putCommandOriginData($this->originData);
$this->putByte($this->outputType); $this->putByte($this->outputType);
$this->putUnsignedVarInt($this->successCount); $this->putUnsignedVarInt($this->successCount);
@ -85,7 +85,7 @@ class CommandOutputPacket extends DataPacket{
} }
} }
protected function putCommandMessage(CommandOutputMessage $message){ protected function putCommandMessage(CommandOutputMessage $message) : void{
$this->putBool($message->isInternal); $this->putBool($message->isInternal);
$this->putString($message->messageId); $this->putString($message->messageId);

View File

@ -38,13 +38,13 @@ class CommandRequestPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $isInternal; public $isInternal;
protected function decodePayload(){ protected function decodePayload() : void{
$this->command = $this->getString(); $this->command = $this->getString();
$this->originData = $this->getCommandOriginData(); $this->originData = $this->getCommandOriginData();
$this->isInternal = $this->getBool(); $this->isInternal = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->command); $this->putString($this->command);
$this->putCommandOriginData($this->originData); $this->putCommandOriginData($this->originData);
$this->putBool($this->isInternal); $this->putBool($this->isInternal);

View File

@ -34,11 +34,11 @@ class ContainerClosePacket extends DataPacket{
/** @var int */ /** @var int */
public $windowId; public $windowId;
protected function decodePayload(){ protected function decodePayload() : void{
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->windowId); $this->putByte($this->windowId);
} }

View File

@ -44,14 +44,14 @@ class ContainerOpenPacket extends DataPacket{
/** @var int */ /** @var int */
public $entityUniqueId = -1; public $entityUniqueId = -1;
protected function decodePayload(){ protected function decodePayload() : void{
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
$this->type = $this->getByte(); $this->type = $this->getByte();
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->windowId); $this->putByte($this->windowId);
$this->putByte($this->type); $this->putByte($this->type);
$this->putBlockPosition($this->x, $this->y, $this->z); $this->putBlockPosition($this->x, $this->y, $this->z);

View File

@ -48,13 +48,13 @@ class ContainerSetDataPacket extends DataPacket{
/** @var int */ /** @var int */
public $value; public $value;
protected function decodePayload(){ protected function decodePayload() : void{
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
$this->property = $this->getVarInt(); $this->property = $this->getVarInt();
$this->value = $this->getVarInt(); $this->value = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->windowId); $this->putByte($this->windowId);
$this->putVarInt($this->property); $this->putVarInt($this->property);
$this->putVarInt($this->value); $this->putVarInt($this->value);

View File

@ -58,7 +58,7 @@ class CraftingDataPacket extends DataPacket{
return parent::clean(); return parent::clean();
} }
protected function decodePayload(){ protected function decodePayload() : void{
$this->decodedEntries = []; $this->decodedEntries = [];
$recipeCount = $this->getUnsignedVarInt(); $recipeCount = $this->getUnsignedVarInt();
for($i = 0; $i < $recipeCount; ++$i){ for($i = 0; $i < $recipeCount; ++$i){
@ -131,7 +131,7 @@ class CraftingDataPacket extends DataPacket{
return -1; return -1;
} }
private static function writeShapelessRecipe(ShapelessRecipe $recipe, NetworkBinaryStream $stream){ private static function writeShapelessRecipe(ShapelessRecipe $recipe, NetworkBinaryStream $stream) : int{
$stream->putUnsignedVarInt($recipe->getIngredientCount()); $stream->putUnsignedVarInt($recipe->getIngredientCount());
foreach($recipe->getIngredientList() as $item){ foreach($recipe->getIngredientList() as $item){
$stream->putSlot($item); $stream->putSlot($item);
@ -148,7 +148,7 @@ class CraftingDataPacket extends DataPacket{
return CraftingDataPacket::ENTRY_SHAPELESS; return CraftingDataPacket::ENTRY_SHAPELESS;
} }
private static function writeShapedRecipe(ShapedRecipe $recipe, NetworkBinaryStream $stream){ private static function writeShapedRecipe(ShapedRecipe $recipe, NetworkBinaryStream $stream) : int{
$stream->putVarInt($recipe->getWidth()); $stream->putVarInt($recipe->getWidth());
$stream->putVarInt($recipe->getHeight()); $stream->putVarInt($recipe->getHeight());
@ -169,7 +169,7 @@ class CraftingDataPacket extends DataPacket{
return CraftingDataPacket::ENTRY_SHAPED; return CraftingDataPacket::ENTRY_SHAPED;
} }
private static function writeFurnaceRecipe(FurnaceRecipe $recipe, NetworkBinaryStream $stream){ private static function writeFurnaceRecipe(FurnaceRecipe $recipe, NetworkBinaryStream $stream) : int{
if(!$recipe->getInput()->hasAnyDamageValue()){ //Data recipe if(!$recipe->getInput()->hasAnyDamageValue()){ //Data recipe
$stream->putVarInt($recipe->getInput()->getId()); $stream->putVarInt($recipe->getInput()->getId());
$stream->putVarInt($recipe->getInput()->getDamage()); $stream->putVarInt($recipe->getInput()->getDamage());
@ -184,19 +184,19 @@ class CraftingDataPacket extends DataPacket{
} }
} }
public function addShapelessRecipe(ShapelessRecipe $recipe){ public function addShapelessRecipe(ShapelessRecipe $recipe) : void{
$this->entries[] = $recipe; $this->entries[] = $recipe;
} }
public function addShapedRecipe(ShapedRecipe $recipe){ public function addShapedRecipe(ShapedRecipe $recipe) : void{
$this->entries[] = $recipe; $this->entries[] = $recipe;
} }
public function addFurnaceRecipe(FurnaceRecipe $recipe){ public function addFurnaceRecipe(FurnaceRecipe $recipe) : void{
$this->entries[] = $recipe; $this->entries[] = $recipe;
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt(count($this->entries)); $this->putUnsignedVarInt(count($this->entries));
$writer = new NetworkBinaryStream(); $writer = new NetworkBinaryStream();

View File

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

View File

@ -41,7 +41,7 @@ abstract class DataPacket extends NetworkBinaryStream{
/** @var int */ /** @var int */
public $recipientSubId = 0; public $recipientSubId = 0;
public function pid(){ public function pid() : int{
return $this::NETWORK_ID; return $this::NETWORK_ID;
} }
@ -65,13 +65,13 @@ abstract class DataPacket extends NetworkBinaryStream{
return false; return false;
} }
public function decode(){ public function decode() : void{
$this->offset = 0; $this->offset = 0;
$this->decodeHeader(); $this->decodeHeader();
$this->decodePayload(); $this->decodePayload();
} }
protected function decodeHeader(){ protected function decodeHeader() : void{
$pid = $this->getUnsignedVarInt(); $pid = $this->getUnsignedVarInt();
assert($pid === static::NETWORK_ID); assert($pid === static::NETWORK_ID);
@ -83,18 +83,18 @@ abstract class DataPacket extends NetworkBinaryStream{
/** /**
* Note for plugin developers: If you're adding your own packets, you should perform decoding in here. * Note for plugin developers: If you're adding your own packets, you should perform decoding in here.
*/ */
protected function decodePayload(){ protected function decodePayload() : void{
} }
public function encode(){ public function encode() : void{
$this->reset(); $this->reset();
$this->encodeHeader(); $this->encodeHeader();
$this->encodePayload(); $this->encodePayload();
$this->isEncoded = true; $this->isEncoded = true;
} }
protected function encodeHeader(){ protected function encodeHeader() : void{
$this->putUnsignedVarInt(static::NETWORK_ID); $this->putUnsignedVarInt(static::NETWORK_ID);
$this->putByte($this->senderSubId); $this->putByte($this->senderSubId);
@ -104,7 +104,7 @@ abstract class DataPacket extends NetworkBinaryStream{
/** /**
* Note for plugin developers: If you're adding your own packets, you should perform encoding in here. * Note for plugin developers: If you're adding your own packets, you should perform encoding in here.
*/ */
protected function encodePayload(){ protected function encodePayload() : void{
} }

View File

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

View File

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

View File

@ -38,13 +38,13 @@ class EntityFallPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $isInVoid; public $isInVoid;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->fallDistance = $this->getLFloat(); $this->fallDistance = $this->getLFloat();
$this->isInVoid = $this->getBool(); $this->isInVoid = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putLFloat($this->fallDistance); $this->putLFloat($this->fallDistance);
$this->putBool($this->isInVoid); $this->putBool($this->isInVoid);

View File

@ -35,12 +35,12 @@ class EntityPickRequestPacket extends DataPacket{
/** @var int */ /** @var int */
public $hotbarSlot; public $hotbarSlot;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityUniqueId = $this->getLLong(); $this->entityUniqueId = $this->getLLong();
$this->hotbarSlot = $this->getByte(); $this->hotbarSlot = $this->getByte();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putLLong($this->entityUniqueId); $this->putLLong($this->entityUniqueId);
$this->putByte($this->hotbarSlot); $this->putByte($this->hotbarSlot);
} }

View File

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

View File

@ -44,7 +44,7 @@ class ExplodePacket extends DataPacket{
return parent::clean(); return parent::clean();
} }
protected function decodePayload(){ protected function decodePayload() : void{
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->radius = (float) ($this->getVarInt() / 32); $this->radius = (float) ($this->getVarInt() / 32);
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
@ -55,7 +55,7 @@ class ExplodePacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putVarInt((int) ($this->radius * 32)); $this->putVarInt((int) ($this->radius * 32));
$this->putUnsignedVarInt(count($this->records)); $this->putUnsignedVarInt(count($this->records));

View File

@ -38,13 +38,13 @@ class FullChunkDataPacket extends DataPacket{
/** @var string */ /** @var string */
public $data; public $data;
protected function decodePayload(){ protected function decodePayload() : void{
$this->chunkX = $this->getVarInt(); $this->chunkX = $this->getVarInt();
$this->chunkZ = $this->getVarInt(); $this->chunkZ = $this->getVarInt();
$this->data = $this->getString(); $this->data = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->chunkX); $this->putVarInt($this->chunkX);
$this->putVarInt($this->chunkZ); $this->putVarInt($this->chunkZ);
$this->putString($this->data); $this->putString($this->data);

View File

@ -33,11 +33,11 @@ class GameRulesChangedPacket extends DataPacket{
/** @var array */ /** @var array */
public $gameRules = []; public $gameRules = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->gameRules = $this->getGameRules(); $this->gameRules = $this->getGameRules();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putGameRules($this->gameRules); $this->putGameRules($this->gameRules);
} }

View File

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

View File

@ -34,11 +34,11 @@ class HurtArmorPacket extends DataPacket{
/** @var int */ /** @var int */
public $health; public $health;
protected function decodePayload(){ protected function decodePayload() : void{
$this->health = $this->getVarInt(); $this->health = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->health); $this->putVarInt($this->health);
} }

View File

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

View File

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

View File

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

View File

@ -69,7 +69,7 @@ class InventoryTransactionPacket extends DataPacket{
/** @var \stdClass */ /** @var \stdClass */
public $trData; public $trData;
protected function decodePayload(){ protected function decodePayload() : void{
$this->transactionType = $this->getUnsignedVarInt(); $this->transactionType = $this->getUnsignedVarInt();
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
@ -111,7 +111,7 @@ class InventoryTransactionPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt($this->transactionType); $this->putUnsignedVarInt($this->transactionType);
$this->putUnsignedVarInt(count($this->actions)); $this->putUnsignedVarInt(count($this->actions));

View File

@ -38,11 +38,11 @@ class ItemFrameDropItemPacket extends DataPacket{
/** @var int */ /** @var int */
public $z; public $z;
protected function decodePayload(){ protected function decodePayload() : void{
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putBlockPosition($this->x, $this->y, $this->z); $this->putBlockPosition($this->x, $this->y, $this->z);
} }

View File

@ -43,13 +43,13 @@ class LabTablePacket extends DataPacket{
/** @var int */ /** @var int */
public $reactionType; public $reactionType;
protected function decodePayload(){ protected function decodePayload() : void{
$this->uselessByte = $this->getByte(); $this->uselessByte = $this->getByte();
$this->getSignedBlockPosition($this->x, $this->y, $this->z); $this->getSignedBlockPosition($this->x, $this->y, $this->z);
$this->reactionType = $this->getByte(); $this->reactionType = $this->getByte();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->uselessByte); $this->putByte($this->uselessByte);
$this->putSignedBlockPosition($this->x, $this->y, $this->z); $this->putSignedBlockPosition($this->x, $this->y, $this->z);
$this->putByte($this->reactionType); $this->putByte($this->reactionType);

View File

@ -118,13 +118,13 @@ class LevelEventPacket extends DataPacket{
/** @var int */ /** @var int */
public $data; public $data;
protected function decodePayload(){ protected function decodePayload() : void{
$this->evid = $this->getVarInt(); $this->evid = $this->getVarInt();
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->data = $this->getVarInt(); $this->data = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->evid); $this->putVarInt($this->evid);
$this->putVector3Nullable($this->position); $this->putVector3Nullable($this->position);
$this->putVarInt($this->data); $this->putVarInt($this->data);

View File

@ -257,7 +257,7 @@ class LevelSoundEventPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $disableRelativeVolume = false; public $disableRelativeVolume = false;
protected function decodePayload(){ protected function decodePayload() : void{
$this->sound = $this->getByte(); $this->sound = $this->getByte();
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->extraData = $this->getVarInt(); $this->extraData = $this->getVarInt();
@ -266,7 +266,7 @@ class LevelSoundEventPacket extends DataPacket{
$this->disableRelativeVolume = $this->getBool(); $this->disableRelativeVolume = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->sound); $this->putByte($this->sound);
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putVarInt($this->extraData); $this->putVarInt($this->extraData);

View File

@ -76,7 +76,7 @@ class LoginPacket extends DataPacket{
return $this->protocol !== null and $this->protocol !== ProtocolInfo::CURRENT_PROTOCOL; return $this->protocol !== null and $this->protocol !== ProtocolInfo::CURRENT_PROTOCOL;
} }
protected function decodePayload(){ protected function decodePayload() : void{
$this->protocol = $this->getInt(); $this->protocol = $this->getInt();
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){ if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
@ -133,7 +133,7 @@ class LoginPacket extends DataPacket{
$this->locale = $this->clientData["LanguageCode"] ?? null; $this->locale = $this->clientData["LanguageCode"] ?? null;
} }
protected function encodePayload(){ protected function encodePayload() : void{
//TODO //TODO
} }

View File

@ -35,11 +35,11 @@ class MapInfoRequestPacket extends DataPacket{
/** @var int */ /** @var int */
public $mapId; public $mapId;
protected function decodePayload(){ protected function decodePayload() : void{
$this->mapId = $this->getEntityUniqueId(); $this->mapId = $this->getEntityUniqueId();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityUniqueId($this->mapId); $this->putEntityUniqueId($this->mapId);
} }

View File

@ -37,14 +37,14 @@ class MobArmorEquipmentPacket extends DataPacket{
/** @var Item[] */ /** @var Item[] */
public $slots = []; public $slots = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
$this->slots[$i] = $this->getSlot(); $this->slots[$i] = $this->getSlot();
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
$this->putSlot($this->slots[$i]); $this->putSlot($this->slots[$i]);

View File

@ -48,7 +48,7 @@ class MobEffectPacket extends DataPacket{
/** @var int */ /** @var int */
public $duration = 0; public $duration = 0;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->eventId = $this->getByte(); $this->eventId = $this->getByte();
$this->effectId = $this->getVarInt(); $this->effectId = $this->getVarInt();
@ -57,7 +57,7 @@ class MobEffectPacket extends DataPacket{
$this->duration = $this->getVarInt(); $this->duration = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->eventId); $this->putByte($this->eventId);
$this->putVarInt($this->effectId); $this->putVarInt($this->effectId);

View File

@ -43,7 +43,7 @@ class MobEquipmentPacket extends DataPacket{
/** @var int */ /** @var int */
public $windowId = 0; public $windowId = 0;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
$this->inventorySlot = $this->getByte(); $this->inventorySlot = $this->getByte();
@ -51,7 +51,7 @@ class MobEquipmentPacket extends DataPacket{
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putByte($this->inventorySlot); $this->putByte($this->inventorySlot);

View File

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

View File

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

View File

@ -47,7 +47,7 @@ class MoveEntityPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $teleported = false; public $teleported = false;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->pitch = $this->getByteRotation(); $this->pitch = $this->getByteRotation();
@ -57,7 +57,7 @@ class MoveEntityPacket extends DataPacket{
$this->teleported = $this->getBool(); $this->teleported = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putByteRotation($this->pitch); $this->putByteRotation($this->pitch);

View File

@ -58,7 +58,7 @@ class MovePlayerPacket extends DataPacket{
/** @var int */ /** @var int */
public $teleportItem = 0; public $teleportItem = 0;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
@ -73,7 +73,7 @@ class MovePlayerPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);

View File

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

View File

@ -27,7 +27,7 @@ class PacketPool{
/** @var \SplFixedArray<DataPacket> */ /** @var \SplFixedArray<DataPacket> */
protected static $pool = null; protected static $pool = null;
public static function init(){ public static function init() : void{
static::$pool = new \SplFixedArray(256); static::$pool = new \SplFixedArray(256);
//Normal packets //Normal packets
@ -148,7 +148,7 @@ class PacketPool{
/** /**
* @param DataPacket $packet * @param DataPacket $packet
*/ */
public static function registerPacket(DataPacket $packet){ public static function registerPacket(DataPacket $packet) : void{
static::$pool[$packet->pid()] = clone $packet; static::$pool[$packet->pid()] = clone $packet;
} }

View File

@ -37,13 +37,13 @@ class PhotoTransferPacket extends DataPacket{
/** @var string */ /** @var string */
public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png) public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
protected function decodePayload(){ protected function decodePayload() : void{
$this->photoName = $this->getString(); $this->photoName = $this->getString();
$this->photoData = $this->getString(); $this->photoData = $this->getString();
$this->bookId = $this->getString(); $this->bookId = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->photoName); $this->putString($this->photoName);
$this->putString($this->photoData); $this->putString($this->photoData);
$this->putString($this->bookId); $this->putString($this->bookId);

View File

@ -45,7 +45,7 @@ class PlaySoundPacket extends DataPacket{
/** @var float */ /** @var float */
public $pitch; public $pitch;
protected function decodePayload(){ protected function decodePayload() : void{
$this->soundName = $this->getString(); $this->soundName = $this->getString();
$this->getBlockPosition($this->x, $this->y, $this->z); $this->getBlockPosition($this->x, $this->y, $this->z);
$this->x /= 8; $this->x /= 8;
@ -55,7 +55,7 @@ class PlaySoundPacket extends DataPacket{
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->soundName); $this->putString($this->soundName);
$this->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8)); $this->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
$this->putLFloat($this->volume); $this->putLFloat($this->volume);

View File

@ -49,7 +49,7 @@ class PlayStatusPacket extends DataPacket{
*/ */
public $protocol; public $protocol;
protected function decodePayload(){ protected function decodePayload() : void{
$this->status = $this->getInt(); $this->status = $this->getInt();
} }
@ -57,7 +57,7 @@ class PlayStatusPacket extends DataPacket{
return true; return true;
} }
protected function encodeHeader(){ protected function encodeHeader() : void{
if($this->protocol < 130){ //MCPE <= 1.1 if($this->protocol < 130){ //MCPE <= 1.1
$this->putByte(static::NETWORK_ID); $this->putByte(static::NETWORK_ID);
}else{ }else{
@ -65,7 +65,7 @@ class PlayStatusPacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putInt($this->status); $this->putInt($this->status);
} }

View File

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

View File

@ -41,13 +41,13 @@ class PlayerHotbarPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $selectHotbarSlot = true; public $selectHotbarSlot = true;
protected function decodePayload(){ protected function decodePayload() : void{
$this->selectedHotbarSlot = $this->getUnsignedVarInt(); $this->selectedHotbarSlot = $this->getUnsignedVarInt();
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
$this->selectHotbarSlot = $this->getBool(); $this->selectHotbarSlot = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt($this->selectedHotbarSlot); $this->putUnsignedVarInt($this->selectedHotbarSlot);
$this->putByte($this->windowId); $this->putByte($this->windowId);
$this->putBool($this->selectHotbarSlot); $this->putBool($this->selectHotbarSlot);

View File

@ -40,14 +40,14 @@ class PlayerInputPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $sneaking; public $sneaking;
protected function decodePayload(){ protected function decodePayload() : void{
$this->motionX = $this->getLFloat(); $this->motionX = $this->getLFloat();
$this->motionY = $this->getLFloat(); $this->motionY = $this->getLFloat();
$this->jumping = $this->getBool(); $this->jumping = $this->getBool();
$this->sneaking = $this->getBool(); $this->sneaking = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putLFloat($this->motionX); $this->putLFloat($this->motionX);
$this->putLFloat($this->motionY); $this->putLFloat($this->motionY);
$this->putBool($this->jumping); $this->putBool($this->jumping);

View File

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

View File

@ -42,7 +42,7 @@ class PlayerSkinPacket extends DataPacket{
public $skin; public $skin;
protected function decodePayload(){ protected function decodePayload() : void{
$this->uuid = $this->getUUID(); $this->uuid = $this->getUUID();
$skinId = $this->getString(); $skinId = $this->getString();
@ -56,7 +56,7 @@ class PlayerSkinPacket extends DataPacket{
$this->skin = new Skin($skinId, $skinData, $capeData, $geometryModel, $geometryData); $this->skin = new Skin($skinId, $skinData, $capeData, $geometryModel, $geometryData);
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUUID($this->uuid); $this->putUUID($this->uuid);
$this->putString($this->skin->getSkinId()); $this->putString($this->skin->getSkinId());

View File

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

View File

@ -34,11 +34,11 @@ class RemoveEntityPacket extends DataPacket{
/** @var int */ /** @var int */
public $entityUniqueId; public $entityUniqueId;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityUniqueId($this->entityUniqueId); $this->putEntityUniqueId($this->entityUniqueId);
} }

View File

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

View File

@ -34,11 +34,11 @@ class RequestChunkRadiusPacket extends DataPacket{
/** @var int */ /** @var int */
public $radius; public $radius;
protected function decodePayload(){ protected function decodePayload() : void{
$this->radius = $this->getVarInt(); $this->radius = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->radius); $this->putVarInt($this->radius);
} }

View File

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

View File

@ -37,12 +37,12 @@ class ResourcePackChunkRequestPacket extends DataPacket{
/** @var int */ /** @var int */
public $chunkIndex; public $chunkIndex;
protected function decodePayload(){ protected function decodePayload() : void{
$this->packId = $this->getString(); $this->packId = $this->getString();
$this->chunkIndex = $this->getLInt(); $this->chunkIndex = $this->getLInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->packId); $this->putString($this->packId);
$this->putLInt($this->chunkIndex); $this->putLInt($this->chunkIndex);
} }

View File

@ -41,7 +41,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
/** @var string[] */ /** @var string[] */
public $packIds = []; public $packIds = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->status = $this->getByte(); $this->status = $this->getByte();
$entryCount = $this->getLShort(); $entryCount = $this->getLShort();
while($entryCount-- > 0){ while($entryCount-- > 0){
@ -49,7 +49,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->status); $this->putByte($this->status);
$this->putLShort(count($this->packIds)); $this->putLShort(count($this->packIds));
foreach($this->packIds as $id){ foreach($this->packIds as $id){

View File

@ -43,7 +43,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
/** @var string */ /** @var string */
public $sha256; public $sha256;
protected function decodePayload(){ protected function decodePayload() : void{
$this->packId = $this->getString(); $this->packId = $this->getString();
$this->maxChunkSize = $this->getLInt(); $this->maxChunkSize = $this->getLInt();
$this->chunkCount = $this->getLInt(); $this->chunkCount = $this->getLInt();
@ -51,7 +51,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
$this->sha256 = $this->getString(); $this->sha256 = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->packId); $this->putString($this->packId);
$this->putLInt($this->maxChunkSize); $this->putLInt($this->maxChunkSize);
$this->putLInt($this->chunkCount); $this->putLInt($this->chunkCount);

View File

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

View File

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

View File

@ -35,11 +35,11 @@ class RespawnPacket extends DataPacket{
/** @var Vector3 */ /** @var Vector3 */
public $position; public $position;
protected function decodePayload(){ protected function decodePayload() : void{
$this->position = $this->getVector3(); $this->position = $this->getVector3();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVector3($this->position); $this->putVector3($this->position);
} }

View File

@ -35,11 +35,11 @@ class RiderJumpPacket extends DataPacket{
/** @var int */ /** @var int */
public $jumpStrength; //percentage public $jumpStrength; //percentage
protected function decodePayload(){ protected function decodePayload() : void{
$this->jumpStrength = $this->getVarInt(); $this->jumpStrength = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->jumpStrength); $this->putVarInt($this->jumpStrength);
} }

View File

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

View File

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

View File

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

View File

@ -34,11 +34,11 @@ class SetCommandsEnabledPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $enabled; public $enabled;
protected function decodePayload(){ protected function decodePayload() : void{
$this->enabled = $this->getBool(); $this->enabled = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putBool($this->enabled); $this->putBool($this->enabled);
} }

View File

@ -33,11 +33,11 @@ class SetDefaultGameTypePacket extends DataPacket{
/** @var int */ /** @var int */
public $gamemode; public $gamemode;
protected function decodePayload(){ protected function decodePayload() : void{
$this->gamemode = $this->getVarInt(); $this->gamemode = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt($this->gamemode); $this->putUnsignedVarInt($this->gamemode);
} }

View File

@ -34,11 +34,11 @@ class SetDifficultyPacket extends DataPacket{
/** @var int */ /** @var int */
public $difficulty; public $difficulty;
protected function decodePayload(){ protected function decodePayload() : void{
$this->difficulty = $this->getUnsignedVarInt(); $this->difficulty = $this->getUnsignedVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putUnsignedVarInt($this->difficulty); $this->putUnsignedVarInt($this->difficulty);
} }

View File

@ -41,7 +41,7 @@ class SetDisplayObjectivePacket extends DataPacket{
/** @var int */ /** @var int */
public $sortOrder; public $sortOrder;
protected function decodePayload(){ protected function decodePayload() : void{
$this->displaySlot = $this->getString(); $this->displaySlot = $this->getString();
$this->objectiveName = $this->getString(); $this->objectiveName = $this->getString();
$this->displayName = $this->getString(); $this->displayName = $this->getString();
@ -49,7 +49,7 @@ class SetDisplayObjectivePacket extends DataPacket{
$this->sortOrder = $this->getVarInt(); $this->sortOrder = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->displaySlot); $this->putString($this->displaySlot);
$this->putString($this->objectiveName); $this->putString($this->objectiveName);
$this->putString($this->displayName); $this->putString($this->displayName);

View File

@ -36,12 +36,12 @@ class SetEntityDataPacket extends DataPacket{
/** @var array */ /** @var array */
public $metadata; public $metadata;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->metadata = $this->getEntityMetadata(); $this->metadata = $this->getEntityMetadata();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putEntityMetadata($this->metadata); $this->putEntityMetadata($this->metadata);
} }

View File

@ -35,11 +35,11 @@ class SetEntityLinkPacket extends DataPacket{
/** @var EntityLink */ /** @var EntityLink */
public $link; public $link;
protected function decodePayload(){ protected function decodePayload() : void{
$this->link = $this->getEntityLink(); $this->link = $this->getEntityLink();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityLink($this->link); $this->putEntityLink($this->link);
} }

View File

@ -37,12 +37,12 @@ class SetEntityMotionPacket extends DataPacket{
/** @var Vector3 */ /** @var Vector3 */
public $motion; public $motion;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->motion = $this->getVector3(); $this->motion = $this->getVector3();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3($this->motion); $this->putVector3($this->motion);
} }

View File

@ -34,11 +34,11 @@ class SetHealthPacket extends DataPacket{
/** @var int */ /** @var int */
public $health; public $health;
protected function decodePayload(){ protected function decodePayload() : void{
$this->health = $this->getVarInt(); $this->health = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->health); $this->putVarInt($this->health);
} }

View File

@ -33,11 +33,11 @@ class SetLastHurtByPacket extends DataPacket{
/** @var int */ /** @var int */
public $entityTypeId; public $entityTypeId;
protected function decodePayload(){ protected function decodePayload() : void{
$this->entityTypeId = $this->getVarInt(); $this->entityTypeId = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->entityTypeId); $this->putVarInt($this->entityTypeId);
} }

View File

@ -34,11 +34,11 @@ class SetPlayerGameTypePacket extends DataPacket{
/** @var int */ /** @var int */
public $gamemode; public $gamemode;
protected function decodePayload(){ protected function decodePayload() : void{
$this->gamemode = $this->getVarInt(); $this->gamemode = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->gamemode); $this->putVarInt($this->gamemode);
} }

View File

@ -39,7 +39,7 @@ class SetScorePacket extends DataPacket{
/** @var ScorePacketEntry[] */ /** @var ScorePacketEntry[] */
public $entries = []; public $entries = [];
protected function decodePayload(){ protected function decodePayload() : void{
$this->type = $this->getByte(); $this->type = $this->getByte();
for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){ for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){
$entry = new ScorePacketEntry(); $entry = new ScorePacketEntry();
@ -49,7 +49,7 @@ class SetScorePacket extends DataPacket{
} }
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putByte($this->type); $this->putByte($this->type);
$this->putUnsignedVarInt(count($this->entries)); $this->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){ foreach($this->entries as $entry){

View File

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

View File

@ -33,11 +33,11 @@ class SetTimePacket extends DataPacket{
/** @var int */ /** @var int */
public $time; public $time;
protected function decodePayload(){ protected function decodePayload() : void{
$this->time = $this->getVarInt(); $this->time = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->time); $this->putVarInt($this->time);
} }

View File

@ -50,7 +50,7 @@ class SetTitlePacket extends DataPacket{
/** @var int */ /** @var int */
public $fadeOutTime = 0; public $fadeOutTime = 0;
protected function decodePayload(){ protected function decodePayload() : void{
$this->type = $this->getVarInt(); $this->type = $this->getVarInt();
$this->text = $this->getString(); $this->text = $this->getString();
$this->fadeInTime = $this->getVarInt(); $this->fadeInTime = $this->getVarInt();
@ -58,7 +58,7 @@ class SetTitlePacket extends DataPacket{
$this->fadeOutTime = $this->getVarInt(); $this->fadeOutTime = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVarInt($this->type); $this->putVarInt($this->type);
$this->putString($this->text); $this->putString($this->text);
$this->putVarInt($this->fadeInTime); $this->putVarInt($this->fadeInTime);

View File

@ -40,12 +40,12 @@ class ShowCreditsPacket extends DataPacket{
/** @var int */ /** @var int */
public $status; public $status;
protected function decodePayload(){ protected function decodePayload() : void{
$this->playerEid = $this->getEntityRuntimeId(); $this->playerEid = $this->getEntityRuntimeId();
$this->status = $this->getVarInt(); $this->status = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->playerEid); $this->putEntityRuntimeId($this->playerEid);
$this->putVarInt($this->status); $this->putVarInt($this->status);
} }

View File

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

View File

@ -35,12 +35,12 @@ class ShowStoreOfferPacket extends DataPacket{
/** @var bool */ /** @var bool */
public $showAll; public $showAll;
protected function decodePayload(){ protected function decodePayload() : void{
$this->offerId = $this->getString(); $this->offerId = $this->getString();
$this->showAll = $this->getBool(); $this->showAll = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putString($this->offerId); $this->putString($this->offerId);
$this->putBool($this->showAll); $this->putBool($this->showAll);
} }

View File

@ -36,11 +36,11 @@ class SimpleEventPacket extends DataPacket{
/** @var int */ /** @var int */
public $eventType; public $eventType;
protected function decodePayload(){ protected function decodePayload() : void{
$this->eventType = $this->getLShort(); $this->eventType = $this->getLShort();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putLShort($this->eventType); $this->putLShort($this->eventType);
} }

View File

@ -37,12 +37,12 @@ class SpawnExperienceOrbPacket extends DataPacket{
/** @var int */ /** @var int */
public $amount; public $amount;
protected function decodePayload(){ protected function decodePayload() : void{
$this->position = $this->getVector3(); $this->position = $this->getVector3();
$this->amount = $this->getVarInt(); $this->amount = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload() : void{
$this->putVector3($this->position); $this->putVector3($this->position);
$this->putVarInt($this->amount); $this->putVarInt($this->amount);
} }

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