Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BlockPickRequestPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public static function create(BlockPosition $blockPosition, bool $addUserData, i
}

protected function decodePayload(ByteBufferReader $in) : void{
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
$this->blockPosition = CommonTypes::getBlockPosition($in);
$this->addUserData = CommonTypes::getBool($in);
$this->hotbarSlot = Byte::readUnsigned($in);
}

protected function encodePayload(ByteBufferWriter $out) : void{
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
CommonTypes::putBlockPosition($out, $this->blockPosition);
CommonTypes::putBool($out, $this->addUserData);
Byte::writeUnsigned($out, $this->hotbarSlot);
}
Expand Down
58 changes: 58 additions & 0 deletions src/ClientboundAttributeLayerSyncPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pmmp\encoding\ByteBufferReader;
use pmmp\encoding\ByteBufferWriter;
use pmmp\encoding\VarInt;
use pocketmine\network\mcpe\protocol\types\AttributeLayerSyncPayload;
use pocketmine\network\mcpe\protocol\types\AttributesRemoveEnvironment;
use pocketmine\network\mcpe\protocol\types\AttributesUpdateEnvironment;
use pocketmine\network\mcpe\protocol\types\AttributeUpdateLayers;
use pocketmine\network\mcpe\protocol\types\AttributeUpdateLayerSettings;

class ClientboundAttributeLayerSyncPacket extends DataPacket{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should implement ClientboundPacket

public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_ATTRIBUTE_LAYER_SYNC_PACKET;

private AttributeLayerSyncPayload $payload;

/**
* @generate-create-func
*/
public static function create(AttributeLayerSyncPayload $payload) : self{
$result = new self;
$result->payload = $payload;
return $result;
}

protected function decodePayload(ByteBufferReader $in) : void{
$this->payload = match(VarInt::readUnsignedInt($in)){
AttributeUpdateLayers::ID => AttributeUpdateLayers::read($in),
AttributeUpdateLayerSettings::ID => AttributeUpdateLayerSettings::read($in),
AttributesUpdateEnvironment::ID => AttributesUpdateEnvironment::read($in),
AttributesRemoveEnvironment::ID => AttributesRemoveEnvironment::read($in),
default => throw new PacketDecodeException("Unknown ClientboundAttributeLayerSync type"),
};
}

protected function encodePayload(ByteBufferWriter $out) : void{
VarInt::writeUnsignedInt($out, $this->payload->getTypeId());
$this->payload->write($out);
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientboundAttributeLayerSync($this);
}
}
49 changes: 49 additions & 0 deletions src/ClientboundDataDrivenUICloseScreenPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pmmp\encoding\ByteBufferReader;
use pmmp\encoding\ByteBufferWriter;
use pmmp\encoding\LE;
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;

class ClientboundDataDrivenUICloseScreenPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DATA_DRIVEN_UI_CLOSE_SCREEN_PACKET;

private ?int $formId;

/**
* @generate-create-func
*/
public static function create(?int $formId) : self{
$result = new self;
$result->formId = $formId;
return $result;
}

public function getFormId() : ?int{ return $this->formId; }

protected function decodePayload(ByteBufferReader $in) : void{
$this->formId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
}

protected function encodePayload(ByteBufferWriter $out) : void{
CommonTypes::writeOptional($out, $this->formId, LE::writeUnsignedInt(...));
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientboundDataDrivenUICloseScreen($this);
}
}
15 changes: 14 additions & 1 deletion src/ClientboundDataDrivenUIShowScreenPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,43 @@

use pmmp\encoding\ByteBufferReader;
use pmmp\encoding\ByteBufferWriter;
use pmmp\encoding\LE;
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;

class ClientboundDataDrivenUIShowScreenPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DATA_DRIVEN_UI_SHOW_SCREEN_PACKET;

private string $screenId;
private int $formId;
private ?int $dataInstanceId;

