mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +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 SetTitlePacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::SET_TITLE_PACKET;
|
||||
@ -48,20 +49,20 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $fadeOutTime = 0;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$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 decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->type = $in->getVarInt();
|
||||
$this->text = $in->getString();
|
||||
$this->fadeInTime = $in->getVarInt();
|
||||
$this->stayTime = $in->getVarInt();
|
||||
$this->fadeOutTime = $in->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$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);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->type);
|
||||
$out->putString($this->text);
|
||||
$out->putVarInt($this->fadeInTime);
|
||||
$out->putVarInt($this->stayTime);
|
||||
$out->putVarInt($this->fadeOutTime);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
Reference in New Issue
Block a user