Class MinecraftRecipeService

java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService

public class MinecraftRecipeService extends Object
This Service is responsible for accessing a RecipeSnapshot. This snapshot contains a compiled list of all recipes that could be found on the Server at the time the Service was loaded. This Service is primarily used by the SurvivalSlimefunGuide.
Author:
TheBusyBiscuit
  • Constructor Details

  • Method Details

    • refresh

      public void refresh()
      This method refreshes the RecipeSnapshot that is used by the MinecraftRecipeService.
    • subscribe

      public void subscribe(@Nonnull Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription)
      This method subscribes to the underlying RecipeSnapshot. When the Server has finished loading and a Collection of all Recipes is created, the given callback will be run.
      Parameters:
      subscription - A callback to run when the RecipeSnapshot has been created.
    • getFurnaceOutput

      @Nonnull public Optional<ItemStack> getFurnaceOutput(@Nullable ItemStack input)
      This method returns an Optional describing the output of a FurnaceRecipe with the given ItemStack as an input.
      Parameters:
      input - The input ItemStack
      Returns:
      An Optional describing the furnace output of the given ItemStack
    • isSmeltable

      public boolean isSmeltable(@Nullable ItemStack input)
      This returns whether a given ItemStack can be smelted in a FurnaceRecipe.
      Parameters:
      input - The ItemStack to test
      Returns:
      Whether this item can be smelted
    • getRecipeShape

      @Nonnull public RecipeChoice[] getRecipeShape(@Nonnull Recipe recipe)
      This returns the shape of a given Recipe. For any shapeless Recipe the result will be equivalent to RecipeSnapshot.getRecipeInput(Recipe). For a ShapedRecipe this method will fix the order so it matches a 3x3 crafting grid.
      Parameters:
      recipe - The Recipe to get the shape from
      Returns:
      An Array of RecipeChoice representing the shape of this Recipe
    • getRecipesFor

      @Nonnull public Recipe[] getRecipesFor(@Nullable ItemStack item)
      This returns an array containing all Recipes for crafting the given ItemStack.
      Parameters:
      item - The ItemStack for which to get the recipes
      Returns:
      An array of Recipes to craft the given ItemStack
    • getRecipe

      @Nullable public Recipe getRecipe(@Nonnull NamespacedKey key)
      This returns the corresponding Keyed Recipe for the given NamespacedKey. If no Recipe was found, null will be returned. This is a significantly faster method over Bukkit.getRecipe(NamespacedKey) since we operate on a cached HashMap
      Parameters:
      key - The NamespacedKey
      Returns:
      The corresponding Recipe or null