Class MinecraftRecipeService
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService
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 Summary
ConstructorsConstructorDescriptionMinecraftRecipeService(org.bukkit.plugin.Plugin plugin) This constructs a newMinecraftRecipeServicefor the givenPlugin. -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.bukkit.inventory.ItemStack> getFurnaceOutput(org.bukkit.inventory.ItemStack input) This method returns anOptionaldescribing the output of aFurnaceRecipewith the givenItemStackas an input.org.bukkit.inventory.RecipegetRecipe(org.bukkit.NamespacedKey key) This returns the correspondingKeyedRecipefor the givenNamespacedKey.org.bukkit.inventory.Recipe[]getRecipesFor(org.bukkit.inventory.ItemStack item) This returns an array containing allRecipesfor crafting the givenItemStack.org.bukkit.inventory.RecipeChoice[]getRecipeShape(org.bukkit.inventory.Recipe recipe) This returns the shape of a givenRecipe.booleanisSmeltable(org.bukkit.inventory.ItemStack input) This returns whether a givenItemStackcan be smelted in aFurnaceRecipe.voidrefresh()This method refreshes theRecipeSnapshotthat is used by theMinecraftRecipeService.voidThis method subscribes to the underlyingRecipeSnapshot.
-
Constructor Details
-
MinecraftRecipeService
public MinecraftRecipeService(@Nonnull org.bukkit.plugin.Plugin plugin) This constructs a newMinecraftRecipeServicefor the givenPlugin. Slimefun already has aMinecraftRecipeServiceso creating your own won't be of much use unless you wanna expand upon it. It is advised to use Slimefun's built-inMinecraftRecipeServicethough.- Parameters:
plugin- ThePluginthat requests this Service
-
-
Method Details
-
refresh
public void refresh()This method refreshes theRecipeSnapshotthat is used by theMinecraftRecipeService. -
subscribe
public void subscribe(@Nonnull Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription) This method subscribes to the underlyingRecipeSnapshot. When theServerhas finished loading and aCollectionof allRecipesis created, the given callback will be run.- Parameters:
subscription- A callback to run when theRecipeSnapshothas been created.
-
getFurnaceOutput
@Nonnull public Optional<org.bukkit.inventory.ItemStack> getFurnaceOutput(@Nullable org.bukkit.inventory.ItemStack input) This method returns anOptionaldescribing the output of aFurnaceRecipewith the givenItemStackas an input.- Parameters:
input- The inputItemStack- Returns:
- An
Optionaldescribing the furnace output of the givenItemStack
-
isSmeltable
public boolean isSmeltable(@Nullable org.bukkit.inventory.ItemStack input) This returns whether a givenItemStackcan be smelted in aFurnaceRecipe.- Parameters:
input- TheItemStackto test- Returns:
- Whether this item can be smelted
-
getRecipeShape
@Nonnull public org.bukkit.inventory.RecipeChoice[] getRecipeShape(@Nonnull org.bukkit.inventory.Recipe recipe) This returns the shape of a givenRecipe. For any shapelessRecipethe result will be equivalent toRecipeSnapshot.getRecipeInput(Recipe). For aShapedRecipethis method will fix the order so it matches a 3x3 crafting grid.- Parameters:
recipe- TheRecipeto get the shape from- Returns:
- An Array of
RecipeChoicerepresenting the shape of thisRecipe
-
getRecipesFor
@Nonnull public org.bukkit.inventory.Recipe[] getRecipesFor(@Nullable org.bukkit.inventory.ItemStack item) This returns an array containing allRecipesfor crafting the givenItemStack.- Parameters:
item- TheItemStackfor which to get the recipes- Returns:
- An array of
Recipesto craft the givenItemStack
-
getRecipe
@Nullable public org.bukkit.inventory.Recipe getRecipe(@Nonnull org.bukkit.NamespacedKey key) This returns the correspondingKeyedRecipefor the givenNamespacedKey. If noRecipewas found, null will be returned. This is a significantly faster method overBukkit.getRecipe(NamespacedKey)since we operate on a cachedHashMap- Parameters:
key- TheNamespacedKey- Returns:
- The corresponding
Recipeor null
-