mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
DataPacket: inject buffer via parameter instead of class field (packet & stream separation, step 2)
this is not complete yet, but the final change (having the binarystream actually come from outside) is a little more disruptive, and some extra changes need to be made. This will grant some sanity in the meantime without breaking too much stuff.
This commit is contained in:
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class PlayerActionPacket extends DataPacket implements ServerboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_ACTION_PACKET;
|
||||
@ -70,18 +71,18 @@ class PlayerActionPacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $face;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->action = $this->buf->getVarInt();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $this->buf->getVarInt();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
||||
$this->action = $in->getVarInt();
|
||||
$in->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVarInt($this->action);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putVarInt($this->face);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$out->putVarInt($this->action);
|
||||
$out->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$out->putVarInt($this->face);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
Reference in New Issue
Block a user