Class GenericRecipe

java.lang.Object
com.minecolonies.api.crafting.GenericRecipe
All Implemented Interfaces:
IGenericRecipe

public class GenericRecipe extends Object implements IGenericRecipe
Standard implementation of IGenericRecipe.
  • Method Details

    • builder

      @NotNull public static @NotNull GenericRecipe.Builder 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

      @Nullable public static @Nullable IGenericRecipe of(@Nullable @Nullable IToken<?> recipeToken)
    • getGridSize

      public int getGridSize()
      Description copied from interface: IGenericRecipe
      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.
      Specified by:
      getGridSize in interface IGenericRecipe
      Returns:
      the crafting grid width required to craft this recipe.
    • getRecipeId

      @Nullable public @Nullable net.minecraft.resources.ResourceLocation getRecipeId()
      Description copied from interface: IGenericRecipe
      Gets 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:
      getRecipeId in interface IGenericRecipe
      Returns:
      Null, or the original recipe id.
    • getPrimaryOutput

      @NotNull public @NotNull net.minecraft.world.item.ItemStack getPrimaryOutput()
      Description copied from interface: IGenericRecipe
      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.
      Specified by:
      getPrimaryOutput in interface IGenericRecipe
      Returns:
      The primary output item.
    • getAllMultiOutputs

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getAllMultiOutputs()
      Description copied from interface: IGenericRecipe
      Gets the primary output plus all alternative outputs of a multi-output recipe.
      Specified by:
      getAllMultiOutputs in interface IGenericRecipe
      Returns:
      A list of the possible outputs of this recipe.
    • getAdditionalOutputs

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getAdditionalOutputs()
      Description copied from interface: IGenericRecipe
      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.
      Specified by:
      getAdditionalOutputs in interface IGenericRecipe
      Returns:
      A list of the secondary outputs (additional, not alternative).
    • getInputs

      @NotNull public @NotNull List<List<net.minecraft.world.item.ItemStack>> getInputs()
      Description copied from interface: IGenericRecipe
      Gets the input ingredient lists of this recipe.
      Specified by:
      getInputs in interface IGenericRecipe
      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

      @NotNull public @NotNull Supplier<List<net.minecraft.network.chat.Component>> getRestrictions()
      Description copied from interface: IGenericRecipe
      Gets some human-readable restrictions on when this recipe is valid.
      Specified by:
      getRestrictions in interface IGenericRecipe
      Returns:
      A list of restrictions.
    • getLevelSort

      public int getLevelSort()
      Description copied from interface: IGenericRecipe
      Returns an arbitrary integer that influences recipe sort order based on level.
      Specified by:
      getLevelSort in interface IGenericRecipe
      Returns:
      a sorting number
    • matchesOutput

      public Optional<Boolean> matchesOutput(@NotNull @NotNull OptionalPredicate<net.minecraft.world.item.ItemStack> predicate)
      Description copied from interface: IGenericRecipe
      Checks whether the given predicate matches the output item of this recipe.
      Specified by:
      matchesOutput in interface IGenericRecipe
      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: IGenericRecipe
      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.
      Specified by:
      matchesInput in interface IGenericRecipe
      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: IGenericRecipe
      Gets the 'intermediate' block required for crafting, in the same sense as IRecipeStorage. Usually either AIR or FURNACE, but may be something else.
      Specified by:
      getIntermediate in interface IGenericRecipe
      Returns:
      The intermediate crafting block.
    • getLootTable

      @Nullable public @Nullable net.minecraft.resources.ResourceLocation getLootTable()
      Description copied from interface: IGenericRecipe
      Gets the identifier of the associated loot table, if any.
      Specified by:
      getLootTable in interface IGenericRecipe
      Returns:
      The loot table identifier, or null.
    • getRequiredTool

      @NotNull public @NotNull EquipmentTypeEntry getRequiredTool()
      Description copied from interface: IGenericRecipe
      Gets the tool required for this craft, if any.
      Specified by:
      getRequiredTool in interface IGenericRecipe
      Returns:
      The required tool.
    • getRequiredEntity

      @Nullable public @Nullable net.minecraft.world.entity.EntityType<?> getRequiredEntity()
      Description copied from interface: IGenericRecipe
      Gets a creature required to produce this recipe, if any.
      Specified by:
      getRequiredEntity in interface IGenericRecipe
      Returns:
      The required creature.
    • toString

      public String toString()
      Overrides:
      toString in class Object