Skip to content

Commit 9c39f26

Browse files
committed
CraftRecipeAutoStackRequestAction: added missing protocol change from 1.19.40
1 parent e5c8a67 commit 9c39f26

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
1818
use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait;
19+
use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient;
1920

2021
/**
2122
* 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{
2627

2728
public const ID = ItemStackRequestActionType::CRAFTING_RECIPE_AUTO;
2829

30+
/**
31+
* @param RecipeIngredient[] $ingredients
32+
* @phpstan-param list<RecipeIngredient> $ingredients
33+
*/
2934
final public function __construct(
3035
private int $recipeId,
31-
private int $repetitions
36+
private int $repetitions,
37+
private array $ingredients
3238
){}
3339

3440
public function getRecipeId() : int{ return $this->recipeId; }
3541

3642
public function getRepetitions() : int{ return $this->repetitions; }
3743

44+
/**
45+
* @return RecipeIngredient[]
46+
* @phpstan-return list<RecipeIngredient>
47+
*/
48+
public function getIngredients() : array{ return $this->ingredients; }
49+
3850
public static function read(PacketSerializer $in) : self{
3951
$recipeId = $in->readGenericTypeNetworkId();
4052
$repetitions = $in->getByte();
41-
return new self($recipeId, $repetitions);
53+
$ingredients = [];
54+
for($i = 0, $count = $in->getByte(); $i < $count; ++$i){
55+
$ingredients[] = $in->getRecipeIngredient();
56+
}
57+
return new self($recipeId, $repetitions, $ingredients);
4258
}
4359

4460
public function write(PacketSerializer $out) : void{
4561
$out->writeGenericTypeNetworkId($this->recipeId);
4662
$out->putByte($this->repetitions);
63+
$out->putByte(count($this->ingredients));
64+
foreach($this->ingredients as $ingredient){
65+
$out->putRecipeIngredient($ingredient);
66+
}
4767
}
4868
}

0 commit comments

Comments
 (0)