-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
357 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?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 pocketmine\math\Vector2; | ||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; | ||
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistActionType; | ||
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistTargetMode; | ||
|
||
class CameraAimAssistPacket extends DataPacket implements ClientboundPacket{ | ||
public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_PACKET; | ||
|
||
private Vector2 $viewAngle; | ||
private float $distance; | ||
private CameraAimAssistTargetMode $targetMode; | ||
private CameraAimAssistActionType $actionType; | ||
|
||
/** | ||
* @generate-create-func | ||
*/ | ||
public static function create(Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType) : self{ | ||
$result = new self; | ||
$result->viewAngle = $viewAngle; | ||
$result->distance = $distance; | ||
$result->targetMode = $targetMode; | ||
$result->actionType = $actionType; | ||
return $result; | ||
} | ||
|
||
public function getViewAngle() : Vector2{ return $this->viewAngle; } | ||
|
||
public function getDistance() : float{ return $this->distance; } | ||
|
||
public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; } | ||
|
||
public function getActionType() : CameraAimAssistActionType{ return $this->actionType; } | ||
|
||
protected function decodePayload(PacketSerializer $in) : void{ | ||
$this->viewAngle = $in->getVector2(); | ||
$this->distance = $in->getLFloat(); | ||
$this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte()); | ||
$this->actionType = CameraAimAssistActionType::fromPacket($in->getByte()); | ||
} | ||
|
||
protected function encodePayload(PacketSerializer $out) : void{ | ||
$out->putVector2($this->viewAngle); | ||
$out->putLFloat($this->distance); | ||
$out->putByte($this->targetMode->value); | ||
$out->putByte($this->actionType->value); | ||
} | ||
|
||
public function handle(PacketHandlerInterface $handler) : bool{ | ||
return $handler->handleCameraAimAssist($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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 pocketmine\network\mcpe\protocol\serializer\PacketSerializer; | ||
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName; | ||
use function count; | ||
|
||
class ContainerRegistryCleanupPacket extends DataPacket implements ClientboundPacket{ | ||
public const NETWORK_ID = ProtocolInfo::CONTAINER_REGISTRY_CLEANUP_PACKET; | ||
|
||
/** @var FullContainerName[] */ | ||
private array $removedContainers; | ||
|
||
/** | ||
* @generate-create-func | ||
* @param FullContainerName[] $removedContainers | ||
*/ | ||
public static function create(array $removedContainers) : self{ | ||
$result = new self; | ||
$result->removedContainers = $removedContainers; | ||
return $result; | ||
} | ||
|
||
/** | ||
* @return FullContainerName[] | ||
*/ | ||
public function getRemovedContainers() : array{ return $this->removedContainers; } | ||
|
||
protected function decodePayload(PacketSerializer $in) : void{ | ||
$this->removedContainers = []; | ||
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ | ||
$this->removedContainers[] = FullContainerName::read($in); | ||
} | ||
} | ||
|
||
protected function encodePayload(PacketSerializer $out) : void{ | ||
$out->putUnsignedVarInt(count($this->removedContainers)); | ||
foreach($this->removedContainers as $container){ | ||
$container->write($out); | ||
} | ||
} | ||
|
||
public function handle(PacketHandlerInterface $handler) : bool{ | ||
return $handler->handleContainerRegistryCleanup($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.