/**
* @generate-create-func
*/
public static function create(string $screenId) : self{
public static function create(string $screenId, int $formId, ?int $dataInstanceId) : self{
$result = new self;
$result->screenId = $screenId;
$result->formId = $formId;
$result->dataInstanceId = $dataInstanceId;
return $result;
}

public function getScreenId() : string{ return $this->screenId; }

public function getFormId() : int{ return $this->formId; }

public function getDataInstanceId() : ?int{ return $this->dataInstanceId; }

protected function decodePayload(ByteBufferReader $in) : void{
$this->screenId = CommonTypes::getString($in);
$this->formId = LE::readUnsignedInt($in);
$this->dataInstanceId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
}

protected function encodePayload(ByteBufferWriter $out) : void{
CommonTypes::putString($out, $this->screenId);
LE::writeUnsignedInt($out, $this->formId);
CommonTypes::writeOptional($out, $this->dataInstanceId, LE::writeUnsignedInt(...));
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down
4 changes: 2 additions & 2 deletions src/ClientboundMapItemDataPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
$this->type = VarInt::readUnsignedInt($in);
$this->dimensionId = Byte::readUnsigned($in);
$this->isLocked = CommonTypes::getBool($in);
$this->origin = CommonTypes::getSignedBlockPosition($in);
$this->origin = CommonTypes::getBlockPosition($in);

if(($this->type & self::BITFLAG_MAP_CREATION) !== 0){
$count = VarInt::readUnsignedInt($in);
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
VarInt::writeUnsignedInt($out, $type);
Byte::writeUnsigned($out, $this->dimensionId);
CommonTypes::putBool($out, $this->isLocked);
CommonTypes::putSignedBlockPosition($out, $this->origin);
CommonTypes::putBlockPosition($out, $this->origin);

if(($type & self::BITFLAG_MAP_CREATION) !== 0){
VarInt::writeUnsignedInt($out, $parentMapIdsCount);
Expand Down
4 changes: 2 additions & 2 deletions src/GameTestRequestPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
$this->repeatCount = VarInt::readSignedInt($in);
$this->rotation = Byte::readUnsigned($in);
$this->stopOnFailure = CommonTypes::getBool($in);
$this->testPosition = CommonTypes::getSignedBlockPosition($in);
$this->testPosition = CommonTypes::getBlockPosition($in);
$this->testsPerRow = VarInt::readSignedInt($in);
$this->testName = CommonTypes::getString($in);
}
Expand All @@ -92,7 +92,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
VarInt::writeSignedInt($out, $this->repeatCount);
Byte::writeUnsigned($out, $this->rotation);
CommonTypes::putBool($out, $this->stopOnFailure);
CommonTypes::putSignedBlockPosition($out, $this->testPosition);
CommonTypes::putBlockPosition($out, $this->testPosition);
VarInt::writeSignedInt($out, $this->testsPerRow);
CommonTypes::putString($out, $this->testName);
}
Expand Down
18 changes: 9 additions & 9 deletions src/GraphicsOverrideParameterPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class GraphicsOverrideParameterPacket extends DataPacket implements ClientboundP

/** @var ParameterKeyframeValue[] */
private array $values = [];
private float $unknownFloat;
private Vector3 $unknownVector3;
private ?float $unknownFloat;
private ?Vector3 $unknownVector3;
private string $biomeIdentifier;
private GraphicsOverrideParameterType $parameterType;
private bool $reset;
Expand All @@ -40,7 +40,7 @@ class GraphicsOverrideParameterPacket extends DataPacket implements ClientboundP
* @generate-create-func
* @param ParameterKeyframeValue[] $values
*/
public static function create(array $values, float $unknownFloat, Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset) : self{
public static function create(array $values, ?float $unknownFloat, ?Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset) : self{
$result = new self;
$result->values = $values;
$result->unknownFloat = $unknownFloat;
Expand All @@ -56,9 +56,9 @@ public static function create(array $values, float $unknownFloat, Vector3 $unkno
*/
public function getValues() : array{ return $this->values; }

public function getUnknownFloat() : float{ return $this->unknownFloat; }
public function getUnknownFloat() : ?float{ return $this->unknownFloat; }

public function getUnknownVector3() : Vector3{ return $this->unknownVector3; }
public function getUnknownVector3() : ?Vector3{ return $this->unknownVector3; }

public function getBiomeIdentifier() : string{ return $this->biomeIdentifier; }

Expand All @@ -71,8 +71,8 @@ protected function decodePayload(ByteBufferReader $in) : void{
for($i = 0; $i < $count; ++$i){
$this->values[] = ParameterKeyframeValue::read($in);
}
$this->unknownFloat = LE::readFloat($in);
$this->unknownVector3 = CommonTypes::getVector3($in);
$this->unknownFloat = CommonTypes::readOptional($in, LE::readFloat(...));
$this->unknownVector3 = CommonTypes::readOptional($in, CommonTypes::getVector3(...));
$this->biomeIdentifier = CommonTypes::getString($in);
$this->parameterType = GraphicsOverrideParameterType::fromPacket(Byte::readUnsigned($in));
$this->reset = CommonTypes::getBool($in);
Expand All @@ -83,8 +83,8 @@ protected function encodePayload(ByteBufferWriter $out) : void{
foreach($this->values as $value){
$value->write($out);
}
LE::writeFloat($out, $this->unknownFloat);
CommonTypes::putVector3($out, $this->unknownVector3);
CommonTypes::writeOptional($out, $this->unknownFloat, LE::writeFloat(...));
CommonTypes::writeOptional($out, $this->unknownVector3, CommonTypes::putVector3(...));
CommonTypes::putString($out, $this->biomeIdentifier);
Byte::writeUnsigned($out, $this->parameterType->value);
CommonTypes::putBool($out, $this->reset);
Expand Down
4 changes: 2 additions & 2 deletions src/LabTablePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public static function create(int $actionType, BlockPosition $blockPosition, int

protected function decodePayload(ByteBufferReader $in) : void{
$this->actionType = Byte::readUnsigned($in);
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
$this->blockPosition = CommonTypes::getBlockPosition($in);
$this->reactionType = Byte::readUnsigned($in);
}

protected function encodePayload(ByteBufferWriter $out) : void{
Byte::writeUnsigned($out, $this->actionType);
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
CommonTypes::putBlockPosition($out, $this->blockPosition);
Byte::writeUnsigned($out, $this->reactionType);
}

Expand Down
60 changes: 60 additions & 0 deletions src/LocatorBarPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pmmp\encoding\ByteBufferReader;
use pmmp\encoding\ByteBufferWriter;
use pmmp\encoding\VarInt;
use pocketmine\network\mcpe\protocol\types\LocatorBarWaypointPayload;
use function count;

class LocatorBarPacket extends DataPacket{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing clientbound/serverbound

public const NETWORK_ID = ProtocolInfo::LOCATOR_BAR_PACKET;

/**
* @var LocatorBarWaypointPayload[]
* @phpstan-var list<LocatorBarWaypointPayload>
*/
private array $waypoints;

/**
* @generate-create-func
* @param LocatorBarWaypointPayload[] $waypoints
* @phpstan-param list<LocatorBarWaypointPayload> $waypoints
*/
public static function create(array $waypoints) : self{
$result = new self;
$result->waypoints = $waypoints;
return $result;
}

protected function decodePayload(ByteBufferReader $in) : void{
$this->waypoints = [];
for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
$this->waypoints[] = LocatorBarWaypointPayload::read($in);
}
}

protected function encodePayload(ByteBufferWriter $out) : void{
VarInt::writeUnsignedInt($out, count($this->waypoints));
foreach($this->waypoints as $waypoint){
$waypoint->write($out);
}
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLocatorBar($this);
}
}
4 changes: 2 additions & 2 deletions src/NetworkChunkPublisherUpdatePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function create(BlockPosition $blockPosition, int $radius, array $
}

protected function decodePayload(ByteBufferReader $in) : void{
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
$this->blockPosition = CommonTypes::getBlockPosition($in);
$this->radius = VarInt::readUnsignedInt($in);

$count = LE::readUnsignedInt($in);
Expand All @@ -59,7 +59,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
}

protected function encodePayload(ByteBufferWriter $out) : void{
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
CommonTypes::putBlockPosition($out, $this->blockPosition);
VarInt::writeUnsignedInt($out, $this->radius);

LE::writeUnsignedInt($out, count($this->savedChunks));
Expand Down
26 changes: 25 additions & 1 deletion src/PacketHandlerDefaultImplTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ public function handleClientboundDataDrivenUIShowScreen(ClientboundDataDrivenUIS
return false;
}

public function handleClientboundDataDrivenUICloseAllScreens(ClientboundDataDrivenUICloseAllScreensPacket $packet) : bool{
public function handleClientboundDataDrivenUICloseScreen(ClientboundDataDrivenUICloseScreenPacket $packet) : bool{
return false;
}

Expand All @@ -893,4 +893,28 @@ public function handleCameraSpline(CameraSplinePacket $packet) : bool{
public function handleCameraAimAssistActorPriority(CameraAimAssistActorPriorityPacket $packet) : bool{
return false;
}

public function handleResourcePacksReadyForValidation(ResourcePacksReadyForValidationPacket $packet) : bool{
return false;
}

public function handleLocatorBar(LocatorBarPacket $packet) : bool{
return false;
}

public function handlePartyChanged(PartyChangedPacket $packet) : bool{
return false;
}

public function handleServerboundDataDrivenScreenClosed(ServerboundDataDrivenScreenClosedPacket $packet) : bool{
return false;
}

public function handleSyncWorldClocks(SyncWorldClocksPacket $packet) : bool{
return false;
}

public function handleClientboundAttributeLayerSync(ClientboundAttributeLayerSyncPacket $packet) : bool{
return false;
}
}
Loading
Loading