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(Plugin plugin) This constructs a newMinecraftRecipeServicefor the givenPlugin. -
Method Summary
Modifier and TypeMethodDescriptiongetFurnaceOutput(ItemStack input) This method returns anOptionaldescribing the output of aFurnaceRecipewith the givenItemStackas an input.getRecipe(NamespacedKey key) Recipe[]getRecipesFor(ItemStack item) getRecipeShape(Recipe recipe) This returns the shape of a givenRecipe.booleanisSmeltable(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
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
This method returns anOptionaldescribing the output of aFurnaceRecipewith the givenItemStackas an input. -
isSmeltable
This returns whether a givenItemStackcan be smelted in aFurnaceRecipe.- Parameters:
input- TheItemStackto test- Returns:
- Whether this item can be smelted
-
getRecipeShape
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
-
getRecipe
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
-