62 public static function create(array $recipesWithTypeIds, array $potionTypeRecipes, array $potionContainerRecipes, array $materialReducerRecipes,
bool $cleanRecipes) : self{
64 $result->recipesWithTypeIds = $recipesWithTypeIds;
65 $result->potionTypeRecipes = $potionTypeRecipes;
66 $result->potionContainerRecipes = $potionContainerRecipes;
67 $result->materialReducerRecipes = $materialReducerRecipes;
68 $result->cleanRecipes = $cleanRecipes;
73 $recipeCount = $in->getUnsignedVarInt();
74 $previousType =
"none";
75 for($i = 0; $i < $recipeCount; ++$i){
78 $this->recipesWithTypeIds[] = match($recipeType){
79 self::ENTRY_SHAPELESS, self::ENTRY_USER_DATA_SHAPELESS, self::ENTRY_SHAPELESS_CHEMISTRY => ShapelessRecipe::decode($recipeType, $in),
80 self::ENTRY_SHAPED, self::ENTRY_SHAPED_CHEMISTRY => ShapedRecipe::decode($recipeType, $in),
81 self::ENTRY_FURNACE, self::ENTRY_FURNACE_DATA => FurnaceRecipe::decode($recipeType, $in),
82 self::ENTRY_MULTI => MultiRecipe::decode($recipeType, $in),
83 self::ENTRY_SMITHING_TRANSFORM => SmithingTransformRecipe::decode($recipeType, $in),
84 self::ENTRY_SMITHING_TRIM => SmithingTrimRecipe::decode($recipeType, $in),
85 default =>
throw new PacketDecodeException(
"Unhandled recipe type $recipeType (previous was $previousType)"),
87 $previousType = $recipeType;
90 $inputId = $in->getVarInt();
91 $inputMeta = $in->getVarInt();
92 $ingredientId = $in->getVarInt();
93 $ingredientMeta = $in->getVarInt();
94 $outputId = $in->getVarInt();
95 $outputMeta = $in->getVarInt();
96 $this->potionTypeRecipes[] = new PotionTypeRecipe($inputId, $inputMeta, $ingredientId, $ingredientMeta, $outputId, $outputMeta);
99 $input = $in->getVarInt();
100 $ingredient = $in->getVarInt();
101 $output = $in->getVarInt();
102 $this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output);
105 $inputIdAndData = $in->getVarInt();
106 [$inputId, $inputMeta] = [$inputIdAndData >> 16, $inputIdAndData & 0x7fff];
108 for($j = 0, $outputCount = $in->getUnsignedVarInt(); $j < $outputCount; ++$j){
109 $outputItemId = $in->getVarInt();
110 $outputItemCount = $in->getVarInt();
111 $outputs[] = new MaterialReducerRecipeOutput($outputItemId, $outputItemCount);
115 $this->cleanRecipes = $in->
getBool();
119 $out->putUnsignedVarInt(count($this->recipesWithTypeIds));
120 foreach($this->recipesWithTypeIds as $d){
125 foreach($this->potionTypeRecipes as $recipe){
126 $out->
putVarInt($recipe->getInputItemId());
127 $out->
putVarInt($recipe->getInputItemMeta());
128 $out->
putVarInt($recipe->getIngredientItemId());
129 $out->
putVarInt($recipe->getIngredientItemMeta());
130 $out->
putVarInt($recipe->getOutputItemId());
131 $out->
putVarInt($recipe->getOutputItemMeta());
134 foreach($this->potionContainerRecipes as $recipe){
135 $out->
putVarInt($recipe->getInputItemId());
136 $out->
putVarInt($recipe->getIngredientItemId());
137 $out->
putVarInt($recipe->getOutputItemId());
140 foreach($this->materialReducerRecipes as $recipe){
141 $out->
putVarInt(($recipe->getInputItemId() << 16) | $recipe->getInputItemMeta());
143 foreach($recipe->getOutputs() as $output){
148 $out->putBool($this->cleanRecipes);