diff --git a/src/types/camera/CameraSetInstruction.php b/src/types/camera/CameraSetInstruction.php index 656445a3..963220e1 100644 --- a/src/types/camera/CameraSetInstruction.php +++ b/src/types/camera/CameraSetInstruction.php @@ -21,6 +21,7 @@ use pocketmine\nbt\tag\DoubleTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\ListTag; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use function count; use function is_infinite; @@ -58,7 +59,9 @@ public static function read(PacketSerializer $in) : self{ $cameraPosition = $in->readOptional($in->getVector3(...)); $rotation = $in->readOptional(fn() => CameraSetInstructionRotation::read($in)); $facingPosition = $in->readOptional($in->getVector3(...)); - $viewOffset = $in->readOptional($in->getVector2(...)); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $viewOffset = $in->readOptional($in->getVector2(...)); + } $default = $in->readOptional($in->getBool(...)); return new self( @@ -67,7 +70,7 @@ public static function read(PacketSerializer $in) : self{ $cameraPosition, $rotation, $facingPosition, - $viewOffset, + $viewOffset ?? null, $default ); } @@ -96,6 +99,7 @@ public static function fromNBT(CompoundTag $nbt) : self{ $cameraPosition, $rotation, $facingPosition, + null, $default ); } @@ -106,7 +110,9 @@ public function write(PacketSerializer $out) : void{ $out->writeOptional($this->cameraPosition, $out->putVector3(...)); $out->writeOptional($this->rotation, fn(CameraSetInstructionRotation $v) => $v->write($out)); $out->writeOptional($this->facingPosition, $out->putVector3(...)); - $out->writeOptional($this->viewOffset, $out->putVector2(...)); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->writeOptional($this->viewOffset, $out->putVector2(...)); + } $out->writeOptional($this->default, $out->putBool(...)); } diff --git a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php index bcd8158c..479caf2e 100644 --- a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php +++ b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php @@ -42,7 +42,7 @@ final public function __construct( public function getRecipeId() : int{ return $this->recipeId; } - public function getRepetitions() : int { return $this->repetitions; } + public function getRepetitions() : int{ return $this->repetitions; } public function getRepetitions2() : int{ return $this->repetitions2; } diff --git a/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php b/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php index 0d7caafd..e7308698 100644 --- a/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php +++ b/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php @@ -33,7 +33,7 @@ final public function __construct( public function getRecipeId() : int{ return $this->recipeId; } - public function getRepetitions() : int { return $this->repetitions; } + public function getRepetitions() : int{ return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $recipeId = $in->readRecipeNetId(); diff --git a/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php b/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php index 1322d29d..eb14b113 100644 --- a/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php +++ b/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php @@ -33,7 +33,7 @@ public function __construct( public function getCreativeItemId() : int{ return $this->creativeItemId; } - public function getRepetitions() : int { return $this->repetitions; } + public function getRepetitions() : int{ return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $creativeItemId = $in->readCreativeItemNetId(); diff --git a/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php b/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php index 39effc1f..3956e707 100644 --- a/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php +++ b/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php @@ -37,7 +37,7 @@ public function getRecipeId() : int{ return $this->recipeId; } /** WARNING: This may be negative */ public function getRepairCost() : int{ return $this->repairCost; } - public function getRepetitions() : int { return $this->repetitions; } + public function getRepetitions() : int{ return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $recipeId = $in->readRecipeNetId(); diff --git a/src/types/inventory/stackrequest/ItemStackRequest.php b/src/types/inventory/stackrequest/ItemStackRequest.php index dd82de79..9e8c698e 100644 --- a/src/types/inventory/stackrequest/ItemStackRequest.php +++ b/src/types/inventory/stackrequest/ItemStackRequest.php @@ -58,6 +58,8 @@ private static function readAction(PacketSerializer $in, int $typeId) : ItemStac DestroyStackRequestAction::ID => DestroyStackRequestAction::read($in), CraftingConsumeInputStackRequestAction::ID => CraftingConsumeInputStackRequestAction::read($in), CraftingCreateSpecificResultStackRequestAction::ID => CraftingCreateSpecificResultStackRequestAction::read($in), + PlaceIntoBundleStackRequestAction::ID => PlaceIntoBundleStackRequestAction::read($in), + TakeFromBundleStackRequestAction::ID => TakeFromBundleStackRequestAction::read($in), LabTableCombineStackRequestAction::ID => LabTableCombineStackRequestAction::read($in), BeaconPaymentStackRequestAction::ID => BeaconPaymentStackRequestAction::read($in), MineBlockStackRequestAction::ID => MineBlockStackRequestAction::read($in), diff --git a/src/types/inventory/stackrequest/ItemStackRequestActionType.php b/src/types/inventory/stackrequest/ItemStackRequestActionType.php index 59ddd8f1..e93d26d8 100644 --- a/src/types/inventory/stackrequest/ItemStackRequestActionType.php +++ b/src/types/inventory/stackrequest/ItemStackRequestActionType.php @@ -27,6 +27,8 @@ private function __construct(){ public const DESTROY = 4; public const CRAFTING_CONSUME_INPUT = 5; public const CRAFTING_CREATE_SPECIFIC_RESULT = 6; + public const PLACE_INTO_BUNDLE = 7; + public const TAKE_FROM_BUNDLE = 8; public const LAB_TABLE_COMBINE = 9; public const BEACON_PAYMENT = 10; public const MINE_BLOCK = 11; diff --git a/src/types/inventory/stackrequest/PlaceIntoBundleStackRequestAction.php b/src/types/inventory/stackrequest/PlaceIntoBundleStackRequestAction.php new file mode 100644 index 00000000..846b4f3c --- /dev/null +++ b/src/types/inventory/stackrequest/PlaceIntoBundleStackRequestAction.php @@ -0,0 +1,27 @@ + + * + * 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\types\inventory\stackrequest; + +use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; + +/** + * Insert an item into a bundle. + */ +final class PlaceIntoBundleStackRequestAction extends ItemStackRequestAction{ + use GetTypeIdFromConstTrait; + use TakeOrPlaceStackRequestActionTrait; + + public const ID = ItemStackRequestActionType::PLACE_INTO_BUNDLE; +} diff --git a/src/types/inventory/stackrequest/TakeFromBundleStackRequestAction.php b/src/types/inventory/stackrequest/TakeFromBundleStackRequestAction.php new file mode 100644 index 00000000..cd096eae --- /dev/null +++ b/src/types/inventory/stackrequest/TakeFromBundleStackRequestAction.php @@ -0,0 +1,27 @@ + + * + * 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\types\inventory\stackrequest; + +use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; + +/** + * Take an item out of a bundle. + */ +final class TakeFromBundleStackRequestAction extends ItemStackRequestAction{ + use GetTypeIdFromConstTrait; + use TakeOrPlaceStackRequestActionTrait; + + public const ID = ItemStackRequestActionType::TAKE_FROM_BUNDLE; +}