private static function writeShapelessRecipe(ShapelessRecipe $recipe, BinaryStream $stream) { $stream->putInt($recipe->getIngredientCount()); foreach ($recipe->getIngredientList() as $item) { $stream->putSlot($item); } $stream->putInt(1); $stream->putSlot($recipe->getResult()); $stream->putUUID($recipe->getId()); return CraftingDataPacket::ENTRY_SHAPELESS; }
/** * @param ShapelessRecipe $recipe */ public function registerShapelessRecipe(ShapelessRecipe $recipe) { $result = $recipe->getResult(); $this->recipes[$recipe->getId()->toBinary()] = $recipe; $hash = ""; $ingredients = $recipe->getIngredientList(); usort($ingredients, [$this, "sort"]); foreach ($ingredients as $item) { $hash .= $item->getId() . ":" . ($item->getDamage() === null ? "?" : $item->getDamage()) . "x" . $item->getCount() . ","; } $this->recipeLookup[$result->getId() . ":" . $result->getDamage()][$hash] = $recipe; }