mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-21 10:26:38 +00:00
DataPacket: inject buffer via parameter instead of class field (packet & stream separation, step 2)
this is not complete yet, but the final change (having the binarystream actually come from outside) is a little more disruptive, and some extra changes need to be made. This will grant some sanity in the meantime without breaking too much stuff.
This commit is contained in:
parent
a633e415ef
commit
5c2ae0257c
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ActorEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_EVENT_PACKET;
|
||||
@ -97,16 +98,16 @@ class ActorEventPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->event = $this->buf->getByte();
|
||||
$this->data = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->event = $in->getByte();
|
||||
$this->data = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->event);
|
||||
$this->buf->putVarInt($this->data);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putByte($this->event);
|
||||
$out->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ActorFallPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_FALL_PACKET;
|
||||
@ -37,16 +38,16 @@ class ActorFallPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var bool */
|
||||
public $isInVoid;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->fallDistance = $this->buf->getLFloat();
|
||||
$this->isInVoid = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->fallDistance = $in->getLFloat();
|
||||
$this->isInVoid = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putLFloat($this->fallDistance);
|
||||
$this->buf->putBool($this->isInVoid);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putLFloat($this->fallDistance);
|
||||
$out->putBool($this->isInVoid);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_PICK_REQUEST_PACKET;
|
||||
@ -35,14 +36,14 @@ class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->buf->getLLong();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityUniqueId = $in->getLLong();
|
||||
$this->hotbarSlot = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLLong($this->entityUniqueId);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLLong($this->entityUniqueId);
|
||||
$out->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function array_search;
|
||||
use function count;
|
||||
|
||||
@ -173,25 +174,25 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var EntityLink[] */
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->buf->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $in->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
if($this->type === false){
|
||||
throw new BadPacketException("Can't map ID $t to legacy ID");
|
||||
}
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->position = $in->getVector3();
|
||||
$this->motion = $in->getVector3();
|
||||
$this->pitch = $in->getLFloat();
|
||||
$this->yaw = $in->getLFloat();
|
||||
$this->headYaw = $in->getLFloat();
|
||||
|
||||
$attrCount = $this->buf->getUnsignedVarInt();
|
||||
$attrCount = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$id = $this->buf->getString();
|
||||
$min = $this->buf->getLFloat();
|
||||
$current = $this->buf->getLFloat();
|
||||
$max = $this->buf->getLFloat();
|
||||
$id = $in->getString();
|
||||
$min = $in->getLFloat();
|
||||
$current = $in->getLFloat();
|
||||
$max = $in->getLFloat();
|
||||
$attr = Attribute::get($id);
|
||||
|
||||
if($attr !== null){
|
||||
@ -208,38 +209,38 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
$linkCount = $this->buf->getUnsignedVarInt();
|
||||
$this->metadata = $in->getEntityMetadata();
|
||||
$linkCount = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[] = $this->buf->getEntityLink();
|
||||
$this->links[] = $in->getEntityLink();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
|
||||
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
|
||||
}
|
||||
$this->buf->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw);
|
||||
$out->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVector3Nullable($this->motion);
|
||||
$out->putLFloat($this->pitch);
|
||||
$out->putLFloat($this->yaw);
|
||||
$out->putLFloat($this->headYaw);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->attributes));
|
||||
$out->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->buf->putString($attribute->getId());
|
||||
$this->buf->putLFloat($attribute->getMinValue());
|
||||
$this->buf->putLFloat($attribute->getValue());
|
||||
$this->buf->putLFloat($attribute->getMaxValue());
|
||||
$out->putString($attribute->getId());
|
||||
$out->putLFloat($attribute->getMinValue());
|
||||
$out->putLFloat($attribute->getValue());
|
||||
$out->putLFloat($attribute->getMaxValue());
|
||||
}
|
||||
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
$this->buf->putUnsignedVarInt(count($this->links));
|
||||
$out->putEntityMetadata($this->metadata);
|
||||
$out->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->buf->putEntityLink($link);
|
||||
$out->putEntityLink($link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET;
|
||||
@ -33,12 +34,12 @@ class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $behaviorTreeJson;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->behaviorTreeJson = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->behaviorTreeJson = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->behaviorTreeJson);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->behaviorTreeJson);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AddEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||
@ -43,12 +44,12 @@ class AddEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->uvarint1;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->uvarint1 = $in->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->uvarint1);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AddItemActorPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET;
|
||||
@ -51,24 +52,24 @@ class AddItemActorPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var bool */
|
||||
public $isFromFishing = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
$this->isFromFishing = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->item = $in->getSlot();
|
||||
$this->position = $in->getVector3();
|
||||
$this->motion = $in->getVector3();
|
||||
$this->metadata = $in->getEntityMetadata();
|
||||
$this->isFromFishing = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
$this->buf->putBool($this->isFromFishing);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putSlot($this->item);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVector3Nullable($this->motion);
|
||||
$out->putEntityMetadata($this->metadata);
|
||||
$out->putBool($this->isFromFishing);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AddPaintingPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
||||
@ -42,20 +43,20 @@ class AddPaintingPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $title;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->direction = $this->buf->getVarInt();
|
||||
$this->title = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->position = $in->getVector3();
|
||||
$this->direction = $in->getVarInt();
|
||||
$this->title = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->direction);
|
||||
$this->buf->putString($this->title);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVarInt($this->direction);
|
||||
$out->putString($this->title);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
|
||||
@ -87,66 +88,66 @@ class AddPlayerPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $buildPlatform = -1;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uuid = $this->buf->getUUID();
|
||||
$this->username = $this->buf->getString();
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->platformChatId = $this->buf->getString();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->uuid = $in->getUUID();
|
||||
$this->username = $in->getString();
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->platformChatId = $in->getString();
|
||||
$this->position = $in->getVector3();
|
||||
$this->motion = $in->getVector3();
|
||||
$this->pitch = $in->getLFloat();
|
||||
$this->yaw = $in->getLFloat();
|
||||
$this->headYaw = $in->getLFloat();
|
||||
$this->item = $in->getSlot();
|
||||
$this->metadata = $in->getEntityMetadata();
|
||||
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint2 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint3 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint4 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint5 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint1 = $in->getUnsignedVarInt();
|
||||
$this->uvarint2 = $in->getUnsignedVarInt();
|
||||
$this->uvarint3 = $in->getUnsignedVarInt();
|
||||
$this->uvarint4 = $in->getUnsignedVarInt();
|
||||
$this->uvarint5 = $in->getUnsignedVarInt();
|
||||
|
||||
$this->long1 = $this->buf->getLLong();
|
||||
$this->long1 = $in->getLLong();
|
||||
|
||||
$linkCount = $this->buf->getUnsignedVarInt();
|
||||
$linkCount = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[$i] = $this->buf->getEntityLink();
|
||||
$this->links[$i] = $in->getEntityLink();
|
||||
}
|
||||
|
||||
$this->deviceId = $this->buf->getString();
|
||||
$this->buildPlatform = $this->buf->getLInt();
|
||||
$this->deviceId = $in->getString();
|
||||
$this->buildPlatform = $in->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUUID($this->uuid);
|
||||
$this->buf->putString($this->username);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putString($this->platformChatId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUUID($this->uuid);
|
||||
$out->putString($this->username);
|
||||
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putString($this->platformChatId);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVector3Nullable($this->motion);
|
||||
$out->putLFloat($this->pitch);
|
||||
$out->putLFloat($this->yaw);
|
||||
$out->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$out->putSlot($this->item);
|
||||
$out->putEntityMetadata($this->metadata);
|
||||
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint2);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint3);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint4);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint5);
|
||||
$out->putUnsignedVarInt($this->uvarint1);
|
||||
$out->putUnsignedVarInt($this->uvarint2);
|
||||
$out->putUnsignedVarInt($this->uvarint3);
|
||||
$out->putUnsignedVarInt($this->uvarint4);
|
||||
$out->putUnsignedVarInt($this->uvarint5);
|
||||
|
||||
$this->buf->putLLong($this->long1);
|
||||
$out->putLLong($this->long1);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->links));
|
||||
$out->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->buf->putEntityLink($link);
|
||||
$out->putEntityLink($link);
|
||||
}
|
||||
|
||||
$this->buf->putString($this->deviceId);
|
||||
$this->buf->putLInt($this->buildPlatform);
|
||||
$out->putString($this->deviceId);
|
||||
$out->putLInt($this->buildPlatform);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
|
||||
@ -75,22 +76,22 @@ class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, S
|
||||
/** @var int */
|
||||
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->flags = $this->buf->getUnsignedVarInt();
|
||||
$this->commandPermission = $this->buf->getUnsignedVarInt();
|
||||
$this->flags2 = $this->buf->getUnsignedVarInt();
|
||||
$this->playerPermission = $this->buf->getUnsignedVarInt();
|
||||
$this->customFlags = $this->buf->getUnsignedVarInt();
|
||||
$this->entityUniqueId = $this->buf->getLLong();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->flags = $in->getUnsignedVarInt();
|
||||
$this->commandPermission = $in->getUnsignedVarInt();
|
||||
$this->flags2 = $in->getUnsignedVarInt();
|
||||
$this->playerPermission = $in->getUnsignedVarInt();
|
||||
$this->customFlags = $in->getUnsignedVarInt();
|
||||
$this->entityUniqueId = $in->getLLong();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->flags);
|
||||
$this->buf->putUnsignedVarInt($this->commandPermission);
|
||||
$this->buf->putUnsignedVarInt($this->flags2);
|
||||
$this->buf->putUnsignedVarInt($this->playerPermission);
|
||||
$this->buf->putUnsignedVarInt($this->customFlags);
|
||||
$this->buf->putLLong($this->entityUniqueId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->flags);
|
||||
$out->putUnsignedVarInt($this->commandPermission);
|
||||
$out->putUnsignedVarInt($this->flags2);
|
||||
$out->putUnsignedVarInt($this->playerPermission);
|
||||
$out->putUnsignedVarInt($this->customFlags);
|
||||
$out->putLLong($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function getFlag(int $flag) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AnimatePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET;
|
||||
@ -57,19 +58,19 @@ class AnimatePacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->buf->getVarInt();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->action = $in->getVarInt();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->float = $this->buf->getLFloat();
|
||||
$this->float = $in->getLFloat();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->action);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->action);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->buf->putLFloat($this->float);
|
||||
$out->putLFloat($this->float);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AnvilDamagePacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET;
|
||||
@ -62,14 +63,14 @@ class AnvilDamagePacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->z;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->damageAmount = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->damageAmount = $in->getByte();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->damageAmount);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->damageAmount);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class AutomationClientConnectPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::AUTOMATION_CLIENT_CONNECT_PACKET;
|
||||
@ -33,12 +34,12 @@ class AutomationClientConnectPacket extends DataPacket implements ClientboundPac
|
||||
/** @var string */
|
||||
public $serverUri;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->serverUri = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->serverUri = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->serverUri);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->serverUri);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function base64_decode;
|
||||
use function file_get_contents;
|
||||
|
||||
@ -38,12 +39,12 @@ class AvailableActorIdentifiersPacket extends DataPacket implements ClientboundP
|
||||
/** @var string */
|
||||
public $namedtag;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->namedtag = $in->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->put(
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->put(
|
||||
$this->namedtag ??
|
||||
self::$DEFAULT_NBT_CACHE ??
|
||||
(self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/entity_identifiers.nbt'))
|
||||
|
@ -31,6 +31,7 @@ use pocketmine\network\mcpe\protocol\types\command\CommandData;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandEnumConstraint;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandParameter;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
use function array_search;
|
||||
use function count;
|
||||
@ -111,38 +112,38 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
public $enumConstraints = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
/** @var string[] $enumValues */
|
||||
$enumValues = [];
|
||||
for($i = 0, $enumValuesCount = $this->buf->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
|
||||
$enumValues[] = $this->buf->getString();
|
||||
for($i = 0, $enumValuesCount = $in->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
|
||||
$enumValues[] = $in->getString();
|
||||
}
|
||||
|
||||
/** @var string[] $postfixes */
|
||||
$postfixes = [];
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$postfixes[] = $this->buf->getString();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$postfixes[] = $in->getString();
|
||||
}
|
||||
|
||||
/** @var CommandEnum[] $enums */
|
||||
$enums = [];
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$enums[] = $enum = $this->getEnum($enumValues);
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$enums[] = $enum = $this->getEnum($enumValues, $in);
|
||||
if(isset(self::HARDCODED_ENUM_NAMES[$enum->getName()])){
|
||||
$this->hardcodedEnums[] = $enum;
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->commandData[] = $this->getCommandData($enums, $postfixes);
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->commandData[] = $this->getCommandData($enums, $postfixes, $in);
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->softEnums[] = $this->getSoftEnum();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->softEnums[] = $this->getSoftEnum($in);
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues);
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues, $in);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,14 +153,14 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BadPacketException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnum(array $enumValueList) : CommandEnum{
|
||||
$enumName = $this->buf->getString();
|
||||
protected function getEnum(array $enumValueList, NetworkBinaryStream $in) : CommandEnum{
|
||||
$enumName = $in->getString();
|
||||
$enumValues = [];
|
||||
|
||||
$listSize = count($enumValueList);
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$index = $this->getEnumValueIndex($listSize);
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$index = $this->getEnumValueIndex($listSize, $in);
|
||||
if(!isset($enumValueList[$index])){
|
||||
throw new BadPacketException("Invalid enum value index $index");
|
||||
}
|
||||
@ -173,13 +174,13 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getSoftEnum() : CommandEnum{
|
||||
$enumName = $this->buf->getString();
|
||||
protected function getSoftEnum(NetworkBinaryStream $in) : CommandEnum{
|
||||
$enumName = $in->getString();
|
||||
$enumValues = [];
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
//Get the enum value from the initial pile of mess
|
||||
$enumValues[] = $this->buf->getString();
|
||||
$enumValues[] = $in->getString();
|
||||
}
|
||||
|
||||
return new CommandEnum($enumName, $enumValues);
|
||||
@ -188,51 +189,51 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
/**
|
||||
* @param int[] $enumValueMap
|
||||
*/
|
||||
protected function putEnum(CommandEnum $enum, array $enumValueMap) : void{
|
||||
$this->buf->putString($enum->getName());
|
||||
protected function putEnum(CommandEnum $enum, array $enumValueMap, NetworkBinaryStream $out) : void{
|
||||
$out->putString($enum->getName());
|
||||
|
||||
$values = $enum->getValues();
|
||||
$this->buf->putUnsignedVarInt(count($values));
|
||||
$out->putUnsignedVarInt(count($values));
|
||||
$listSize = count($enumValueMap);
|
||||
foreach($values as $value){
|
||||
$index = $enumValueMap[$value] ?? -1;
|
||||
if($index === -1){
|
||||
throw new \InvalidStateException("Enum value '$value' not found");
|
||||
}
|
||||
$this->putEnumValueIndex($index, $listSize);
|
||||
$this->putEnumValueIndex($index, $listSize, $out);
|
||||
}
|
||||
}
|
||||
|
||||
protected function putSoftEnum(CommandEnum $enum) : void{
|
||||
$this->buf->putString($enum->getName());
|
||||
protected function putSoftEnum(CommandEnum $enum, NetworkBinaryStream $out) : void{
|
||||
$out->putString($enum->getName());
|
||||
|
||||
$values = $enum->getValues();
|
||||
$this->buf->putUnsignedVarInt(count($values));
|
||||
$out->putUnsignedVarInt(count($values));
|
||||
foreach($values as $value){
|
||||
$this->buf->putString($value);
|
||||
$out->putString($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnumValueIndex(int $valueCount) : int{
|
||||
protected function getEnumValueIndex(int $valueCount, NetworkBinaryStream $in) : int{
|
||||
if($valueCount < 256){
|
||||
return $this->buf->getByte();
|
||||
return $in->getByte();
|
||||
}elseif($valueCount < 65536){
|
||||
return $this->buf->getLShort();
|
||||
return $in->getLShort();
|
||||
}else{
|
||||
return $this->buf->getLInt();
|
||||
return $in->getLInt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function putEnumValueIndex(int $index, int $valueCount) : void{
|
||||
protected function putEnumValueIndex(int $index, int $valueCount, NetworkBinaryStream $out) : void{
|
||||
if($valueCount < 256){
|
||||
$this->buf->putByte($index);
|
||||
$out->putByte($index);
|
||||
}elseif($valueCount < 65536){
|
||||
$this->buf->putLShort($index);
|
||||
$out->putLShort($index);
|
||||
}else{
|
||||
$this->buf->putLInt($index);
|
||||
$out->putLInt($index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,13 +244,13 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BadPacketException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnumConstraint(array $enums, array $enumValues) : CommandEnumConstraint{
|
||||
protected function getEnumConstraint(array $enums, array $enumValues, NetworkBinaryStream $in) : CommandEnumConstraint{
|
||||
//wtf, what was wrong with an offset inside the enum? :(
|
||||
$valueIndex = $this->buf->getLInt();
|
||||
$valueIndex = $in->getLInt();
|
||||
if(!isset($enumValues[$valueIndex])){
|
||||
throw new BadPacketException("Enum constraint refers to unknown enum value index $valueIndex");
|
||||
}
|
||||
$enumIndex = $this->buf->getLInt();
|
||||
$enumIndex = $in->getLInt();
|
||||
if(!isset($enums[$enumIndex])){
|
||||
throw new BadPacketException("Enum constraint refers to unknown enum index $enumIndex");
|
||||
}
|
||||
@ -260,8 +261,8 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
$constraintIds = [];
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$constraintIds[] = $this->buf->getByte();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$constraintIds[] = $in->getByte();
|
||||
}
|
||||
|
||||
return new CommandEnumConstraint($enum, $valueOffset, $constraintIds);
|
||||
@ -271,12 +272,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $enumIndexes string enum name -> int index
|
||||
* @param int[] $enumValueIndexes string value -> int index
|
||||
*/
|
||||
protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes) : void{
|
||||
$this->buf->putLInt($enumValueIndexes[$constraint->getAffectedValue()]);
|
||||
$this->buf->putLInt($enumIndexes[$constraint->getEnum()->getName()]);
|
||||
$this->buf->putUnsignedVarInt(count($constraint->getConstraints()));
|
||||
protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes, NetworkBinaryStream $out) : void{
|
||||
$out->putLInt($enumValueIndexes[$constraint->getAffectedValue()]);
|
||||
$out->putLInt($enumIndexes[$constraint->getEnum()->getName()]);
|
||||
$out->putUnsignedVarInt(count($constraint->getConstraints()));
|
||||
foreach($constraint->getConstraints() as $v){
|
||||
$this->buf->putByte($v);
|
||||
$out->putByte($v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,22 +288,22 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BadPacketException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getCommandData(array $enums, array $postfixes) : CommandData{
|
||||
$name = $this->buf->getString();
|
||||
$description = $this->buf->getString();
|
||||
$flags = $this->buf->getByte();
|
||||
$permission = $this->buf->getByte();
|
||||
$aliases = $enums[$this->buf->getLInt()] ?? null;
|
||||
protected function getCommandData(array $enums, array $postfixes, NetworkBinaryStream $in) : CommandData{
|
||||
$name = $in->getString();
|
||||
$description = $in->getString();
|
||||
$flags = $in->getByte();
|
||||
$permission = $in->getByte();
|
||||
$aliases = $enums[$in->getLInt()] ?? null;
|
||||
$overloads = [];
|
||||
|
||||
for($overloadIndex = 0, $overloadCount = $this->buf->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||
for($overloadIndex = 0, $overloadCount = $in->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||
$overloads[$overloadIndex] = [];
|
||||
for($paramIndex = 0, $paramCount = $this->buf->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||
for($paramIndex = 0, $paramCount = $in->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||
$parameter = new CommandParameter();
|
||||
$parameter->paramName = $this->buf->getString();
|
||||
$parameter->paramType = $this->buf->getLInt();
|
||||
$parameter->isOptional = $this->buf->getBool();
|
||||
$parameter->flags = $this->buf->getByte();
|
||||
$parameter->paramName = $in->getString();
|
||||
$parameter->paramType = $in->getLInt();
|
||||
$parameter->isOptional = $in->getBool();
|
||||
$parameter->flags = $in->getByte();
|
||||
|
||||
if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
@ -331,24 +332,24 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $enumIndexes string enum name -> int index
|
||||
* @param int[] $postfixIndexes
|
||||
*/
|
||||
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes) : void{
|
||||
$this->buf->putString($data->name);
|
||||
$this->buf->putString($data->description);
|
||||
$this->buf->putByte($data->flags);
|
||||
$this->buf->putByte($data->permission);
|
||||
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes, NetworkBinaryStream $out) : void{
|
||||
$out->putString($data->name);
|
||||
$out->putString($data->description);
|
||||
$out->putByte($data->flags);
|
||||
$out->putByte($data->permission);
|
||||
|
||||
if($data->aliases !== null){
|
||||
$this->buf->putLInt($enumIndexes[$data->aliases->getName()] ?? -1);
|
||||
$out->putLInt($enumIndexes[$data->aliases->getName()] ?? -1);
|
||||
}else{
|
||||
$this->buf->putLInt(-1);
|
||||
$out->putLInt(-1);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($data->overloads));
|
||||
$out->putUnsignedVarInt(count($data->overloads));
|
||||
foreach($data->overloads as $overload){
|
||||
/** @var CommandParameter[] $overload */
|
||||
$this->buf->putUnsignedVarInt(count($overload));
|
||||
$out->putUnsignedVarInt(count($overload));
|
||||
foreach($overload as $parameter){
|
||||
$this->buf->putString($parameter->paramName);
|
||||
$out->putString($parameter->paramName);
|
||||
|
||||
if($parameter->enum !== null){
|
||||
$type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->getName()] ?? -1);
|
||||
@ -362,9 +363,9 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
$type = $parameter->paramType;
|
||||
}
|
||||
|
||||
$this->buf->putLInt($type);
|
||||
$this->buf->putBool($parameter->isOptional);
|
||||
$this->buf->putByte($parameter->flags);
|
||||
$out->putLInt($type);
|
||||
$out->putBool($parameter->isOptional);
|
||||
$out->putByte($parameter->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -412,7 +413,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
return "unknown ($argtype)";
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
/** @var int[] $enumValueIndexes */
|
||||
$enumValueIndexes = [];
|
||||
/** @var int[] $postfixIndexes */
|
||||
@ -452,34 +453,34 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($enumValueIndexes));
|
||||
$out->putUnsignedVarInt(count($enumValueIndexes));
|
||||
foreach($enumValueIndexes as $enumValue => $index){
|
||||
$this->buf->putString((string) $enumValue); //stupid PHP key casting D:
|
||||
$out->putString((string) $enumValue); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($postfixIndexes));
|
||||
$out->putUnsignedVarInt(count($postfixIndexes));
|
||||
foreach($postfixIndexes as $postfix => $index){
|
||||
$this->buf->putString((string) $postfix); //stupid PHP key casting D:
|
||||
$out->putString((string) $postfix); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($enums));
|
||||
$out->putUnsignedVarInt(count($enums));
|
||||
foreach($enums as $enum){
|
||||
$this->putEnum($enum, $enumValueIndexes);
|
||||
$this->putEnum($enum, $enumValueIndexes, $out);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->commandData));
|
||||
$out->putUnsignedVarInt(count($this->commandData));
|
||||
foreach($this->commandData as $data){
|
||||
$this->putCommandData($data, $enumIndexes, $postfixIndexes);
|
||||
$this->putCommandData($data, $enumIndexes, $postfixIndexes, $out);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->softEnums));
|
||||
$out->putUnsignedVarInt(count($this->softEnums));
|
||||
foreach($this->softEnums as $enum){
|
||||
$this->putSoftEnum($enum);
|
||||
$this->putSoftEnum($enum, $out);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->enumConstraints));
|
||||
$out->putUnsignedVarInt(count($this->enumConstraints));
|
||||
foreach($this->enumConstraints as $constraint){
|
||||
$this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes);
|
||||
$this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes, $out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function file_get_contents;
|
||||
|
||||
class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -37,12 +38,12 @@ class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $namedtag;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->namedtag = $in->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->put(
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->put(
|
||||
$this->namedtag ??
|
||||
self::$DEFAULT_NBT_CACHE ??
|
||||
(self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/biome_definitions.nbt'))
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class BlockActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_ACTOR_DATA_PACKET;
|
||||
@ -46,14 +47,14 @@ class BlockActorDataPacket extends DataPacket implements ClientboundPacket, Serv
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $in->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->put($this->namedtag);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->put($this->namedtag);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class BlockEventPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET;
|
||||
@ -52,16 +53,16 @@ class BlockEventPacket extends DataPacket implements ClientboundPacket{
|
||||
return $pk;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->eventType = $this->buf->getVarInt();
|
||||
$this->eventData = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->eventType = $in->getVarInt();
|
||||
$this->eventData = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putVarInt($this->eventType);
|
||||
$this->buf->putVarInt($this->eventData);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putVarInt($this->eventType);
|
||||
$out->putVarInt($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
|
||||
@ -41,16 +42,16 @@ class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->buf->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->addUserData = $this->buf->getBool();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$in->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->addUserData = $in->getBool();
|
||||
$this->hotbarSlot = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->buf->putBool($this->addUserData);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$out->putBool($this->addUserData);
|
||||
$out->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\BadPacketException;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class BookEditPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET;
|
||||
@ -58,56 +59,56 @@ class BookEditPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var string */
|
||||
public $xuid;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->type = $this->buf->getByte();
|
||||
$this->inventorySlot = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->type = $in->getByte();
|
||||
$this->inventorySlot = $in->getByte();
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_REPLACE_PAGE:
|
||||
case self::TYPE_ADD_PAGE:
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
$this->text = $this->buf->getString();
|
||||
$this->photoName = $this->buf->getString();
|
||||
$this->pageNumber = $in->getByte();
|
||||
$this->text = $in->getString();
|
||||
$this->photoName = $in->getString();
|
||||
break;
|
||||
case self::TYPE_DELETE_PAGE:
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
$this->pageNumber = $in->getByte();
|
||||
break;
|
||||
case self::TYPE_SWAP_PAGES:
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
$this->secondaryPageNumber = $this->buf->getByte();
|
||||
$this->pageNumber = $in->getByte();
|
||||
$this->secondaryPageNumber = $in->getByte();
|
||||
break;
|
||||
case self::TYPE_SIGN_BOOK:
|
||||
$this->title = $this->buf->getString();
|
||||
$this->author = $this->buf->getString();
|
||||
$this->xuid = $this->buf->getString();
|
||||
$this->title = $in->getString();
|
||||
$this->author = $in->getString();
|
||||
$this->xuid = $in->getString();
|
||||
break;
|
||||
default:
|
||||
throw new BadPacketException("Unknown book edit type $this->type!");
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putByte($this->inventorySlot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->type);
|
||||
$out->putByte($this->inventorySlot);
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_REPLACE_PAGE:
|
||||
case self::TYPE_ADD_PAGE:
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
$this->buf->putString($this->text);
|
||||
$this->buf->putString($this->photoName);
|
||||
$out->putByte($this->pageNumber);
|
||||
$out->putString($this->text);
|
||||
$out->putString($this->photoName);
|
||||
break;
|
||||
case self::TYPE_DELETE_PAGE:
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
$out->putByte($this->pageNumber);
|
||||
break;
|
||||
case self::TYPE_SWAP_PAGES:
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
$this->buf->putByte($this->secondaryPageNumber);
|
||||
$out->putByte($this->pageNumber);
|
||||
$out->putByte($this->secondaryPageNumber);
|
||||
break;
|
||||
case self::TYPE_SIGN_BOOK:
|
||||
$this->buf->putString($this->title);
|
||||
$this->buf->putString($this->author);
|
||||
$this->buf->putString($this->xuid);
|
||||
$out->putString($this->title);
|
||||
$out->putString($this->author);
|
||||
$out->putString($this->xuid);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException("Unknown book edit type $this->type!");
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class BossEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET;
|
||||
@ -118,60 +119,60 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->bossEid = $this->buf->getEntityUniqueId();
|
||||
$this->eventType = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->bossEid = $in->getEntityUniqueId();
|
||||
$this->eventType = $in->getUnsignedVarInt();
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->playerEid = $this->buf->getEntityUniqueId();
|
||||
$this->playerEid = $in->getEntityUniqueId();
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_SHOW:
|
||||
$this->title = $this->buf->getString();
|
||||
$this->healthPercent = $this->buf->getLFloat();
|
||||
$this->title = $in->getString();
|
||||
$this->healthPercent = $in->getLFloat();
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->unknownShort = $this->buf->getLShort();
|
||||
$this->unknownShort = $in->getLShort();
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->color = $this->buf->getUnsignedVarInt();
|
||||
$this->overlay = $this->buf->getUnsignedVarInt();
|
||||
$this->color = $in->getUnsignedVarInt();
|
||||
$this->overlay = $in->getUnsignedVarInt();
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->healthPercent = $this->buf->getLFloat();
|
||||
$this->healthPercent = $in->getLFloat();
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->title = $this->buf->getString();
|
||||
$this->title = $in->getString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->bossEid);
|
||||
$this->buf->putUnsignedVarInt($this->eventType);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->bossEid);
|
||||
$out->putUnsignedVarInt($this->eventType);
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->buf->putEntityUniqueId($this->playerEid);
|
||||
$out->putEntityUniqueId($this->playerEid);
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_SHOW:
|
||||
$this->buf->putString($this->title);
|
||||
$this->buf->putLFloat($this->healthPercent);
|
||||
$out->putString($this->title);
|
||||
$out->putLFloat($this->healthPercent);
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->buf->putLShort($this->unknownShort);
|
||||
$out->putLShort($this->unknownShort);
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->buf->putUnsignedVarInt($this->color);
|
||||
$this->buf->putUnsignedVarInt($this->overlay);
|
||||
$out->putUnsignedVarInt($this->color);
|
||||
$out->putUnsignedVarInt($this->overlay);
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->buf->putLFloat($this->healthPercent);
|
||||
$out->putLFloat($this->healthPercent);
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->buf->putString($this->title);
|
||||
$out->putString($this->title);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class CameraPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CAMERA_PACKET;
|
||||
@ -35,14 +36,14 @@ class CameraPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $playerUniqueId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->cameraUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->playerUniqueId = $this->buf->getEntityUniqueId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->cameraUniqueId = $in->getEntityUniqueId();
|
||||
$this->playerUniqueId = $in->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->cameraUniqueId);
|
||||
$this->buf->putEntityUniqueId($this->playerUniqueId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->cameraUniqueId);
|
||||
$out->putEntityUniqueId($this->playerUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET;
|
||||
@ -38,16 +39,16 @@ class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var bool */
|
||||
public $respawn = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->dimension = $this->buf->getVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->respawn = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->dimension = $in->getVarInt();
|
||||
$this->position = $in->getVector3();
|
||||
$this->respawn = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->dimension);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putBool($this->respawn);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->dimension);
|
||||
$out->putVector3($this->position);
|
||||
$out->putBool($this->respawn);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET;
|
||||
@ -39,12 +40,12 @@ class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->radius = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->radius = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->radius);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacket{
|
||||
@ -65,25 +66,25 @@ class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacke
|
||||
return $this->missHashes;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$hitCount = $this->buf->getUnsignedVarInt();
|
||||
$missCount = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$hitCount = $in->getUnsignedVarInt();
|
||||
$missCount = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $hitCount; ++$i){
|
||||
$this->hitHashes[] = $this->buf->getLLong();
|
||||
$this->hitHashes[] = $in->getLLong();
|
||||
}
|
||||
for($i = 0; $i < $missCount; ++$i){
|
||||
$this->missHashes[] = $this->buf->getLLong();
|
||||
$this->missHashes[] = $in->getLLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt(count($this->hitHashes));
|
||||
$this->buf->putUnsignedVarInt(count($this->missHashes));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt(count($this->hitHashes));
|
||||
$out->putUnsignedVarInt(count($this->missHashes));
|
||||
foreach($this->hitHashes as $hash){
|
||||
$this->buf->putLLong($hash);
|
||||
$out->putLLong($hash);
|
||||
}
|
||||
foreach($this->missHashes as $hash){
|
||||
$this->buf->putLLong($hash);
|
||||
$out->putLLong($hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\ChunkCacheBlob;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPacket{
|
||||
@ -54,19 +55,19 @@ class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPac
|
||||
return $this->blobs;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$hash = $this->buf->getLLong();
|
||||
$payload = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$hash = $in->getLLong();
|
||||
$payload = $in->getString();
|
||||
$this->blobs[] = new ChunkCacheBlob($hash, $payload);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt(count($this->blobs));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt(count($this->blobs));
|
||||
foreach($this->blobs as $blob){
|
||||
$this->buf->putLLong($blob->getHash());
|
||||
$this->buf->putString($blob->getPayload());
|
||||
$out->putLLong($blob->getHash());
|
||||
$out->putString($blob->getPayload());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_STATUS_PACKET;
|
||||
@ -43,12 +44,12 @@ class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->enabled = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->enabled = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBool($this->enabled);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBool($this->enabled);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ClientToServerHandshakePacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET;
|
||||
@ -34,11 +35,11 @@ class ClientToServerHandshakePacket extends DataPacket implements ServerboundPac
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
//No payload
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
//No payload
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\MapDecoration;
|
||||
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\Color;
|
||||
use function count;
|
||||
#ifndef COMPILE
|
||||
@ -72,69 +73,69 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
/** @var Color[][] */
|
||||
public $colors = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mapId = $this->buf->getEntityUniqueId();
|
||||
$this->type = $this->buf->getUnsignedVarInt();
|
||||
$this->dimensionId = $this->buf->getByte();
|
||||
$this->isLocked = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->mapId = $in->getEntityUniqueId();
|
||||
$this->type = $in->getUnsignedVarInt();
|
||||
$this->dimensionId = $in->getByte();
|
||||
$this->isLocked = $in->getBool();
|
||||
|
||||
if(($this->type & 0x08) !== 0){
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
$count = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->eids[] = $this->buf->getEntityUniqueId();
|
||||
$this->eids[] = $in->getEntityUniqueId();
|
||||
}
|
||||
}
|
||||
|
||||
if(($this->type & (0x08 | self::BITFLAG_DECORATION_UPDATE | self::BITFLAG_TEXTURE_UPDATE)) !== 0){ //Decoration bitflag or colour bitflag
|
||||
$this->scale = $this->buf->getByte();
|
||||
$this->scale = $in->getByte();
|
||||
}
|
||||
|
||||
if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$object = new MapTrackedObject();
|
||||
$object->type = $this->buf->getLInt();
|
||||
$object->type = $in->getLInt();
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->buf->getBlockPosition($object->x, $object->y, $object->z);
|
||||
$in->getBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$object->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$object->entityUniqueId = $in->getEntityUniqueId();
|
||||
}else{
|
||||
throw new BadPacketException("Unknown map object type $object->type");
|
||||
}
|
||||
$this->trackedEntities[] = $object;
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$icon = $this->buf->getByte();
|
||||
$rotation = $this->buf->getByte();
|
||||
$xOffset = $this->buf->getByte();
|
||||
$yOffset = $this->buf->getByte();
|
||||
$label = $this->buf->getString();
|
||||
$color = Color::fromRGBA(Binary::flipIntEndianness($this->buf->getUnsignedVarInt()));
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$icon = $in->getByte();
|
||||
$rotation = $in->getByte();
|
||||
$xOffset = $in->getByte();
|
||||
$yOffset = $in->getByte();
|
||||
$label = $in->getString();
|
||||
$color = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt()));
|
||||
$this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color);
|
||||
}
|
||||
}
|
||||
|
||||
if(($this->type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
|
||||
$this->width = $this->buf->getVarInt();
|
||||
$this->height = $this->buf->getVarInt();
|
||||
$this->xOffset = $this->buf->getVarInt();
|
||||
$this->yOffset = $this->buf->getVarInt();
|
||||
$this->width = $in->getVarInt();
|
||||
$this->height = $in->getVarInt();
|
||||
$this->xOffset = $in->getVarInt();
|
||||
$this->yOffset = $in->getVarInt();
|
||||
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
$count = $in->getUnsignedVarInt();
|
||||
if($count !== $this->width * $this->height){
|
||||
throw new BadPacketException("Expected colour count of " . ($this->height * $this->width) . " (height $this->height * width $this->width), got $count");
|
||||
}
|
||||
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
$this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($this->buf->getUnsignedVarInt()));
|
||||
$this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->mapId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->mapId);
|
||||
|
||||
$type = 0;
|
||||
if(($eidsCount = count($this->eids)) > 0){
|
||||
@ -147,57 +148,57 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
$type |= self::BITFLAG_TEXTURE_UPDATE;
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt($type);
|
||||
$this->buf->putByte($this->dimensionId);
|
||||
$this->buf->putBool($this->isLocked);
|
||||
$out->putUnsignedVarInt($type);
|
||||
$out->putByte($this->dimensionId);
|
||||
$out->putBool($this->isLocked);
|
||||
|
||||
if(($type & 0x08) !== 0){ //TODO: find out what these are for
|
||||
$this->buf->putUnsignedVarInt($eidsCount);
|
||||
$out->putUnsignedVarInt($eidsCount);
|
||||
foreach($this->eids as $eid){
|
||||
$this->buf->putEntityUniqueId($eid);
|
||||
$out->putEntityUniqueId($eid);
|
||||
}
|
||||
}
|
||||
|
||||
if(($type & (0x08 | self::BITFLAG_TEXTURE_UPDATE | self::BITFLAG_DECORATION_UPDATE)) !== 0){
|
||||
$this->buf->putByte($this->scale);
|
||||
$out->putByte($this->scale);
|
||||
}
|
||||
|
||||
if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
$this->buf->putUnsignedVarInt(count($this->trackedEntities));
|
||||
$out->putUnsignedVarInt(count($this->trackedEntities));
|
||||
foreach($this->trackedEntities as $object){
|
||||
$this->buf->putLInt($object->type);
|
||||
$out->putLInt($object->type);
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->buf->putBlockPosition($object->x, $object->y, $object->z);
|
||||
$out->putBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$this->buf->putEntityUniqueId($object->entityUniqueId);
|
||||
$out->putEntityUniqueId($object->entityUniqueId);
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Unknown map object type $object->type");
|
||||
}
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt($decorationCount);
|
||||
$out->putUnsignedVarInt($decorationCount);
|
||||
foreach($this->decorations as $decoration){
|
||||
$this->buf->putByte($decoration->getIcon());
|
||||
$this->buf->putByte($decoration->getRotation());
|
||||
$this->buf->putByte($decoration->getXOffset());
|
||||
$this->buf->putByte($decoration->getYOffset());
|
||||
$this->buf->putString($decoration->getLabel());
|
||||
$this->buf->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
|
||||
$out->putByte($decoration->getIcon());
|
||||
$out->putByte($decoration->getRotation());
|
||||
$out->putByte($decoration->getXOffset());
|
||||
$out->putByte($decoration->getYOffset());
|
||||
$out->putString($decoration->getLabel());
|
||||
$out->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
|
||||
}
|
||||
}
|
||||
|
||||
if(($type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
|
||||
$this->buf->putVarInt($this->width);
|
||||
$this->buf->putVarInt($this->height);
|
||||
$this->buf->putVarInt($this->xOffset);
|
||||
$this->buf->putVarInt($this->yOffset);
|
||||
$out->putVarInt($this->width);
|
||||
$out->putVarInt($this->height);
|
||||
$out->putVarInt($this->xOffset);
|
||||
$out->putVarInt($this->yOffset);
|
||||
|
||||
$this->buf->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
|
||||
$out->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
|
||||
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
//if mojang had any sense this would just be a regular LE int
|
||||
$this->buf->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA()));
|
||||
$out->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
|
||||
@ -62,47 +63,47 @@ class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var bool */
|
||||
public $executeOnFirstTick;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->isBlock = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->isBlock = $in->getBool();
|
||||
|
||||
if($this->isBlock){
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->commandBlockMode = $this->buf->getUnsignedVarInt();
|
||||
$this->isRedstoneMode = $this->buf->getBool();
|
||||
$this->isConditional = $this->buf->getBool();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->commandBlockMode = $in->getUnsignedVarInt();
|
||||
$this->isRedstoneMode = $in->getBool();
|
||||
$this->isConditional = $in->getBool();
|
||||
}else{
|
||||
//Minecart with command block
|
||||
$this->minecartEid = $this->buf->getEntityRuntimeId();
|
||||
$this->minecartEid = $in->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
$this->command = $this->buf->getString();
|
||||
$this->lastOutput = $this->buf->getString();
|
||||
$this->name = $this->buf->getString();
|
||||
$this->command = $in->getString();
|
||||
$this->lastOutput = $in->getString();
|
||||
$this->name = $in->getString();
|
||||
|
||||
$this->shouldTrackOutput = $this->buf->getBool();
|
||||
$this->tickDelay = $this->buf->getLInt();
|
||||
$this->executeOnFirstTick = $this->buf->getBool();
|
||||
$this->shouldTrackOutput = $in->getBool();
|
||||
$this->tickDelay = $in->getLInt();
|
||||
$this->executeOnFirstTick = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBool($this->isBlock);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBool($this->isBlock);
|
||||
|
||||
if($this->isBlock){
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putUnsignedVarInt($this->commandBlockMode);
|
||||
$this->buf->putBool($this->isRedstoneMode);
|
||||
$this->buf->putBool($this->isConditional);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putUnsignedVarInt($this->commandBlockMode);
|
||||
$out->putBool($this->isRedstoneMode);
|
||||
$out->putBool($this->isConditional);
|
||||
}else{
|
||||
$this->buf->putEntityRuntimeId($this->minecartEid);
|
||||
$out->putEntityRuntimeId($this->minecartEid);
|
||||
}
|
||||
|
||||
$this->buf->putString($this->command);
|
||||
$this->buf->putString($this->lastOutput);
|
||||
$this->buf->putString($this->name);
|
||||
$out->putString($this->command);
|
||||
$out->putString($this->lastOutput);
|
||||
$out->putString($this->name);
|
||||
|
||||
$this->buf->putBool($this->shouldTrackOutput);
|
||||
$this->buf->putLInt($this->tickDelay);
|
||||
$this->buf->putBool($this->executeOnFirstTick);
|
||||
$out->putBool($this->shouldTrackOutput);
|
||||
$out->putLInt($this->tickDelay);
|
||||
$out->putBool($this->executeOnFirstTick);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandOutputMessage;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
use function count;
|
||||
|
||||
@ -45,58 +46,58 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $unknownString;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->originData = $this->buf->getCommandOriginData();
|
||||
$this->outputType = $this->buf->getByte();
|
||||
$this->successCount = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->originData = $in->getCommandOriginData();
|
||||
$this->outputType = $in->getByte();
|
||||
$this->successCount = $in->getUnsignedVarInt();
|
||||
|
||||
for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$this->messages[] = $this->getCommandMessage();
|
||||
for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$this->messages[] = $this->getCommandMessage($in);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
$this->unknownString = $this->buf->getString();
|
||||
$this->unknownString = $in->getString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getCommandMessage() : CommandOutputMessage{
|
||||
protected function getCommandMessage(NetworkBinaryStream $in) : CommandOutputMessage{
|
||||
$message = new CommandOutputMessage();
|
||||
|
||||
$message->isInternal = $this->buf->getBool();
|
||||
$message->messageId = $this->buf->getString();
|
||||
$message->isInternal = $in->getBool();
|
||||
$message->messageId = $in->getString();
|
||||
|
||||
for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$message->parameters[] = $this->buf->getString();
|
||||
for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$message->parameters[] = $in->getString();
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putCommandOriginData($this->originData);
|
||||
$this->buf->putByte($this->outputType);
|
||||
$this->buf->putUnsignedVarInt($this->successCount);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putCommandOriginData($this->originData);
|
||||
$out->putByte($this->outputType);
|
||||
$out->putUnsignedVarInt($this->successCount);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->messages));
|
||||
$out->putUnsignedVarInt(count($this->messages));
|
||||
foreach($this->messages as $message){
|
||||
$this->putCommandMessage($message);
|
||||
$this->putCommandMessage($message, $out);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
$this->buf->putString($this->unknownString);
|
||||
$out->putString($this->unknownString);
|
||||
}
|
||||
}
|
||||
|
||||
protected function putCommandMessage(CommandOutputMessage $message) : void{
|
||||
$this->buf->putBool($message->isInternal);
|
||||
$this->buf->putString($message->messageId);
|
||||
protected function putCommandMessage(CommandOutputMessage $message, NetworkBinaryStream $out) : void{
|
||||
$out->putBool($message->isInternal);
|
||||
$out->putString($message->messageId);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($message->parameters));
|
||||
$out->putUnsignedVarInt(count($message->parameters));
|
||||
foreach($message->parameters as $parameter){
|
||||
$this->buf->putString($parameter);
|
||||
$out->putString($parameter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class CommandRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET;
|
||||
@ -38,16 +39,16 @@ class CommandRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var bool */
|
||||
public $isInternal;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->command = $this->buf->getString();
|
||||
$this->originData = $this->buf->getCommandOriginData();
|
||||
$this->isInternal = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->command = $in->getString();
|
||||
$this->originData = $in->getCommandOriginData();
|
||||
$this->isInternal = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->command);
|
||||
$this->buf->putCommandOriginData($this->originData);
|
||||
$this->buf->putBool($this->isInternal);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->command);
|
||||
$out->putCommandOriginData($this->originData);
|
||||
$out->putBool($this->isInternal);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMPLETED_USING_ITEM_PACKET;
|
||||
@ -52,14 +53,14 @@ class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $action;
|
||||
|
||||
public function decodePayload() : void{
|
||||
$this->itemId = $this->buf->getShort();
|
||||
$this->action = $this->buf->getLInt();
|
||||
public function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->itemId = $in->getShort();
|
||||
$this->action = $in->getLInt();
|
||||
}
|
||||
|
||||
public function encodePayload() : void{
|
||||
$this->buf->putShort($this->itemId);
|
||||
$this->buf->putLInt($this->action);
|
||||
public function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putShort($this->itemId);
|
||||
$out->putLInt($this->action);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ContainerClosePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;
|
||||
@ -39,12 +40,12 @@ class ContainerClosePacket extends DataPacket implements ClientboundPacket, Serv
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->windowId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ContainerOpenPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET;
|
||||
@ -65,18 +66,18 @@ class ContainerOpenPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->type = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getByte();
|
||||
$this->type = $in->getByte();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->windowId);
|
||||
$out->putByte($this->type);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET;
|
||||
@ -55,16 +56,16 @@ class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->property = $this->buf->getVarInt();
|
||||
$this->value = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getByte();
|
||||
$this->property = $in->getVarInt();
|
||||
$this->value = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putVarInt($this->property);
|
||||
$this->buf->putVarInt($this->value);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->windowId);
|
||||
$out->putVarInt($this->property);
|
||||
$out->putVarInt($this->value);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -65,62 +65,62 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var mixed[][] */
|
||||
public $decodedEntries = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->decodedEntries = [];
|
||||
$recipeCount = $this->buf->getUnsignedVarInt();
|
||||
$recipeCount = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $recipeCount; ++$i){
|
||||
$entry = [];
|
||||
$entry["type"] = $recipeType = $this->buf->getVarInt();
|
||||
$entry["type"] = $recipeType = $in->getVarInt();
|
||||
|
||||
switch($recipeType){
|
||||
case self::ENTRY_SHAPELESS:
|
||||
case self::ENTRY_SHULKER_BOX:
|
||||
case self::ENTRY_SHAPELESS_CHEMISTRY:
|
||||
$entry["recipe_id"] = $this->buf->getString();
|
||||
$ingredientCount = $this->buf->getUnsignedVarInt();
|
||||
$entry["recipe_id"] = $in->getString();
|
||||
$ingredientCount = $in->getUnsignedVarInt();
|
||||
/** @var Item */
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $ingredientCount; ++$j){
|
||||
$entry["input"][] = $in = $this->buf->getRecipeIngredient();
|
||||
$entry["input"][] = $in = $in->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system because it isn't always 1
|
||||
}
|
||||
$resultCount = $this->buf->getUnsignedVarInt();
|
||||
$resultCount = $in->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->buf->getSlot();
|
||||
$entry["output"][] = $in->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
$entry["block"] = $this->buf->getString();
|
||||
$entry["priority"] = $this->buf->getVarInt();
|
||||
$entry["uuid"] = $in->getUUID()->toString();
|
||||
$entry["block"] = $in->getString();
|
||||
$entry["priority"] = $in->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_SHAPED:
|
||||
case self::ENTRY_SHAPED_CHEMISTRY:
|
||||
$entry["recipe_id"] = $this->buf->getString();
|
||||
$entry["width"] = $this->buf->getVarInt();
|
||||
$entry["height"] = $this->buf->getVarInt();
|
||||
$entry["recipe_id"] = $in->getString();
|
||||
$entry["width"] = $in->getVarInt();
|
||||
$entry["height"] = $in->getVarInt();
|
||||
$count = $entry["width"] * $entry["height"];
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $count; ++$j){
|
||||
$entry["input"][] = $in = $this->buf->getRecipeIngredient();
|
||||
$entry["input"][] = $in = $in->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system
|
||||
}
|
||||
$resultCount = $this->buf->getUnsignedVarInt();
|
||||
$resultCount = $in->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->buf->getSlot();
|
||||
$entry["output"][] = $in->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
$entry["block"] = $this->buf->getString();
|
||||
$entry["priority"] = $this->buf->getVarInt();
|
||||
$entry["uuid"] = $in->getUUID()->toString();
|
||||
$entry["block"] = $in->getString();
|
||||
$entry["priority"] = $in->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_FURNACE:
|
||||
case self::ENTRY_FURNACE_DATA:
|
||||
$inputId = $this->buf->getVarInt();
|
||||
$inputId = $in->getVarInt();
|
||||
$inputData = -1;
|
||||
if($recipeType === self::ENTRY_FURNACE_DATA){
|
||||
$inputData = $this->buf->getVarInt();
|
||||
$inputData = $in->getVarInt();
|
||||
if($inputData === 0x7fff){
|
||||
$inputData = -1;
|
||||
}
|
||||
@ -130,34 +130,34 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}catch(\InvalidArgumentException $e){
|
||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||
}
|
||||
$entry["output"] = $out = $this->buf->getSlot();
|
||||
$entry["output"] = $out = $in->getSlot();
|
||||
if($out->getMeta() === 0x7fff){
|
||||
$entry["output"] = ItemFactory::get($out->getId(), 0); //TODO HACK: some 1.12 furnace recipe outputs have wildcard damage values
|
||||
}
|
||||
$entry["block"] = $this->buf->getString();
|
||||
$entry["block"] = $in->getString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_MULTI:
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
$entry["uuid"] = $in->getUUID()->toString();
|
||||
break;
|
||||
default:
|
||||
throw new BadPacketException("Unhandled recipe type $recipeType!"); //do not continue attempting to decode
|
||||
}
|
||||
$this->decodedEntries[] = $entry;
|
||||
}
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->buf->getVarInt();
|
||||
$ingredient = $this->buf->getVarInt();
|
||||
$output = $this->buf->getVarInt();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $in->getVarInt();
|
||||
$ingredient = $in->getVarInt();
|
||||
$output = $in->getVarInt();
|
||||
$this->potionTypeRecipes[] = new PotionTypeRecipe($input, $ingredient, $output);
|
||||
}
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->buf->getVarInt();
|
||||
$ingredient = $this->buf->getVarInt();
|
||||
$output = $this->buf->getVarInt();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $in->getVarInt();
|
||||
$ingredient = $in->getVarInt();
|
||||
$output = $in->getVarInt();
|
||||
$this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output);
|
||||
}
|
||||
$this->cleanRecipes = $this->buf->getBool();
|
||||
$this->cleanRecipes = $in->getBool();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,36 +244,36 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt(count($this->entries));
|
||||
|
||||
$writer = new NetworkBinaryStream();
|
||||
$counter = 0;
|
||||
foreach($this->entries as $d){
|
||||
$entryType = self::writeEntry($d, $writer, $counter++);
|
||||
if($entryType >= 0){
|
||||
$this->buf->putVarInt($entryType);
|
||||
$this->buf->put($writer->getBuffer());
|
||||
$out->putVarInt($entryType);
|
||||
$out->put($writer->getBuffer());
|
||||
}else{
|
||||
$this->buf->putVarInt(-1);
|
||||
$out->putVarInt(-1);
|
||||
}
|
||||
|
||||
$writer->reset();
|
||||
}
|
||||
$this->buf->putUnsignedVarInt(count($this->potionTypeRecipes));
|
||||
$out->putUnsignedVarInt(count($this->potionTypeRecipes));
|
||||
foreach($this->potionTypeRecipes as $recipe){
|
||||
$this->buf->putVarInt($recipe->getInputPotionType());
|
||||
$this->buf->putVarInt($recipe->getIngredientItemId());
|
||||
$this->buf->putVarInt($recipe->getOutputPotionType());
|
||||
$out->putVarInt($recipe->getInputPotionType());
|
||||
$out->putVarInt($recipe->getIngredientItemId());
|
||||
$out->putVarInt($recipe->getOutputPotionType());
|
||||
}
|
||||
$this->buf->putUnsignedVarInt(count($this->potionContainerRecipes));
|
||||
$out->putUnsignedVarInt(count($this->potionContainerRecipes));
|
||||
foreach($this->potionContainerRecipes as $recipe){
|
||||
$this->buf->putVarInt($recipe->getInputItemId());
|
||||
$this->buf->putVarInt($recipe->getIngredientItemId());
|
||||
$this->buf->putVarInt($recipe->getOutputItemId());
|
||||
$out->putVarInt($recipe->getInputItemId());
|
||||
$out->putVarInt($recipe->getIngredientItemId());
|
||||
$out->putVarInt($recipe->getOutputItemId());
|
||||
}
|
||||
|
||||
$this->buf->putBool($this->cleanRecipes);
|
||||
$out->putBool($this->cleanRecipes);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
|
||||
@ -44,35 +45,35 @@ class CraftingEventPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var Item[] */
|
||||
public $output = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->type = $this->buf->getVarInt();
|
||||
$this->id = $this->buf->getUUID();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getByte();
|
||||
$this->type = $in->getVarInt();
|
||||
$this->id = $in->getUUID();
|
||||
|
||||
$size = $this->buf->getUnsignedVarInt();
|
||||
$size = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->input[] = $this->buf->getSlot();
|
||||
$this->input[] = $in->getSlot();
|
||||
}
|
||||
|
||||
$size = $this->buf->getUnsignedVarInt();
|
||||
$size = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->output[] = $this->buf->getSlot();
|
||||
$this->output[] = $in->getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putVarInt($this->type);
|
||||
$this->buf->putUUID($this->id);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->windowId);
|
||||
$out->putVarInt($this->type);
|
||||
$out->putUUID($this->id);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->input));
|
||||
$out->putUnsignedVarInt(count($this->input));
|
||||
foreach($this->input as $item){
|
||||
$this->buf->putSlot($item);
|
||||
$out->putSlot($item);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->output));
|
||||
$out->putUnsignedVarInt(count($this->output));
|
||||
foreach($this->output as $item){
|
||||
$this->buf->putSlot($item);
|
||||
$out->putSlot($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ abstract class DataPacket implements Packet{
|
||||
public $recipientSubId = 0;
|
||||
|
||||
/** @var NetworkBinaryStream */
|
||||
protected $buf;
|
||||
private $buf;
|
||||
|
||||
public function __construct(){
|
||||
$this->buf = new NetworkBinaryStream();
|
||||
@ -79,8 +79,8 @@ abstract class DataPacket implements Packet{
|
||||
final public function decode() : void{
|
||||
$this->buf->rewind();
|
||||
try{
|
||||
$this->decodeHeader();
|
||||
$this->decodePayload();
|
||||
$this->decodeHeader($this->buf);
|
||||
$this->decodePayload($this->buf);
|
||||
}catch(BinaryDataException | BadPacketException $e){
|
||||
throw new BadPacketException($this->getName() . ": " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
@ -90,8 +90,8 @@ abstract class DataPacket implements Packet{
|
||||
* @throws BinaryDataException
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
protected function decodeHeader() : void{
|
||||
$header = $this->buf->getUnsignedVarInt();
|
||||
protected function decodeHeader(NetworkBinaryStream $in) : void{
|
||||
$header = $in->getUnsignedVarInt();
|
||||
$pid = $header & self::PID_MASK;
|
||||
if($pid !== static::NETWORK_ID){
|
||||
//TODO: this means a logical error in the code, but how to prevent it from happening?
|
||||
@ -108,16 +108,16 @@ abstract class DataPacket implements Packet{
|
||||
* @throws BadPacketException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
abstract protected function decodePayload() : void;
|
||||
abstract protected function decodePayload(NetworkBinaryStream $in) : void;
|
||||
|
||||
final public function encode() : void{
|
||||
$this->buf->reset();
|
||||
$this->encodeHeader();
|
||||
$this->encodePayload();
|
||||
$this->encodeHeader($this->buf);
|
||||
$this->encodePayload($this->buf);
|
||||
}
|
||||
|
||||
protected function encodeHeader() : void{
|
||||
$this->buf->putUnsignedVarInt(
|
||||
protected function encodeHeader(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt(
|
||||
static::NETWORK_ID |
|
||||
($this->senderSubId << self::SENDER_SUBCLIENT_ID_SHIFT) |
|
||||
($this->recipientSubId << self::RECIPIENT_SUBCLIENT_ID_SHIFT)
|
||||
@ -127,7 +127,7 @@ abstract class DataPacket implements Packet{
|
||||
/**
|
||||
* Encodes the packet body, without the packet ID or other generic header fields.
|
||||
*/
|
||||
abstract protected function encodePayload() : void;
|
||||
abstract protected function encodePayload(NetworkBinaryStream $out) : void;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class DisconnectPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET;
|
||||
@ -52,17 +53,17 @@ class DisconnectPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->hideDisconnectionScreen = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->hideDisconnectionScreen = $in->getBool();
|
||||
if(!$this->hideDisconnectionScreen){
|
||||
$this->message = $this->buf->getString();
|
||||
$this->message = $in->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBool($this->hideDisconnectionScreen);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBool($this->hideDisconnectionScreen);
|
||||
if(!$this->hideDisconnectionScreen){
|
||||
$this->buf->putString($this->message);
|
||||
$out->putString($this->message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class EducationSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET;
|
||||
@ -50,14 +51,14 @@ class EducationSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->hasQuiz;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->codeBuilderDefaultUri = $this->buf->getString();
|
||||
$this->hasQuiz = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->codeBuilderDefaultUri = $in->getString();
|
||||
$this->hasQuiz = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->codeBuilderDefaultUri);
|
||||
$this->buf->putBool($this->hasQuiz);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->codeBuilderDefaultUri);
|
||||
$out->putBool($this->hasQuiz);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET;
|
||||
@ -62,16 +63,16 @@ class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPa
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->emoteId = $this->buf->getString();
|
||||
$this->flags = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->emoteId = $in->getString();
|
||||
$this->flags = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putString($this->emoteId);
|
||||
$this->buf->putByte($this->flags);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putString($this->emoteId);
|
||||
$out->putByte($this->flags);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class EventPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EVENT_PACKET;
|
||||
@ -56,18 +57,18 @@ class EventPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $type;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->playerRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->eventData = $this->buf->getVarInt();
|
||||
$this->type = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->playerRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->eventData = $in->getVarInt();
|
||||
$this->type = $in->getByte();
|
||||
|
||||
//TODO: nice confusing mess
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->playerRuntimeId);
|
||||
$this->buf->putVarInt($this->eventData);
|
||||
$this->buf->putByte($this->type);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->playerRuntimeId);
|
||||
$out->putVarInt($this->eventData);
|
||||
$out->putByte($this->type);
|
||||
|
||||
//TODO: also nice confusing mess
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET;
|
||||
@ -36,12 +37,12 @@ class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
public $gameRules = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->gameRules = $this->buf->getGameRules();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->gameRules = $in->getGameRules();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putGameRules($this->gameRules);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putGameRules($this->gameRules);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET;
|
||||
@ -37,16 +38,16 @@ class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->itemDescription = $this->buf->getString();
|
||||
$this->itemEffects = $this->buf->getString();
|
||||
$this->hotbarSlot = $this->buf->getLInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->itemDescription = $in->getString();
|
||||
$this->itemEffects = $in->getString();
|
||||
$this->hotbarSlot = $in->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->itemDescription);
|
||||
$this->buf->putString($this->itemEffects);
|
||||
$this->buf->putLInt($this->hotbarSlot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->itemDescription);
|
||||
$out->putString($this->itemEffects);
|
||||
$out->putLInt($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class HurtArmorPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
|
||||
@ -33,12 +34,12 @@ class HurtArmorPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $health;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->health = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->health = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->health);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->health);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class InteractPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::INTERACT_PACKET;
|
||||
@ -47,26 +48,26 @@ class InteractPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var float */
|
||||
public $z;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->buf->getByte();
|
||||
$this->target = $this->buf->getEntityRuntimeId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->action = $in->getByte();
|
||||
$this->target = $in->getEntityRuntimeId();
|
||||
|
||||
if($this->action === self::ACTION_MOUSEOVER){
|
||||
//TODO: should this be a vector3?
|
||||
$this->x = $this->buf->getLFloat();
|
||||
$this->y = $this->buf->getLFloat();
|
||||
$this->z = $this->buf->getLFloat();
|
||||
$this->x = $in->getLFloat();
|
||||
$this->y = $in->getLFloat();
|
||||
$this->z = $in->getLFloat();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->action);
|
||||
$this->buf->putEntityRuntimeId($this->target);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->action);
|
||||
$out->putEntityRuntimeId($this->target);
|
||||
|
||||
if($this->action === self::ACTION_MOUSEOVER){
|
||||
$this->buf->putLFloat($this->x);
|
||||
$this->buf->putLFloat($this->y);
|
||||
$this->buf->putLFloat($this->z);
|
||||
$out->putLFloat($this->x);
|
||||
$out->putLFloat($this->y);
|
||||
$out->putLFloat($this->z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class InventoryContentPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -49,19 +50,19 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getUnsignedVarInt();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getUnsignedVarInt();
|
||||
$count = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->items[] = $this->buf->getSlot();
|
||||
$this->items[] = $in->getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->windowId);
|
||||
$this->buf->putUnsignedVarInt(count($this->items));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->windowId);
|
||||
$out->putUnsignedVarInt(count($this->items));
|
||||
foreach($this->items as $item){
|
||||
$this->buf->putSlot($item);
|
||||
$out->putSlot($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class InventorySlotPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;
|
||||
@ -46,16 +47,16 @@ class InventorySlotPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->buf->getUnsignedVarInt();
|
||||
$this->inventorySlot = $this->buf->getUnsignedVarInt();
|
||||
$this->item = $this->buf->getSlot();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->windowId = $in->getUnsignedVarInt();
|
||||
$this->inventorySlot = $in->getUnsignedVarInt();
|
||||
$this->item = $in->getSlot();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->windowId);
|
||||
$this->buf->putUnsignedVarInt($this->inventorySlot);
|
||||
$this->buf->putSlot($this->item);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->windowId);
|
||||
$out->putUnsignedVarInt($this->inventorySlot);
|
||||
$out->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -33,6 +33,7 @@ use pocketmine\network\mcpe\protocol\types\inventory\ReleaseItemTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\TransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
/**
|
||||
* This packet effectively crams multiple packets into one.
|
||||
@ -49,8 +50,8 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket
|
||||
/** @var TransactionData */
|
||||
public $trData;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$transactionType = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$transactionType = $in->getUnsignedVarInt();
|
||||
|
||||
switch($transactionType){
|
||||
case self::TYPE_NORMAL:
|
||||
@ -72,12 +73,12 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket
|
||||
throw new BadPacketException("Unknown transaction type $transactionType");
|
||||
}
|
||||
|
||||
$this->trData->decode($this->buf);
|
||||
$this->trData->decode($in);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->trData->getTypeId());
|
||||
$this->trData->encode($this->buf);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->trData->getTypeId());
|
||||
$this->trData->encode($out);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{
|
||||
|
||||
@ -38,12 +39,12 @@ class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $z;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class LabTablePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET;
|
||||
@ -43,16 +44,16 @@ class LabTablePacket extends DataPacket implements ClientboundPacket, Serverboun
|
||||
/** @var int */
|
||||
public $reactionType;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uselessByte = $this->buf->getByte();
|
||||
$this->buf->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->reactionType = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->uselessByte = $in->getByte();
|
||||
$in->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->reactionType = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->uselessByte);
|
||||
$this->buf->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putByte($this->reactionType);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->uselessByte);
|
||||
$out->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putByte($this->reactionType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LECTERN_UPDATE_PACKET;
|
||||
@ -43,18 +44,18 @@ class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var bool */
|
||||
public $dropBook;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->page = $this->buf->getByte();
|
||||
$this->totalPages = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->dropBook = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->page = $in->getByte();
|
||||
$this->totalPages = $in->getByte();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->dropBook = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->page);
|
||||
$this->buf->putByte($this->totalPages);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putBool($this->dropBook);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->page);
|
||||
$out->putByte($this->totalPages);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putBool($this->dropBook);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class LevelChunkPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -100,31 +101,31 @@ class LevelChunkPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->extraPayload;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->chunkX = $this->buf->getVarInt();
|
||||
$this->chunkZ = $this->buf->getVarInt();
|
||||
$this->subChunkCount = $this->buf->getUnsignedVarInt();
|
||||
$this->cacheEnabled = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->chunkX = $in->getVarInt();
|
||||
$this->chunkZ = $in->getVarInt();
|
||||
$this->subChunkCount = $in->getUnsignedVarInt();
|
||||
$this->cacheEnabled = $in->getBool();
|
||||
if($this->cacheEnabled){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->usedBlobHashes[] = $this->buf->getLLong();
|
||||
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->usedBlobHashes[] = $in->getLLong();
|
||||
}
|
||||
}
|
||||
$this->extraPayload = $this->buf->getString();
|
||||
$this->extraPayload = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->chunkX);
|
||||
$this->buf->putVarInt($this->chunkZ);
|
||||
$this->buf->putUnsignedVarInt($this->subChunkCount);
|
||||
$this->buf->putBool($this->cacheEnabled);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->chunkX);
|
||||
$out->putVarInt($this->chunkZ);
|
||||
$out->putUnsignedVarInt($this->subChunkCount);
|
||||
$out->putBool($this->cacheEnabled);
|
||||
if($this->cacheEnabled){
|
||||
$this->buf->putUnsignedVarInt(count($this->usedBlobHashes));
|
||||
$out->putUnsignedVarInt(count($this->usedBlobHashes));
|
||||
foreach($this->usedBlobHashes as $hash){
|
||||
$this->buf->putLLong($hash);
|
||||
$out->putLLong($hash);
|
||||
}
|
||||
}
|
||||
$this->buf->putString($this->extraPayload);
|
||||
$out->putString($this->extraPayload);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\serializer\NetworkNbtSerializer;
|
||||
|
||||
class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -53,14 +54,14 @@ class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->eventData;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->eventId = $this->buf->getVarInt();
|
||||
$this->eventData = $this->buf->getRemaining();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->eventId = $in->getVarInt();
|
||||
$this->eventData = $in->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->eventId);
|
||||
$this->buf->put($this->eventData);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->eventId);
|
||||
$out->put($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class LevelEventPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_PACKET;
|
||||
@ -133,16 +134,16 @@ class LevelEventPacket extends DataPacket implements ClientboundPacket{
|
||||
return self::create(self::EVENT_ADD_PARTICLE_MASK | $particleId, $data, $pos);
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->evid = $this->buf->getVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->data = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->evid = $in->getVarInt();
|
||||
$this->position = $in->getVector3();
|
||||
$this->data = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->evid);
|
||||
$this->buf->putVector3Nullable($this->position);
|
||||
$this->buf->putVarInt($this->data);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->evid);
|
||||
$out->putVector3Nullable($this->position);
|
||||
$out->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET;
|
||||
@ -335,22 +336,22 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
|
||||
/** @var bool */
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->buf->getUnsignedVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getString();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->sound = $in->getUnsignedVarInt();
|
||||
$this->position = $in->getVector3();
|
||||
$this->extraData = $in->getVarInt();
|
||||
$this->entityType = $in->getString();
|
||||
$this->isBabyMob = $in->getBool();
|
||||
$this->disableRelativeVolume = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putString($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->sound);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVarInt($this->extraData);
|
||||
$out->putString($this->entityType);
|
||||
$out->putBool($this->isBabyMob);
|
||||
$out->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
/**
|
||||
* Useless leftover from a 1.8 refactor, does nothing
|
||||
@ -47,22 +48,22 @@ class LevelSoundEventPacketV1 extends DataPacket{
|
||||
/** @var bool */
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getVarInt();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->sound = $in->getByte();
|
||||
$this->position = $in->getVector3();
|
||||
$this->extraData = $in->getVarInt();
|
||||
$this->entityType = $in->getVarInt();
|
||||
$this->isBabyMob = $in->getBool();
|
||||
$this->disableRelativeVolume = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putVarInt($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->sound);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVarInt($this->extraData);
|
||||
$out->putVarInt($this->entityType);
|
||||
$out->putBool($this->isBabyMob);
|
||||
$out->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
/**
|
||||
* Useless leftover from a 1.9 refactor, does nothing
|
||||
@ -47,22 +48,22 @@ class LevelSoundEventPacketV2 extends DataPacket{
|
||||
/** @var bool */
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getString();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->sound = $in->getByte();
|
||||
$this->position = $in->getVector3();
|
||||
$this->extraData = $in->getVarInt();
|
||||
$this->entityType = $in->getString();
|
||||
$this->isBabyMob = $in->getBool();
|
||||
$this->disableRelativeVolume = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putString($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->sound);
|
||||
$out->putVector3($this->position);
|
||||
$out->putVarInt($this->extraData);
|
||||
$out->putString($this->entityType);
|
||||
$out->putBool($this->isBabyMob);
|
||||
$out->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use Particle\Validator\Validator;
|
||||
use pocketmine\network\BadPacketException;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\Utils;
|
||||
@ -108,9 +109,9 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->protocol = $this->buf->getInt();
|
||||
$this->decodeConnectionRequest();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->protocol = $in->getInt();
|
||||
$this->decodeConnectionRequest($in);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,8 +134,8 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
|
||||
* @throws BadPacketException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function decodeConnectionRequest() : void{
|
||||
$buffer = new BinaryStream($this->buf->getString());
|
||||
protected function decodeConnectionRequest(NetworkBinaryStream $in) : void{
|
||||
$buffer = new BinaryStream($in->getString());
|
||||
|
||||
$chainData = json_decode($buffer->get($buffer->getLInt()), true);
|
||||
if(!is_array($chainData)){
|
||||
@ -219,7 +220,7 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
|
||||
$this->clientData = $clientData;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MAP_CREATE_LOCKED_COPY_PACKET;
|
||||
@ -35,14 +36,14 @@ class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $newMapId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->originalMapId = $this->buf->getEntityUniqueId();
|
||||
$this->newMapId = $this->buf->getEntityUniqueId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->originalMapId = $in->getEntityUniqueId();
|
||||
$this->newMapId = $in->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->originalMapId);
|
||||
$this->buf->putEntityUniqueId($this->newMapId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->originalMapId);
|
||||
$out->putEntityUniqueId($this->newMapId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET;
|
||||
@ -33,12 +34,12 @@ class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $mapId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mapId = $this->buf->getEntityUniqueId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->mapId = $in->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->mapId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->mapId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
|
||||
@ -55,20 +56,20 @@ class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, S
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->head = $this->buf->getSlot();
|
||||
$this->chest = $this->buf->getSlot();
|
||||
$this->legs = $this->buf->getSlot();
|
||||
$this->feet = $this->buf->getSlot();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->head = $in->getSlot();
|
||||
$this->chest = $in->getSlot();
|
||||
$this->legs = $in->getSlot();
|
||||
$this->feet = $in->getSlot();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->head);
|
||||
$this->buf->putSlot($this->chest);
|
||||
$this->buf->putSlot($this->legs);
|
||||
$this->buf->putSlot($this->feet);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putSlot($this->head);
|
||||
$out->putSlot($this->chest);
|
||||
$out->putSlot($this->legs);
|
||||
$out->putSlot($this->feet);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MobEffectPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET;
|
||||
@ -66,22 +67,22 @@ class MobEffectPacket extends DataPacket implements ClientboundPacket{
|
||||
return $pk;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->eventId = $this->buf->getByte();
|
||||
$this->effectId = $this->buf->getVarInt();
|
||||
$this->amplifier = $this->buf->getVarInt();
|
||||
$this->particles = $this->buf->getBool();
|
||||
$this->duration = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->eventId = $in->getByte();
|
||||
$this->effectId = $in->getVarInt();
|
||||
$this->amplifier = $in->getVarInt();
|
||||
$this->particles = $in->getBool();
|
||||
$this->duration = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->eventId);
|
||||
$this->buf->putVarInt($this->effectId);
|
||||
$this->buf->putVarInt($this->amplifier);
|
||||
$this->buf->putBool($this->particles);
|
||||
$this->buf->putVarInt($this->duration);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putByte($this->eventId);
|
||||
$out->putVarInt($this->effectId);
|
||||
$out->putVarInt($this->amplifier);
|
||||
$out->putBool($this->particles);
|
||||
$out->putVarInt($this->duration);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MobEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
|
||||
@ -52,20 +53,20 @@ class MobEquipmentPacket extends DataPacket implements ClientboundPacket, Server
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->inventorySlot = $this->buf->getByte();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->item = $in->getSlot();
|
||||
$this->inventorySlot = $in->getByte();
|
||||
$this->hotbarSlot = $in->getByte();
|
||||
$this->windowId = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putByte($this->inventorySlot);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
$this->buf->putByte($this->windowId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putSlot($this->item);
|
||||
$out->putByte($this->inventorySlot);
|
||||
$out->putByte($this->hotbarSlot);
|
||||
$out->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET;
|
||||
@ -42,14 +43,14 @@ class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->formId = $this->buf->getUnsignedVarInt();
|
||||
$this->formData = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->formId = $in->getUnsignedVarInt();
|
||||
$this->formData = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->formId);
|
||||
$this->buf->putString($this->formData);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->formId);
|
||||
$out->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET;
|
||||
@ -35,14 +36,14 @@ class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var string */
|
||||
public $formData; //json
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->formId = $this->buf->getUnsignedVarInt();
|
||||
$this->formData = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->formId = $in->getUnsignedVarInt();
|
||||
$this->formData = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->formId);
|
||||
$this->buf->putString($this->formData);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->formId);
|
||||
$out->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_ABSOLUTE_PACKET;
|
||||
@ -47,22 +48,22 @@ class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, S
|
||||
/** @var float */
|
||||
public $zRot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->flags = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->xRot = $this->buf->getByteRotation();
|
||||
$this->yRot = $this->buf->getByteRotation();
|
||||
$this->zRot = $this->buf->getByteRotation();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->flags = $in->getByte();
|
||||
$this->position = $in->getVector3();
|
||||
$this->xRot = $in->getByteRotation();
|
||||
$this->yRot = $in->getByteRotation();
|
||||
$this->zRot = $in->getByteRotation();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->flags);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putByteRotation($this->xRot);
|
||||
$this->buf->putByteRotation($this->yRot);
|
||||
$this->buf->putByteRotation($this->zRot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putByte($this->flags);
|
||||
$out->putVector3($this->position);
|
||||
$out->putByteRotation($this->xRot);
|
||||
$out->putByteRotation($this->yRot);
|
||||
$out->putByteRotation($this->zRot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
|
||||
class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -58,9 +59,9 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
private function maybeReadCoord(int $flag) : int{
|
||||
private function maybeReadCoord(int $flag, NetworkBinaryStream $in) : int{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->buf->getVarInt();
|
||||
return $in->getVarInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -68,45 +69,45 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
/**
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
private function maybeReadRotation(int $flag) : float{
|
||||
private function maybeReadRotation(int $flag, NetworkBinaryStream $in) : float{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->buf->getByteRotation();
|
||||
return $in->getByteRotation();
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->flags = $this->buf->getLShort();
|
||||
$this->xDiff = $this->maybeReadCoord(self::FLAG_HAS_X);
|
||||
$this->yDiff = $this->maybeReadCoord(self::FLAG_HAS_Y);
|
||||
$this->zDiff = $this->maybeReadCoord(self::FLAG_HAS_Z);
|
||||
$this->xRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_X);
|
||||
$this->yRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Y);
|
||||
$this->zRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Z);
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->flags = $in->getLShort();
|
||||
$this->xDiff = $this->maybeReadCoord(self::FLAG_HAS_X, $in);
|
||||
$this->yDiff = $this->maybeReadCoord(self::FLAG_HAS_Y, $in);
|
||||
$this->zDiff = $this->maybeReadCoord(self::FLAG_HAS_Z, $in);
|
||||
$this->xRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_X, $in);
|
||||
$this->yRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Y, $in);
|
||||
$this->zRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Z, $in);
|
||||
}
|
||||
|
||||
private function maybeWriteCoord(int $flag, int $val) : void{
|
||||
private function maybeWriteCoord(int $flag, int $val, NetworkBinaryStream $out) : void{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->buf->putVarInt($val);
|
||||
$out->putVarInt($val);
|
||||
}
|
||||
}
|
||||
|
||||
private function maybeWriteRotation(int $flag, float $val) : void{
|
||||
private function maybeWriteRotation(int $flag, float $val, NetworkBinaryStream $out) : void{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->buf->putByteRotation($val);
|
||||
$out->putByteRotation($val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putLShort($this->flags);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_X, $this->xDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zDiff);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_X, $this->xRot);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Y, $this->yRot);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putLShort($this->flags);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_X, $this->xDiff, $out);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yDiff, $out);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zDiff, $out);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_X, $this->xRot, $out);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Y, $this->yRot, $out);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot, $out);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MovePlayerPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET;
|
||||
@ -57,33 +58,33 @@ class MovePlayerPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
/** @var int */
|
||||
public $teleportItem = 0;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->mode = $this->buf->getByte();
|
||||
$this->onGround = $this->buf->getBool();
|
||||
$this->ridingEid = $this->buf->getEntityRuntimeId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->position = $in->getVector3();
|
||||
$this->pitch = $in->getLFloat();
|
||||
$this->yaw = $in->getLFloat();
|
||||
$this->headYaw = $in->getLFloat();
|
||||
$this->mode = $in->getByte();
|
||||
$this->onGround = $in->getBool();
|
||||
$this->ridingEid = $in->getEntityRuntimeId();
|
||||
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
|
||||
$this->teleportCause = $this->buf->getLInt();
|
||||
$this->teleportItem = $this->buf->getLInt();
|
||||
$this->teleportCause = $in->getLInt();
|
||||
$this->teleportItem = $in->getLInt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw); //TODO
|
||||
$this->buf->putByte($this->mode);
|
||||
$this->buf->putBool($this->onGround);
|
||||
$this->buf->putEntityRuntimeId($this->ridingEid);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putVector3($this->position);
|
||||
$out->putLFloat($this->pitch);
|
||||
$out->putLFloat($this->yaw);
|
||||
$out->putLFloat($this->headYaw); //TODO
|
||||
$out->putByte($this->mode);
|
||||
$out->putBool($this->onGround);
|
||||
$out->putEntityRuntimeId($this->ridingEid);
|
||||
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
|
||||
$this->buf->putLInt($this->teleportCause);
|
||||
$this->buf->putLInt($this->teleportItem);
|
||||
$out->putLInt($this->teleportCause);
|
||||
$out->putLInt($this->teleportItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class MultiplayerSettingsPacket extends DataPacket implements ServerboundPacket{ //TODO: this might be clientbound too, but unsure
|
||||
public const NETWORK_ID = ProtocolInfo::MULTIPLAYER_SETTINGS_PACKET;
|
||||
@ -47,12 +48,12 @@ class MultiplayerSettingsPacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->action = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->action);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->action);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class NetworkChunkPublisherUpdatePacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::NETWORK_CHUNK_PUBLISHER_UPDATE_PACKET;
|
||||
@ -48,14 +49,14 @@ class NetworkChunkPublisherUpdatePacket extends DataPacket implements Clientboun
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->buf->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->radius = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$in->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->radius = $in->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putUnsignedVarInt($this->radius);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putUnsignedVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::NETWORK_SETTINGS_PACKET;
|
||||
@ -46,12 +47,12 @@ class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->compressionThreshold;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->compressionThreshold = $this->buf->getLShort();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->compressionThreshold = $in->getLShort();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLShort($this->compressionThreshold);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLShort($this->compressionThreshold);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::NETWORK_STACK_LATENCY_PACKET;
|
||||
@ -35,14 +36,14 @@ class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket,
|
||||
/** @var bool */
|
||||
public $needResponse;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->timestamp = $this->buf->getLLong();
|
||||
$this->needResponse = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->timestamp = $in->getLLong();
|
||||
$this->needResponse = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLLong($this->timestamp);
|
||||
$this->buf->putBool($this->needResponse);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLLong($this->timestamp);
|
||||
$out->putBool($this->needResponse);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class NpcRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET;
|
||||
@ -39,18 +40,18 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $actionType;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->requestType = $this->buf->getByte();
|
||||
$this->commandString = $this->buf->getString();
|
||||
$this->actionType = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->requestType = $in->getByte();
|
||||
$this->commandString = $in->getString();
|
||||
$this->actionType = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->requestType);
|
||||
$this->buf->putString($this->commandString);
|
||||
$this->buf->putByte($this->actionType);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putByte($this->requestType);
|
||||
$out->putString($this->commandString);
|
||||
$out->putByte($this->actionType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ON_SCREEN_TEXTURE_ANIMATION_PACKET;
|
||||
@ -33,12 +34,12 @@ class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPa
|
||||
/** @var int */
|
||||
public $effectId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->effectId = $this->buf->getLInt(); //unsigned
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->effectId = $in->getLInt(); //unsigned
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLInt($this->effectId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLInt($this->effectId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
|
||||
@ -37,16 +38,16 @@ class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->photoName = $this->buf->getString();
|
||||
$this->photoData = $this->buf->getString();
|
||||
$this->bookId = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->photoName = $in->getString();
|
||||
$this->photoData = $in->getString();
|
||||
$this->bookId = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->photoName);
|
||||
$this->buf->putString($this->photoData);
|
||||
$this->buf->putString($this->bookId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->photoName);
|
||||
$out->putString($this->photoData);
|
||||
$out->putString($this->bookId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlaySoundPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
|
||||
@ -43,21 +44,21 @@ class PlaySoundPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var float */
|
||||
public $pitch;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->soundName = $this->buf->getString();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->soundName = $in->getString();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->x /= 8;
|
||||
$this->y /= 8;
|
||||
$this->z /= 8;
|
||||
$this->volume = $this->buf->getLFloat();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->volume = $in->getLFloat();
|
||||
$this->pitch = $in->getLFloat();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->soundName);
|
||||
$this->buf->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
|
||||
$this->buf->putLFloat($this->volume);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->soundName);
|
||||
$out->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
|
||||
$out->putLFloat($this->volume);
|
||||
$out->putLFloat($this->pitch);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlayStatusPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAY_STATUS_PACKET;
|
||||
@ -48,16 +49,16 @@ class PlayStatusPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->status = $this->buf->getInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->status = $in->getInt();
|
||||
}
|
||||
|
||||
public function canBeSentBeforeLogin() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putInt($this->status);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putInt($this->status);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlayerActionPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_ACTION_PACKET;
|
||||
@ -70,18 +71,18 @@ class PlayerActionPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $face;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->action = $this->buf->getVarInt();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->action = $in->getVarInt();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVarInt($this->action);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putVarInt($this->face);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putVarInt($this->action);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putVarInt($this->face);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\InputMode;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayMode;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function assert;
|
||||
|
||||
class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
@ -127,34 +128,34 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->vrGazeDirection;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->moveVecX = $this->buf->getLFloat();
|
||||
$this->moveVecZ = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->inputFlags = $this->buf->getUnsignedVarLong();
|
||||
$this->inputMode = $this->buf->getUnsignedVarInt();
|
||||
$this->playMode = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->yaw = $in->getLFloat();
|
||||
$this->pitch = $in->getLFloat();
|
||||
$this->position = $in->getVector3();
|
||||
$this->moveVecX = $in->getLFloat();
|
||||
$this->moveVecZ = $in->getLFloat();
|
||||
$this->headYaw = $in->getLFloat();
|
||||
$this->inputFlags = $in->getUnsignedVarLong();
|
||||
$this->inputMode = $in->getUnsignedVarInt();
|
||||
$this->playMode = $in->getUnsignedVarInt();
|
||||
if($this->playMode === PlayMode::VR){
|
||||
$this->vrGazeDirection = $this->buf->getVector3();
|
||||
$this->vrGazeDirection = $in->getVector3();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putLFloat($this->moveVecX);
|
||||
$this->buf->putLFloat($this->moveVecZ);
|
||||
$this->buf->putLFloat($this->headYaw);
|
||||
$this->buf->putUnsignedVarLong($this->inputFlags);
|
||||
$this->buf->putUnsignedVarInt($this->inputMode);
|
||||
$this->buf->putUnsignedVarInt($this->playMode);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLFloat($this->yaw);
|
||||
$out->putLFloat($this->pitch);
|
||||
$out->putVector3($this->position);
|
||||
$out->putLFloat($this->moveVecX);
|
||||
$out->putLFloat($this->moveVecZ);
|
||||
$out->putLFloat($this->headYaw);
|
||||
$out->putUnsignedVarLong($this->inputFlags);
|
||||
$out->putUnsignedVarInt($this->inputMode);
|
||||
$out->putUnsignedVarInt($this->playMode);
|
||||
if($this->playMode === PlayMode::VR){
|
||||
assert($this->vrGazeDirection !== null);
|
||||
$this->buf->putVector3($this->vrGazeDirection);
|
||||
$out->putVector3($this->vrGazeDirection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
|
||||
@ -46,16 +47,16 @@ class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, Server
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->selectedHotbarSlot = $this->buf->getUnsignedVarInt();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->selectHotbarSlot = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->selectedHotbarSlot = $in->getUnsignedVarInt();
|
||||
$this->windowId = $in->getByte();
|
||||
$this->selectHotbarSlot = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->selectedHotbarSlot);
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putBool($this->selectHotbarSlot);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->selectedHotbarSlot);
|
||||
$out->putByte($this->windowId);
|
||||
$out->putBool($this->selectHotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlayerInputPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET;
|
||||
@ -39,18 +40,18 @@ class PlayerInputPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var bool */
|
||||
public $sneaking;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->motionX = $this->buf->getLFloat();
|
||||
$this->motionY = $this->buf->getLFloat();
|
||||
$this->jumping = $this->buf->getBool();
|
||||
$this->sneaking = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->motionX = $in->getLFloat();
|
||||
$this->motionY = $in->getLFloat();
|
||||
$this->jumping = $in->getBool();
|
||||
$this->sneaking = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putLFloat($this->motionX);
|
||||
$this->buf->putLFloat($this->motionY);
|
||||
$this->buf->putBool($this->jumping);
|
||||
$this->buf->putBool($this->sneaking);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putLFloat($this->motionX);
|
||||
$out->putLFloat($this->motionY);
|
||||
$out->putBool($this->jumping);
|
||||
$out->putBool($this->sneaking);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class PlayerListPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -60,46 +61,46 @@ class PlayerListPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->type = $this->buf->getByte();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->type = $in->getByte();
|
||||
$count = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$entry = new PlayerListEntry();
|
||||
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$entry->uuid = $this->buf->getUUID();
|
||||
$entry->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$entry->username = $this->buf->getString();
|
||||
$entry->xboxUserId = $this->buf->getString();
|
||||
$entry->platformChatId = $this->buf->getString();
|
||||
$entry->buildPlatform = $this->buf->getLInt();
|
||||
$entry->skinData = $this->buf->getSkin();
|
||||
$entry->isTeacher = $this->buf->getBool();
|
||||
$entry->isHost = $this->buf->getBool();
|
||||
$entry->uuid = $in->getUUID();
|
||||
$entry->entityUniqueId = $in->getEntityUniqueId();
|
||||
$entry->username = $in->getString();
|
||||
$entry->xboxUserId = $in->getString();
|
||||
$entry->platformChatId = $in->getString();
|
||||
$entry->buildPlatform = $in->getLInt();
|
||||
$entry->skinData = $in->getSkin();
|
||||
$entry->isTeacher = $in->getBool();
|
||||
$entry->isHost = $in->getBool();
|
||||
}else{
|
||||
$entry->uuid = $this->buf->getUUID();
|
||||
$entry->uuid = $in->getUUID();
|
||||
}
|
||||
|
||||
$this->entries[$i] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->type);
|
||||
$out->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$this->buf->putUUID($entry->uuid);
|
||||
$this->buf->putEntityUniqueId($entry->entityUniqueId);
|
||||
$this->buf->putString($entry->username);
|
||||
$this->buf->putString($entry->xboxUserId);
|
||||
$this->buf->putString($entry->platformChatId);
|
||||
$this->buf->putLInt($entry->buildPlatform);
|
||||
$this->buf->putSkin($entry->skinData);
|
||||
$this->buf->putBool($entry->isTeacher);
|
||||
$this->buf->putBool($entry->isHost);
|
||||
$out->putUUID($entry->uuid);
|
||||
$out->putEntityUniqueId($entry->entityUniqueId);
|
||||
$out->putString($entry->username);
|
||||
$out->putString($entry->xboxUserId);
|
||||
$out->putString($entry->platformChatId);
|
||||
$out->putLInt($entry->buildPlatform);
|
||||
$out->putSkin($entry->skinData);
|
||||
$out->putBool($entry->isTeacher);
|
||||
$out->putBool($entry->isHost);
|
||||
}else{
|
||||
$this->buf->putUUID($entry->uuid);
|
||||
$out->putUUID($entry->uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinData;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class PlayerSkinPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
@ -41,18 +42,18 @@ class PlayerSkinPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
/** @var SkinData */
|
||||
public $skin;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uuid = $this->buf->getUUID();
|
||||
$this->skin = $this->buf->getSkin();
|
||||
$this->newSkinName = $this->buf->getString();
|
||||
$this->oldSkinName = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->uuid = $in->getUUID();
|
||||
$this->skin = $in->getSkin();
|
||||
$this->newSkinName = $in->getString();
|
||||
$this->oldSkinName = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUUID($this->uuid);
|
||||
$this->buf->putSkin($this->skin);
|
||||
$this->buf->putString($this->newSkinName);
|
||||
$this->buf->putString($this->oldSkinName);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUUID($this->uuid);
|
||||
$out->putSkin($this->skin);
|
||||
$out->putString($this->newSkinName);
|
||||
$out->putString($this->oldSkinName);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{
|
||||
@ -34,17 +35,17 @@ class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var string[] */
|
||||
public $entries = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$count = $in->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->entries[] = $this->buf->getString();
|
||||
$this->entries[] = $in->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
$this->buf->putString($entry);
|
||||
$out->putString($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RemoveActorPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REMOVE_ACTOR_PACKET;
|
||||
@ -39,12 +40,12 @@ class RemoveActorPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RemoveEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET;
|
||||
@ -43,12 +44,12 @@ class RemoveEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
return $this->uvarint1;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->uvarint1 = $in->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putUnsignedVarInt($this->uvarint1);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RemoveObjectivePacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET;
|
||||
@ -33,12 +34,12 @@ class RemoveObjectivePacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $objectiveName;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->objectiveName = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->objectiveName = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->objectiveName);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->objectiveName);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RequestChunkRadiusPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET;
|
||||
@ -33,12 +34,12 @@ class RequestChunkRadiusPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $radius;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->radius = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->radius = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->radius);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function strlen;
|
||||
|
||||
class ResourcePackChunkDataPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -49,18 +50,18 @@ class ResourcePackChunkDataPacket extends DataPacket implements ClientboundPacke
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->chunkIndex = $this->buf->getLInt();
|
||||
$this->progress = $this->buf->getLLong();
|
||||
$this->data = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->packId = $in->getString();
|
||||
$this->chunkIndex = $in->getLInt();
|
||||
$this->progress = $in->getLLong();
|
||||
$this->data = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->chunkIndex);
|
||||
$this->buf->putLLong($this->progress);
|
||||
$this->buf->putString($this->data);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->packId);
|
||||
$out->putLInt($this->chunkIndex);
|
||||
$out->putLLong($this->progress);
|
||||
$out->putString($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ResourcePackChunkRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET;
|
||||
@ -35,14 +36,14 @@ class ResourcePackChunkRequestPacket extends DataPacket implements ServerboundPa
|
||||
/** @var int */
|
||||
public $chunkIndex;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->chunkIndex = $this->buf->getLInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->packId = $in->getString();
|
||||
$this->chunkIndex = $in->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->chunkIndex);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->packId);
|
||||
$out->putLInt($this->chunkIndex);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class ResourcePackClientResponsePacket extends DataPacket implements ServerboundPacket{
|
||||
@ -41,19 +42,19 @@ class ResourcePackClientResponsePacket extends DataPacket implements Serverbound
|
||||
/** @var string[] */
|
||||
public $packIds = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->status = $this->buf->getByte();
|
||||
$entryCount = $this->buf->getLShort();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->status = $in->getByte();
|
||||
$entryCount = $in->getLShort();
|
||||
while($entryCount-- > 0){
|
||||
$this->packIds[] = $this->buf->getString();
|
||||
$this->packIds[] = $in->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putByte($this->status);
|
||||
$this->buf->putLShort(count($this->packIds));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putByte($this->status);
|
||||
$out->putLShort(count($this->packIds));
|
||||
foreach($this->packIds as $id){
|
||||
$this->buf->putString($id);
|
||||
$out->putString($id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackType;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET;
|
||||
@ -56,24 +57,24 @@ class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->maxChunkSize = $this->buf->getLInt();
|
||||
$this->chunkCount = $this->buf->getLInt();
|
||||
$this->compressedPackSize = $this->buf->getLLong();
|
||||
$this->sha256 = $this->buf->getString();
|
||||
$this->isPremium = $this->buf->getBool();
|
||||
$this->packType = $this->buf->getByte();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->packId = $in->getString();
|
||||
$this->maxChunkSize = $in->getLInt();
|
||||
$this->chunkCount = $in->getLInt();
|
||||
$this->compressedPackSize = $in->getLLong();
|
||||
$this->sha256 = $in->getString();
|
||||
$this->isPremium = $in->getBool();
|
||||
$this->packType = $in->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->maxChunkSize);
|
||||
$this->buf->putLInt($this->chunkCount);
|
||||
$this->buf->putLLong($this->compressedPackSize);
|
||||
$this->buf->putString($this->sha256);
|
||||
$this->buf->putBool($this->isPremium);
|
||||
$this->buf->putByte($this->packType);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->packId);
|
||||
$out->putLInt($this->maxChunkSize);
|
||||
$out->putLInt($this->chunkCount);
|
||||
$out->putLLong($this->compressedPackSize);
|
||||
$out->putString($this->sha256);
|
||||
$out->putBool($this->isPremium);
|
||||
$out->putByte($this->packType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackStackEntry;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -60,37 +61,37 @@ class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mustAccept = $this->buf->getBool();
|
||||
$behaviorPackCount = $this->buf->getUnsignedVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->mustAccept = $in->getBool();
|
||||
$behaviorPackCount = $in->getUnsignedVarInt();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$this->behaviorPackStack[] = ResourcePackStackEntry::read($this->buf);
|
||||
$this->behaviorPackStack[] = ResourcePackStackEntry::read($in);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->buf->getUnsignedVarInt();
|
||||
$resourcePackCount = $in->getUnsignedVarInt();
|
||||
while($resourcePackCount-- > 0){
|
||||
$this->resourcePackStack[] = ResourcePackStackEntry::read($this->buf);
|
||||
$this->resourcePackStack[] = ResourcePackStackEntry::read($in);
|
||||
}
|
||||
|
||||
$this->isExperimental = $this->buf->getBool();
|
||||
$this->baseGameVersion = $this->buf->getString();
|
||||
$this->isExperimental = $in->getBool();
|
||||
$this->baseGameVersion = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBool($this->mustAccept);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBool($this->mustAccept);
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
$out->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
foreach($this->behaviorPackStack as $entry){
|
||||
$entry->write($this->buf);
|
||||
$entry->write($out);
|
||||
}
|
||||
|
||||
$this->buf->putUnsignedVarInt(count($this->resourcePackStack));
|
||||
$out->putUnsignedVarInt(count($this->resourcePackStack));
|
||||
foreach($this->resourcePackStack as $entry){
|
||||
$entry->write($this->buf);
|
||||
$entry->write($out);
|
||||
}
|
||||
|
||||
$this->buf->putBool($this->isExperimental);
|
||||
$this->buf->putString($this->baseGameVersion);
|
||||
$out->putBool($this->isExperimental);
|
||||
$out->putString($this->baseGameVersion);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use function count;
|
||||
|
||||
class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
|
||||
@ -56,30 +57,30 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mustAccept = $this->buf->getBool();
|
||||
$this->hasScripts = $this->buf->getBool();
|
||||
$behaviorPackCount = $this->buf->getLShort();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->mustAccept = $in->getBool();
|
||||
$this->hasScripts = $in->getBool();
|
||||
$behaviorPackCount = $in->getLShort();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$this->behaviorPackEntries[] = ResourcePackInfoEntry::read($this->buf);
|
||||
$this->behaviorPackEntries[] = ResourcePackInfoEntry::read($in);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->buf->getLShort();
|
||||
$resourcePackCount = $in->getLShort();
|
||||
while($resourcePackCount-- > 0){
|
||||
$this->resourcePackEntries[] = ResourcePackInfoEntry::read($this->buf);
|
||||
$this->resourcePackEntries[] = ResourcePackInfoEntry::read($in);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putBool($this->mustAccept);
|
||||
$this->buf->putBool($this->hasScripts);
|
||||
$this->buf->putLShort(count($this->behaviorPackEntries));
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putBool($this->mustAccept);
|
||||
$out->putBool($this->hasScripts);
|
||||
$out->putLShort(count($this->behaviorPackEntries));
|
||||
foreach($this->behaviorPackEntries as $entry){
|
||||
$entry->write($this->buf);
|
||||
$entry->write($out);
|
||||
}
|
||||
$this->buf->putLShort(count($this->resourcePackEntries));
|
||||
$out->putLShort(count($this->resourcePackEntries));
|
||||
foreach($this->resourcePackEntries as $entry){
|
||||
$entry->write($this->buf);
|
||||
$entry->write($out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RespawnPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET;
|
||||
@ -50,16 +51,16 @@ class RespawnPacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->respawnState = $this->buf->getByte();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->position = $in->getVector3();
|
||||
$this->respawnState = $in->getByte();
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putByte($this->respawnState);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVector3($this->position);
|
||||
$out->putByte($this->respawnState);
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class RiderJumpPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET;
|
||||
@ -33,12 +34,12 @@ class RiderJumpPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $jumpStrength; //percentage
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->jumpStrength = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->jumpStrength = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->jumpStrength);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->jumpStrength);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have handlers in either client or server in the game as of 1.8
|
||||
public const NETWORK_ID = ProtocolInfo::SCRIPT_CUSTOM_EVENT_PACKET;
|
||||
@ -35,14 +36,14 @@ class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have hand
|
||||
/** @var string json data */
|
||||
public $eventData;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->eventName = $this->buf->getString();
|
||||
$this->eventData = $this->buf->getString();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->eventName = $in->getString();
|
||||
$this->eventData = $in->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putString($this->eventName);
|
||||
$this->buf->putString($this->eventData);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putString($this->eventName);
|
||||
$out->putString($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -26,15 +26,16 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ServerSettingsRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
//No payload
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
//No payload
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user