Class AbstractRecipe
java.lang.Object
io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractRecipe
This class abstracts away from concrete recipes.
It supports
ShapedRecipe
, ShapelessRecipe
and
recipes made using the EnhancedCraftingTable
.- Author:
- TheBusyBiscuit
- See Also:
-
AbstractAutoCrafter
VanillaRecipe
SlimefunItemRecipe
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractRecipe
(Collection<Predicate<ItemStack>> ingredients, ItemStack result) Protected constructor. -
Method Summary
Modifier and TypeMethodDescriptionThis returns theCollection
of ingredients asPredicates
.This returns the result of thisAbstractRecipe
.boolean
This returns whether or not this recipe has been enabled.static AbstractRecipe
of
(SlimefunItem item, RecipeType recipeType) This static accessor is forSlimefunItem
recipes.static AbstractRecipe
This is our static accessor for theAbstractRecipe
class.void
setEnabled
(boolean enabled) This method enables or disables this recipe.abstract void
show
(ChestMenu menu, AsyncRecipeChoiceTask task) This will visually represent thisAbstractRecipe
in the givenChestMenu
.
-
Constructor Details
-
AbstractRecipe
@ParametersAreNonnullByDefault protected AbstractRecipe(Collection<Predicate<ItemStack>> ingredients, ItemStack result) Protected constructor. For implementation classes only.- Parameters:
ingredients
- The ingredients for this recipe as predicatesresult
- The resultingItemStack
-
-
Method Details
-
getIngredients
This returns theCollection
of ingredients asPredicates
.- Returns:
- The ingredients for this
AbstractRecipe
-
getResult
This returns the result of thisAbstractRecipe
. This will return the originalItemStack
, so make sure toItemStack.clone()
it.- Returns:
- The resulting
ItemStack
-
isEnabled
public boolean isEnabled()This returns whether or not this recipe has been enabled. A disabled recipe will not be crafted.- Returns:
- Whether this recipe is enabled
-
setEnabled
public void setEnabled(boolean enabled) This method enables or disables this recipe. A disabled recipe will not be crafted.- Parameters:
enabled
- Whether this recipe is enabled
-
show
This will visually represent thisAbstractRecipe
in the givenChestMenu
. AnyRecipeChoice.MaterialChoice
will be cycled through using theAsyncRecipeChoiceTask
.- Parameters:
menu
- TheChestMenu
to display the recipe intask
- TheAsyncRecipeChoiceTask
instance
-
of
This is our static accessor for theAbstractRecipe
class. It will create a newVanillaRecipe
for the givenRecipe
if it is a validRecipe
.Currently supported recipe types are
ShapedRecipe
andShapelessRecipe
. If theRecipe
is null or none of the aforementioned types, null will be returned.- Parameters:
recipe
- TheRecipe
to wrap- Returns:
- The wrapped
AbstractRecipe
or null
-
of
@Nullable public static AbstractRecipe of(@Nullable SlimefunItem item, @Nonnull RecipeType recipeType) This static accessor is forSlimefunItem
recipes. Note that theSlimefunItem
must be crafted using the specifiedRecipeType
, otherwise null will be returned.- Parameters:
item
- TheSlimefunItem
the recipe belongs torecipeType
- TheRecipeType
- Returns:
- The wrapped
AbstractRecipe
or null
-