Package com.minecolonies.api.crafting
Class GenericRecipe
java.lang.Object
com.minecolonies.api.crafting.GenericRecipe
- All Implemented Interfaces:
IGenericRecipe
Standard implementation of IGenericRecipe.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull GenericRecipe.Builderbuilder()Start building a generic recipe.static @NotNull GenericRecipe.Builderbuilder(@NotNull IGenericRecipe recipe) Start building a generic recipe.static @NotNull GenericRecipe.Builderbuilder(@NotNull IRecipeStorage storage) Start building a generic recipe.@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.ResourceLocationGets 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.static @Nullable IGenericRecipestatic @Nullable IGenericRecipeof(@Nullable net.minecraft.world.item.crafting.Recipe<?> recipe, @NotNull net.minecraft.world.level.Level world) Construct from vanilla recipe.toString()
-
Method Details
-
builder
Start building a generic recipe.- Returns:
- a builder.
-
builder
@NotNull public static @NotNull GenericRecipe.Builder builder(@NotNull @NotNull IGenericRecipe recipe) Start building a generic recipe.- Parameters:
recipe- initialise from this recipe.- Returns:
- a builder.
-
builder
@NotNull public static @NotNull GenericRecipe.Builder builder(@NotNull @NotNull IRecipeStorage storage) Start building a generic recipe.- Parameters:
storage- initialise from this recipe.- Returns:
- a builder.
-
of
@Nullable public static @Nullable IGenericRecipe of(@Nullable @Nullable net.minecraft.world.item.crafting.Recipe<?> recipe, @NotNull @NotNull net.minecraft.world.level.Level world) Construct from vanilla recipe.- Parameters:
recipe- the vanilla recipe.world- the world.- Returns:
- the recipe, or null.
-
of
-
getGridSize
public int getGridSize()Description copied from interface:IGenericRecipeGets 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.- Specified by:
getGridSizein interfaceIGenericRecipe- Returns:
- the crafting grid width required to craft this recipe.
-
getRecipeId
@Nullable public @Nullable net.minecraft.resources.ResourceLocation getRecipeId()Description copied from interface:IGenericRecipeGets the id of the original recipe used to build this. Note that it may be null if this is a dynamic/taught recipe.- Specified by:
getRecipeIdin interfaceIGenericRecipe- Returns:
- Null, or the original recipe id.
-
getPrimaryOutput
@NotNull public @NotNull net.minecraft.world.item.ItemStack getPrimaryOutput()Description copied from interface:IGenericRecipeGets 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.- Specified by:
getPrimaryOutputin interfaceIGenericRecipe- Returns:
- The primary output item.
-
getAllMultiOutputs
Description copied from interface:IGenericRecipeGets the primary output plus all alternative outputs of a multi-output recipe.- Specified by:
getAllMultiOutputsin interfaceIGenericRecipe- Returns:
- A list of the possible outputs of this recipe.
-
getAdditionalOutputs
Description copied from interface:IGenericRecipeGets 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.- Specified by:
getAdditionalOutputsin interfaceIGenericRecipe- Returns:
- A list of the secondary outputs (additional, not alternative).
-
getInputs
Description copied from interface:IGenericRecipeGets the input ingredient lists of this recipe.- Specified by:
getInputsin interfaceIGenericRecipe- 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).
-
getRestrictions
Description copied from interface:IGenericRecipeGets some human-readable restrictions on when this recipe is valid.- Specified by:
getRestrictionsin interfaceIGenericRecipe- Returns:
- A list of restrictions.
-
getLevelSort
public int getLevelSort()Description copied from interface:IGenericRecipeReturns an arbitrary integer that influences recipe sort order based on level.- Specified by:
getLevelSortin interfaceIGenericRecipe- Returns:
- a sorting number
-
matchesOutput
public Optional<Boolean> matchesOutput(@NotNull @NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Description copied from interface:IGenericRecipeChecks whether the given predicate matches the output item of this recipe.- Specified by:
matchesOutputin interfaceIGenericRecipe- 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
public Optional<Boolean> matchesInput(@NotNull @NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate) Description copied from interface:IGenericRecipeChecks 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.- Specified by:
matchesInputin interfaceIGenericRecipe- 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 public @NotNull net.minecraft.world.level.block.Block getIntermediate()Description copied from interface:IGenericRecipeGets the 'intermediate' block required for crafting, in the same sense as IRecipeStorage. Usually either AIR or FURNACE, but may be something else.- Specified by:
getIntermediatein interfaceIGenericRecipe- Returns:
- The intermediate crafting block.
-
getLootTable
@Nullable public @Nullable net.minecraft.resources.ResourceLocation getLootTable()Description copied from interface:IGenericRecipeGets the identifier of the associated loot table, if any.- Specified by:
getLootTablein interfaceIGenericRecipe- Returns:
- The loot table identifier, or null.
-
getRequiredTool
Description copied from interface:IGenericRecipeGets the tool required for this craft, if any.- Specified by:
getRequiredToolin interfaceIGenericRecipe- Returns:
- The required tool.
-
getRequiredEntity
@Nullable public @Nullable net.minecraft.world.entity.EntityType<?> getRequiredEntity()Description copied from interface:IGenericRecipeGets a creature required to produce this recipe, if any.- Specified by:
getRequiredEntityin interfaceIGenericRecipe- Returns:
- The required creature.
-
toString
-