13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol\types\recipe;
19use Ramsey\Uuid\UuidInterface;
29 private string $recipeId,
30 private array $inputs,
31 private array $outputs,
32 private UuidInterface $uuid,
33 private string $blockName,
34 private int $priority,
36 private int $recipeNetId
38 parent::__construct($typeId);
41 public function getRecipeId() : string{
42 return $this->recipeId;
56 return $this->outputs;
59 public function getUuid() : UuidInterface{
63 public function getBlockName() : string{
64 return $this->blockName;
67 public function getPriority() : int{
68 return $this->priority;
71 public function getUnlockingRequirement() : RecipeUnlockingRequirement{ return $this->unlockingRequirement; }
73 public function getRecipeNetId() : int{
74 return $this->recipeNetId;
77 public static function decode(
int $recipeType, PacketSerializer $in) : self{
78 $recipeId = $in->getString();
80 for($j = 0, $ingredientCount = $in->getUnsignedVarInt(); $j < $ingredientCount; ++$j){
81 $input[] = $in->getRecipeIngredient();
84 for($k = 0, $resultCount = $in->getUnsignedVarInt(); $k < $resultCount; ++$k){
85 $output[] = $in->getItemStackWithoutStackId();
87 $uuid = $in->getUUID();
88 $block = $in->getString();
89 $priority = $in->getVarInt();
90 $unlockingRequirement = RecipeUnlockingRequirement::read($in);
92 $recipeNetId = $in->readRecipeNetId();
94 return new self($recipeType, $recipeId, $input, $output, $uuid, $block, $priority, $unlockingRequirement, $recipeNetId);
97 public function encode(PacketSerializer $out) : void{
98 $out->putString($this->recipeId);
99 $out->putUnsignedVarInt(count($this->inputs));
100 foreach($this->inputs as $item){
101 $out->putRecipeIngredient($item);
104 $out->putUnsignedVarInt(count($this->outputs));
105 foreach($this->outputs as $item){
106 $out->putItemStackWithoutStackId($item);
109 $out->putUUID($this->uuid);
110 $out->putString($this->blockName);
111 $out->putVarInt($this->priority);
112 $this->unlockingRequirement->write($out);
114 $out->writeRecipeNetId($this->recipeNetId);
__construct(int $typeId, private string $recipeId, private array $inputs, private array $outputs, private UuidInterface $uuid, private string $blockName, private int $priority, private RecipeUnlockingRequirement $unlockingRequirement, private int $recipeNetId)