PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
21
23
24 public function __construct(
25 int $typeId,
26 private string $recipeId,
27 private RecipeIngredient $template,
28 private RecipeIngredient $input,
29 private RecipeIngredient $addition,
30 private ItemStack $output,
31 private string $blockName,
32 private int $recipeNetId
33 ){
34 parent::__construct($typeId);
35 }
36
37 public function getRecipeId() : string{ return $this->recipeId; }
38
39 public function getTemplate() : RecipeIngredient{ return $this->template; }
40
41 public function getInput() : RecipeIngredient{ return $this->input; }
42
43 public function getAddition() : RecipeIngredient{ return $this->addition; }
44
45 public function getOutput() : ItemStack{ return $this->output; }
46
47 public function getBlockName() : string{ return $this->blockName; }
48
49 public function getRecipeNetId() : int{ return $this->recipeNetId; }
50
51 public static function decode(int $typeId, ByteBufferReader $in) : self{
52 $recipeId = CommonTypes::getString($in);
53 $template = CommonTypes::getRecipeIngredient($in);
54 $input = CommonTypes::getRecipeIngredient($in);
55 $addition = CommonTypes::getRecipeIngredient($in);
56 $output = CommonTypes::getItemStackWithoutStackId($in);
57 $blockName = CommonTypes::getString($in);
58 $recipeNetId = CommonTypes::readRecipeNetId($in);
59
60 return new self(
61 $typeId,
62 $recipeId,
63 $template,
64 $input,
65 $addition,
66 $output,
67 $blockName,
68 $recipeNetId
69 );
70 }
71
72 public function encode(ByteBufferWriter $out) : void{
73 CommonTypes::putString($out, $this->recipeId);
74 CommonTypes::putRecipeIngredient($out, $this->template);
75 CommonTypes::putRecipeIngredient($out, $this->input);
76 CommonTypes::putRecipeIngredient($out, $this->addition);
77 CommonTypes::putItemStackWithoutStackId($out, $this->output);
78 CommonTypes::putString($out, $this->blockName);
79 CommonTypes::writeRecipeNetId($out, $this->recipeNetId);
80 }
81}