PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
20
22
23 public function __construct(
24 int $typeId,
25 private string $recipeId,
26 private RecipeIngredient $template,
27 private RecipeIngredient $input,
28 private RecipeIngredient $addition,
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 getBlockName() : string{ return $this->blockName; }
44
45 public function getRecipeNetId() : int{ return $this->recipeNetId; }
46
47 public static function decode(int $typeId, ByteBufferReader $in) : self{
48 $recipeId = CommonTypes::getString($in);
49 $template = CommonTypes::getRecipeIngredient($in);
50 $input = CommonTypes::getRecipeIngredient($in);
51 $addition = CommonTypes::getRecipeIngredient($in);
52 $blockName = CommonTypes::getString($in);
53 $recipeNetId = CommonTypes::readRecipeNetId($in);
54
55 return new self(
56 $typeId,
57 $recipeId,
58 $template,
59 $input,
60 $addition,
61 $blockName,
62 $recipeNetId
63 );
64 }
65
66 public function encode(ByteBufferWriter $out) : void{
67 CommonTypes::putString($out, $this->recipeId);
68 CommonTypes::putRecipeIngredient($out, $this->template);
69 CommonTypes::putRecipeIngredient($out, $this->input);
70 CommonTypes::putRecipeIngredient($out, $this->addition);
71 CommonTypes::putString($out, $this->blockName);
72 CommonTypes::writeRecipeNetId($out, $this->recipeNetId);
73 }
74}