diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 27ddf11b2f..0925f12493 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -303,7 +303,7 @@ class NetworkSession{ try{ $this->handleDataPacket($pk); }catch(BadPacketException $e){ - $this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBuffer())); + $this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBinaryStream()->getBuffer())); throw new BadPacketException("Error processing " . $pk->getName() . ": " . $e->getMessage(), 0, $e); } } @@ -315,7 +315,7 @@ class NetworkSession{ public function handleDataPacket(Packet $packet) : void{ if(!($packet instanceof ServerboundPacket)){ if($packet instanceof GarbageServerboundPacket){ - $this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getBuffer())); + $this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getBinaryStream()->getBuffer())); return; } throw new BadPacketException("Unexpected non-serverbound packet"); @@ -326,15 +326,16 @@ class NetworkSession{ try{ $packet->decode(); - if(!$packet->feof()){ - $remains = substr($packet->getBuffer(), $packet->getOffset()); + $stream = $packet->getBinaryStream(); + if(!$stream->feof()){ + $remains = substr($stream->getBuffer(), $stream->getOffset()); $this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains)); } $ev = new DataPacketReceiveEvent($this, $packet); $ev->call(); if(!$ev->isCancelled() and !$packet->handle($this->handler)){ - $this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($packet->getBuffer())); + $this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer())); } }finally{ $timings->stopTiming(); diff --git a/src/network/mcpe/PacketBatch.php b/src/network/mcpe/PacketBatch.php index aab0b93190..82f9412f1e 100644 --- a/src/network/mcpe/PacketBatch.php +++ b/src/network/mcpe/PacketBatch.php @@ -32,7 +32,7 @@ class PacketBatch extends NetworkBinaryStream{ public function putPacket(Packet $packet) : void{ $packet->encode(); - $this->putString($packet->getBuffer()); + $this->putString($packet->getBinaryStream()->getBuffer()); } /** diff --git a/src/network/mcpe/protocol/ActorEventPacket.php b/src/network/mcpe/protocol/ActorEventPacket.php index ae459f8cd8..438f7ce83c 100644 --- a/src/network/mcpe/protocol/ActorEventPacket.php +++ b/src/network/mcpe/protocol/ActorEventPacket.php @@ -98,15 +98,15 @@ class ActorEventPacket extends DataPacket implements ClientboundPacket, Serverbo } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->event = $this->getByte(); - $this->data = $this->getVarInt(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->event = $this->buf->getByte(); + $this->data = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putByte($this->event); - $this->putVarInt($this->data); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putByte($this->event); + $this->buf->putVarInt($this->data); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ActorFallPacket.php b/src/network/mcpe/protocol/ActorFallPacket.php index 420940f239..10fd48cc92 100644 --- a/src/network/mcpe/protocol/ActorFallPacket.php +++ b/src/network/mcpe/protocol/ActorFallPacket.php @@ -38,15 +38,15 @@ class ActorFallPacket extends DataPacket implements ServerboundPacket{ public $isInVoid; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->fallDistance = $this->getLFloat(); - $this->isInVoid = $this->getBool(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->fallDistance = $this->buf->getLFloat(); + $this->isInVoid = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putLFloat($this->fallDistance); - $this->putBool($this->isInVoid); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putLFloat($this->fallDistance); + $this->buf->putBool($this->isInVoid); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ActorPickRequestPacket.php b/src/network/mcpe/protocol/ActorPickRequestPacket.php index 6022ea703c..b307e7d518 100644 --- a/src/network/mcpe/protocol/ActorPickRequestPacket.php +++ b/src/network/mcpe/protocol/ActorPickRequestPacket.php @@ -36,13 +36,13 @@ class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{ public $hotbarSlot; protected function decodePayload() : void{ - $this->entityUniqueId = $this->getLLong(); - $this->hotbarSlot = $this->getByte(); + $this->entityUniqueId = $this->buf->getLLong(); + $this->hotbarSlot = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putLLong($this->entityUniqueId); - $this->putByte($this->hotbarSlot); + $this->buf->putLLong($this->entityUniqueId); + $this->buf->putByte($this->hotbarSlot); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AddActorPacket.php b/src/network/mcpe/protocol/AddActorPacket.php index 30f827f73c..60e802af72 100644 --- a/src/network/mcpe/protocol/AddActorPacket.php +++ b/src/network/mcpe/protocol/AddActorPacket.php @@ -174,24 +174,24 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{ public $links = []; protected function decodePayload() : void{ - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->type = array_search($t = $this->getString(), self::LEGACY_ID_MAP_BC, true); + $this->entityUniqueId = $this->buf->getEntityUniqueId(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->type = array_search($t = $this->buf->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->getVector3(); - $this->motion = $this->getVector3(); - $this->pitch = $this->getLFloat(); - $this->yaw = $this->getLFloat(); - $this->headYaw = $this->getLFloat(); + $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(); - $attrCount = $this->getUnsignedVarInt(); + $attrCount = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $attrCount; ++$i){ - $id = $this->getString(); - $min = $this->getLFloat(); - $current = $this->getLFloat(); - $max = $this->getLFloat(); + $id = $this->buf->getString(); + $min = $this->buf->getLFloat(); + $current = $this->buf->getLFloat(); + $max = $this->buf->getLFloat(); $attr = Attribute::get($id); if($attr !== null){ @@ -208,38 +208,38 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{ } } - $this->metadata = $this->getEntityMetadata(); - $linkCount = $this->getUnsignedVarInt(); + $this->metadata = $this->buf->getEntityMetadata(); + $linkCount = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $linkCount; ++$i){ - $this->links[] = $this->getEntityLink(); + $this->links[] = $this->buf->getEntityLink(); } } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $this->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){ throw new \InvalidArgumentException("Unknown entity numeric ID $this->type"); } - $this->putString(self::LEGACY_ID_MAP_BC[$this->type]); - $this->putVector3($this->position); - $this->putVector3Nullable($this->motion); - $this->putLFloat($this->pitch); - $this->putLFloat($this->yaw); - $this->putLFloat($this->headYaw); + $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); - $this->putUnsignedVarInt(count($this->attributes)); + $this->buf->putUnsignedVarInt(count($this->attributes)); foreach($this->attributes as $attribute){ - $this->putString($attribute->getId()); - $this->putLFloat($attribute->getMinValue()); - $this->putLFloat($attribute->getValue()); - $this->putLFloat($attribute->getMaxValue()); + $this->buf->putString($attribute->getId()); + $this->buf->putLFloat($attribute->getMinValue()); + $this->buf->putLFloat($attribute->getValue()); + $this->buf->putLFloat($attribute->getMaxValue()); } - $this->putEntityMetadata($this->metadata); - $this->putUnsignedVarInt(count($this->links)); + $this->buf->putEntityMetadata($this->metadata); + $this->buf->putUnsignedVarInt(count($this->links)); foreach($this->links as $link){ - $this->putEntityLink($link); + $this->buf->putEntityLink($link); } } diff --git a/src/network/mcpe/protocol/AddBehaviorTreePacket.php b/src/network/mcpe/protocol/AddBehaviorTreePacket.php index 0ce5e4dd4c..57bb64c4f8 100644 --- a/src/network/mcpe/protocol/AddBehaviorTreePacket.php +++ b/src/network/mcpe/protocol/AddBehaviorTreePacket.php @@ -34,11 +34,11 @@ class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{ public $behaviorTreeJson; protected function decodePayload() : void{ - $this->behaviorTreeJson = $this->getString(); + $this->behaviorTreeJson = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->behaviorTreeJson); + $this->buf->putString($this->behaviorTreeJson); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AddEntityPacket.php b/src/network/mcpe/protocol/AddEntityPacket.php index b4e0694f07..7e03e96a29 100644 --- a/src/network/mcpe/protocol/AddEntityPacket.php +++ b/src/network/mcpe/protocol/AddEntityPacket.php @@ -44,11 +44,11 @@ class AddEntityPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->uvarint1 = $this->getUnsignedVarInt(); + $this->uvarint1 = $this->buf->getUnsignedVarInt(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->uvarint1); + $this->buf->putUnsignedVarInt($this->uvarint1); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AddItemActorPacket.php b/src/network/mcpe/protocol/AddItemActorPacket.php index 0a4efa9ab0..9f841ea2c6 100644 --- a/src/network/mcpe/protocol/AddItemActorPacket.php +++ b/src/network/mcpe/protocol/AddItemActorPacket.php @@ -52,23 +52,23 @@ class AddItemActorPacket extends DataPacket implements ClientboundPacket{ public $isFromFishing = false; protected function decodePayload() : void{ - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->item = $this->getSlot(); - $this->position = $this->getVector3(); - $this->motion = $this->getVector3(); - $this->metadata = $this->getEntityMetadata(); - $this->isFromFishing = $this->getBool(); + $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 encodePayload() : void{ - $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putSlot($this->item); - $this->putVector3($this->position); - $this->putVector3Nullable($this->motion); - $this->putEntityMetadata($this->metadata); - $this->putBool($this->isFromFishing); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AddPaintingPacket.php b/src/network/mcpe/protocol/AddPaintingPacket.php index 805e1eeabd..a4db84d687 100644 --- a/src/network/mcpe/protocol/AddPaintingPacket.php +++ b/src/network/mcpe/protocol/AddPaintingPacket.php @@ -43,19 +43,19 @@ class AddPaintingPacket extends DataPacket implements ClientboundPacket{ public $title; protected function decodePayload() : void{ - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->position = $this->getVector3(); - $this->direction = $this->getVarInt(); - $this->title = $this->getString(); + $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 encodePayload() : void{ - $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3($this->position); - $this->putVarInt($this->direction); - $this->putString($this->title); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AddPlayerPacket.php b/src/network/mcpe/protocol/AddPlayerPacket.php index b0d281834c..beb6fa5950 100644 --- a/src/network/mcpe/protocol/AddPlayerPacket.php +++ b/src/network/mcpe/protocol/AddPlayerPacket.php @@ -88,65 +88,65 @@ class AddPlayerPacket extends DataPacket implements ClientboundPacket{ public $buildPlatform = -1; protected function decodePayload() : void{ - $this->uuid = $this->getUUID(); - $this->username = $this->getString(); - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->platformChatId = $this->getString(); - $this->position = $this->getVector3(); - $this->motion = $this->getVector3(); - $this->pitch = $this->getLFloat(); - $this->yaw = $this->getLFloat(); - $this->headYaw = $this->getLFloat(); - $this->item = $this->getSlot(); - $this->metadata = $this->getEntityMetadata(); + $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(); - $this->uvarint1 = $this->getUnsignedVarInt(); - $this->uvarint2 = $this->getUnsignedVarInt(); - $this->uvarint3 = $this->getUnsignedVarInt(); - $this->uvarint4 = $this->getUnsignedVarInt(); - $this->uvarint5 = $this->getUnsignedVarInt(); + $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->long1 = $this->getLLong(); + $this->long1 = $this->buf->getLLong(); - $linkCount = $this->getUnsignedVarInt(); + $linkCount = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $linkCount; ++$i){ - $this->links[$i] = $this->getEntityLink(); + $this->links[$i] = $this->buf->getEntityLink(); } - $this->deviceId = $this->getString(); - $this->buildPlatform = $this->getLInt(); + $this->deviceId = $this->buf->getString(); + $this->buildPlatform = $this->buf->getLInt(); } protected function encodePayload() : void{ - $this->putUUID($this->uuid); - $this->putString($this->username); - $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putString($this->platformChatId); - $this->putVector3($this->position); - $this->putVector3Nullable($this->motion); - $this->putLFloat($this->pitch); - $this->putLFloat($this->yaw); - $this->putLFloat($this->headYaw ?? $this->yaw); - $this->putSlot($this->item); - $this->putEntityMetadata($this->metadata); + $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); - $this->putUnsignedVarInt($this->uvarint1); - $this->putUnsignedVarInt($this->uvarint2); - $this->putUnsignedVarInt($this->uvarint3); - $this->putUnsignedVarInt($this->uvarint4); - $this->putUnsignedVarInt($this->uvarint5); + $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); - $this->putLLong($this->long1); + $this->buf->putLLong($this->long1); - $this->putUnsignedVarInt(count($this->links)); + $this->buf->putUnsignedVarInt(count($this->links)); foreach($this->links as $link){ - $this->putEntityLink($link); + $this->buf->putEntityLink($link); } - $this->putString($this->deviceId); - $this->putLInt($this->buildPlatform); + $this->buf->putString($this->deviceId); + $this->buf->putLInt($this->buildPlatform); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AdventureSettingsPacket.php b/src/network/mcpe/protocol/AdventureSettingsPacket.php index ccd0668560..a81782af25 100644 --- a/src/network/mcpe/protocol/AdventureSettingsPacket.php +++ b/src/network/mcpe/protocol/AdventureSettingsPacket.php @@ -76,21 +76,21 @@ class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, S public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang) protected function decodePayload() : void{ - $this->flags = $this->getUnsignedVarInt(); - $this->commandPermission = $this->getUnsignedVarInt(); - $this->flags2 = $this->getUnsignedVarInt(); - $this->playerPermission = $this->getUnsignedVarInt(); - $this->customFlags = $this->getUnsignedVarInt(); - $this->entityUniqueId = $this->getLLong(); + $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 encodePayload() : void{ - $this->putUnsignedVarInt($this->flags); - $this->putUnsignedVarInt($this->commandPermission); - $this->putUnsignedVarInt($this->flags2); - $this->putUnsignedVarInt($this->playerPermission); - $this->putUnsignedVarInt($this->customFlags); - $this->putLLong($this->entityUniqueId); + $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); } public function getFlag(int $flag) : bool{ diff --git a/src/network/mcpe/protocol/AnimatePacket.php b/src/network/mcpe/protocol/AnimatePacket.php index 9ecdc5bb8e..003d7d5e4a 100644 --- a/src/network/mcpe/protocol/AnimatePacket.php +++ b/src/network/mcpe/protocol/AnimatePacket.php @@ -58,18 +58,18 @@ class AnimatePacket extends DataPacket implements ClientboundPacket, Serverbound } protected function decodePayload() : void{ - $this->action = $this->getVarInt(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); + $this->action = $this->buf->getVarInt(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); if(($this->action & 0x80) !== 0){ - $this->float = $this->getLFloat(); + $this->float = $this->buf->getLFloat(); } } protected function encodePayload() : void{ - $this->putVarInt($this->action); - $this->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putVarInt($this->action); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); if(($this->action & 0x80) !== 0){ - $this->putLFloat($this->float); + $this->buf->putLFloat($this->float); } } diff --git a/src/network/mcpe/protocol/AnvilDamagePacket.php b/src/network/mcpe/protocol/AnvilDamagePacket.php index 7aa0a0a6ba..a0f1d1e20a 100644 --- a/src/network/mcpe/protocol/AnvilDamagePacket.php +++ b/src/network/mcpe/protocol/AnvilDamagePacket.php @@ -63,13 +63,13 @@ class AnvilDamagePacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->damageAmount = $this->getByte(); - $this->getBlockPosition($this->x, $this->y, $this->z); + $this->damageAmount = $this->buf->getByte(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); } protected function encodePayload() : void{ - $this->putByte($this->damageAmount); - $this->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putByte($this->damageAmount); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AutomationClientConnectPacket.php b/src/network/mcpe/protocol/AutomationClientConnectPacket.php index ee968cff1c..98e9740b63 100644 --- a/src/network/mcpe/protocol/AutomationClientConnectPacket.php +++ b/src/network/mcpe/protocol/AutomationClientConnectPacket.php @@ -34,11 +34,11 @@ class AutomationClientConnectPacket extends DataPacket implements ClientboundPac public $serverUri; protected function decodePayload() : void{ - $this->serverUri = $this->getString(); + $this->serverUri = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->serverUri); + $this->buf->putString($this->serverUri); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php b/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php index d237877f04..53bb70539d 100644 --- a/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php +++ b/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php @@ -39,11 +39,11 @@ class AvailableActorIdentifiersPacket extends DataPacket implements ClientboundP public $namedtag; protected function decodePayload() : void{ - $this->namedtag = $this->getRemaining(); + $this->namedtag = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->put( + $this->buf->put( $this->namedtag ?? self::$DEFAULT_NBT_CACHE ?? (self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/entity_identifiers.nbt')) diff --git a/src/network/mcpe/protocol/AvailableCommandsPacket.php b/src/network/mcpe/protocol/AvailableCommandsPacket.php index 47ad0ee8d4..4ed1ae8f39 100644 --- a/src/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/network/mcpe/protocol/AvailableCommandsPacket.php @@ -114,34 +114,34 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ protected function decodePayload() : void{ /** @var string[] $enumValues */ $enumValues = []; - for($i = 0, $enumValuesCount = $this->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){ - $enumValues[] = $this->getString(); + for($i = 0, $enumValuesCount = $this->buf->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){ + $enumValues[] = $this->buf->getString(); } /** @var string[] $postfixes */ $postfixes = []; - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $postfixes[] = $this->getString(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $postfixes[] = $this->buf->getString(); } /** @var CommandEnum[] $enums */ $enums = []; - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $enums[] = $enum = $this->getEnum($enumValues); if(isset(self::HARDCODED_ENUM_NAMES[$enum->getName()])){ $this->hardcodedEnums[] = $enum; } } - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $this->commandData[] = $this->getCommandData($enums, $postfixes); } - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $this->softEnums[] = $this->getSoftEnum(); } - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues); } } @@ -153,12 +153,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @throws BinaryDataException */ protected function getEnum(array $enumValueList) : CommandEnum{ - $enumName = $this->getString(); + $enumName = $this->buf->getString(); $enumValues = []; $listSize = count($enumValueList); - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $index = $this->getEnumValueIndex($listSize); if(!isset($enumValueList[$index])){ throw new BadPacketException("Invalid enum value index $index"); @@ -174,12 +174,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @throws BinaryDataException */ protected function getSoftEnum() : CommandEnum{ - $enumName = $this->getString(); + $enumName = $this->buf->getString(); $enumValues = []; - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ //Get the enum value from the initial pile of mess - $enumValues[] = $this->getString(); + $enumValues[] = $this->buf->getString(); } return new CommandEnum($enumName, $enumValues); @@ -189,10 +189,10 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @param int[] $enumValueMap */ protected function putEnum(CommandEnum $enum, array $enumValueMap) : void{ - $this->putString($enum->getName()); + $this->buf->putString($enum->getName()); $values = $enum->getValues(); - $this->putUnsignedVarInt(count($values)); + $this->buf->putUnsignedVarInt(count($values)); $listSize = count($enumValueMap); foreach($values as $value){ $index = $enumValueMap[$value] ?? -1; @@ -204,12 +204,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ } protected function putSoftEnum(CommandEnum $enum) : void{ - $this->putString($enum->getName()); + $this->buf->putString($enum->getName()); $values = $enum->getValues(); - $this->putUnsignedVarInt(count($values)); + $this->buf->putUnsignedVarInt(count($values)); foreach($values as $value){ - $this->putString($value); + $this->buf->putString($value); } } @@ -218,21 +218,21 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ */ protected function getEnumValueIndex(int $valueCount) : int{ if($valueCount < 256){ - return $this->getByte(); + return $this->buf->getByte(); }elseif($valueCount < 65536){ - return $this->getLShort(); + return $this->buf->getLShort(); }else{ - return $this->getLInt(); + return $this->buf->getLInt(); } } protected function putEnumValueIndex(int $index, int $valueCount) : void{ if($valueCount < 256){ - $this->putByte($index); + $this->buf->putByte($index); }elseif($valueCount < 65536){ - $this->putLShort($index); + $this->buf->putLShort($index); }else{ - $this->putLInt($index); + $this->buf->putLInt($index); } } @@ -245,11 +245,11 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ */ protected function getEnumConstraint(array $enums, array $enumValues) : CommandEnumConstraint{ //wtf, what was wrong with an offset inside the enum? :( - $valueIndex = $this->getLInt(); + $valueIndex = $this->buf->getLInt(); if(!isset($enumValues[$valueIndex])){ throw new BadPacketException("Enum constraint refers to unknown enum value index $valueIndex"); } - $enumIndex = $this->getLInt(); + $enumIndex = $this->buf->getLInt(); if(!isset($enums[$enumIndex])){ throw new BadPacketException("Enum constraint refers to unknown enum index $enumIndex"); } @@ -260,8 +260,8 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ } $constraintIds = []; - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $constraintIds[] = $this->getByte(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $constraintIds[] = $this->buf->getByte(); } return new CommandEnumConstraint($enum, $valueOffset, $constraintIds); @@ -272,11 +272,11 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @param int[] $enumValueIndexes string value -> int index */ protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes) : void{ - $this->putLInt($enumValueIndexes[$constraint->getAffectedValue()]); - $this->putLInt($enumIndexes[$constraint->getEnum()->getName()]); - $this->putUnsignedVarInt(count($constraint->getConstraints())); + $this->buf->putLInt($enumValueIndexes[$constraint->getAffectedValue()]); + $this->buf->putLInt($enumIndexes[$constraint->getEnum()->getName()]); + $this->buf->putUnsignedVarInt(count($constraint->getConstraints())); foreach($constraint->getConstraints() as $v){ - $this->putByte($v); + $this->buf->putByte($v); } } @@ -288,21 +288,21 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @throws BinaryDataException */ protected function getCommandData(array $enums, array $postfixes) : CommandData{ - $name = $this->getString(); - $description = $this->getString(); - $flags = $this->getByte(); - $permission = $this->getByte(); - $aliases = $enums[$this->getLInt()] ?? null; + $name = $this->buf->getString(); + $description = $this->buf->getString(); + $flags = $this->buf->getByte(); + $permission = $this->buf->getByte(); + $aliases = $enums[$this->buf->getLInt()] ?? null; $overloads = []; - for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){ + for($overloadIndex = 0, $overloadCount = $this->buf->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){ $overloads[$overloadIndex] = []; - for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){ + for($paramIndex = 0, $paramCount = $this->buf->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){ $parameter = new CommandParameter(); - $parameter->paramName = $this->getString(); - $parameter->paramType = $this->getLInt(); - $parameter->isOptional = $this->getBool(); - $parameter->flags = $this->getByte(); + $parameter->paramName = $this->buf->getString(); + $parameter->paramType = $this->buf->getLInt(); + $parameter->isOptional = $this->buf->getBool(); + $parameter->flags = $this->buf->getByte(); if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){ $index = ($parameter->paramType & 0xffff); @@ -332,23 +332,23 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ * @param int[] $postfixIndexes */ protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes) : void{ - $this->putString($data->name); - $this->putString($data->description); - $this->putByte($data->flags); - $this->putByte($data->permission); + $this->buf->putString($data->name); + $this->buf->putString($data->description); + $this->buf->putByte($data->flags); + $this->buf->putByte($data->permission); if($data->aliases !== null){ - $this->putLInt($enumIndexes[$data->aliases->getName()] ?? -1); + $this->buf->putLInt($enumIndexes[$data->aliases->getName()] ?? -1); }else{ - $this->putLInt(-1); + $this->buf->putLInt(-1); } - $this->putUnsignedVarInt(count($data->overloads)); + $this->buf->putUnsignedVarInt(count($data->overloads)); foreach($data->overloads as $overload){ /** @var CommandParameter[] $overload */ - $this->putUnsignedVarInt(count($overload)); + $this->buf->putUnsignedVarInt(count($overload)); foreach($overload as $parameter){ - $this->putString($parameter->paramName); + $this->buf->putString($parameter->paramName); if($parameter->enum !== null){ $type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->getName()] ?? -1); @@ -362,9 +362,9 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ $type = $parameter->paramType; } - $this->putLInt($type); - $this->putBool($parameter->isOptional); - $this->putByte($parameter->flags); + $this->buf->putLInt($type); + $this->buf->putBool($parameter->isOptional); + $this->buf->putByte($parameter->flags); } } } @@ -452,32 +452,32 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ } } - $this->putUnsignedVarInt(count($enumValueIndexes)); + $this->buf->putUnsignedVarInt(count($enumValueIndexes)); foreach($enumValueIndexes as $enumValue => $index){ - $this->putString((string) $enumValue); //stupid PHP key casting D: + $this->buf->putString((string) $enumValue); //stupid PHP key casting D: } - $this->putUnsignedVarInt(count($postfixIndexes)); + $this->buf->putUnsignedVarInt(count($postfixIndexes)); foreach($postfixIndexes as $postfix => $index){ - $this->putString((string) $postfix); //stupid PHP key casting D: + $this->buf->putString((string) $postfix); //stupid PHP key casting D: } - $this->putUnsignedVarInt(count($enums)); + $this->buf->putUnsignedVarInt(count($enums)); foreach($enums as $enum){ $this->putEnum($enum, $enumValueIndexes); } - $this->putUnsignedVarInt(count($this->commandData)); + $this->buf->putUnsignedVarInt(count($this->commandData)); foreach($this->commandData as $data){ $this->putCommandData($data, $enumIndexes, $postfixIndexes); } - $this->putUnsignedVarInt(count($this->softEnums)); + $this->buf->putUnsignedVarInt(count($this->softEnums)); foreach($this->softEnums as $enum){ $this->putSoftEnum($enum); } - $this->putUnsignedVarInt(count($this->enumConstraints)); + $this->buf->putUnsignedVarInt(count($this->enumConstraints)); foreach($this->enumConstraints as $constraint){ $this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes); } diff --git a/src/network/mcpe/protocol/BiomeDefinitionListPacket.php b/src/network/mcpe/protocol/BiomeDefinitionListPacket.php index 4a691b7d33..a16f17708a 100644 --- a/src/network/mcpe/protocol/BiomeDefinitionListPacket.php +++ b/src/network/mcpe/protocol/BiomeDefinitionListPacket.php @@ -38,11 +38,11 @@ class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{ public $namedtag; protected function decodePayload() : void{ - $this->namedtag = $this->getRemaining(); + $this->namedtag = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->put( + $this->buf->put( $this->namedtag ?? self::$DEFAULT_NBT_CACHE ?? (self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/biome_definitions.nbt')) diff --git a/src/network/mcpe/protocol/BlockActorDataPacket.php b/src/network/mcpe/protocol/BlockActorDataPacket.php index 476a33f91b..2bcc51067b 100644 --- a/src/network/mcpe/protocol/BlockActorDataPacket.php +++ b/src/network/mcpe/protocol/BlockActorDataPacket.php @@ -47,13 +47,13 @@ class BlockActorDataPacket extends DataPacket implements ClientboundPacket, Serv } protected function decodePayload() : void{ - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->namedtag = $this->getRemaining(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); + $this->namedtag = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->put($this->namedtag); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->put($this->namedtag); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/BlockEventPacket.php b/src/network/mcpe/protocol/BlockEventPacket.php index 855995ac8c..b928db6c8a 100644 --- a/src/network/mcpe/protocol/BlockEventPacket.php +++ b/src/network/mcpe/protocol/BlockEventPacket.php @@ -53,15 +53,15 @@ class BlockEventPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->eventType = $this->getVarInt(); - $this->eventData = $this->getVarInt(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); + $this->eventType = $this->buf->getVarInt(); + $this->eventData = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putVarInt($this->eventType); - $this->putVarInt($this->eventData); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putVarInt($this->eventType); + $this->buf->putVarInt($this->eventData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/BlockPickRequestPacket.php b/src/network/mcpe/protocol/BlockPickRequestPacket.php index 8e2760b7ee..4adf0251de 100644 --- a/src/network/mcpe/protocol/BlockPickRequestPacket.php +++ b/src/network/mcpe/protocol/BlockPickRequestPacket.php @@ -42,15 +42,15 @@ class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{ public $hotbarSlot; protected function decodePayload() : void{ - $this->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); - $this->addUserData = $this->getBool(); - $this->hotbarSlot = $this->getByte(); + $this->buf->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); + $this->addUserData = $this->buf->getBool(); + $this->hotbarSlot = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); - $this->putBool($this->addUserData); - $this->putByte($this->hotbarSlot); + $this->buf->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); + $this->buf->putBool($this->addUserData); + $this->buf->putByte($this->hotbarSlot); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/BookEditPacket.php b/src/network/mcpe/protocol/BookEditPacket.php index 4d54cf8cb2..6df127780b 100644 --- a/src/network/mcpe/protocol/BookEditPacket.php +++ b/src/network/mcpe/protocol/BookEditPacket.php @@ -59,27 +59,27 @@ class BookEditPacket extends DataPacket implements ServerboundPacket{ public $xuid; protected function decodePayload() : void{ - $this->type = $this->getByte(); - $this->inventorySlot = $this->getByte(); + $this->type = $this->buf->getByte(); + $this->inventorySlot = $this->buf->getByte(); switch($this->type){ case self::TYPE_REPLACE_PAGE: case self::TYPE_ADD_PAGE: - $this->pageNumber = $this->getByte(); - $this->text = $this->getString(); - $this->photoName = $this->getString(); + $this->pageNumber = $this->buf->getByte(); + $this->text = $this->buf->getString(); + $this->photoName = $this->buf->getString(); break; case self::TYPE_DELETE_PAGE: - $this->pageNumber = $this->getByte(); + $this->pageNumber = $this->buf->getByte(); break; case self::TYPE_SWAP_PAGES: - $this->pageNumber = $this->getByte(); - $this->secondaryPageNumber = $this->getByte(); + $this->pageNumber = $this->buf->getByte(); + $this->secondaryPageNumber = $this->buf->getByte(); break; case self::TYPE_SIGN_BOOK: - $this->title = $this->getString(); - $this->author = $this->getString(); - $this->xuid = $this->getString(); + $this->title = $this->buf->getString(); + $this->author = $this->buf->getString(); + $this->xuid = $this->buf->getString(); break; default: throw new BadPacketException("Unknown book edit type $this->type!"); @@ -87,27 +87,27 @@ class BookEditPacket extends DataPacket implements ServerboundPacket{ } protected function encodePayload() : void{ - $this->putByte($this->type); - $this->putByte($this->inventorySlot); + $this->buf->putByte($this->type); + $this->buf->putByte($this->inventorySlot); switch($this->type){ case self::TYPE_REPLACE_PAGE: case self::TYPE_ADD_PAGE: - $this->putByte($this->pageNumber); - $this->putString($this->text); - $this->putString($this->photoName); + $this->buf->putByte($this->pageNumber); + $this->buf->putString($this->text); + $this->buf->putString($this->photoName); break; case self::TYPE_DELETE_PAGE: - $this->putByte($this->pageNumber); + $this->buf->putByte($this->pageNumber); break; case self::TYPE_SWAP_PAGES: - $this->putByte($this->pageNumber); - $this->putByte($this->secondaryPageNumber); + $this->buf->putByte($this->pageNumber); + $this->buf->putByte($this->secondaryPageNumber); break; case self::TYPE_SIGN_BOOK: - $this->putString($this->title); - $this->putString($this->author); - $this->putString($this->xuid); + $this->buf->putString($this->title); + $this->buf->putString($this->author); + $this->buf->putString($this->xuid); break; default: throw new \InvalidArgumentException("Unknown book edit type $this->type!"); diff --git a/src/network/mcpe/protocol/BossEventPacket.php b/src/network/mcpe/protocol/BossEventPacket.php index bc215e1546..460e9492d4 100644 --- a/src/network/mcpe/protocol/BossEventPacket.php +++ b/src/network/mcpe/protocol/BossEventPacket.php @@ -119,29 +119,29 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou } protected function decodePayload() : void{ - $this->bossEid = $this->getEntityUniqueId(); - $this->eventType = $this->getUnsignedVarInt(); + $this->bossEid = $this->buf->getEntityUniqueId(); + $this->eventType = $this->buf->getUnsignedVarInt(); switch($this->eventType){ case self::TYPE_REGISTER_PLAYER: case self::TYPE_UNREGISTER_PLAYER: - $this->playerEid = $this->getEntityUniqueId(); + $this->playerEid = $this->buf->getEntityUniqueId(); break; /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_SHOW: - $this->title = $this->getString(); - $this->healthPercent = $this->getLFloat(); + $this->title = $this->buf->getString(); + $this->healthPercent = $this->buf->getLFloat(); /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_UNKNOWN_6: - $this->unknownShort = $this->getLShort(); + $this->unknownShort = $this->buf->getLShort(); case self::TYPE_TEXTURE: - $this->color = $this->getUnsignedVarInt(); - $this->overlay = $this->getUnsignedVarInt(); + $this->color = $this->buf->getUnsignedVarInt(); + $this->overlay = $this->buf->getUnsignedVarInt(); break; case self::TYPE_HEALTH_PERCENT: - $this->healthPercent = $this->getLFloat(); + $this->healthPercent = $this->buf->getLFloat(); break; case self::TYPE_TITLE: - $this->title = $this->getString(); + $this->title = $this->buf->getString(); break; default: break; @@ -149,29 +149,29 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->bossEid); - $this->putUnsignedVarInt($this->eventType); + $this->buf->putEntityUniqueId($this->bossEid); + $this->buf->putUnsignedVarInt($this->eventType); switch($this->eventType){ case self::TYPE_REGISTER_PLAYER: case self::TYPE_UNREGISTER_PLAYER: - $this->putEntityUniqueId($this->playerEid); + $this->buf->putEntityUniqueId($this->playerEid); break; /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_SHOW: - $this->putString($this->title); - $this->putLFloat($this->healthPercent); + $this->buf->putString($this->title); + $this->buf->putLFloat($this->healthPercent); /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_UNKNOWN_6: - $this->putLShort($this->unknownShort); + $this->buf->putLShort($this->unknownShort); case self::TYPE_TEXTURE: - $this->putUnsignedVarInt($this->color); - $this->putUnsignedVarInt($this->overlay); + $this->buf->putUnsignedVarInt($this->color); + $this->buf->putUnsignedVarInt($this->overlay); break; case self::TYPE_HEALTH_PERCENT: - $this->putLFloat($this->healthPercent); + $this->buf->putLFloat($this->healthPercent); break; case self::TYPE_TITLE: - $this->putString($this->title); + $this->buf->putString($this->title); break; default: break; diff --git a/src/network/mcpe/protocol/CameraPacket.php b/src/network/mcpe/protocol/CameraPacket.php index 06ce1cd034..81a3bfe074 100644 --- a/src/network/mcpe/protocol/CameraPacket.php +++ b/src/network/mcpe/protocol/CameraPacket.php @@ -36,13 +36,13 @@ class CameraPacket extends DataPacket implements ClientboundPacket{ public $playerUniqueId; protected function decodePayload() : void{ - $this->cameraUniqueId = $this->getEntityUniqueId(); - $this->playerUniqueId = $this->getEntityUniqueId(); + $this->cameraUniqueId = $this->buf->getEntityUniqueId(); + $this->playerUniqueId = $this->buf->getEntityUniqueId(); } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->cameraUniqueId); - $this->putEntityUniqueId($this->playerUniqueId); + $this->buf->putEntityUniqueId($this->cameraUniqueId); + $this->buf->putEntityUniqueId($this->playerUniqueId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ChangeDimensionPacket.php b/src/network/mcpe/protocol/ChangeDimensionPacket.php index 0cf5dfae5c..ac68ac1d14 100644 --- a/src/network/mcpe/protocol/ChangeDimensionPacket.php +++ b/src/network/mcpe/protocol/ChangeDimensionPacket.php @@ -39,15 +39,15 @@ class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{ public $respawn = false; protected function decodePayload() : void{ - $this->dimension = $this->getVarInt(); - $this->position = $this->getVector3(); - $this->respawn = $this->getBool(); + $this->dimension = $this->buf->getVarInt(); + $this->position = $this->buf->getVector3(); + $this->respawn = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putVarInt($this->dimension); - $this->putVector3($this->position); - $this->putBool($this->respawn); + $this->buf->putVarInt($this->dimension); + $this->buf->putVector3($this->position); + $this->buf->putBool($this->respawn); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php b/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php index 567c291e44..996dfc3c70 100644 --- a/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php +++ b/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php @@ -40,11 +40,11 @@ class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->radius = $this->getVarInt(); + $this->radius = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->radius); + $this->buf->putVarInt($this->radius); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php b/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php index 46a1eb005a..7954fa6bb5 100644 --- a/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php +++ b/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php @@ -66,24 +66,24 @@ class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacke } protected function decodePayload() : void{ - $hitCount = $this->getUnsignedVarInt(); - $missCount = $this->getUnsignedVarInt(); + $hitCount = $this->buf->getUnsignedVarInt(); + $missCount = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $hitCount; ++$i){ - $this->hitHashes[] = $this->getLLong(); + $this->hitHashes[] = $this->buf->getLLong(); } for($i = 0; $i < $missCount; ++$i){ - $this->missHashes[] = $this->getLLong(); + $this->missHashes[] = $this->buf->getLLong(); } } protected function encodePayload() : void{ - $this->putUnsignedVarInt(count($this->hitHashes)); - $this->putUnsignedVarInt(count($this->missHashes)); + $this->buf->putUnsignedVarInt(count($this->hitHashes)); + $this->buf->putUnsignedVarInt(count($this->missHashes)); foreach($this->hitHashes as $hash){ - $this->putLLong($hash); + $this->buf->putLLong($hash); } foreach($this->missHashes as $hash){ - $this->putLLong($hash); + $this->buf->putLLong($hash); } } diff --git a/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php b/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php index e523c479c8..883859acc3 100644 --- a/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php +++ b/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php @@ -55,18 +55,18 @@ class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPac } protected function decodePayload() : void{ - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $hash = $this->getLLong(); - $payload = $this->getString(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $hash = $this->buf->getLLong(); + $payload = $this->buf->getString(); $this->blobs[] = new ChunkCacheBlob($hash, $payload); } } protected function encodePayload() : void{ - $this->putUnsignedVarInt(count($this->blobs)); + $this->buf->putUnsignedVarInt(count($this->blobs)); foreach($this->blobs as $blob){ - $this->putLLong($blob->getHash()); - $this->putString($blob->getPayload()); + $this->buf->putLLong($blob->getHash()); + $this->buf->putString($blob->getPayload()); } } diff --git a/src/network/mcpe/protocol/ClientCacheStatusPacket.php b/src/network/mcpe/protocol/ClientCacheStatusPacket.php index ec42d5cfc1..4b44f6dc18 100644 --- a/src/network/mcpe/protocol/ClientCacheStatusPacket.php +++ b/src/network/mcpe/protocol/ClientCacheStatusPacket.php @@ -44,11 +44,11 @@ class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->enabled = $this->getBool(); + $this->enabled = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putBool($this->enabled); + $this->buf->putBool($this->enabled); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php b/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php index 8be2da58e9..d9be5178e8 100644 --- a/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php +++ b/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php @@ -73,68 +73,68 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack public $colors = []; protected function decodePayload() : void{ - $this->mapId = $this->getEntityUniqueId(); - $this->type = $this->getUnsignedVarInt(); - $this->dimensionId = $this->getByte(); - $this->isLocked = $this->getBool(); + $this->mapId = $this->buf->getEntityUniqueId(); + $this->type = $this->buf->getUnsignedVarInt(); + $this->dimensionId = $this->buf->getByte(); + $this->isLocked = $this->buf->getBool(); if(($this->type & 0x08) !== 0){ - $count = $this->getUnsignedVarInt(); + $count = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ - $this->eids[] = $this->getEntityUniqueId(); + $this->eids[] = $this->buf->getEntityUniqueId(); } } if(($this->type & (0x08 | self::BITFLAG_DECORATION_UPDATE | self::BITFLAG_TEXTURE_UPDATE)) !== 0){ //Decoration bitflag or colour bitflag - $this->scale = $this->getByte(); + $this->scale = $this->buf->getByte(); } if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){ - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $object = new MapTrackedObject(); - $object->type = $this->getLInt(); + $object->type = $this->buf->getLInt(); if($object->type === MapTrackedObject::TYPE_BLOCK){ - $this->getBlockPosition($object->x, $object->y, $object->z); + $this->buf->getBlockPosition($object->x, $object->y, $object->z); }elseif($object->type === MapTrackedObject::TYPE_ENTITY){ - $object->entityUniqueId = $this->getEntityUniqueId(); + $object->entityUniqueId = $this->buf->getEntityUniqueId(); }else{ throw new BadPacketException("Unknown map object type $object->type"); } $this->trackedEntities[] = $object; } - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $icon = $this->getByte(); - $rotation = $this->getByte(); - $xOffset = $this->getByte(); - $yOffset = $this->getByte(); - $label = $this->getString(); - $color = Color::fromRGBA(Binary::flipIntEndianness($this->getUnsignedVarInt())); + 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())); $this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color); } } if(($this->type & self::BITFLAG_TEXTURE_UPDATE) !== 0){ - $this->width = $this->getVarInt(); - $this->height = $this->getVarInt(); - $this->xOffset = $this->getVarInt(); - $this->yOffset = $this->getVarInt(); + $this->width = $this->buf->getVarInt(); + $this->height = $this->buf->getVarInt(); + $this->xOffset = $this->buf->getVarInt(); + $this->yOffset = $this->buf->getVarInt(); - $count = $this->getUnsignedVarInt(); + $count = $this->buf->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->getUnsignedVarInt())); + $this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($this->buf->getUnsignedVarInt())); } } } } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->mapId); + $this->buf->putEntityUniqueId($this->mapId); $type = 0; if(($eidsCount = count($this->eids)) > 0){ @@ -147,57 +147,57 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack $type |= self::BITFLAG_TEXTURE_UPDATE; } - $this->putUnsignedVarInt($type); - $this->putByte($this->dimensionId); - $this->putBool($this->isLocked); + $this->buf->putUnsignedVarInt($type); + $this->buf->putByte($this->dimensionId); + $this->buf->putBool($this->isLocked); if(($type & 0x08) !== 0){ //TODO: find out what these are for - $this->putUnsignedVarInt($eidsCount); + $this->buf->putUnsignedVarInt($eidsCount); foreach($this->eids as $eid){ - $this->putEntityUniqueId($eid); + $this->buf->putEntityUniqueId($eid); } } if(($type & (0x08 | self::BITFLAG_TEXTURE_UPDATE | self::BITFLAG_DECORATION_UPDATE)) !== 0){ - $this->putByte($this->scale); + $this->buf->putByte($this->scale); } if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){ - $this->putUnsignedVarInt(count($this->trackedEntities)); + $this->buf->putUnsignedVarInt(count($this->trackedEntities)); foreach($this->trackedEntities as $object){ - $this->putLInt($object->type); + $this->buf->putLInt($object->type); if($object->type === MapTrackedObject::TYPE_BLOCK){ - $this->putBlockPosition($object->x, $object->y, $object->z); + $this->buf->putBlockPosition($object->x, $object->y, $object->z); }elseif($object->type === MapTrackedObject::TYPE_ENTITY){ - $this->putEntityUniqueId($object->entityUniqueId); + $this->buf->putEntityUniqueId($object->entityUniqueId); }else{ throw new \InvalidArgumentException("Unknown map object type $object->type"); } } - $this->putUnsignedVarInt($decorationCount); + $this->buf->putUnsignedVarInt($decorationCount); foreach($this->decorations as $decoration){ - $this->putByte($decoration->getIcon()); - $this->putByte($decoration->getRotation()); - $this->putByte($decoration->getXOffset()); - $this->putByte($decoration->getYOffset()); - $this->putString($decoration->getLabel()); - $this->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA())); + $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())); } } if(($type & self::BITFLAG_TEXTURE_UPDATE) !== 0){ - $this->putVarInt($this->width); - $this->putVarInt($this->height); - $this->putVarInt($this->xOffset); - $this->putVarInt($this->yOffset); + $this->buf->putVarInt($this->width); + $this->buf->putVarInt($this->height); + $this->buf->putVarInt($this->xOffset); + $this->buf->putVarInt($this->yOffset); - $this->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang + $this->buf->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->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA())); + $this->buf->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA())); } } } diff --git a/src/network/mcpe/protocol/CommandBlockUpdatePacket.php b/src/network/mcpe/protocol/CommandBlockUpdatePacket.php index da4f66ec3e..038e1bacb8 100644 --- a/src/network/mcpe/protocol/CommandBlockUpdatePacket.php +++ b/src/network/mcpe/protocol/CommandBlockUpdatePacket.php @@ -63,46 +63,46 @@ class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{ public $executeOnFirstTick; protected function decodePayload() : void{ - $this->isBlock = $this->getBool(); + $this->isBlock = $this->buf->getBool(); if($this->isBlock){ - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->commandBlockMode = $this->getUnsignedVarInt(); - $this->isRedstoneMode = $this->getBool(); - $this->isConditional = $this->getBool(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); + $this->commandBlockMode = $this->buf->getUnsignedVarInt(); + $this->isRedstoneMode = $this->buf->getBool(); + $this->isConditional = $this->buf->getBool(); }else{ //Minecart with command block - $this->minecartEid = $this->getEntityRuntimeId(); + $this->minecartEid = $this->buf->getEntityRuntimeId(); } - $this->command = $this->getString(); - $this->lastOutput = $this->getString(); - $this->name = $this->getString(); + $this->command = $this->buf->getString(); + $this->lastOutput = $this->buf->getString(); + $this->name = $this->buf->getString(); - $this->shouldTrackOutput = $this->getBool(); - $this->tickDelay = $this->getLInt(); - $this->executeOnFirstTick = $this->getBool(); + $this->shouldTrackOutput = $this->buf->getBool(); + $this->tickDelay = $this->buf->getLInt(); + $this->executeOnFirstTick = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putBool($this->isBlock); + $this->buf->putBool($this->isBlock); if($this->isBlock){ - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putUnsignedVarInt($this->commandBlockMode); - $this->putBool($this->isRedstoneMode); - $this->putBool($this->isConditional); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putUnsignedVarInt($this->commandBlockMode); + $this->buf->putBool($this->isRedstoneMode); + $this->buf->putBool($this->isConditional); }else{ - $this->putEntityRuntimeId($this->minecartEid); + $this->buf->putEntityRuntimeId($this->minecartEid); } - $this->putString($this->command); - $this->putString($this->lastOutput); - $this->putString($this->name); + $this->buf->putString($this->command); + $this->buf->putString($this->lastOutput); + $this->buf->putString($this->name); - $this->putBool($this->shouldTrackOutput); - $this->putLInt($this->tickDelay); - $this->putBool($this->executeOnFirstTick); + $this->buf->putBool($this->shouldTrackOutput); + $this->buf->putLInt($this->tickDelay); + $this->buf->putBool($this->executeOnFirstTick); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/CommandOutputPacket.php b/src/network/mcpe/protocol/CommandOutputPacket.php index 313933b649..ec15f581ec 100644 --- a/src/network/mcpe/protocol/CommandOutputPacket.php +++ b/src/network/mcpe/protocol/CommandOutputPacket.php @@ -46,16 +46,16 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{ public $unknownString; protected function decodePayload() : void{ - $this->originData = $this->getCommandOriginData(); - $this->outputType = $this->getByte(); - $this->successCount = $this->getUnsignedVarInt(); + $this->originData = $this->buf->getCommandOriginData(); + $this->outputType = $this->buf->getByte(); + $this->successCount = $this->buf->getUnsignedVarInt(); - for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){ + for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){ $this->messages[] = $this->getCommandMessage(); } if($this->outputType === 4){ - $this->unknownString = $this->getString(); + $this->unknownString = $this->buf->getString(); } } @@ -65,38 +65,38 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{ protected function getCommandMessage() : CommandOutputMessage{ $message = new CommandOutputMessage(); - $message->isInternal = $this->getBool(); - $message->messageId = $this->getString(); + $message->isInternal = $this->buf->getBool(); + $message->messageId = $this->buf->getString(); - for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){ - $message->parameters[] = $this->getString(); + for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){ + $message->parameters[] = $this->buf->getString(); } return $message; } protected function encodePayload() : void{ - $this->putCommandOriginData($this->originData); - $this->putByte($this->outputType); - $this->putUnsignedVarInt($this->successCount); + $this->buf->putCommandOriginData($this->originData); + $this->buf->putByte($this->outputType); + $this->buf->putUnsignedVarInt($this->successCount); - $this->putUnsignedVarInt(count($this->messages)); + $this->buf->putUnsignedVarInt(count($this->messages)); foreach($this->messages as $message){ $this->putCommandMessage($message); } if($this->outputType === 4){ - $this->putString($this->unknownString); + $this->buf->putString($this->unknownString); } } protected function putCommandMessage(CommandOutputMessage $message) : void{ - $this->putBool($message->isInternal); - $this->putString($message->messageId); + $this->buf->putBool($message->isInternal); + $this->buf->putString($message->messageId); - $this->putUnsignedVarInt(count($message->parameters)); + $this->buf->putUnsignedVarInt(count($message->parameters)); foreach($message->parameters as $parameter){ - $this->putString($parameter); + $this->buf->putString($parameter); } } diff --git a/src/network/mcpe/protocol/CommandRequestPacket.php b/src/network/mcpe/protocol/CommandRequestPacket.php index 293acb1dbb..ab49ada1f8 100644 --- a/src/network/mcpe/protocol/CommandRequestPacket.php +++ b/src/network/mcpe/protocol/CommandRequestPacket.php @@ -39,15 +39,15 @@ class CommandRequestPacket extends DataPacket implements ServerboundPacket{ public $isInternal; protected function decodePayload() : void{ - $this->command = $this->getString(); - $this->originData = $this->getCommandOriginData(); - $this->isInternal = $this->getBool(); + $this->command = $this->buf->getString(); + $this->originData = $this->buf->getCommandOriginData(); + $this->isInternal = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putString($this->command); - $this->putCommandOriginData($this->originData); - $this->putBool($this->isInternal); + $this->buf->putString($this->command); + $this->buf->putCommandOriginData($this->originData); + $this->buf->putBool($this->isInternal); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/CompletedUsingItemPacket.php b/src/network/mcpe/protocol/CompletedUsingItemPacket.php index 984c9c14a1..4e7e4724a9 100644 --- a/src/network/mcpe/protocol/CompletedUsingItemPacket.php +++ b/src/network/mcpe/protocol/CompletedUsingItemPacket.php @@ -53,13 +53,13 @@ class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{ public $action; public function decodePayload() : void{ - $this->itemId = $this->getShort(); - $this->action = $this->getLInt(); + $this->itemId = $this->buf->getShort(); + $this->action = $this->buf->getLInt(); } public function encodePayload() : void{ - $this->putShort($this->itemId); - $this->putLInt($this->action); + $this->buf->putShort($this->itemId); + $this->buf->putLInt($this->action); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ContainerClosePacket.php b/src/network/mcpe/protocol/ContainerClosePacket.php index 1d3ae9c6f0..13a6948625 100644 --- a/src/network/mcpe/protocol/ContainerClosePacket.php +++ b/src/network/mcpe/protocol/ContainerClosePacket.php @@ -40,11 +40,11 @@ class ContainerClosePacket extends DataPacket implements ClientboundPacket, Serv } protected function decodePayload() : void{ - $this->windowId = $this->getByte(); + $this->windowId = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putByte($this->windowId); + $this->buf->putByte($this->windowId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ContainerOpenPacket.php b/src/network/mcpe/protocol/ContainerOpenPacket.php index 99743b7364..f45eccc064 100644 --- a/src/network/mcpe/protocol/ContainerOpenPacket.php +++ b/src/network/mcpe/protocol/ContainerOpenPacket.php @@ -66,17 +66,17 @@ class ContainerOpenPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->windowId = $this->getByte(); - $this->type = $this->getByte(); - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->entityUniqueId = $this->getEntityUniqueId(); + $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 encodePayload() : void{ - $this->putByte($this->windowId); - $this->putByte($this->type); - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putEntityUniqueId($this->entityUniqueId); + $this->buf->putByte($this->windowId); + $this->buf->putByte($this->type); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putEntityUniqueId($this->entityUniqueId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ContainerSetDataPacket.php b/src/network/mcpe/protocol/ContainerSetDataPacket.php index d8b3a59342..a67b3f2d3d 100644 --- a/src/network/mcpe/protocol/ContainerSetDataPacket.php +++ b/src/network/mcpe/protocol/ContainerSetDataPacket.php @@ -56,15 +56,15 @@ class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->windowId = $this->getByte(); - $this->property = $this->getVarInt(); - $this->value = $this->getVarInt(); + $this->windowId = $this->buf->getByte(); + $this->property = $this->buf->getVarInt(); + $this->value = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putByte($this->windowId); - $this->putVarInt($this->property); - $this->putVarInt($this->value); + $this->buf->putByte($this->windowId); + $this->buf->putVarInt($this->property); + $this->buf->putVarInt($this->value); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/CraftingDataPacket.php b/src/network/mcpe/protocol/CraftingDataPacket.php index f586b76b39..362f10d28e 100644 --- a/src/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/network/mcpe/protocol/CraftingDataPacket.php @@ -67,60 +67,60 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{ protected function decodePayload() : void{ $this->decodedEntries = []; - $recipeCount = $this->getUnsignedVarInt(); + $recipeCount = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $recipeCount; ++$i){ $entry = []; - $entry["type"] = $recipeType = $this->getVarInt(); + $entry["type"] = $recipeType = $this->buf->getVarInt(); switch($recipeType){ case self::ENTRY_SHAPELESS: case self::ENTRY_SHULKER_BOX: case self::ENTRY_SHAPELESS_CHEMISTRY: - $entry["recipe_id"] = $this->getString(); - $ingredientCount = $this->getUnsignedVarInt(); + $entry["recipe_id"] = $this->buf->getString(); + $ingredientCount = $this->buf->getUnsignedVarInt(); /** @var Item */ $entry["input"] = []; for($j = 0; $j < $ingredientCount; ++$j){ - $entry["input"][] = $in = $this->getRecipeIngredient(); + $entry["input"][] = $in = $this->buf->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->getUnsignedVarInt(); + $resultCount = $this->buf->getUnsignedVarInt(); $entry["output"] = []; for($k = 0; $k < $resultCount; ++$k){ - $entry["output"][] = $this->getSlot(); + $entry["output"][] = $this->buf->getSlot(); } - $entry["uuid"] = $this->getUUID()->toString(); - $entry["block"] = $this->getString(); - $entry["priority"] = $this->getVarInt(); + $entry["uuid"] = $this->buf->getUUID()->toString(); + $entry["block"] = $this->buf->getString(); + $entry["priority"] = $this->buf->getVarInt(); break; case self::ENTRY_SHAPED: case self::ENTRY_SHAPED_CHEMISTRY: - $entry["recipe_id"] = $this->getString(); - $entry["width"] = $this->getVarInt(); - $entry["height"] = $this->getVarInt(); + $entry["recipe_id"] = $this->buf->getString(); + $entry["width"] = $this->buf->getVarInt(); + $entry["height"] = $this->buf->getVarInt(); $count = $entry["width"] * $entry["height"]; $entry["input"] = []; for($j = 0; $j < $count; ++$j){ - $entry["input"][] = $in = $this->getRecipeIngredient(); + $entry["input"][] = $in = $this->buf->getRecipeIngredient(); $in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system } - $resultCount = $this->getUnsignedVarInt(); + $resultCount = $this->buf->getUnsignedVarInt(); $entry["output"] = []; for($k = 0; $k < $resultCount; ++$k){ - $entry["output"][] = $this->getSlot(); + $entry["output"][] = $this->buf->getSlot(); } - $entry["uuid"] = $this->getUUID()->toString(); - $entry["block"] = $this->getString(); - $entry["priority"] = $this->getVarInt(); + $entry["uuid"] = $this->buf->getUUID()->toString(); + $entry["block"] = $this->buf->getString(); + $entry["priority"] = $this->buf->getVarInt(); break; case self::ENTRY_FURNACE: case self::ENTRY_FURNACE_DATA: - $inputId = $this->getVarInt(); + $inputId = $this->buf->getVarInt(); $inputData = -1; if($recipeType === self::ENTRY_FURNACE_DATA){ - $inputData = $this->getVarInt(); + $inputData = $this->buf->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->getSlot(); + $entry["output"] = $out = $this->buf->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->getString(); + $entry["block"] = $this->buf->getString(); break; case self::ENTRY_MULTI: - $entry["uuid"] = $this->getUUID()->toString(); + $entry["uuid"] = $this->buf->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->getUnsignedVarInt(); $i < $count; ++$i){ - $input = $this->getVarInt(); - $ingredient = $this->getVarInt(); - $output = $this->getVarInt(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $input = $this->buf->getVarInt(); + $ingredient = $this->buf->getVarInt(); + $output = $this->buf->getVarInt(); $this->potionTypeRecipes[] = new PotionTypeRecipe($input, $ingredient, $output); } - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $input = $this->getVarInt(); - $ingredient = $this->getVarInt(); - $output = $this->getVarInt(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $input = $this->buf->getVarInt(); + $ingredient = $this->buf->getVarInt(); + $output = $this->buf->getVarInt(); $this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output); } - $this->cleanRecipes = $this->getBool(); + $this->cleanRecipes = $this->buf->getBool(); } /** @@ -245,35 +245,35 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{ } protected function encodePayload() : void{ - $this->putUnsignedVarInt(count($this->entries)); + $this->buf->putUnsignedVarInt(count($this->entries)); $writer = new NetworkBinaryStream(); $counter = 0; foreach($this->entries as $d){ $entryType = self::writeEntry($d, $writer, $counter++); if($entryType >= 0){ - $this->putVarInt($entryType); - $this->put($writer->getBuffer()); + $this->buf->putVarInt($entryType); + $this->buf->put($writer->getBuffer()); }else{ - $this->putVarInt(-1); + $this->buf->putVarInt(-1); } $writer->reset(); } - $this->putUnsignedVarInt(count($this->potionTypeRecipes)); + $this->buf->putUnsignedVarInt(count($this->potionTypeRecipes)); foreach($this->potionTypeRecipes as $recipe){ - $this->putVarInt($recipe->getInputPotionType()); - $this->putVarInt($recipe->getIngredientItemId()); - $this->putVarInt($recipe->getOutputPotionType()); + $this->buf->putVarInt($recipe->getInputPotionType()); + $this->buf->putVarInt($recipe->getIngredientItemId()); + $this->buf->putVarInt($recipe->getOutputPotionType()); } - $this->putUnsignedVarInt(count($this->potionContainerRecipes)); + $this->buf->putUnsignedVarInt(count($this->potionContainerRecipes)); foreach($this->potionContainerRecipes as $recipe){ - $this->putVarInt($recipe->getInputItemId()); - $this->putVarInt($recipe->getIngredientItemId()); - $this->putVarInt($recipe->getOutputItemId()); + $this->buf->putVarInt($recipe->getInputItemId()); + $this->buf->putVarInt($recipe->getIngredientItemId()); + $this->buf->putVarInt($recipe->getOutputItemId()); } - $this->putBool($this->cleanRecipes); + $this->buf->putBool($this->cleanRecipes); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/CraftingEventPacket.php b/src/network/mcpe/protocol/CraftingEventPacket.php index 53371d75ed..e932aa08a2 100644 --- a/src/network/mcpe/protocol/CraftingEventPacket.php +++ b/src/network/mcpe/protocol/CraftingEventPacket.php @@ -45,34 +45,34 @@ class CraftingEventPacket extends DataPacket implements ServerboundPacket{ public $output = []; protected function decodePayload() : void{ - $this->windowId = $this->getByte(); - $this->type = $this->getVarInt(); - $this->id = $this->getUUID(); + $this->windowId = $this->buf->getByte(); + $this->type = $this->buf->getVarInt(); + $this->id = $this->buf->getUUID(); - $size = $this->getUnsignedVarInt(); + $size = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $size and $i < 128; ++$i){ - $this->input[] = $this->getSlot(); + $this->input[] = $this->buf->getSlot(); } - $size = $this->getUnsignedVarInt(); + $size = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $size and $i < 128; ++$i){ - $this->output[] = $this->getSlot(); + $this->output[] = $this->buf->getSlot(); } } protected function encodePayload() : void{ - $this->putByte($this->windowId); - $this->putVarInt($this->type); - $this->putUUID($this->id); + $this->buf->putByte($this->windowId); + $this->buf->putVarInt($this->type); + $this->buf->putUUID($this->id); - $this->putUnsignedVarInt(count($this->input)); + $this->buf->putUnsignedVarInt(count($this->input)); foreach($this->input as $item){ - $this->putSlot($item); + $this->buf->putSlot($item); } - $this->putUnsignedVarInt(count($this->output)); + $this->buf->putUnsignedVarInt(count($this->output)); foreach($this->output as $item){ - $this->putSlot($item); + $this->buf->putSlot($item); } } diff --git a/src/network/mcpe/protocol/DataPacket.php b/src/network/mcpe/protocol/DataPacket.php index 53fd9bd716..390e141c97 100644 --- a/src/network/mcpe/protocol/DataPacket.php +++ b/src/network/mcpe/protocol/DataPacket.php @@ -35,7 +35,7 @@ use function is_object; use function is_string; use function method_exists; -abstract class DataPacket extends NetworkBinaryStream implements Packet{ +abstract class DataPacket implements Packet{ public const NETWORK_ID = 0; @@ -43,6 +43,17 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ public $senderSubId = 0; /** @var int */ public $recipientSubId = 0; + + /** @var NetworkBinaryStream */ + protected $buf; + + public function __construct(){ + $this->buf = new NetworkBinaryStream(); + } + + public function getBinaryStream() : NetworkBinaryStream{ + return $this->buf; + } public function pid() : int{ return $this::NETWORK_ID; @@ -60,7 +71,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ * @throws BadPacketException */ final public function decode() : void{ - $this->rewind(); + $this->buf->rewind(); try{ $this->decodeHeader(); $this->decodePayload(); @@ -74,7 +85,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ * @throws \UnexpectedValueException */ protected function decodeHeader() : void{ - $pid = $this->getUnsignedVarInt(); + $pid = $this->buf->getUnsignedVarInt(); if($pid !== static::NETWORK_ID){ //TODO: this means a logical error in the code, but how to prevent it from happening? throw new \UnexpectedValueException("Expected " . static::NETWORK_ID . " for packet ID, got $pid"); @@ -90,13 +101,13 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ abstract protected function decodePayload() : void; final public function encode() : void{ - $this->reset(); + $this->buf->reset(); $this->encodeHeader(); $this->encodePayload(); } protected function encodeHeader() : void{ - $this->putUnsignedVarInt(static::NETWORK_ID); + $this->buf->putUnsignedVarInt(static::NETWORK_ID); } /** @@ -104,24 +115,6 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ */ abstract protected function encodePayload() : void; - /** - * @return mixed[] - */ - public function __debugInfo() : array{ - $data = []; - foreach((array) $this as $k => $v){ - if($v === $this->getBuffer()){ - $data[$k] = bin2hex($v); - }elseif(is_string($v) or (is_object($v) and method_exists($v, "__toString"))){ - $data[$k] = Utils::printable((string) $v); - }else{ - $data[$k] = $v; - } - } - - return $data; - } - /** * @param string $name * diff --git a/src/network/mcpe/protocol/DisconnectPacket.php b/src/network/mcpe/protocol/DisconnectPacket.php index 3c665d3447..25f84743fc 100644 --- a/src/network/mcpe/protocol/DisconnectPacket.php +++ b/src/network/mcpe/protocol/DisconnectPacket.php @@ -53,16 +53,16 @@ class DisconnectPacket extends DataPacket implements ClientboundPacket, Serverbo } protected function decodePayload() : void{ - $this->hideDisconnectionScreen = $this->getBool(); + $this->hideDisconnectionScreen = $this->buf->getBool(); if(!$this->hideDisconnectionScreen){ - $this->message = $this->getString(); + $this->message = $this->buf->getString(); } } protected function encodePayload() : void{ - $this->putBool($this->hideDisconnectionScreen); + $this->buf->putBool($this->hideDisconnectionScreen); if(!$this->hideDisconnectionScreen){ - $this->putString($this->message); + $this->buf->putString($this->message); } } diff --git a/src/network/mcpe/protocol/EducationSettingsPacket.php b/src/network/mcpe/protocol/EducationSettingsPacket.php index 498cf9f0d4..a561b5acb8 100644 --- a/src/network/mcpe/protocol/EducationSettingsPacket.php +++ b/src/network/mcpe/protocol/EducationSettingsPacket.php @@ -51,13 +51,13 @@ class EducationSettingsPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->codeBuilderDefaultUri = $this->getString(); - $this->hasQuiz = $this->getBool(); + $this->codeBuilderDefaultUri = $this->buf->getString(); + $this->hasQuiz = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putString($this->codeBuilderDefaultUri); - $this->putBool($this->hasQuiz); + $this->buf->putString($this->codeBuilderDefaultUri); + $this->buf->putBool($this->hasQuiz); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/EmotePacket.php b/src/network/mcpe/protocol/EmotePacket.php index 9bf12c3306..23194e6809 100644 --- a/src/network/mcpe/protocol/EmotePacket.php +++ b/src/network/mcpe/protocol/EmotePacket.php @@ -63,15 +63,15 @@ class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPa } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->emoteId = $this->getString(); - $this->flags = $this->getByte(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->emoteId = $this->buf->getString(); + $this->flags = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putString($this->emoteId); - $this->putByte($this->flags); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putString($this->emoteId); + $this->buf->putByte($this->flags); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/EventPacket.php b/src/network/mcpe/protocol/EventPacket.php index d44edecd2f..6dffeb7b4d 100644 --- a/src/network/mcpe/protocol/EventPacket.php +++ b/src/network/mcpe/protocol/EventPacket.php @@ -57,17 +57,17 @@ class EventPacket extends DataPacket implements ClientboundPacket{ public $type; protected function decodePayload() : void{ - $this->playerRuntimeId = $this->getEntityRuntimeId(); - $this->eventData = $this->getVarInt(); - $this->type = $this->getByte(); + $this->playerRuntimeId = $this->buf->getEntityRuntimeId(); + $this->eventData = $this->buf->getVarInt(); + $this->type = $this->buf->getByte(); //TODO: nice confusing mess } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->playerRuntimeId); - $this->putVarInt($this->eventData); - $this->putByte($this->type); + $this->buf->putEntityRuntimeId($this->playerRuntimeId); + $this->buf->putVarInt($this->eventData); + $this->buf->putByte($this->type); //TODO: also nice confusing mess } diff --git a/src/network/mcpe/protocol/GameRulesChangedPacket.php b/src/network/mcpe/protocol/GameRulesChangedPacket.php index 76895424df..7acbe1abcb 100644 --- a/src/network/mcpe/protocol/GameRulesChangedPacket.php +++ b/src/network/mcpe/protocol/GameRulesChangedPacket.php @@ -37,11 +37,11 @@ class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{ public $gameRules = []; protected function decodePayload() : void{ - $this->gameRules = $this->getGameRules(); + $this->gameRules = $this->buf->getGameRules(); } protected function encodePayload() : void{ - $this->putGameRules($this->gameRules); + $this->buf->putGameRules($this->gameRules); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/GuiDataPickItemPacket.php b/src/network/mcpe/protocol/GuiDataPickItemPacket.php index cdba42aaef..f898dc6b1c 100644 --- a/src/network/mcpe/protocol/GuiDataPickItemPacket.php +++ b/src/network/mcpe/protocol/GuiDataPickItemPacket.php @@ -38,15 +38,15 @@ class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{ public $hotbarSlot; protected function decodePayload() : void{ - $this->itemDescription = $this->getString(); - $this->itemEffects = $this->getString(); - $this->hotbarSlot = $this->getLInt(); + $this->itemDescription = $this->buf->getString(); + $this->itemEffects = $this->buf->getString(); + $this->hotbarSlot = $this->buf->getLInt(); } protected function encodePayload() : void{ - $this->putString($this->itemDescription); - $this->putString($this->itemEffects); - $this->putLInt($this->hotbarSlot); + $this->buf->putString($this->itemDescription); + $this->buf->putString($this->itemEffects); + $this->buf->putLInt($this->hotbarSlot); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/HurtArmorPacket.php b/src/network/mcpe/protocol/HurtArmorPacket.php index b9e236c4f7..7ad5174a28 100644 --- a/src/network/mcpe/protocol/HurtArmorPacket.php +++ b/src/network/mcpe/protocol/HurtArmorPacket.php @@ -34,11 +34,11 @@ class HurtArmorPacket extends DataPacket implements ClientboundPacket{ public $health; protected function decodePayload() : void{ - $this->health = $this->getVarInt(); + $this->health = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->health); + $this->buf->putVarInt($this->health); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/InteractPacket.php b/src/network/mcpe/protocol/InteractPacket.php index 03773799f0..715b248092 100644 --- a/src/network/mcpe/protocol/InteractPacket.php +++ b/src/network/mcpe/protocol/InteractPacket.php @@ -48,25 +48,25 @@ class InteractPacket extends DataPacket implements ServerboundPacket{ public $z; protected function decodePayload() : void{ - $this->action = $this->getByte(); - $this->target = $this->getEntityRuntimeId(); + $this->action = $this->buf->getByte(); + $this->target = $this->buf->getEntityRuntimeId(); if($this->action === self::ACTION_MOUSEOVER){ //TODO: should this be a vector3? - $this->x = $this->getLFloat(); - $this->y = $this->getLFloat(); - $this->z = $this->getLFloat(); + $this->x = $this->buf->getLFloat(); + $this->y = $this->buf->getLFloat(); + $this->z = $this->buf->getLFloat(); } } protected function encodePayload() : void{ - $this->putByte($this->action); - $this->putEntityRuntimeId($this->target); + $this->buf->putByte($this->action); + $this->buf->putEntityRuntimeId($this->target); if($this->action === self::ACTION_MOUSEOVER){ - $this->putLFloat($this->x); - $this->putLFloat($this->y); - $this->putLFloat($this->z); + $this->buf->putLFloat($this->x); + $this->buf->putLFloat($this->y); + $this->buf->putLFloat($this->z); } } diff --git a/src/network/mcpe/protocol/InventoryContentPacket.php b/src/network/mcpe/protocol/InventoryContentPacket.php index 2054dc7323..0375a651b5 100644 --- a/src/network/mcpe/protocol/InventoryContentPacket.php +++ b/src/network/mcpe/protocol/InventoryContentPacket.php @@ -50,18 +50,18 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->windowId = $this->getUnsignedVarInt(); - $count = $this->getUnsignedVarInt(); + $this->windowId = $this->buf->getUnsignedVarInt(); + $count = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ - $this->items[] = $this->getSlot(); + $this->items[] = $this->buf->getSlot(); } } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->windowId); - $this->putUnsignedVarInt(count($this->items)); + $this->buf->putUnsignedVarInt($this->windowId); + $this->buf->putUnsignedVarInt(count($this->items)); foreach($this->items as $item){ - $this->putSlot($item); + $this->buf->putSlot($item); } } diff --git a/src/network/mcpe/protocol/InventorySlotPacket.php b/src/network/mcpe/protocol/InventorySlotPacket.php index 5fc2f76c97..6c9c526ddc 100644 --- a/src/network/mcpe/protocol/InventorySlotPacket.php +++ b/src/network/mcpe/protocol/InventorySlotPacket.php @@ -47,15 +47,15 @@ class InventorySlotPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->windowId = $this->getUnsignedVarInt(); - $this->inventorySlot = $this->getUnsignedVarInt(); - $this->item = $this->getSlot(); + $this->windowId = $this->buf->getUnsignedVarInt(); + $this->inventorySlot = $this->buf->getUnsignedVarInt(); + $this->item = $this->buf->getSlot(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->windowId); - $this->putUnsignedVarInt($this->inventorySlot); - $this->putSlot($this->item); + $this->buf->putUnsignedVarInt($this->windowId); + $this->buf->putUnsignedVarInt($this->inventorySlot); + $this->buf->putSlot($this->item); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/InventoryTransactionPacket.php b/src/network/mcpe/protocol/InventoryTransactionPacket.php index a4cb59f834..9d34042528 100644 --- a/src/network/mcpe/protocol/InventoryTransactionPacket.php +++ b/src/network/mcpe/protocol/InventoryTransactionPacket.php @@ -50,7 +50,7 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket public $trData; protected function decodePayload() : void{ - $transactionType = $this->getUnsignedVarInt(); + $transactionType = $this->buf->getUnsignedVarInt(); switch($transactionType){ case self::TYPE_NORMAL: @@ -72,12 +72,12 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket throw new BadPacketException("Unknown transaction type $transactionType"); } - $this->trData->decode($this); + $this->trData->decode($this->buf); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->trData->getTypeId()); - $this->trData->encode($this); + $this->buf->putUnsignedVarInt($this->trData->getTypeId()); + $this->trData->encode($this->buf); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ItemFrameDropItemPacket.php b/src/network/mcpe/protocol/ItemFrameDropItemPacket.php index c0a16b1eeb..f9bfb9753e 100644 --- a/src/network/mcpe/protocol/ItemFrameDropItemPacket.php +++ b/src/network/mcpe/protocol/ItemFrameDropItemPacket.php @@ -39,11 +39,11 @@ class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{ public $z; protected function decodePayload() : void{ - $this->getBlockPosition($this->x, $this->y, $this->z); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); } protected function encodePayload() : void{ - $this->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LabTablePacket.php b/src/network/mcpe/protocol/LabTablePacket.php index 70e0640cf9..09a5b11310 100644 --- a/src/network/mcpe/protocol/LabTablePacket.php +++ b/src/network/mcpe/protocol/LabTablePacket.php @@ -44,15 +44,15 @@ class LabTablePacket extends DataPacket implements ClientboundPacket, Serverboun public $reactionType; protected function decodePayload() : void{ - $this->uselessByte = $this->getByte(); - $this->getSignedBlockPosition($this->x, $this->y, $this->z); - $this->reactionType = $this->getByte(); + $this->uselessByte = $this->buf->getByte(); + $this->buf->getSignedBlockPosition($this->x, $this->y, $this->z); + $this->reactionType = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putByte($this->uselessByte); - $this->putSignedBlockPosition($this->x, $this->y, $this->z); - $this->putByte($this->reactionType); + $this->buf->putByte($this->uselessByte); + $this->buf->putSignedBlockPosition($this->x, $this->y, $this->z); + $this->buf->putByte($this->reactionType); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LecternUpdatePacket.php b/src/network/mcpe/protocol/LecternUpdatePacket.php index a3ddf31d57..c46904d2e2 100644 --- a/src/network/mcpe/protocol/LecternUpdatePacket.php +++ b/src/network/mcpe/protocol/LecternUpdatePacket.php @@ -44,17 +44,17 @@ class LecternUpdatePacket extends DataPacket implements ServerboundPacket{ public $dropBook; protected function decodePayload() : void{ - $this->page = $this->getByte(); - $this->totalPages = $this->getByte(); - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->dropBook = $this->getBool(); + $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 encodePayload() : void{ - $this->putByte($this->page); - $this->putByte($this->totalPages); - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putBool($this->dropBook); + $this->buf->putByte($this->page); + $this->buf->putByte($this->totalPages); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putBool($this->dropBook); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelChunkPacket.php b/src/network/mcpe/protocol/LevelChunkPacket.php index 38f578cbcd..f244911987 100644 --- a/src/network/mcpe/protocol/LevelChunkPacket.php +++ b/src/network/mcpe/protocol/LevelChunkPacket.php @@ -101,30 +101,30 @@ class LevelChunkPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->chunkX = $this->getVarInt(); - $this->chunkZ = $this->getVarInt(); - $this->subChunkCount = $this->getUnsignedVarInt(); - $this->cacheEnabled = $this->getBool(); + $this->chunkX = $this->buf->getVarInt(); + $this->chunkZ = $this->buf->getVarInt(); + $this->subChunkCount = $this->buf->getUnsignedVarInt(); + $this->cacheEnabled = $this->buf->getBool(); if($this->cacheEnabled){ - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $this->usedBlobHashes[] = $this->getLLong(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $this->usedBlobHashes[] = $this->buf->getLLong(); } } - $this->extraPayload = $this->getString(); + $this->extraPayload = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putVarInt($this->chunkX); - $this->putVarInt($this->chunkZ); - $this->putUnsignedVarInt($this->subChunkCount); - $this->putBool($this->cacheEnabled); + $this->buf->putVarInt($this->chunkX); + $this->buf->putVarInt($this->chunkZ); + $this->buf->putUnsignedVarInt($this->subChunkCount); + $this->buf->putBool($this->cacheEnabled); if($this->cacheEnabled){ - $this->putUnsignedVarInt(count($this->usedBlobHashes)); + $this->buf->putUnsignedVarInt(count($this->usedBlobHashes)); foreach($this->usedBlobHashes as $hash){ - $this->putLLong($hash); + $this->buf->putLLong($hash); } } - $this->putString($this->extraPayload); + $this->buf->putString($this->extraPayload); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelEventGenericPacket.php b/src/network/mcpe/protocol/LevelEventGenericPacket.php index 1c6c0eaecd..6ae513b893 100644 --- a/src/network/mcpe/protocol/LevelEventGenericPacket.php +++ b/src/network/mcpe/protocol/LevelEventGenericPacket.php @@ -54,13 +54,13 @@ class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->eventId = $this->getVarInt(); - $this->eventData = $this->getRemaining(); + $this->eventId = $this->buf->getVarInt(); + $this->eventData = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->putVarInt($this->eventId); - $this->put($this->eventData); + $this->buf->putVarInt($this->eventId); + $this->buf->put($this->eventData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelEventPacket.php b/src/network/mcpe/protocol/LevelEventPacket.php index 99a3231d30..3c1d8e8a54 100644 --- a/src/network/mcpe/protocol/LevelEventPacket.php +++ b/src/network/mcpe/protocol/LevelEventPacket.php @@ -134,15 +134,15 @@ class LevelEventPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->evid = $this->getVarInt(); - $this->position = $this->getVector3(); - $this->data = $this->getVarInt(); + $this->evid = $this->buf->getVarInt(); + $this->position = $this->buf->getVector3(); + $this->data = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->evid); - $this->putVector3Nullable($this->position); - $this->putVarInt($this->data); + $this->buf->putVarInt($this->evid); + $this->buf->putVector3Nullable($this->position); + $this->buf->putVarInt($this->data); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelSoundEventPacket.php b/src/network/mcpe/protocol/LevelSoundEventPacket.php index 503622c02f..86d2631d8a 100644 --- a/src/network/mcpe/protocol/LevelSoundEventPacket.php +++ b/src/network/mcpe/protocol/LevelSoundEventPacket.php @@ -336,21 +336,21 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser public $disableRelativeVolume = false; protected function decodePayload() : void{ - $this->sound = $this->getUnsignedVarInt(); - $this->position = $this->getVector3(); - $this->extraData = $this->getVarInt(); - $this->entityType = $this->getString(); - $this->isBabyMob = $this->getBool(); - $this->disableRelativeVolume = $this->getBool(); + $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 encodePayload() : void{ - $this->putUnsignedVarInt($this->sound); - $this->putVector3($this->position); - $this->putVarInt($this->extraData); - $this->putString($this->entityType); - $this->putBool($this->isBabyMob); - $this->putBool($this->disableRelativeVolume); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelSoundEventPacketV1.php b/src/network/mcpe/protocol/LevelSoundEventPacketV1.php index ae45de3e4b..cb20f6042b 100644 --- a/src/network/mcpe/protocol/LevelSoundEventPacketV1.php +++ b/src/network/mcpe/protocol/LevelSoundEventPacketV1.php @@ -48,21 +48,21 @@ class LevelSoundEventPacketV1 extends DataPacket{ public $disableRelativeVolume = false; protected function decodePayload() : void{ - $this->sound = $this->getByte(); - $this->position = $this->getVector3(); - $this->extraData = $this->getVarInt(); - $this->entityType = $this->getVarInt(); - $this->isBabyMob = $this->getBool(); - $this->disableRelativeVolume = $this->getBool(); + $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 encodePayload() : void{ - $this->putByte($this->sound); - $this->putVector3($this->position); - $this->putVarInt($this->extraData); - $this->putVarInt($this->entityType); - $this->putBool($this->isBabyMob); - $this->putBool($this->disableRelativeVolume); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LevelSoundEventPacketV2.php b/src/network/mcpe/protocol/LevelSoundEventPacketV2.php index d540c4111f..753f6c9bad 100644 --- a/src/network/mcpe/protocol/LevelSoundEventPacketV2.php +++ b/src/network/mcpe/protocol/LevelSoundEventPacketV2.php @@ -48,21 +48,21 @@ class LevelSoundEventPacketV2 extends DataPacket{ public $disableRelativeVolume = false; protected function decodePayload() : void{ - $this->sound = $this->getByte(); - $this->position = $this->getVector3(); - $this->extraData = $this->getVarInt(); - $this->entityType = $this->getString(); - $this->isBabyMob = $this->getBool(); - $this->disableRelativeVolume = $this->getBool(); + $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 encodePayload() : void{ - $this->putByte($this->sound); - $this->putVector3($this->position); - $this->putVarInt($this->extraData); - $this->putString($this->entityType); - $this->putBool($this->isBabyMob); - $this->putBool($this->disableRelativeVolume); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/LoginPacket.php b/src/network/mcpe/protocol/LoginPacket.php index 92e7a2cd55..4206694ebd 100644 --- a/src/network/mcpe/protocol/LoginPacket.php +++ b/src/network/mcpe/protocol/LoginPacket.php @@ -109,7 +109,7 @@ class LoginPacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->protocol = $this->getInt(); + $this->protocol = $this->buf->getInt(); $this->decodeConnectionRequest(); } @@ -134,7 +134,7 @@ class LoginPacket extends DataPacket implements ServerboundPacket{ * @throws BinaryDataException */ protected function decodeConnectionRequest() : void{ - $buffer = new BinaryStream($this->getString()); + $buffer = new BinaryStream($this->buf->getString()); $chainData = json_decode($buffer->get($buffer->getLInt()), true); if(!is_array($chainData)){ diff --git a/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php b/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php index 92b8e9d461..3405c7b3b7 100644 --- a/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php +++ b/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php @@ -36,13 +36,13 @@ class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{ public $newMapId; protected function decodePayload() : void{ - $this->originalMapId = $this->getEntityUniqueId(); - $this->newMapId = $this->getEntityUniqueId(); + $this->originalMapId = $this->buf->getEntityUniqueId(); + $this->newMapId = $this->buf->getEntityUniqueId(); } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->originalMapId); - $this->putEntityUniqueId($this->newMapId); + $this->buf->putEntityUniqueId($this->originalMapId); + $this->buf->putEntityUniqueId($this->newMapId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MapInfoRequestPacket.php b/src/network/mcpe/protocol/MapInfoRequestPacket.php index 08248acf42..6aa6c21551 100644 --- a/src/network/mcpe/protocol/MapInfoRequestPacket.php +++ b/src/network/mcpe/protocol/MapInfoRequestPacket.php @@ -34,11 +34,11 @@ class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{ public $mapId; protected function decodePayload() : void{ - $this->mapId = $this->getEntityUniqueId(); + $this->mapId = $this->buf->getEntityUniqueId(); } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->mapId); + $this->buf->putEntityUniqueId($this->mapId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MobArmorEquipmentPacket.php b/src/network/mcpe/protocol/MobArmorEquipmentPacket.php index 22b1556e82..d6cffa39b9 100644 --- a/src/network/mcpe/protocol/MobArmorEquipmentPacket.php +++ b/src/network/mcpe/protocol/MobArmorEquipmentPacket.php @@ -56,19 +56,19 @@ class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, S } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->head = $this->getSlot(); - $this->chest = $this->getSlot(); - $this->legs = $this->getSlot(); - $this->feet = $this->getSlot(); + $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 encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putSlot($this->head); - $this->putSlot($this->chest); - $this->putSlot($this->legs); - $this->putSlot($this->feet); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MobEffectPacket.php b/src/network/mcpe/protocol/MobEffectPacket.php index 03912a5fc6..14d29fd77a 100644 --- a/src/network/mcpe/protocol/MobEffectPacket.php +++ b/src/network/mcpe/protocol/MobEffectPacket.php @@ -67,21 +67,21 @@ class MobEffectPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->eventId = $this->getByte(); - $this->effectId = $this->getVarInt(); - $this->amplifier = $this->getVarInt(); - $this->particles = $this->getBool(); - $this->duration = $this->getVarInt(); + $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 encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putByte($this->eventId); - $this->putVarInt($this->effectId); - $this->putVarInt($this->amplifier); - $this->putBool($this->particles); - $this->putVarInt($this->duration); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MobEquipmentPacket.php b/src/network/mcpe/protocol/MobEquipmentPacket.php index 8b5486218d..0393df687b 100644 --- a/src/network/mcpe/protocol/MobEquipmentPacket.php +++ b/src/network/mcpe/protocol/MobEquipmentPacket.php @@ -53,19 +53,19 @@ class MobEquipmentPacket extends DataPacket implements ClientboundPacket, Server } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->item = $this->getSlot(); - $this->inventorySlot = $this->getByte(); - $this->hotbarSlot = $this->getByte(); - $this->windowId = $this->getByte(); + $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 encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putSlot($this->item); - $this->putByte($this->inventorySlot); - $this->putByte($this->hotbarSlot); - $this->putByte($this->windowId); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ModalFormRequestPacket.php b/src/network/mcpe/protocol/ModalFormRequestPacket.php index b60fb8cdf7..9f17b74509 100644 --- a/src/network/mcpe/protocol/ModalFormRequestPacket.php +++ b/src/network/mcpe/protocol/ModalFormRequestPacket.php @@ -43,13 +43,13 @@ class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->formId = $this->getUnsignedVarInt(); - $this->formData = $this->getString(); + $this->formId = $this->buf->getUnsignedVarInt(); + $this->formData = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->formId); - $this->putString($this->formData); + $this->buf->putUnsignedVarInt($this->formId); + $this->buf->putString($this->formData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ModalFormResponsePacket.php b/src/network/mcpe/protocol/ModalFormResponsePacket.php index f97a7c0c33..06af847fed 100644 --- a/src/network/mcpe/protocol/ModalFormResponsePacket.php +++ b/src/network/mcpe/protocol/ModalFormResponsePacket.php @@ -36,13 +36,13 @@ class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{ public $formData; //json protected function decodePayload() : void{ - $this->formId = $this->getUnsignedVarInt(); - $this->formData = $this->getString(); + $this->formId = $this->buf->getUnsignedVarInt(); + $this->formData = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->formId); - $this->putString($this->formData); + $this->buf->putUnsignedVarInt($this->formId); + $this->buf->putString($this->formData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MoveActorAbsolutePacket.php b/src/network/mcpe/protocol/MoveActorAbsolutePacket.php index 04116f46f8..566ba2b9dd 100644 --- a/src/network/mcpe/protocol/MoveActorAbsolutePacket.php +++ b/src/network/mcpe/protocol/MoveActorAbsolutePacket.php @@ -48,21 +48,21 @@ class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, S public $zRot; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->flags = $this->getByte(); - $this->position = $this->getVector3(); - $this->xRot = $this->getByteRotation(); - $this->yRot = $this->getByteRotation(); - $this->zRot = $this->getByteRotation(); + $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 encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putByte($this->flags); - $this->putVector3($this->position); - $this->putByteRotation($this->xRot); - $this->putByteRotation($this->yRot); - $this->putByteRotation($this->zRot); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/MoveActorDeltaPacket.php b/src/network/mcpe/protocol/MoveActorDeltaPacket.php index c030415470..d252baf8e7 100644 --- a/src/network/mcpe/protocol/MoveActorDeltaPacket.php +++ b/src/network/mcpe/protocol/MoveActorDeltaPacket.php @@ -60,7 +60,7 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{ */ private function maybeReadCoord(int $flag) : int{ if(($this->flags & $flag) !== 0){ - return $this->getVarInt(); + return $this->buf->getVarInt(); } return 0; } @@ -70,14 +70,14 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{ */ private function maybeReadRotation(int $flag) : float{ if(($this->flags & $flag) !== 0){ - return $this->getByteRotation(); + return $this->buf->getByteRotation(); } return 0.0; } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->flags = $this->getLShort(); + $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); @@ -88,19 +88,19 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{ private function maybeWriteCoord(int $flag, int $val) : void{ if(($this->flags & $flag) !== 0){ - $this->putVarInt($val); + $this->buf->putVarInt($val); } } private function maybeWriteRotation(int $flag, float $val) : void{ if(($this->flags & $flag) !== 0){ - $this->putByteRotation($val); + $this->buf->putByteRotation($val); } } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putLShort($this->flags); + $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); diff --git a/src/network/mcpe/protocol/MovePlayerPacket.php b/src/network/mcpe/protocol/MovePlayerPacket.php index 98786299e1..3c42186a26 100644 --- a/src/network/mcpe/protocol/MovePlayerPacket.php +++ b/src/network/mcpe/protocol/MovePlayerPacket.php @@ -58,32 +58,32 @@ class MovePlayerPacket extends DataPacket implements ClientboundPacket, Serverbo public $teleportItem = 0; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->position = $this->getVector3(); - $this->pitch = $this->getLFloat(); - $this->yaw = $this->getLFloat(); - $this->headYaw = $this->getLFloat(); - $this->mode = $this->getByte(); - $this->onGround = $this->getBool(); - $this->ridingEid = $this->getEntityRuntimeId(); + $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(); if($this->mode === MovePlayerPacket::MODE_TELEPORT){ - $this->teleportCause = $this->getLInt(); - $this->teleportItem = $this->getLInt(); + $this->teleportCause = $this->buf->getLInt(); + $this->teleportItem = $this->buf->getLInt(); } } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3($this->position); - $this->putLFloat($this->pitch); - $this->putLFloat($this->yaw); - $this->putLFloat($this->headYaw); //TODO - $this->putByte($this->mode); - $this->putBool($this->onGround); - $this->putEntityRuntimeId($this->ridingEid); + $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); if($this->mode === MovePlayerPacket::MODE_TELEPORT){ - $this->putLInt($this->teleportCause); - $this->putLInt($this->teleportItem); + $this->buf->putLInt($this->teleportCause); + $this->buf->putLInt($this->teleportItem); } } diff --git a/src/network/mcpe/protocol/MultiplayerSettingsPacket.php b/src/network/mcpe/protocol/MultiplayerSettingsPacket.php index 61d5e85fdd..7b59c8a8a9 100644 --- a/src/network/mcpe/protocol/MultiplayerSettingsPacket.php +++ b/src/network/mcpe/protocol/MultiplayerSettingsPacket.php @@ -48,11 +48,11 @@ class MultiplayerSettingsPacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->action = $this->getVarInt(); + $this->action = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->action); + $this->buf->putVarInt($this->action); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php b/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php index fc78a0b9f1..0fccd283a1 100644 --- a/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php +++ b/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php @@ -49,13 +49,13 @@ class NetworkChunkPublisherUpdatePacket extends DataPacket implements Clientboun } protected function decodePayload() : void{ - $this->getSignedBlockPosition($this->x, $this->y, $this->z); - $this->radius = $this->getUnsignedVarInt(); + $this->buf->getSignedBlockPosition($this->x, $this->y, $this->z); + $this->radius = $this->buf->getUnsignedVarInt(); } protected function encodePayload() : void{ - $this->putSignedBlockPosition($this->x, $this->y, $this->z); - $this->putUnsignedVarInt($this->radius); + $this->buf->putSignedBlockPosition($this->x, $this->y, $this->z); + $this->buf->putUnsignedVarInt($this->radius); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/NetworkSettingsPacket.php b/src/network/mcpe/protocol/NetworkSettingsPacket.php index d509191664..7d1096eb4f 100644 --- a/src/network/mcpe/protocol/NetworkSettingsPacket.php +++ b/src/network/mcpe/protocol/NetworkSettingsPacket.php @@ -47,11 +47,11 @@ class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->compressionThreshold = $this->getLShort(); + $this->compressionThreshold = $this->buf->getLShort(); } protected function encodePayload() : void{ - $this->putLShort($this->compressionThreshold); + $this->buf->putLShort($this->compressionThreshold); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/NetworkStackLatencyPacket.php b/src/network/mcpe/protocol/NetworkStackLatencyPacket.php index 27add3d3c2..327303c6e0 100644 --- a/src/network/mcpe/protocol/NetworkStackLatencyPacket.php +++ b/src/network/mcpe/protocol/NetworkStackLatencyPacket.php @@ -36,13 +36,13 @@ class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket, public $needResponse; protected function decodePayload() : void{ - $this->timestamp = $this->getLLong(); - $this->needResponse = $this->getBool(); + $this->timestamp = $this->buf->getLLong(); + $this->needResponse = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putLLong($this->timestamp); - $this->putBool($this->needResponse); + $this->buf->putLLong($this->timestamp); + $this->buf->putBool($this->needResponse); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/NpcRequestPacket.php b/src/network/mcpe/protocol/NpcRequestPacket.php index 7e9e6c69aa..d01c71d830 100644 --- a/src/network/mcpe/protocol/NpcRequestPacket.php +++ b/src/network/mcpe/protocol/NpcRequestPacket.php @@ -40,17 +40,17 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{ public $actionType; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->requestType = $this->getByte(); - $this->commandString = $this->getString(); - $this->actionType = $this->getByte(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->requestType = $this->buf->getByte(); + $this->commandString = $this->buf->getString(); + $this->actionType = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putByte($this->requestType); - $this->putString($this->commandString); - $this->putByte($this->actionType); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putByte($this->requestType); + $this->buf->putString($this->commandString); + $this->buf->putByte($this->actionType); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php b/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php index e4cf449404..0aaf2b218f 100644 --- a/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php +++ b/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php @@ -34,11 +34,11 @@ class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPa public $effectId; protected function decodePayload() : void{ - $this->effectId = $this->getLInt(); //unsigned + $this->effectId = $this->buf->getLInt(); //unsigned } protected function encodePayload() : void{ - $this->putLInt($this->effectId); + $this->buf->putLInt($this->effectId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/Packet.php b/src/network/mcpe/protocol/Packet.php index 6e68038726..ded5c0f707 100644 --- a/src/network/mcpe/protocol/Packet.php +++ b/src/network/mcpe/protocol/Packet.php @@ -25,27 +25,11 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\BadPacketException; use pocketmine\network\mcpe\handler\PacketHandler; +use pocketmine\network\mcpe\serializer\NetworkBinaryStream; interface Packet{ - public function setOffset(int $offset) : void; - - /** - * TODO: this can't have a native return type yet because of incompatibility with BinaryUtils - * really this should be addressed by making packets not extend BinaryStream, but that's a task for another day. - * - * @return void - */ - public function setBuffer(string $buffer = "", int $offset = 0); - - public function getOffset() : int; - - public function getBuffer() : string; - - /** - * Returns whether the offset has reached the end of the buffer. - */ - public function feof() : bool; + public function getBinaryStream() : NetworkBinaryStream; public function pid() : int; diff --git a/src/network/mcpe/protocol/PacketPool.php b/src/network/mcpe/protocol/PacketPool.php index 4596c40e6d..f58f900efa 100644 --- a/src/network/mcpe/protocol/PacketPool.php +++ b/src/network/mcpe/protocol/PacketPool.php @@ -191,7 +191,7 @@ class PacketPool{ public static function getPacket(string $buffer) : Packet{ $offset = 0; $pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset)); - $pk->setBuffer($buffer, $offset); + $pk->getBinaryStream()->setBuffer($buffer, $offset); return $pk; } diff --git a/src/network/mcpe/protocol/PhotoTransferPacket.php b/src/network/mcpe/protocol/PhotoTransferPacket.php index cf32d1472e..a08c56eada 100644 --- a/src/network/mcpe/protocol/PhotoTransferPacket.php +++ b/src/network/mcpe/protocol/PhotoTransferPacket.php @@ -38,15 +38,15 @@ class PhotoTransferPacket extends DataPacket implements ClientboundPacket{ 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->getString(); - $this->photoData = $this->getString(); - $this->bookId = $this->getString(); + $this->photoName = $this->buf->getString(); + $this->photoData = $this->buf->getString(); + $this->bookId = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->photoName); - $this->putString($this->photoData); - $this->putString($this->bookId); + $this->buf->putString($this->photoName); + $this->buf->putString($this->photoData); + $this->buf->putString($this->bookId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlaySoundPacket.php b/src/network/mcpe/protocol/PlaySoundPacket.php index cda6b01a14..e90f1f403c 100644 --- a/src/network/mcpe/protocol/PlaySoundPacket.php +++ b/src/network/mcpe/protocol/PlaySoundPacket.php @@ -44,20 +44,20 @@ class PlaySoundPacket extends DataPacket implements ClientboundPacket{ public $pitch; protected function decodePayload() : void{ - $this->soundName = $this->getString(); - $this->getBlockPosition($this->x, $this->y, $this->z); + $this->soundName = $this->buf->getString(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); $this->x /= 8; $this->y /= 8; $this->z /= 8; - $this->volume = $this->getLFloat(); - $this->pitch = $this->getLFloat(); + $this->volume = $this->buf->getLFloat(); + $this->pitch = $this->buf->getLFloat(); } protected function encodePayload() : void{ - $this->putString($this->soundName); - $this->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8)); - $this->putLFloat($this->volume); - $this->putLFloat($this->pitch); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlayStatusPacket.php b/src/network/mcpe/protocol/PlayStatusPacket.php index 9f4402d18b..b0f88740d2 100644 --- a/src/network/mcpe/protocol/PlayStatusPacket.php +++ b/src/network/mcpe/protocol/PlayStatusPacket.php @@ -49,7 +49,7 @@ class PlayStatusPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->status = $this->getInt(); + $this->status = $this->buf->getInt(); } public function canBeSentBeforeLogin() : bool{ @@ -57,7 +57,7 @@ class PlayStatusPacket extends DataPacket implements ClientboundPacket{ } protected function encodePayload() : void{ - $this->putInt($this->status); + $this->buf->putInt($this->status); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlayerActionPacket.php b/src/network/mcpe/protocol/PlayerActionPacket.php index 7cffd0c5fe..2985a206e7 100644 --- a/src/network/mcpe/protocol/PlayerActionPacket.php +++ b/src/network/mcpe/protocol/PlayerActionPacket.php @@ -71,17 +71,17 @@ class PlayerActionPacket extends DataPacket implements ServerboundPacket{ public $face; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->action = $this->getVarInt(); - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->face = $this->getVarInt(); + $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 encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVarInt($this->action); - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putVarInt($this->face); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putVarInt($this->action); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putVarInt($this->face); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlayerAuthInputPacket.php b/src/network/mcpe/protocol/PlayerAuthInputPacket.php index 9ab85d79e0..12fdcc80bc 100644 --- a/src/network/mcpe/protocol/PlayerAuthInputPacket.php +++ b/src/network/mcpe/protocol/PlayerAuthInputPacket.php @@ -128,33 +128,33 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->yaw = $this->getLFloat(); - $this->pitch = $this->getLFloat(); - $this->position = $this->getVector3(); - $this->moveVecX = $this->getLFloat(); - $this->moveVecZ = $this->getLFloat(); - $this->headYaw = $this->getLFloat(); - $this->inputFlags = $this->getUnsignedVarLong(); - $this->inputMode = $this->getUnsignedVarInt(); - $this->playMode = $this->getUnsignedVarInt(); + $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(); if($this->playMode === PlayMode::VR){ - $this->vrGazeDirection = $this->getVector3(); + $this->vrGazeDirection = $this->buf->getVector3(); } } protected function encodePayload() : void{ - $this->putLFloat($this->yaw); - $this->putLFloat($this->pitch); - $this->putVector3($this->position); - $this->putLFloat($this->moveVecX); - $this->putLFloat($this->moveVecZ); - $this->putLFloat($this->headYaw); - $this->putUnsignedVarLong($this->inputFlags); - $this->putUnsignedVarInt($this->inputMode); - $this->putUnsignedVarInt($this->playMode); + $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); if($this->playMode === PlayMode::VR){ assert($this->vrGazeDirection !== null); - $this->putVector3($this->vrGazeDirection); + $this->buf->putVector3($this->vrGazeDirection); } } diff --git a/src/network/mcpe/protocol/PlayerHotbarPacket.php b/src/network/mcpe/protocol/PlayerHotbarPacket.php index e0c9e53fb0..e5bd9f2d13 100644 --- a/src/network/mcpe/protocol/PlayerHotbarPacket.php +++ b/src/network/mcpe/protocol/PlayerHotbarPacket.php @@ -47,15 +47,15 @@ class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, Server } protected function decodePayload() : void{ - $this->selectedHotbarSlot = $this->getUnsignedVarInt(); - $this->windowId = $this->getByte(); - $this->selectHotbarSlot = $this->getBool(); + $this->selectedHotbarSlot = $this->buf->getUnsignedVarInt(); + $this->windowId = $this->buf->getByte(); + $this->selectHotbarSlot = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->selectedHotbarSlot); - $this->putByte($this->windowId); - $this->putBool($this->selectHotbarSlot); + $this->buf->putUnsignedVarInt($this->selectedHotbarSlot); + $this->buf->putByte($this->windowId); + $this->buf->putBool($this->selectHotbarSlot); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlayerInputPacket.php b/src/network/mcpe/protocol/PlayerInputPacket.php index 6828cdaa57..f74da921ec 100644 --- a/src/network/mcpe/protocol/PlayerInputPacket.php +++ b/src/network/mcpe/protocol/PlayerInputPacket.php @@ -40,17 +40,17 @@ class PlayerInputPacket extends DataPacket implements ServerboundPacket{ public $sneaking; protected function decodePayload() : void{ - $this->motionX = $this->getLFloat(); - $this->motionY = $this->getLFloat(); - $this->jumping = $this->getBool(); - $this->sneaking = $this->getBool(); + $this->motionX = $this->buf->getLFloat(); + $this->motionY = $this->buf->getLFloat(); + $this->jumping = $this->buf->getBool(); + $this->sneaking = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putLFloat($this->motionX); - $this->putLFloat($this->motionY); - $this->putBool($this->jumping); - $this->putBool($this->sneaking); + $this->buf->putLFloat($this->motionX); + $this->buf->putLFloat($this->motionY); + $this->buf->putBool($this->jumping); + $this->buf->putBool($this->sneaking); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PlayerListPacket.php b/src/network/mcpe/protocol/PlayerListPacket.php index c514f4fdbc..068f68b0f6 100644 --- a/src/network/mcpe/protocol/PlayerListPacket.php +++ b/src/network/mcpe/protocol/PlayerListPacket.php @@ -61,23 +61,23 @@ class PlayerListPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->type = $this->getByte(); - $count = $this->getUnsignedVarInt(); + $this->type = $this->buf->getByte(); + $count = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ $entry = new PlayerListEntry(); if($this->type === self::TYPE_ADD){ - $entry->uuid = $this->getUUID(); - $entry->entityUniqueId = $this->getEntityUniqueId(); - $entry->username = $this->getString(); - $entry->xboxUserId = $this->getString(); - $entry->platformChatId = $this->getString(); - $entry->buildPlatform = $this->getLInt(); - $entry->skinData = $this->getSkin(); - $entry->isTeacher = $this->getBool(); - $entry->isHost = $this->getBool(); + $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(); }else{ - $entry->uuid = $this->getUUID(); + $entry->uuid = $this->buf->getUUID(); } $this->entries[$i] = $entry; @@ -85,21 +85,21 @@ class PlayerListPacket extends DataPacket implements ClientboundPacket{ } protected function encodePayload() : void{ - $this->putByte($this->type); - $this->putUnsignedVarInt(count($this->entries)); + $this->buf->putByte($this->type); + $this->buf->putUnsignedVarInt(count($this->entries)); foreach($this->entries as $entry){ if($this->type === self::TYPE_ADD){ - $this->putUUID($entry->uuid); - $this->putEntityUniqueId($entry->entityUniqueId); - $this->putString($entry->username); - $this->putString($entry->xboxUserId); - $this->putString($entry->platformChatId); - $this->putLInt($entry->buildPlatform); - $this->putSkin($entry->skinData); - $this->putBool($entry->isTeacher); - $this->putBool($entry->isHost); + $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); }else{ - $this->putUUID($entry->uuid); + $this->buf->putUUID($entry->uuid); } } } diff --git a/src/network/mcpe/protocol/PlayerSkinPacket.php b/src/network/mcpe/protocol/PlayerSkinPacket.php index e2de10b78b..cefa9fbc86 100644 --- a/src/network/mcpe/protocol/PlayerSkinPacket.php +++ b/src/network/mcpe/protocol/PlayerSkinPacket.php @@ -42,17 +42,17 @@ class PlayerSkinPacket extends DataPacket implements ClientboundPacket, Serverbo public $skin; protected function decodePayload() : void{ - $this->uuid = $this->getUUID(); - $this->skin = $this->getSkin(); - $this->newSkinName = $this->getString(); - $this->oldSkinName = $this->getString(); + $this->uuid = $this->buf->getUUID(); + $this->skin = $this->buf->getSkin(); + $this->newSkinName = $this->buf->getString(); + $this->oldSkinName = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putUUID($this->uuid); - $this->putSkin($this->skin); - $this->putString($this->newSkinName); - $this->putString($this->oldSkinName); + $this->buf->putUUID($this->uuid); + $this->buf->putSkin($this->skin); + $this->buf->putString($this->newSkinName); + $this->buf->putString($this->oldSkinName); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/PurchaseReceiptPacket.php b/src/network/mcpe/protocol/PurchaseReceiptPacket.php index 8b6b02b868..3d7fdc3101 100644 --- a/src/network/mcpe/protocol/PurchaseReceiptPacket.php +++ b/src/network/mcpe/protocol/PurchaseReceiptPacket.php @@ -35,16 +35,16 @@ class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{ public $entries = []; protected function decodePayload() : void{ - $count = $this->getUnsignedVarInt(); + $count = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ - $this->entries[] = $this->getString(); + $this->entries[] = $this->buf->getString(); } } protected function encodePayload() : void{ - $this->putUnsignedVarInt(count($this->entries)); + $this->buf->putUnsignedVarInt(count($this->entries)); foreach($this->entries as $entry){ - $this->putString($entry); + $this->buf->putString($entry); } } diff --git a/src/network/mcpe/protocol/RemoveActorPacket.php b/src/network/mcpe/protocol/RemoveActorPacket.php index 54e8aedede..991fac0649 100644 --- a/src/network/mcpe/protocol/RemoveActorPacket.php +++ b/src/network/mcpe/protocol/RemoveActorPacket.php @@ -40,11 +40,11 @@ class RemoveActorPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->entityUniqueId = $this->getEntityUniqueId(); + $this->entityUniqueId = $this->buf->getEntityUniqueId(); } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->entityUniqueId); + $this->buf->putEntityUniqueId($this->entityUniqueId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/RemoveEntityPacket.php b/src/network/mcpe/protocol/RemoveEntityPacket.php index 9b052ae506..2c26a1c350 100644 --- a/src/network/mcpe/protocol/RemoveEntityPacket.php +++ b/src/network/mcpe/protocol/RemoveEntityPacket.php @@ -44,11 +44,11 @@ class RemoveEntityPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->uvarint1 = $this->getUnsignedVarInt(); + $this->uvarint1 = $this->buf->getUnsignedVarInt(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->uvarint1); + $this->buf->putUnsignedVarInt($this->uvarint1); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/RemoveObjectivePacket.php b/src/network/mcpe/protocol/RemoveObjectivePacket.php index e05e1ed33c..c44291daf9 100644 --- a/src/network/mcpe/protocol/RemoveObjectivePacket.php +++ b/src/network/mcpe/protocol/RemoveObjectivePacket.php @@ -34,11 +34,11 @@ class RemoveObjectivePacket extends DataPacket implements ClientboundPacket{ public $objectiveName; protected function decodePayload() : void{ - $this->objectiveName = $this->getString(); + $this->objectiveName = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->objectiveName); + $this->buf->putString($this->objectiveName); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/RequestChunkRadiusPacket.php b/src/network/mcpe/protocol/RequestChunkRadiusPacket.php index 7d7fccf86e..57b38afa60 100644 --- a/src/network/mcpe/protocol/RequestChunkRadiusPacket.php +++ b/src/network/mcpe/protocol/RequestChunkRadiusPacket.php @@ -34,11 +34,11 @@ class RequestChunkRadiusPacket extends DataPacket implements ServerboundPacket{ public $radius; protected function decodePayload() : void{ - $this->radius = $this->getVarInt(); + $this->radius = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->radius); + $this->buf->putVarInt($this->radius); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php b/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php index 87e1496bc5..a2adbe8380 100644 --- a/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php +++ b/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php @@ -50,17 +50,17 @@ class ResourcePackChunkDataPacket extends DataPacket implements ClientboundPacke } protected function decodePayload() : void{ - $this->packId = $this->getString(); - $this->chunkIndex = $this->getLInt(); - $this->progress = $this->getLLong(); - $this->data = $this->getString(); + $this->packId = $this->buf->getString(); + $this->chunkIndex = $this->buf->getLInt(); + $this->progress = $this->buf->getLLong(); + $this->data = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->packId); - $this->putLInt($this->chunkIndex); - $this->putLLong($this->progress); - $this->putString($this->data); + $this->buf->putString($this->packId); + $this->buf->putLInt($this->chunkIndex); + $this->buf->putLLong($this->progress); + $this->buf->putString($this->data); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php b/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php index c15e7c3d27..e90154bcd1 100644 --- a/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php +++ b/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php @@ -36,13 +36,13 @@ class ResourcePackChunkRequestPacket extends DataPacket implements ServerboundPa public $chunkIndex; protected function decodePayload() : void{ - $this->packId = $this->getString(); - $this->chunkIndex = $this->getLInt(); + $this->packId = $this->buf->getString(); + $this->chunkIndex = $this->buf->getLInt(); } protected function encodePayload() : void{ - $this->putString($this->packId); - $this->putLInt($this->chunkIndex); + $this->buf->putString($this->packId); + $this->buf->putLInt($this->chunkIndex); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php b/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php index 06bd7a039d..ca4b193632 100644 --- a/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php +++ b/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php @@ -42,18 +42,18 @@ class ResourcePackClientResponsePacket extends DataPacket implements Serverbound public $packIds = []; protected function decodePayload() : void{ - $this->status = $this->getByte(); - $entryCount = $this->getLShort(); + $this->status = $this->buf->getByte(); + $entryCount = $this->buf->getLShort(); while($entryCount-- > 0){ - $this->packIds[] = $this->getString(); + $this->packIds[] = $this->buf->getString(); } } protected function encodePayload() : void{ - $this->putByte($this->status); - $this->putLShort(count($this->packIds)); + $this->buf->putByte($this->status); + $this->buf->putLShort(count($this->packIds)); foreach($this->packIds as $id){ - $this->putString($id); + $this->buf->putString($id); } } diff --git a/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php b/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php index 37fbde3b92..f8066dcc17 100644 --- a/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php +++ b/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php @@ -57,23 +57,23 @@ class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket } protected function decodePayload() : void{ - $this->packId = $this->getString(); - $this->maxChunkSize = $this->getLInt(); - $this->chunkCount = $this->getLInt(); - $this->compressedPackSize = $this->getLLong(); - $this->sha256 = $this->getString(); - $this->isPremium = $this->getBool(); - $this->packType = $this->getByte(); + $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 encodePayload() : void{ - $this->putString($this->packId); - $this->putLInt($this->maxChunkSize); - $this->putLInt($this->chunkCount); - $this->putLLong($this->compressedPackSize); - $this->putString($this->sha256); - $this->putBool($this->isPremium); - $this->putByte($this->packType); + $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); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ResourcePackStackPacket.php b/src/network/mcpe/protocol/ResourcePackStackPacket.php index 08d4e572cb..f424fe8b58 100644 --- a/src/network/mcpe/protocol/ResourcePackStackPacket.php +++ b/src/network/mcpe/protocol/ResourcePackStackPacket.php @@ -61,36 +61,36 @@ class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->mustAccept = $this->getBool(); - $behaviorPackCount = $this->getUnsignedVarInt(); + $this->mustAccept = $this->buf->getBool(); + $behaviorPackCount = $this->buf->getUnsignedVarInt(); while($behaviorPackCount-- > 0){ - $this->behaviorPackStack[] = ResourcePackStackEntry::read($this); + $this->behaviorPackStack[] = ResourcePackStackEntry::read($this->buf); } - $resourcePackCount = $this->getUnsignedVarInt(); + $resourcePackCount = $this->buf->getUnsignedVarInt(); while($resourcePackCount-- > 0){ - $this->resourcePackStack[] = ResourcePackStackEntry::read($this); + $this->resourcePackStack[] = ResourcePackStackEntry::read($this->buf); } - $this->isExperimental = $this->getBool(); - $this->baseGameVersion = $this->getString(); + $this->isExperimental = $this->buf->getBool(); + $this->baseGameVersion = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putBool($this->mustAccept); + $this->buf->putBool($this->mustAccept); - $this->putUnsignedVarInt(count($this->behaviorPackStack)); + $this->buf->putUnsignedVarInt(count($this->behaviorPackStack)); foreach($this->behaviorPackStack as $entry){ - $entry->write($this); + $entry->write($this->buf); } - $this->putUnsignedVarInt(count($this->resourcePackStack)); + $this->buf->putUnsignedVarInt(count($this->resourcePackStack)); foreach($this->resourcePackStack as $entry){ - $entry->write($this); + $entry->write($this->buf); } - $this->putBool($this->isExperimental); - $this->putString($this->baseGameVersion); + $this->buf->putBool($this->isExperimental); + $this->buf->putString($this->baseGameVersion); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/network/mcpe/protocol/ResourcePacksInfoPacket.php index 868e219420..a0acc75860 100644 --- a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ b/src/network/mcpe/protocol/ResourcePacksInfoPacket.php @@ -57,29 +57,29 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->mustAccept = $this->getBool(); - $this->hasScripts = $this->getBool(); - $behaviorPackCount = $this->getLShort(); + $this->mustAccept = $this->buf->getBool(); + $this->hasScripts = $this->buf->getBool(); + $behaviorPackCount = $this->buf->getLShort(); while($behaviorPackCount-- > 0){ - $this->behaviorPackEntries[] = ResourcePackInfoEntry::read($this); + $this->behaviorPackEntries[] = ResourcePackInfoEntry::read($this->buf); } - $resourcePackCount = $this->getLShort(); + $resourcePackCount = $this->buf->getLShort(); while($resourcePackCount-- > 0){ - $this->resourcePackEntries[] = ResourcePackInfoEntry::read($this); + $this->resourcePackEntries[] = ResourcePackInfoEntry::read($this->buf); } } protected function encodePayload() : void{ - $this->putBool($this->mustAccept); - $this->putBool($this->hasScripts); - $this->putLShort(count($this->behaviorPackEntries)); + $this->buf->putBool($this->mustAccept); + $this->buf->putBool($this->hasScripts); + $this->buf->putLShort(count($this->behaviorPackEntries)); foreach($this->behaviorPackEntries as $entry){ - $entry->write($this); + $entry->write($this->buf); } - $this->putLShort(count($this->resourcePackEntries)); + $this->buf->putLShort(count($this->resourcePackEntries)); foreach($this->resourcePackEntries as $entry){ - $entry->write($this); + $entry->write($this->buf); } } diff --git a/src/network/mcpe/protocol/RespawnPacket.php b/src/network/mcpe/protocol/RespawnPacket.php index 923ea7a4dc..3bb6c69b9d 100644 --- a/src/network/mcpe/protocol/RespawnPacket.php +++ b/src/network/mcpe/protocol/RespawnPacket.php @@ -51,15 +51,15 @@ class RespawnPacket extends DataPacket implements ClientboundPacket, Serverbound } protected function decodePayload() : void{ - $this->position = $this->getVector3(); - $this->respawnState = $this->getByte(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); + $this->position = $this->buf->getVector3(); + $this->respawnState = $this->buf->getByte(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); } protected function encodePayload() : void{ - $this->putVector3($this->position); - $this->putByte($this->respawnState); - $this->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putVector3($this->position); + $this->buf->putByte($this->respawnState); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/RiderJumpPacket.php b/src/network/mcpe/protocol/RiderJumpPacket.php index c6b9f534d3..162424be83 100644 --- a/src/network/mcpe/protocol/RiderJumpPacket.php +++ b/src/network/mcpe/protocol/RiderJumpPacket.php @@ -34,11 +34,11 @@ class RiderJumpPacket extends DataPacket implements ServerboundPacket{ public $jumpStrength; //percentage protected function decodePayload() : void{ - $this->jumpStrength = $this->getVarInt(); + $this->jumpStrength = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->jumpStrength); + $this->buf->putVarInt($this->jumpStrength); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ScriptCustomEventPacket.php b/src/network/mcpe/protocol/ScriptCustomEventPacket.php index 999dad4f9f..3247bffed6 100644 --- a/src/network/mcpe/protocol/ScriptCustomEventPacket.php +++ b/src/network/mcpe/protocol/ScriptCustomEventPacket.php @@ -36,13 +36,13 @@ class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have hand public $eventData; protected function decodePayload() : void{ - $this->eventName = $this->getString(); - $this->eventData = $this->getString(); + $this->eventName = $this->buf->getString(); + $this->eventData = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->eventName); - $this->putString($this->eventData); + $this->buf->putString($this->eventName); + $this->buf->putString($this->eventData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ServerSettingsResponsePacket.php b/src/network/mcpe/protocol/ServerSettingsResponsePacket.php index 9bff90f314..1134a44b9b 100644 --- a/src/network/mcpe/protocol/ServerSettingsResponsePacket.php +++ b/src/network/mcpe/protocol/ServerSettingsResponsePacket.php @@ -36,13 +36,13 @@ class ServerSettingsResponsePacket extends DataPacket implements ClientboundPack public $formData; //json protected function decodePayload() : void{ - $this->formId = $this->getUnsignedVarInt(); - $this->formData = $this->getString(); + $this->formId = $this->buf->getUnsignedVarInt(); + $this->formData = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->formId); - $this->putString($this->formData); + $this->buf->putUnsignedVarInt($this->formId); + $this->buf->putString($this->formData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ServerToClientHandshakePacket.php b/src/network/mcpe/protocol/ServerToClientHandshakePacket.php index 577bf38dcf..51a2859b2c 100644 --- a/src/network/mcpe/protocol/ServerToClientHandshakePacket.php +++ b/src/network/mcpe/protocol/ServerToClientHandshakePacket.php @@ -47,11 +47,11 @@ class ServerToClientHandshakePacket extends DataPacket implements ClientboundPac } protected function decodePayload() : void{ - $this->jwt = $this->getString(); + $this->jwt = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->jwt); + $this->buf->putString($this->jwt); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetActorDataPacket.php b/src/network/mcpe/protocol/SetActorDataPacket.php index ebde0894a0..0d93ffe0bf 100644 --- a/src/network/mcpe/protocol/SetActorDataPacket.php +++ b/src/network/mcpe/protocol/SetActorDataPacket.php @@ -52,13 +52,13 @@ class SetActorDataPacket extends DataPacket implements ClientboundPacket, Server } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->metadata = $this->getEntityMetadata(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->metadata = $this->buf->getEntityMetadata(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putEntityMetadata($this->metadata); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putEntityMetadata($this->metadata); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetActorLinkPacket.php b/src/network/mcpe/protocol/SetActorLinkPacket.php index 6e03372d8b..76efc27242 100644 --- a/src/network/mcpe/protocol/SetActorLinkPacket.php +++ b/src/network/mcpe/protocol/SetActorLinkPacket.php @@ -35,11 +35,11 @@ class SetActorLinkPacket extends DataPacket implements ClientboundPacket{ public $link; protected function decodePayload() : void{ - $this->link = $this->getEntityLink(); + $this->link = $this->buf->getEntityLink(); } protected function encodePayload() : void{ - $this->putEntityLink($this->link); + $this->buf->putEntityLink($this->link); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetActorMotionPacket.php b/src/network/mcpe/protocol/SetActorMotionPacket.php index 863af7485b..553eeddd72 100644 --- a/src/network/mcpe/protocol/SetActorMotionPacket.php +++ b/src/network/mcpe/protocol/SetActorMotionPacket.php @@ -47,13 +47,13 @@ class SetActorMotionPacket extends DataPacket implements ClientboundPacket, Garb } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->motion = $this->getVector3(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->motion = $this->buf->getVector3(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3($this->motion); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putVector3($this->motion); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetCommandsEnabledPacket.php b/src/network/mcpe/protocol/SetCommandsEnabledPacket.php index 6f0d1bcb3f..38bcd87809 100644 --- a/src/network/mcpe/protocol/SetCommandsEnabledPacket.php +++ b/src/network/mcpe/protocol/SetCommandsEnabledPacket.php @@ -34,11 +34,11 @@ class SetCommandsEnabledPacket extends DataPacket implements ClientboundPacket{ public $enabled; protected function decodePayload() : void{ - $this->enabled = $this->getBool(); + $this->enabled = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putBool($this->enabled); + $this->buf->putBool($this->enabled); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetDefaultGameTypePacket.php b/src/network/mcpe/protocol/SetDefaultGameTypePacket.php index 383c91266e..f39bbce4d0 100644 --- a/src/network/mcpe/protocol/SetDefaultGameTypePacket.php +++ b/src/network/mcpe/protocol/SetDefaultGameTypePacket.php @@ -40,11 +40,11 @@ class SetDefaultGameTypePacket extends DataPacket implements ClientboundPacket, } protected function decodePayload() : void{ - $this->gamemode = $this->getVarInt(); + $this->gamemode = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->gamemode); + $this->buf->putUnsignedVarInt($this->gamemode); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetDifficultyPacket.php b/src/network/mcpe/protocol/SetDifficultyPacket.php index a6de96175c..3489abe99c 100644 --- a/src/network/mcpe/protocol/SetDifficultyPacket.php +++ b/src/network/mcpe/protocol/SetDifficultyPacket.php @@ -40,11 +40,11 @@ class SetDifficultyPacket extends DataPacket implements ClientboundPacket, Serve } protected function decodePayload() : void{ - $this->difficulty = $this->getUnsignedVarInt(); + $this->difficulty = $this->buf->getUnsignedVarInt(); } protected function encodePayload() : void{ - $this->putUnsignedVarInt($this->difficulty); + $this->buf->putUnsignedVarInt($this->difficulty); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetDisplayObjectivePacket.php b/src/network/mcpe/protocol/SetDisplayObjectivePacket.php index 9a0ba7bacf..2f4075b2ab 100644 --- a/src/network/mcpe/protocol/SetDisplayObjectivePacket.php +++ b/src/network/mcpe/protocol/SetDisplayObjectivePacket.php @@ -42,19 +42,19 @@ class SetDisplayObjectivePacket extends DataPacket implements ClientboundPacket{ public $sortOrder; protected function decodePayload() : void{ - $this->displaySlot = $this->getString(); - $this->objectiveName = $this->getString(); - $this->displayName = $this->getString(); - $this->criteriaName = $this->getString(); - $this->sortOrder = $this->getVarInt(); + $this->displaySlot = $this->buf->getString(); + $this->objectiveName = $this->buf->getString(); + $this->displayName = $this->buf->getString(); + $this->criteriaName = $this->buf->getString(); + $this->sortOrder = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putString($this->displaySlot); - $this->putString($this->objectiveName); - $this->putString($this->displayName); - $this->putString($this->criteriaName); - $this->putVarInt($this->sortOrder); + $this->buf->putString($this->displaySlot); + $this->buf->putString($this->objectiveName); + $this->buf->putString($this->displayName); + $this->buf->putString($this->criteriaName); + $this->buf->putVarInt($this->sortOrder); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetHealthPacket.php b/src/network/mcpe/protocol/SetHealthPacket.php index 4efee7493d..4fb3f16097 100644 --- a/src/network/mcpe/protocol/SetHealthPacket.php +++ b/src/network/mcpe/protocol/SetHealthPacket.php @@ -34,11 +34,11 @@ class SetHealthPacket extends DataPacket implements ClientboundPacket{ public $health; protected function decodePayload() : void{ - $this->health = $this->getVarInt(); + $this->health = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->health); + $this->buf->putVarInt($this->health); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetLastHurtByPacket.php b/src/network/mcpe/protocol/SetLastHurtByPacket.php index ab2b703e01..6cff93835b 100644 --- a/src/network/mcpe/protocol/SetLastHurtByPacket.php +++ b/src/network/mcpe/protocol/SetLastHurtByPacket.php @@ -34,11 +34,11 @@ class SetLastHurtByPacket extends DataPacket implements ClientboundPacket{ public $entityTypeId; protected function decodePayload() : void{ - $this->entityTypeId = $this->getVarInt(); + $this->entityTypeId = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->entityTypeId); + $this->buf->putVarInt($this->entityTypeId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php b/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php index 7b15c525ba..0897c63294 100644 --- a/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php +++ b/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php @@ -34,11 +34,11 @@ class SetLocalPlayerAsInitializedPacket extends DataPacket implements Serverboun public $entityRuntimeId; protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetPlayerGameTypePacket.php b/src/network/mcpe/protocol/SetPlayerGameTypePacket.php index 94695ac4aa..bb8699aab7 100644 --- a/src/network/mcpe/protocol/SetPlayerGameTypePacket.php +++ b/src/network/mcpe/protocol/SetPlayerGameTypePacket.php @@ -40,11 +40,11 @@ class SetPlayerGameTypePacket extends DataPacket implements ClientboundPacket, S } protected function decodePayload() : void{ - $this->gamemode = $this->getVarInt(); + $this->gamemode = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->gamemode); + $this->buf->putVarInt($this->gamemode); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetScorePacket.php b/src/network/mcpe/protocol/SetScorePacket.php index 9128ceac05..59f61d321c 100644 --- a/src/network/mcpe/protocol/SetScorePacket.php +++ b/src/network/mcpe/protocol/SetScorePacket.php @@ -42,21 +42,21 @@ class SetScorePacket extends DataPacket implements ClientboundPacket{ public $entries = []; protected function decodePayload() : void{ - $this->type = $this->getByte(); - for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){ + $this->type = $this->buf->getByte(); + for($i = 0, $i2 = $this->buf->getUnsignedVarInt(); $i < $i2; ++$i){ $entry = new ScorePacketEntry(); - $entry->scoreboardId = $this->getVarLong(); - $entry->objectiveName = $this->getString(); - $entry->score = $this->getLInt(); + $entry->scoreboardId = $this->buf->getVarLong(); + $entry->objectiveName = $this->buf->getString(); + $entry->score = $this->buf->getLInt(); if($this->type !== self::TYPE_REMOVE){ - $entry->type = $this->getByte(); + $entry->type = $this->buf->getByte(); switch($entry->type){ case ScorePacketEntry::TYPE_PLAYER: case ScorePacketEntry::TYPE_ENTITY: - $entry->entityUniqueId = $this->getEntityUniqueId(); + $entry->entityUniqueId = $this->buf->getEntityUniqueId(); break; case ScorePacketEntry::TYPE_FAKE_PLAYER: - $entry->customName = $this->getString(); + $entry->customName = $this->buf->getString(); break; default: throw new BadPacketException("Unknown entry type $entry->type"); @@ -67,21 +67,21 @@ class SetScorePacket extends DataPacket implements ClientboundPacket{ } protected function encodePayload() : void{ - $this->putByte($this->type); - $this->putUnsignedVarInt(count($this->entries)); + $this->buf->putByte($this->type); + $this->buf->putUnsignedVarInt(count($this->entries)); foreach($this->entries as $entry){ - $this->putVarLong($entry->scoreboardId); - $this->putString($entry->objectiveName); - $this->putLInt($entry->score); + $this->buf->putVarLong($entry->scoreboardId); + $this->buf->putString($entry->objectiveName); + $this->buf->putLInt($entry->score); if($this->type !== self::TYPE_REMOVE){ - $this->putByte($entry->type); + $this->buf->putByte($entry->type); switch($entry->type){ case ScorePacketEntry::TYPE_PLAYER: case ScorePacketEntry::TYPE_ENTITY: - $this->putEntityUniqueId($entry->entityUniqueId); + $this->buf->putEntityUniqueId($entry->entityUniqueId); break; case ScorePacketEntry::TYPE_FAKE_PLAYER: - $this->putString($entry->customName); + $this->buf->putString($entry->customName); break; default: throw new \InvalidArgumentException("Unknown entry type $entry->type"); diff --git a/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php b/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php index 2d8a39961e..991771accb 100644 --- a/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php +++ b/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php @@ -41,12 +41,12 @@ class SetScoreboardIdentityPacket extends DataPacket implements ClientboundPacke public $entries = []; protected function decodePayload() : void{ - $this->type = $this->getByte(); - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + $this->type = $this->buf->getByte(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ $entry = new ScoreboardIdentityPacketEntry(); - $entry->scoreboardId = $this->getVarLong(); + $entry->scoreboardId = $this->buf->getVarLong(); if($this->type === self::TYPE_REGISTER_IDENTITY){ - $entry->entityUniqueId = $this->getEntityUniqueId(); + $entry->entityUniqueId = $this->buf->getEntityUniqueId(); } $this->entries[] = $entry; @@ -54,12 +54,12 @@ class SetScoreboardIdentityPacket extends DataPacket implements ClientboundPacke } protected function encodePayload() : void{ - $this->putByte($this->type); - $this->putUnsignedVarInt(count($this->entries)); + $this->buf->putByte($this->type); + $this->buf->putUnsignedVarInt(count($this->entries)); foreach($this->entries as $entry){ - $this->putVarLong($entry->scoreboardId); + $this->buf->putVarLong($entry->scoreboardId); if($this->type === self::TYPE_REGISTER_IDENTITY){ - $this->putEntityUniqueId($entry->entityUniqueId); + $this->buf->putEntityUniqueId($entry->entityUniqueId); } } } diff --git a/src/network/mcpe/protocol/SetSpawnPositionPacket.php b/src/network/mcpe/protocol/SetSpawnPositionPacket.php index a5c600110e..9e8320a140 100644 --- a/src/network/mcpe/protocol/SetSpawnPositionPacket.php +++ b/src/network/mcpe/protocol/SetSpawnPositionPacket.php @@ -60,15 +60,15 @@ class SetSpawnPositionPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->spawnType = $this->getVarInt(); - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->spawnForced = $this->getBool(); + $this->spawnType = $this->buf->getVarInt(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); + $this->spawnForced = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putVarInt($this->spawnType); - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putBool($this->spawnForced); + $this->buf->putVarInt($this->spawnType); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putBool($this->spawnForced); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetTimePacket.php b/src/network/mcpe/protocol/SetTimePacket.php index a86d87046b..b6fbac90b6 100644 --- a/src/network/mcpe/protocol/SetTimePacket.php +++ b/src/network/mcpe/protocol/SetTimePacket.php @@ -40,11 +40,11 @@ class SetTimePacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->time = $this->getVarInt(); + $this->time = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->time); + $this->buf->putVarInt($this->time); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SetTitlePacket.php b/src/network/mcpe/protocol/SetTitlePacket.php index 937dffeca8..0e1585fa74 100644 --- a/src/network/mcpe/protocol/SetTitlePacket.php +++ b/src/network/mcpe/protocol/SetTitlePacket.php @@ -49,19 +49,19 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{ public $fadeOutTime = 0; protected function decodePayload() : void{ - $this->type = $this->getVarInt(); - $this->text = $this->getString(); - $this->fadeInTime = $this->getVarInt(); - $this->stayTime = $this->getVarInt(); - $this->fadeOutTime = $this->getVarInt(); + $this->type = $this->buf->getVarInt(); + $this->text = $this->buf->getString(); + $this->fadeInTime = $this->buf->getVarInt(); + $this->stayTime = $this->buf->getVarInt(); + $this->fadeOutTime = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVarInt($this->type); - $this->putString($this->text); - $this->putVarInt($this->fadeInTime); - $this->putVarInt($this->stayTime); - $this->putVarInt($this->fadeOutTime); + $this->buf->putVarInt($this->type); + $this->buf->putString($this->text); + $this->buf->putVarInt($this->fadeInTime); + $this->buf->putVarInt($this->stayTime); + $this->buf->putVarInt($this->fadeOutTime); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SettingsCommandPacket.php b/src/network/mcpe/protocol/SettingsCommandPacket.php index 8752a8a0fe..0844494551 100644 --- a/src/network/mcpe/protocol/SettingsCommandPacket.php +++ b/src/network/mcpe/protocol/SettingsCommandPacket.php @@ -51,13 +51,13 @@ class SettingsCommandPacket extends DataPacket implements ServerboundPacket{ } protected function decodePayload() : void{ - $this->command = $this->getString(); - $this->suppressOutput = $this->getBool(); + $this->command = $this->buf->getString(); + $this->suppressOutput = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putString($this->command); - $this->putBool($this->suppressOutput); + $this->buf->putString($this->command); + $this->buf->putBool($this->suppressOutput); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ShowCreditsPacket.php b/src/network/mcpe/protocol/ShowCreditsPacket.php index d898831f4e..7d58c4cddc 100644 --- a/src/network/mcpe/protocol/ShowCreditsPacket.php +++ b/src/network/mcpe/protocol/ShowCreditsPacket.php @@ -39,13 +39,13 @@ class ShowCreditsPacket extends DataPacket implements ClientboundPacket, Serverb public $status; protected function decodePayload() : void{ - $this->playerEid = $this->getEntityRuntimeId(); - $this->status = $this->getVarInt(); + $this->playerEid = $this->buf->getEntityRuntimeId(); + $this->status = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->playerEid); - $this->putVarInt($this->status); + $this->buf->putEntityRuntimeId($this->playerEid); + $this->buf->putVarInt($this->status); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ShowProfilePacket.php b/src/network/mcpe/protocol/ShowProfilePacket.php index e9e4a900cd..0b78bc2a2d 100644 --- a/src/network/mcpe/protocol/ShowProfilePacket.php +++ b/src/network/mcpe/protocol/ShowProfilePacket.php @@ -34,11 +34,11 @@ class ShowProfilePacket extends DataPacket implements ClientboundPacket{ public $xuid; protected function decodePayload() : void{ - $this->xuid = $this->getString(); + $this->xuid = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->xuid); + $this->buf->putString($this->xuid); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/ShowStoreOfferPacket.php b/src/network/mcpe/protocol/ShowStoreOfferPacket.php index 7cf83dc08f..992dd18f8a 100644 --- a/src/network/mcpe/protocol/ShowStoreOfferPacket.php +++ b/src/network/mcpe/protocol/ShowStoreOfferPacket.php @@ -36,13 +36,13 @@ class ShowStoreOfferPacket extends DataPacket implements ClientboundPacket{ public $showAll; protected function decodePayload() : void{ - $this->offerId = $this->getString(); - $this->showAll = $this->getBool(); + $this->offerId = $this->buf->getString(); + $this->showAll = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putString($this->offerId); - $this->putBool($this->showAll); + $this->buf->putString($this->offerId); + $this->buf->putBool($this->showAll); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SimpleEventPacket.php b/src/network/mcpe/protocol/SimpleEventPacket.php index 94a43dac23..573fecbe87 100644 --- a/src/network/mcpe/protocol/SimpleEventPacket.php +++ b/src/network/mcpe/protocol/SimpleEventPacket.php @@ -37,11 +37,11 @@ class SimpleEventPacket extends DataPacket implements ClientboundPacket, Serverb public $eventType; protected function decodePayload() : void{ - $this->eventType = $this->getLShort(); + $this->eventType = $this->buf->getLShort(); } protected function encodePayload() : void{ - $this->putLShort($this->eventType); + $this->buf->putLShort($this->eventType); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php b/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php index 0ce2e61254..ea4aed7667 100644 --- a/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php +++ b/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php @@ -37,13 +37,13 @@ class SpawnExperienceOrbPacket extends DataPacket implements ServerboundPacket{ public $amount; protected function decodePayload() : void{ - $this->position = $this->getVector3(); - $this->amount = $this->getVarInt(); + $this->position = $this->buf->getVector3(); + $this->amount = $this->buf->getVarInt(); } protected function encodePayload() : void{ - $this->putVector3($this->position); - $this->putVarInt($this->amount); + $this->buf->putVector3($this->position); + $this->buf->putVarInt($this->amount); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/SpawnParticleEffectPacket.php b/src/network/mcpe/protocol/SpawnParticleEffectPacket.php index 36374e5196..692dd8645c 100644 --- a/src/network/mcpe/protocol/SpawnParticleEffectPacket.php +++ b/src/network/mcpe/protocol/SpawnParticleEffectPacket.php @@ -42,17 +42,17 @@ class SpawnParticleEffectPacket extends DataPacket implements ClientboundPacket{ public $particleName; protected function decodePayload() : void{ - $this->dimensionId = $this->getByte(); - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->position = $this->getVector3(); - $this->particleName = $this->getString(); + $this->dimensionId = $this->buf->getByte(); + $this->entityUniqueId = $this->buf->getEntityUniqueId(); + $this->position = $this->buf->getVector3(); + $this->particleName = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putByte($this->dimensionId); - $this->putEntityUniqueId($this->entityUniqueId); - $this->putVector3($this->position); - $this->putString($this->particleName); + $this->buf->putByte($this->dimensionId); + $this->buf->putEntityUniqueId($this->entityUniqueId); + $this->buf->putVector3($this->position); + $this->buf->putString($this->particleName); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/StartGamePacket.php b/src/network/mcpe/protocol/StartGamePacket.php index 90c4fed2ce..43099a9071 100644 --- a/src/network/mcpe/protocol/StartGamePacket.php +++ b/src/network/mcpe/protocol/StartGamePacket.php @@ -163,147 +163,149 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{ public $itemTable = null; protected function decodePayload() : void{ - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->playerGamemode = $this->getVarInt(); + $this->entityUniqueId = $this->buf->getEntityUniqueId(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->playerGamemode = $this->buf->getVarInt(); - $this->playerPosition = $this->getVector3(); + $this->playerPosition = $this->buf->getVector3(); - $this->pitch = $this->getLFloat(); - $this->yaw = $this->getLFloat(); + $this->pitch = $this->buf->getLFloat(); + $this->yaw = $this->buf->getLFloat(); //Level settings - $this->seed = $this->getVarInt(); - $this->dimension = $this->getVarInt(); - $this->generator = $this->getVarInt(); - $this->worldGamemode = $this->getVarInt(); - $this->difficulty = $this->getVarInt(); - $this->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); - $this->hasAchievementsDisabled = $this->getBool(); - $this->time = $this->getVarInt(); - $this->eduEditionOffer = $this->getVarInt(); - $this->hasEduFeaturesEnabled = $this->getBool(); - $this->rainLevel = $this->getLFloat(); - $this->lightningLevel = $this->getLFloat(); - $this->hasConfirmedPlatformLockedContent = $this->getBool(); - $this->isMultiplayerGame = $this->getBool(); - $this->hasLANBroadcast = $this->getBool(); - $this->xboxLiveBroadcastMode = $this->getVarInt(); - $this->platformBroadcastMode = $this->getVarInt(); - $this->commandsEnabled = $this->getBool(); - $this->isTexturePacksRequired = $this->getBool(); - $this->gameRules = $this->getGameRules(); - $this->hasBonusChestEnabled = $this->getBool(); - $this->hasStartWithMapEnabled = $this->getBool(); - $this->defaultPlayerPermission = $this->getVarInt(); - $this->serverChunkTickRadius = $this->getLInt(); - $this->hasLockedBehaviorPack = $this->getBool(); - $this->hasLockedResourcePack = $this->getBool(); - $this->isFromLockedWorldTemplate = $this->getBool(); - $this->useMsaGamertagsOnly = $this->getBool(); - $this->isFromWorldTemplate = $this->getBool(); - $this->isWorldTemplateOptionLocked = $this->getBool(); - $this->onlySpawnV1Villagers = $this->getBool(); + $this->seed = $this->buf->getVarInt(); + $this->dimension = $this->buf->getVarInt(); + $this->generator = $this->buf->getVarInt(); + $this->worldGamemode = $this->buf->getVarInt(); + $this->difficulty = $this->buf->getVarInt(); + $this->buf->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); + $this->hasAchievementsDisabled = $this->buf->getBool(); + $this->time = $this->buf->getVarInt(); + $this->eduEditionOffer = $this->buf->getVarInt(); + $this->hasEduFeaturesEnabled = $this->buf->getBool(); + $this->rainLevel = $this->buf->getLFloat(); + $this->lightningLevel = $this->buf->getLFloat(); + $this->hasConfirmedPlatformLockedContent = $this->buf->getBool(); + $this->isMultiplayerGame = $this->buf->getBool(); + $this->hasLANBroadcast = $this->buf->getBool(); + $this->xboxLiveBroadcastMode = $this->buf->getVarInt(); + $this->platformBroadcastMode = $this->buf->getVarInt(); + $this->commandsEnabled = $this->buf->getBool(); + $this->isTexturePacksRequired = $this->buf->getBool(); + $this->gameRules = $this->buf->getGameRules(); + $this->hasBonusChestEnabled = $this->buf->getBool(); + $this->hasStartWithMapEnabled = $this->buf->getBool(); + $this->defaultPlayerPermission = $this->buf->getVarInt(); + $this->serverChunkTickRadius = $this->buf->getLInt(); + $this->hasLockedBehaviorPack = $this->buf->getBool(); + $this->hasLockedResourcePack = $this->buf->getBool(); + $this->isFromLockedWorldTemplate = $this->buf->getBool(); + $this->useMsaGamertagsOnly = $this->buf->getBool(); + $this->isFromWorldTemplate = $this->buf->getBool(); + $this->isWorldTemplateOptionLocked = $this->buf->getBool(); + $this->onlySpawnV1Villagers = $this->buf->getBool(); - $this->vanillaVersion = $this->getString(); - $this->levelId = $this->getString(); - $this->worldName = $this->getString(); - $this->premiumWorldTemplateId = $this->getString(); - $this->isTrial = $this->getBool(); - $this->isMovementServerAuthoritative = $this->getBool(); - $this->currentTick = $this->getLLong(); + $this->vanillaVersion = $this->buf->getString(); + $this->levelId = $this->buf->getString(); + $this->worldName = $this->buf->getString(); + $this->premiumWorldTemplateId = $this->buf->getString(); + $this->isTrial = $this->buf->getBool(); + $this->isMovementServerAuthoritative = $this->buf->getBool(); + $this->currentTick = $this->buf->getLLong(); - $this->enchantmentSeed = $this->getVarInt(); + $this->enchantmentSeed = $this->buf->getVarInt(); - $blockTable = (new NetworkNbtSerializer())->read($this->buffer, $this->offset, 512)->getTag(); + $offset = $this->buf->getOffset(); + $blockTable = (new NetworkNbtSerializer())->read($this->buf->getBuffer(), $offset, 512)->getTag(); + $this->buf->setOffset($offset); if(!($blockTable instanceof ListTag)){ throw new \UnexpectedValueException("Wrong block table root NBT tag type"); } $this->blockTable = $blockTable; $this->itemTable = []; - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $id = $this->getString(); - $legacyId = $this->getSignedLShort(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $id = $this->buf->getString(); + $legacyId = $this->buf->getSignedLShort(); $this->itemTable[$id] = $legacyId; } - $this->multiplayerCorrelationId = $this->getString(); + $this->multiplayerCorrelationId = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putEntityUniqueId($this->entityUniqueId); - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVarInt($this->playerGamemode); + $this->buf->putEntityUniqueId($this->entityUniqueId); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putVarInt($this->playerGamemode); - $this->putVector3($this->playerPosition); + $this->buf->putVector3($this->playerPosition); - $this->putLFloat($this->pitch); - $this->putLFloat($this->yaw); + $this->buf->putLFloat($this->pitch); + $this->buf->putLFloat($this->yaw); //Level settings - $this->putVarInt($this->seed); - $this->putVarInt($this->dimension); - $this->putVarInt($this->generator); - $this->putVarInt($this->worldGamemode); - $this->putVarInt($this->difficulty); - $this->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); - $this->putBool($this->hasAchievementsDisabled); - $this->putVarInt($this->time); - $this->putVarInt($this->eduEditionOffer); - $this->putBool($this->hasEduFeaturesEnabled); - $this->putLFloat($this->rainLevel); - $this->putLFloat($this->lightningLevel); - $this->putBool($this->hasConfirmedPlatformLockedContent); - $this->putBool($this->isMultiplayerGame); - $this->putBool($this->hasLANBroadcast); - $this->putVarInt($this->xboxLiveBroadcastMode); - $this->putVarInt($this->platformBroadcastMode); - $this->putBool($this->commandsEnabled); - $this->putBool($this->isTexturePacksRequired); - $this->putGameRules($this->gameRules); - $this->putBool($this->hasBonusChestEnabled); - $this->putBool($this->hasStartWithMapEnabled); - $this->putVarInt($this->defaultPlayerPermission); - $this->putLInt($this->serverChunkTickRadius); - $this->putBool($this->hasLockedBehaviorPack); - $this->putBool($this->hasLockedResourcePack); - $this->putBool($this->isFromLockedWorldTemplate); - $this->putBool($this->useMsaGamertagsOnly); - $this->putBool($this->isFromWorldTemplate); - $this->putBool($this->isWorldTemplateOptionLocked); - $this->putBool($this->onlySpawnV1Villagers); + $this->buf->putVarInt($this->seed); + $this->buf->putVarInt($this->dimension); + $this->buf->putVarInt($this->generator); + $this->buf->putVarInt($this->worldGamemode); + $this->buf->putVarInt($this->difficulty); + $this->buf->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); + $this->buf->putBool($this->hasAchievementsDisabled); + $this->buf->putVarInt($this->time); + $this->buf->putVarInt($this->eduEditionOffer); + $this->buf->putBool($this->hasEduFeaturesEnabled); + $this->buf->putLFloat($this->rainLevel); + $this->buf->putLFloat($this->lightningLevel); + $this->buf->putBool($this->hasConfirmedPlatformLockedContent); + $this->buf->putBool($this->isMultiplayerGame); + $this->buf->putBool($this->hasLANBroadcast); + $this->buf->putVarInt($this->xboxLiveBroadcastMode); + $this->buf->putVarInt($this->platformBroadcastMode); + $this->buf->putBool($this->commandsEnabled); + $this->buf->putBool($this->isTexturePacksRequired); + $this->buf->putGameRules($this->gameRules); + $this->buf->putBool($this->hasBonusChestEnabled); + $this->buf->putBool($this->hasStartWithMapEnabled); + $this->buf->putVarInt($this->defaultPlayerPermission); + $this->buf->putLInt($this->serverChunkTickRadius); + $this->buf->putBool($this->hasLockedBehaviorPack); + $this->buf->putBool($this->hasLockedResourcePack); + $this->buf->putBool($this->isFromLockedWorldTemplate); + $this->buf->putBool($this->useMsaGamertagsOnly); + $this->buf->putBool($this->isFromWorldTemplate); + $this->buf->putBool($this->isWorldTemplateOptionLocked); + $this->buf->putBool($this->onlySpawnV1Villagers); - $this->putString($this->vanillaVersion); - $this->putString($this->levelId); - $this->putString($this->worldName); - $this->putString($this->premiumWorldTemplateId); - $this->putBool($this->isTrial); - $this->putBool($this->isMovementServerAuthoritative); - $this->putLLong($this->currentTick); + $this->buf->putString($this->vanillaVersion); + $this->buf->putString($this->levelId); + $this->buf->putString($this->worldName); + $this->buf->putString($this->premiumWorldTemplateId); + $this->buf->putBool($this->isTrial); + $this->buf->putBool($this->isMovementServerAuthoritative); + $this->buf->putLLong($this->currentTick); - $this->putVarInt($this->enchantmentSeed); + $this->buf->putVarInt($this->enchantmentSeed); if($this->blockTable === null){ if(self::$blockTableCache === null){ //this is a really nasty hack, but it'll do for now self::$blockTableCache = (new NetworkNbtSerializer())->write(new TreeRoot(new ListTag(RuntimeBlockMapping::getBedrockKnownStates()))); } - $this->put(self::$blockTableCache); + $this->buf->put(self::$blockTableCache); }else{ - $this->put((new NetworkNbtSerializer())->write(new TreeRoot($this->blockTable))); + $this->buf->put((new NetworkNbtSerializer())->write(new TreeRoot($this->blockTable))); } if($this->itemTable === null){ if(self::$itemTableCache === null){ self::$itemTableCache = self::serializeItemTable(json_decode(file_get_contents(RESOURCE_PATH . '/vanilla/item_id_map.json'), true)); } - $this->put(self::$itemTableCache); + $this->buf->put(self::$itemTableCache); }else{ - $this->put(self::serializeItemTable($this->itemTable)); + $this->buf->put(self::serializeItemTable($this->itemTable)); } - $this->putString($this->multiplayerCorrelationId); + $this->buf->putString($this->multiplayerCorrelationId); } /** diff --git a/src/network/mcpe/protocol/StopSoundPacket.php b/src/network/mcpe/protocol/StopSoundPacket.php index 72460d70d2..4a61eea6bf 100644 --- a/src/network/mcpe/protocol/StopSoundPacket.php +++ b/src/network/mcpe/protocol/StopSoundPacket.php @@ -36,13 +36,13 @@ class StopSoundPacket extends DataPacket implements ClientboundPacket{ public $stopAll; protected function decodePayload() : void{ - $this->soundName = $this->getString(); - $this->stopAll = $this->getBool(); + $this->soundName = $this->buf->getString(); + $this->stopAll = $this->buf->getBool(); } protected function encodePayload() : void{ - $this->putString($this->soundName); - $this->putBool($this->stopAll); + $this->buf->putString($this->soundName); + $this->buf->putBool($this->stopAll); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php b/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php index 847e457e67..b2c52ea31c 100644 --- a/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php +++ b/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php @@ -48,17 +48,17 @@ class StructureTemplateDataRequestPacket extends DataPacket implements Serverbou public $structureTemplateResponseType; protected function decodePayload() : void{ - $this->structureTemplateName = $this->getString(); - $this->getBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); - $this->structureSettings = $this->getStructureSettings(); - $this->structureTemplateResponseType = $this->getByte(); + $this->structureTemplateName = $this->buf->getString(); + $this->buf->getBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); + $this->structureSettings = $this->buf->getStructureSettings(); + $this->structureTemplateResponseType = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putString($this->structureTemplateName); - $this->putBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); - $this->putStructureSettings($this->structureSettings); - $this->putByte($this->structureTemplateResponseType); + $this->buf->putString($this->structureTemplateName); + $this->buf->putBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); + $this->buf->putStructureSettings($this->structureSettings); + $this->buf->putByte($this->structureTemplateResponseType); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php b/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php index 0f4d2b40fc..7d81ac3eef 100644 --- a/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php +++ b/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php @@ -36,17 +36,17 @@ class StructureTemplateDataResponsePacket extends DataPacket implements Clientbo public $namedtag; protected function decodePayload() : void{ - $this->structureTemplateName = $this->getString(); - if($this->getBool()){ - $this->namedtag = $this->getRemaining(); + $this->structureTemplateName = $this->buf->getString(); + if($this->buf->getBool()){ + $this->namedtag = $this->buf->getRemaining(); } } protected function encodePayload() : void{ - $this->putString($this->structureTemplateName); - $this->putBool($this->namedtag !== null); + $this->buf->putString($this->structureTemplateName); + $this->buf->putBool($this->namedtag !== null); if($this->namedtag !== null){ - $this->put($this->namedtag); + $this->buf->put($this->namedtag); } } diff --git a/src/network/mcpe/protocol/SubClientLoginPacket.php b/src/network/mcpe/protocol/SubClientLoginPacket.php index 8be6b0e985..90a4fa1b1d 100644 --- a/src/network/mcpe/protocol/SubClientLoginPacket.php +++ b/src/network/mcpe/protocol/SubClientLoginPacket.php @@ -34,11 +34,11 @@ class SubClientLoginPacket extends DataPacket implements ServerboundPacket{ public $connectionRequestData; protected function decodePayload() : void{ - $this->connectionRequestData = $this->getString(); + $this->connectionRequestData = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putString($this->connectionRequestData); + $this->buf->putString($this->connectionRequestData); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/TakeItemActorPacket.php b/src/network/mcpe/protocol/TakeItemActorPacket.php index 1968922ddb..e3b768afe4 100644 --- a/src/network/mcpe/protocol/TakeItemActorPacket.php +++ b/src/network/mcpe/protocol/TakeItemActorPacket.php @@ -43,13 +43,13 @@ class TakeItemActorPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->target = $this->getEntityRuntimeId(); - $this->eid = $this->getEntityRuntimeId(); + $this->target = $this->buf->getEntityRuntimeId(); + $this->eid = $this->buf->getEntityRuntimeId(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->target); - $this->putEntityRuntimeId($this->eid); + $this->buf->putEntityRuntimeId($this->target); + $this->buf->putEntityRuntimeId($this->eid); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/TextPacket.php b/src/network/mcpe/protocol/TextPacket.php index 5594b9e657..0e37555c63 100644 --- a/src/network/mcpe/protocol/TextPacket.php +++ b/src/network/mcpe/protocol/TextPacket.php @@ -116,65 +116,65 @@ class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPac } protected function decodePayload() : void{ - $this->type = $this->getByte(); - $this->needsTranslation = $this->getBool(); + $this->type = $this->buf->getByte(); + $this->needsTranslation = $this->buf->getBool(); switch($this->type){ case self::TYPE_CHAT: case self::TYPE_WHISPER: /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_ANNOUNCEMENT: - $this->sourceName = $this->getString(); + $this->sourceName = $this->buf->getString(); case self::TYPE_RAW: case self::TYPE_TIP: case self::TYPE_SYSTEM: case self::TYPE_JSON: - $this->message = $this->getString(); + $this->message = $this->buf->getString(); break; case self::TYPE_TRANSLATION: case self::TYPE_POPUP: case self::TYPE_JUKEBOX_POPUP: - $this->message = $this->getString(); - $count = $this->getUnsignedVarInt(); + $this->message = $this->buf->getString(); + $count = $this->buf->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ - $this->parameters[] = $this->getString(); + $this->parameters[] = $this->buf->getString(); } break; } - $this->xboxUserId = $this->getString(); - $this->platformChatId = $this->getString(); + $this->xboxUserId = $this->buf->getString(); + $this->platformChatId = $this->buf->getString(); } protected function encodePayload() : void{ - $this->putByte($this->type); - $this->putBool($this->needsTranslation); + $this->buf->putByte($this->type); + $this->buf->putBool($this->needsTranslation); switch($this->type){ case self::TYPE_CHAT: case self::TYPE_WHISPER: /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_ANNOUNCEMENT: - $this->putString($this->sourceName); + $this->buf->putString($this->sourceName); case self::TYPE_RAW: case self::TYPE_TIP: case self::TYPE_SYSTEM: case self::TYPE_JSON: - $this->putString($this->message); + $this->buf->putString($this->message); break; case self::TYPE_TRANSLATION: case self::TYPE_POPUP: case self::TYPE_JUKEBOX_POPUP: - $this->putString($this->message); - $this->putUnsignedVarInt(count($this->parameters)); + $this->buf->putString($this->message); + $this->buf->putUnsignedVarInt(count($this->parameters)); foreach($this->parameters as $p){ - $this->putString($p); + $this->buf->putString($p); } break; } - $this->putString($this->xboxUserId); - $this->putString($this->platformChatId); + $this->buf->putString($this->xboxUserId); + $this->buf->putString($this->platformChatId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/TickSyncPacket.php b/src/network/mcpe/protocol/TickSyncPacket.php index b8982efba9..c192f6d62c 100644 --- a/src/network/mcpe/protocol/TickSyncPacket.php +++ b/src/network/mcpe/protocol/TickSyncPacket.php @@ -58,13 +58,13 @@ class TickSyncPacket extends DataPacket implements ClientboundPacket, Serverboun } protected function decodePayload() : void{ - $this->clientSendTime = $this->getLLong(); - $this->serverReceiveTime = $this->getLLong(); + $this->clientSendTime = $this->buf->getLLong(); + $this->serverReceiveTime = $this->buf->getLLong(); } protected function encodePayload() : void{ - $this->putLLong($this->clientSendTime); - $this->putLLong($this->serverReceiveTime); + $this->buf->putLLong($this->clientSendTime); + $this->buf->putLLong($this->serverReceiveTime); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/TransferPacket.php b/src/network/mcpe/protocol/TransferPacket.php index 58170bd867..d02d1e5341 100644 --- a/src/network/mcpe/protocol/TransferPacket.php +++ b/src/network/mcpe/protocol/TransferPacket.php @@ -43,13 +43,13 @@ class TransferPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->address = $this->getString(); - $this->port = $this->getLShort(); + $this->address = $this->buf->getString(); + $this->port = $this->buf->getLShort(); } protected function encodePayload() : void{ - $this->putString($this->address); - $this->putLShort($this->port); + $this->buf->putString($this->address); + $this->buf->putLShort($this->port); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UnknownPacket.php b/src/network/mcpe/protocol/UnknownPacket.php index 184115b07c..dee77cce62 100644 --- a/src/network/mcpe/protocol/UnknownPacket.php +++ b/src/network/mcpe/protocol/UnknownPacket.php @@ -49,7 +49,7 @@ class UnknownPacket extends DataPacket{ } protected function decodePayload() : void{ - $this->payload = $this->getRemaining(); + $this->payload = $this->buf->getRemaining(); } protected function encodeHeader() : void{ @@ -57,7 +57,7 @@ class UnknownPacket extends DataPacket{ } protected function encodePayload() : void{ - $this->put($this->payload); + $this->buf->put($this->payload); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateAttributesPacket.php b/src/network/mcpe/protocol/UpdateAttributesPacket.php index 18a7e7acec..4f14f13d8b 100644 --- a/src/network/mcpe/protocol/UpdateAttributesPacket.php +++ b/src/network/mcpe/protocol/UpdateAttributesPacket.php @@ -50,13 +50,13 @@ class UpdateAttributesPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->entries = $this->getAttributeList(); + $this->entityRuntimeId = $this->buf->getEntityRuntimeId(); + $this->entries = $this->buf->getAttributeList(); } protected function encodePayload() : void{ - $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putAttributeList(...array_values($this->entries)); + $this->buf->putEntityRuntimeId($this->entityRuntimeId); + $this->buf->putAttributeList(...array_values($this->entries)); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateBlockPacket.php b/src/network/mcpe/protocol/UpdateBlockPacket.php index 46729ab80d..314999ef64 100644 --- a/src/network/mcpe/protocol/UpdateBlockPacket.php +++ b/src/network/mcpe/protocol/UpdateBlockPacket.php @@ -59,17 +59,17 @@ class UpdateBlockPacket extends DataPacket implements ClientboundPacket{ } protected function decodePayload() : void{ - $this->getBlockPosition($this->x, $this->y, $this->z); - $this->blockRuntimeId = $this->getUnsignedVarInt(); - $this->flags = $this->getUnsignedVarInt(); - $this->dataLayerId = $this->getUnsignedVarInt(); + $this->buf->getBlockPosition($this->x, $this->y, $this->z); + $this->blockRuntimeId = $this->buf->getUnsignedVarInt(); + $this->flags = $this->buf->getUnsignedVarInt(); + $this->dataLayerId = $this->buf->getUnsignedVarInt(); } protected function encodePayload() : void{ - $this->putBlockPosition($this->x, $this->y, $this->z); - $this->putUnsignedVarInt($this->blockRuntimeId); - $this->putUnsignedVarInt($this->flags); - $this->putUnsignedVarInt($this->dataLayerId); + $this->buf->putBlockPosition($this->x, $this->y, $this->z); + $this->buf->putUnsignedVarInt($this->blockRuntimeId); + $this->buf->putUnsignedVarInt($this->flags); + $this->buf->putUnsignedVarInt($this->dataLayerId); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateBlockPropertiesPacket.php b/src/network/mcpe/protocol/UpdateBlockPropertiesPacket.php index f0f1d41f43..1ab72c79dd 100644 --- a/src/network/mcpe/protocol/UpdateBlockPropertiesPacket.php +++ b/src/network/mcpe/protocol/UpdateBlockPropertiesPacket.php @@ -43,11 +43,11 @@ class UpdateBlockPropertiesPacket extends DataPacket implements ClientboundPacke } protected function decodePayload() : void{ - $this->nbt = $this->getRemaining(); + $this->nbt = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->put($this->nbt); + $this->buf->put($this->nbt); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php b/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php index f5c6fdc225..ace3894d86 100644 --- a/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php +++ b/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php @@ -37,14 +37,14 @@ class UpdateBlockSyncedPacket extends UpdateBlockPacket{ protected function decodePayload() : void{ parent::decodePayload(); - $this->entityUniqueId = $this->getUnsignedVarLong(); - $this->uvarint64_2 = $this->getUnsignedVarLong(); + $this->entityUniqueId = $this->buf->getUnsignedVarLong(); + $this->uvarint64_2 = $this->buf->getUnsignedVarLong(); } protected function encodePayload() : void{ parent::encodePayload(); - $this->putUnsignedVarLong($this->entityUniqueId); - $this->putUnsignedVarLong($this->uvarint64_2); + $this->buf->putUnsignedVarLong($this->entityUniqueId); + $this->buf->putUnsignedVarLong($this->uvarint64_2); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateEquipPacket.php b/src/network/mcpe/protocol/UpdateEquipPacket.php index 594a505166..9567e865fc 100644 --- a/src/network/mcpe/protocol/UpdateEquipPacket.php +++ b/src/network/mcpe/protocol/UpdateEquipPacket.php @@ -42,19 +42,19 @@ class UpdateEquipPacket extends DataPacket implements ClientboundPacket{ public $namedtag; protected function decodePayload() : void{ - $this->windowId = $this->getByte(); - $this->windowType = $this->getByte(); - $this->unknownVarint = $this->getVarInt(); - $this->entityUniqueId = $this->getEntityUniqueId(); - $this->namedtag = $this->getRemaining(); + $this->windowId = $this->buf->getByte(); + $this->windowType = $this->buf->getByte(); + $this->unknownVarint = $this->buf->getVarInt(); + $this->entityUniqueId = $this->buf->getEntityUniqueId(); + $this->namedtag = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->putByte($this->windowId); - $this->putByte($this->windowType); - $this->putVarInt($this->unknownVarint); - $this->putEntityUniqueId($this->entityUniqueId); - $this->put($this->namedtag); + $this->buf->putByte($this->windowId); + $this->buf->putByte($this->windowType); + $this->buf->putVarInt($this->unknownVarint); + $this->buf->putEntityUniqueId($this->entityUniqueId); + $this->buf->put($this->namedtag); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateSoftEnumPacket.php b/src/network/mcpe/protocol/UpdateSoftEnumPacket.php index d20f186d76..5744a02c40 100644 --- a/src/network/mcpe/protocol/UpdateSoftEnumPacket.php +++ b/src/network/mcpe/protocol/UpdateSoftEnumPacket.php @@ -43,20 +43,20 @@ class UpdateSoftEnumPacket extends DataPacket implements ClientboundPacket{ public $type; protected function decodePayload() : void{ - $this->enumName = $this->getString(); - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $this->values[] = $this->getString(); + $this->enumName = $this->buf->getString(); + for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){ + $this->values[] = $this->buf->getString(); } - $this->type = $this->getByte(); + $this->type = $this->buf->getByte(); } protected function encodePayload() : void{ - $this->putString($this->enumName); - $this->putUnsignedVarInt(count($this->values)); + $this->buf->putString($this->enumName); + $this->buf->putUnsignedVarInt(count($this->values)); foreach($this->values as $v){ - $this->putString($v); + $this->buf->putString($v); } - $this->putByte($this->type); + $this->buf->putByte($this->type); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/UpdateTradePacket.php b/src/network/mcpe/protocol/UpdateTradePacket.php index 08d01c76d1..b581dd9261 100644 --- a/src/network/mcpe/protocol/UpdateTradePacket.php +++ b/src/network/mcpe/protocol/UpdateTradePacket.php @@ -55,29 +55,29 @@ class UpdateTradePacket extends DataPacket implements ClientboundPacket{ public $offers; protected function decodePayload() : void{ - $this->windowId = $this->getByte(); - $this->windowType = $this->getByte(); - $this->thisIsAlwaysZero = $this->getVarInt(); - $this->tradeTier = $this->getVarInt(); - $this->traderEid = $this->getEntityUniqueId(); - $this->playerEid = $this->getEntityUniqueId(); - $this->displayName = $this->getString(); - $this->isWilling = $this->getBool(); - $this->isV2Trading = $this->getBool(); - $this->offers = $this->getRemaining(); + $this->windowId = $this->buf->getByte(); + $this->windowType = $this->buf->getByte(); + $this->thisIsAlwaysZero = $this->buf->getVarInt(); + $this->tradeTier = $this->buf->getVarInt(); + $this->traderEid = $this->buf->getEntityUniqueId(); + $this->playerEid = $this->buf->getEntityUniqueId(); + $this->displayName = $this->buf->getString(); + $this->isWilling = $this->buf->getBool(); + $this->isV2Trading = $this->buf->getBool(); + $this->offers = $this->buf->getRemaining(); } protected function encodePayload() : void{ - $this->putByte($this->windowId); - $this->putByte($this->windowType); - $this->putVarInt($this->thisIsAlwaysZero); - $this->putVarInt($this->tradeTier); - $this->putEntityUniqueId($this->traderEid); - $this->putEntityUniqueId($this->playerEid); - $this->putString($this->displayName); - $this->putBool($this->isWilling); - $this->putBool($this->isV2Trading); - $this->put($this->offers); + $this->buf->putByte($this->windowId); + $this->buf->putByte($this->windowType); + $this->buf->putVarInt($this->thisIsAlwaysZero); + $this->buf->putVarInt($this->tradeTier); + $this->buf->putEntityUniqueId($this->traderEid); + $this->buf->putEntityUniqueId($this->playerEid); + $this->buf->putString($this->displayName); + $this->buf->putBool($this->isWilling); + $this->buf->putBool($this->isV2Trading); + $this->buf->put($this->offers); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/VideoStreamConnectPacket.php b/src/network/mcpe/protocol/VideoStreamConnectPacket.php index ba7f643bf5..d599b2a61b 100644 --- a/src/network/mcpe/protocol/VideoStreamConnectPacket.php +++ b/src/network/mcpe/protocol/VideoStreamConnectPacket.php @@ -45,19 +45,19 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public $resolutionY; protected function decodePayload() : void{ - $this->serverUri = $this->getString(); - $this->frameSendFrequency = $this->getLFloat(); - $this->action = $this->getByte(); - $this->resolutionX = $this->getLInt(); - $this->resolutionY = $this->getLInt(); + $this->serverUri = $this->buf->getString(); + $this->frameSendFrequency = $this->buf->getLFloat(); + $this->action = $this->buf->getByte(); + $this->resolutionX = $this->buf->getLInt(); + $this->resolutionY = $this->buf->getLInt(); } protected function encodePayload() : void{ - $this->putString($this->serverUri); - $this->putLFloat($this->frameSendFrequency); - $this->putByte($this->action); - $this->putLInt($this->resolutionX); - $this->putLInt($this->resolutionY); + $this->buf->putString($this->serverUri); + $this->buf->putLFloat($this->frameSendFrequency); + $this->buf->putByte($this->action); + $this->buf->putLInt($this->resolutionX); + $this->buf->putLInt($this->resolutionY); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/serializer/NetworkBinaryStream.php b/src/network/mcpe/serializer/NetworkBinaryStream.php index b1618ac16a..5248a8998b 100644 --- a/src/network/mcpe/serializer/NetworkBinaryStream.php +++ b/src/network/mcpe/serializer/NetworkBinaryStream.php @@ -595,7 +595,7 @@ class NetworkBinaryStream extends BinaryStream{ /** * @throws BinaryDataException */ - protected function getEntityLink() : EntityLink{ + public function getEntityLink() : EntityLink{ $link = new EntityLink(); $link->fromEntityUniqueId = $this->getEntityUniqueId(); @@ -606,7 +606,7 @@ class NetworkBinaryStream extends BinaryStream{ return $link; } - protected function putEntityLink(EntityLink $link) : void{ + public function putEntityLink(EntityLink $link) : void{ $this->putEntityUniqueId($link->fromEntityUniqueId); $this->putEntityUniqueId($link->toEntityUniqueId); $this->putByte($link->type); @@ -616,7 +616,7 @@ class NetworkBinaryStream extends BinaryStream{ /** * @throws BinaryDataException */ - protected function getCommandOriginData() : CommandOriginData{ + public function getCommandOriginData() : CommandOriginData{ $result = new CommandOriginData(); $result->type = $this->getUnsignedVarInt(); @@ -630,7 +630,7 @@ class NetworkBinaryStream extends BinaryStream{ return $result; } - protected function putCommandOriginData(CommandOriginData $data) : void{ + public function putCommandOriginData(CommandOriginData $data) : void{ $this->putUnsignedVarInt($data->type); $this->putUUID($data->uuid); $this->putString($data->requestId); @@ -640,7 +640,7 @@ class NetworkBinaryStream extends BinaryStream{ } } - protected function getStructureSettings() : StructureSettings{ + public function getStructureSettings() : StructureSettings{ $result = new StructureSettings(); $result->paletteName = $this->getString(); @@ -660,7 +660,7 @@ class NetworkBinaryStream extends BinaryStream{ return $result; } - protected function putStructureSettings(StructureSettings $structureSettings) : void{ + public function putStructureSettings(StructureSettings $structureSettings) : void{ $this->putString($structureSettings->paletteName); $this->putBool($structureSettings->ignoreEntities);