Package com.minecolonies.api.crafting
Interface IGenericRecipe
- All Known Implementing Classes:
GenericRecipe
public interface IGenericRecipe
This is a generic recipe wrapper, used to abstract both potential
IRecipes (with multiple alternative ingredient sets) and concrete
IRecipeStorages (with one specific ingredient set selected by the
player). It is primarily used to make recipe validity checks and
used in the JEI integration display, but not for actual crafting.
-
Method Summary
Modifier and TypeMethodDescription@NotNull List<net.minecraft.world.item.ItemStack> Gets the secondary outputs of this recipe.@NotNull List<net.minecraft.world.item.ItemStack> Gets the primary output plus all alternative outputs of a multi-output recipe.intGets the required size of the crafting grid, 1-3.Gets the input ingredient lists of this recipe.@NotNull net.minecraft.world.level.block.BlockGets the 'intermediate' block required for crafting, in the same sense as IRecipeStorage.intReturns an arbitrary integer that influences recipe sort order based on level.@Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> Gets the identifier of the associated loot table, if any.@NotNull net.minecraft.world.item.ItemStackGets the primary output item of this recipe.@Nullable net.minecraft.resources.ResourceLocationGets the id of the original recipe used to build this.@Nullable net.minecraft.world.entity.EntityType<?> Gets a creature required to produce this recipe, if any.@NotNull EquipmentTypeEntryGets the tool required for this craft, if any.Gets some human-readable restrictions on when this recipe is valid.matchesInput(@NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Checks whether the given predicate matches any input item of this recipe.matchesOutput(@NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Checks whether the given predicate matches the output item of this recipe.
-
Method Details
-
getGridSize
int getGridSize()Gets the required size of the crafting grid, 1-3. (In particular, a value of 3 means that it can't be crafted in a 2x2 grid.) Although note that recipes derived from CustomRecipe always specify a size of 1 regardless of the number of input ingredients, since they don't want to apply any restriction. So don't rely on this too much.- Returns:
- the crafting grid width required to craft this recipe.
-
getRecipeId
@Nullable @Nullable net.minecraft.resources.ResourceLocation getRecipeId()Gets the id of the original recipe used to build this. Note that it may be null if this is a dynamic/taught recipe.- Returns:
- Null, or the original recipe id.
-
getPrimaryOutput
@NotNull @NotNull net.minecraft.world.item.ItemStack getPrimaryOutput()Gets the primary output item of this recipe. If this is empty, it means that this is a "loot recipe" where only the loot table defines the outputs.- Returns:
- The primary output item.
-
getAllMultiOutputs
Gets the primary output plus all alternative outputs of a multi-output recipe.- Returns:
- A list of the possible outputs of this recipe.
-
getAdditionalOutputs
Gets the secondary outputs of this recipe. Note that when the primary output is empty, these aren't extra outputs; they're a summary of the most likely drops from the loot table, purely for display purposes.- Returns:
- A list of the secondary outputs (additional, not alternative).
-
getInputs
Gets the input ingredient lists of this recipe.- Returns:
- The list of slots, each of which is a list of alternatives. Note that some recipes may have been "compacted" with a count of multiple items required in one slot, so you can't ignore that. As such this does not preserve the original crafting grid layout (if any).
-
matchesOutput
Optional<Boolean> matchesOutput(@NotNull @NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Checks whether the given predicate matches the output item of this recipe.- Parameters:
predicate- The predicate to test.- Returns:
- True if the output of this recipe matches the predicate; false if the output fails the predicate; empty otherwise.
-
matchesInput
Optional<Boolean> matchesInput(@NotNull @NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Checks whether the given predicate matches any input item of this recipe. Explicitly failing the predicate is considered more important -- if there's some inputs that pass and others that fail then this will return false.- Parameters:
predicate- The predicate to test.- Returns:
- True if any input (including alternates) matches the predicate; false if any input (including alternates) fails the predicate; empty otherwise.
-
getIntermediate
@NotNull @NotNull net.minecraft.world.level.block.Block getIntermediate()Gets the 'intermediate' block required for crafting, in the same sense as IRecipeStorage. Usually either AIR or FURNACE, but may be something else.- Returns:
- The intermediate crafting block.
-
getLootTable
@Nullable @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> getLootTable()Gets the identifier of the associated loot table, if any.- Returns:
- The loot table identifier, or null.
-
getRequiredTool
Gets the tool required for this craft, if any.- Returns:
- The required tool.
-
getRequiredEntity
@Nullable @Nullable net.minecraft.world.entity.EntityType<?> getRequiredEntity()Gets a creature required to produce this recipe, if any.- Returns:
- The required creature.
-
getRestrictions
Gets some human-readable restrictions on when this recipe is valid.- Returns:
- A list of restrictions.
-
getLevelSort
int getLevelSort()Returns an arbitrary integer that influences recipe sort order based on level.- Returns:
- a sorting number
-