mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +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:
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET;
|
||||
@ -38,16 +39,16 @@ class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var bool */
|
||||
public $respawn = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->dimension = $this->buf->getVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->respawn = $this->buf->getBool();
|
||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||
$this->dimension = $in->getVarInt();
|
||||
$this->position = $in->getVector3();
|
||||
$this->respawn = $in->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->buf->putVarInt($this->dimension);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putBool($this->respawn);
|
||||
protected function encodePayload(NetworkBinaryStream $out) : void{
|
||||
$out->putVarInt($this->dimension);
|
||||
$out->putVector3($this->position);
|
||||
$out->putBool($this->respawn);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
Reference in New Issue
Block a user