PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
SmithingTransformRecipe.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol\types\recipe;
16
19
21
22 public function __construct(
23 int $typeId,
24 private string $recipeId,
25 private RecipeIngredient $template,
26 private RecipeIngredient $input,
27 private RecipeIngredient $addition,
28 private ItemStack $output,
29 private string $blockName,
30 private int $recipeNetId
31 ){
32 parent::__construct($typeId);
33 }
34
35 public function getRecipeId() : string{ return $this->recipeId; }
36
37 public function getTemplate() : RecipeIngredient{ return $this->template; }
38
39 public function getInput() : RecipeIngredient{ return $this->input; }
40
41 public function getAddition() : RecipeIngredient{ return $this->addition; }
42
43 public function getOutput() : ItemStack{ return $this->output; }
44
45 public function getBlockName() : string{ return $this->blockName; }
46
47 public function getRecipeNetId() : int{ return $this->recipeNetId; }
48
49 public static function decode(int $typeId, PacketSerializer $in) : self{
50 $recipeId = $in->getString();
51 $template = $in->getRecipeIngredient();
52 $input = $in->getRecipeIngredient();
53 $addition = $in->getRecipeIngredient();
54 $output = $in->getItemStackWithoutStackId();
55 $blockName = $in->getString();
56 $recipeNetId = $in->readRecipeNetId();
57
58 return new self(
59 $typeId,
60 $recipeId,
61 $template,
62 $input,
63 $addition,
64 $output,
65 $blockName,
66 $recipeNetId
67 );
68 }
69
70 public function encode(PacketSerializer $out) : void{
71 $out->putString($this->recipeId);
72 $out->putRecipeIngredient($this->template);
73 $out->putRecipeIngredient($this->input);
74 $out->putRecipeIngredient($this->addition);
75 $out->putItemStackWithoutStackId($this->output);
76 $out->putString($this->blockName);
77 $out->writeRecipeNetId($this->recipeNetId);
78 }
79}