PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
SmithingTrimRecipe.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
18
20
21 public function __construct(
22 int $typeId,
23 private string $recipeId,
24 private RecipeIngredient $template,
25 private RecipeIngredient $input,
26 private RecipeIngredient $addition,
27 private string $blockName,
28 private int $recipeNetId
29 ){
30 parent::__construct($typeId);
31 }
32
33 public function getRecipeId() : string{ return $this->recipeId; }
34
35 public function getTemplate() : RecipeIngredient{ return $this->template; }
36
37 public function getInput() : RecipeIngredient{ return $this->input; }
38
39 public function getAddition() : RecipeIngredient{ return $this->addition; }
40
41 public function getBlockName() : string{ return $this->blockName; }
42
43 public function getRecipeNetId() : int{ return $this->recipeNetId; }
44
45 public static function decode(int $typeId, PacketSerializer $in) : self{
46 $recipeId = $in->getString();
47 $template = $in->getRecipeIngredient();
48 $input = $in->getRecipeIngredient();
49 $addition = $in->getRecipeIngredient();
50 $blockName = $in->getString();
51 $recipeNetId = $in->readRecipeNetId();
52
53 return new self(
54 $typeId,
55 $recipeId,
56 $template,
57 $input,
58 $addition,
59 $blockName,
60 $recipeNetId
61 );
62 }
63
64 public function encode(PacketSerializer $out) : void{
65 $out->putString($this->recipeId);
66 $out->putRecipeIngredient($this->template);
67 $out->putRecipeIngredient($this->input);
68 $out->putRecipeIngredient($this->addition);
69 $out->putString($this->blockName);
70 $out->writeRecipeNetId($this->recipeNetId);
71 }
72}