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
ConstructorDescriptionMinecraftRecipeService
(Plugin plugin) This constructs a newMinecraftRecipeService
for the givenPlugin
. -
Method Summary
Modifier and TypeMethodDescriptiongetFurnaceOutput
(ItemStack input) This method returns anOptional
describing the output of aFurnaceRecipe
with the givenItemStack
as an input.getRecipe
(NamespacedKey key) Recipe[]
getRecipesFor
(ItemStack item) getRecipeShape
(Recipe recipe) This returns the shape of a givenRecipe
.boolean
isSmeltable
(ItemStack input) This returns whether a givenItemStack
can be smelted in aFurnaceRecipe
.void
refresh()
This method refreshes theRecipeSnapshot
that is used by theMinecraftRecipeService
.void
This method subscribes to the underlyingRecipeSnapshot
.
-
Constructor Details
-
MinecraftRecipeService
This constructs a newMinecraftRecipeService
for the givenPlugin
. Slimefun already has aMinecraftRecipeService
so creating your own won't be of much use unless you wanna expand upon it. It is advised to use Slimefun's built-inMinecraftRecipeService
though.- Parameters:
plugin
- ThePlugin
that requests this Service
-
-
Method Details
-
refresh
public void refresh()This method refreshes theRecipeSnapshot
that is used by theMinecraftRecipeService
. -
subscribe
public void subscribe(@Nonnull Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription) This method subscribes to the underlyingRecipeSnapshot
. When theServer
has finished loading and aCollection
of allRecipes
is created, the given callback will be run.- Parameters:
subscription
- A callback to run when theRecipeSnapshot
has been created.
-
getFurnaceOutput
This method returns anOptional
describing the output of aFurnaceRecipe
with the givenItemStack
as an input. -
isSmeltable
This returns whether a givenItemStack
can be smelted in aFurnaceRecipe
.- Parameters:
input
- TheItemStack
to test- Returns:
- Whether this item can be smelted
-
getRecipeShape
This returns the shape of a givenRecipe
. For any shapelessRecipe
the result will be equivalent toRecipeSnapshot.getRecipeInput(Recipe)
. For aShapedRecipe
this method will fix the order so it matches a 3x3 crafting grid.- Parameters:
recipe
- TheRecipe
to get the shape from- Returns:
- An Array of
RecipeChoice
representing the shape of thisRecipe
-
getRecipesFor
-
getRecipe
This returns the correspondingKeyed
Recipe
for the givenNamespacedKey
. If noRecipe
was 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
Recipe
or null
-