From 9c39f26599ccbdcf344fe3acb616012fd20af18d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 19 Nov 2022 15:00:57 +0000 Subject: [PATCH] CraftRecipeAutoStackRequestAction: added missing protocol change from 1.19.40 --- .../CraftRecipeAutoStackRequestAction.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php index 872c41e6..205cc042 100644 --- a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php +++ b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php @@ -16,6 +16,7 @@ use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; +use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient; /** * Tells that the current transaction crafted the specified recipe, using the recipe book. This is effectively the same @@ -26,23 +27,42 @@ final class CraftRecipeAutoStackRequestAction extends ItemStackRequestAction{ public const ID = ItemStackRequestActionType::CRAFTING_RECIPE_AUTO; + /** + * @param RecipeIngredient[] $ingredients + * @phpstan-param list $ingredients + */ final public function __construct( private int $recipeId, - private int $repetitions + private int $repetitions, + private array $ingredients ){} public function getRecipeId() : int{ return $this->recipeId; } public function getRepetitions() : int{ return $this->repetitions; } + /** + * @return RecipeIngredient[] + * @phpstan-return list + */ + public function getIngredients() : array{ return $this->ingredients; } + public static function read(PacketSerializer $in) : self{ $recipeId = $in->readGenericTypeNetworkId(); $repetitions = $in->getByte(); - return new self($recipeId, $repetitions); + $ingredients = []; + for($i = 0, $count = $in->getByte(); $i < $count; ++$i){ + $ingredients[] = $in->getRecipeIngredient(); + } + return new self($recipeId, $repetitions, $ingredients); } public function write(PacketSerializer $out) : void{ $out->writeGenericTypeNetworkId($this->recipeId); $out->putByte($this->repetitions); + $out->putByte(count($this->ingredients)); + foreach($this->ingredients as $ingredient){ + $out->putRecipeIngredient($ingredient); + } } }