Class RecipeStorage

java.lang.Object
com.minecolonies.api.crafting.RecipeStorage
All Implemented Interfaces:
IRecipeStorage

public class RecipeStorage extends Object implements IRecipeStorage
Class used to represent a recipe in minecolonies.
  • Field Details

    • recipeLootParameters

      public static final net.minecraft.world.level.storage.loot.parameters.LootContextParamSet recipeLootParameters
      The loot parameter set definition
  • Method Details

    • builder

      public static RecipeStorage.Builder builder()
      Start building a RecipeStorage.
      Returns:
      the builder.
    • builder

      public static RecipeStorage.Builder builder(@NotNull @NotNull IRecipeStorage recipe)
      Start building a RecipeStorage.
      Parameters:
      recipe - a recipe to use as a base.
      Returns:
      the builder.
    • getInput

      public List<ItemStorage> getInput()
      Description copied from interface: IRecipeStorage
      Get the list of input items. Suppressing Sonar Rule Squid:S2384 The rule thinks we should return a copy of the list and not the list itself. But in this case the rule does not apply because the list is an unmodifiable list already
      Specified by:
      getInput in interface IRecipeStorage
      Returns:
      the list.
    • getCleanedInput

      @NotNull public @NotNull List<ItemStorage> getCleanedInput()
      Description copied from interface: IRecipeStorage
      Get the cleaned up list of the recipes. Air gets removed and equal items get put together. This returns an list of immutable itemStorage elements that cannot be tempered with.
      Specified by:
      getCleanedInput in interface IRecipeStorage
      Returns:
      the list.
    • getPrimaryOutput

      @NotNull public @NotNull net.minecraft.world.item.ItemStack getPrimaryOutput()
      Description copied from interface: IRecipeStorage
      Getter for the primary output.
      Specified by:
      getPrimaryOutput in interface IRecipeStorage
      Returns:
      the itemStack to be produced.
    • getGridSize

      public int getGridSize()
      Description copied from interface: IRecipeStorage
      Get the grid size.
      Specified by:
      getGridSize in interface IRecipeStorage
      Returns:
      the integer representing it. (2x2 = 4, 3x3 = 9, etc)
    • getIntermediate

      public net.minecraft.world.level.block.Block getIntermediate()
      Description copied from interface: IRecipeStorage
      Get the required intermediate for the recipe.
      Specified by:
      getIntermediate in interface IRecipeStorage
      Returns:
      the block.
    • canFullFillRecipe

      public boolean canFullFillRecipe(int qty, Map<ItemStorage,Integer> existingRequirements, @NotNull @NotNull net.neoforged.neoforge.items.IItemHandler... inventories)
      Description copied from interface: IRecipeStorage
      Method to check if with the help of inventories this recipe can be fulfilled. Also check if the inventory has enough to fulfill the existing requirements.
      Specified by:
      canFullFillRecipe in interface IRecipeStorage
      Parameters:
      qty - the quantity to craft.
      existingRequirements - map of existing requirements (pending requests).
      inventories - the inventories to check.
      Returns:
      true if possible, else false.
    • canFullFillRecipe

      public boolean canFullFillRecipe(int qty, Map<ItemStorage,Integer> existingRequirements, @NotNull @NotNull List<net.neoforged.neoforge.items.IItemHandler> citizen, @NotNull @NotNull IBuilding building)
      Description copied from interface: IRecipeStorage
      Method to check if with the help of inventories this recipe can be fulfilled. Also check if the inventory has enough to fulfill the existing requirements.
      Specified by:
      canFullFillRecipe in interface IRecipeStorage
      Parameters:
      qty - the quantity to craft.
      existingRequirements - map of existing requirements (pending requests).
      citizen - the citizen inventory to check.
      building - the building inv to check.
      Returns:
      true if possible, else false.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fullfillRecipeAndCopy

      public List<net.minecraft.world.item.ItemStack> fullfillRecipeAndCopy(net.minecraft.world.level.storage.loot.LootParams context, List<net.neoforged.neoforge.items.IItemHandler> handlers, boolean doInsert)
      Check for space, remove items, and insert crafted items, returning a copy of the crafted items.
      Specified by:
      fullfillRecipeAndCopy in interface IRecipeStorage
      Parameters:
      context - loot context
      handlers - the handlers to use
      Returns:
      copy of the crafted items if successful, null on failure
    • getToken

      public IToken<?> getToken()
      Description copied from interface: IRecipeStorage
      Get the unique token of the recipe.
      Specified by:
      getToken in interface IRecipeStorage
      Returns:
      the IToken.
    • getClassicForMultiOutput

      public RecipeStorage getClassicForMultiOutput(net.minecraft.world.item.ItemStack requiredOutput)
      Description copied from interface: IRecipeStorage
      Get the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternate
      Specified by:
      getClassicForMultiOutput in interface IRecipeStorage
      Parameters:
      requiredOutput - Which output wanted
      Returns:
      the RecipeStorage that is "right" for that output
    • getClassicForMultiOutput

      public RecipeStorage getClassicForMultiOutput(Predicate<net.minecraft.world.item.ItemStack> stackPredicate)
      Description copied from interface: IRecipeStorage
      Get the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternate
      Specified by:
      getClassicForMultiOutput in interface IRecipeStorage
      Parameters:
      stackPredicate - Predicate to select the right stack
      Returns:
      the RecipeStorage that is "right" for that output
    • getRecipeType

      public AbstractRecipeType<IRecipeStorage> getRecipeType()
      Description copied from interface: IRecipeStorage
      Get which type this recipe is This type comes from the RecipeTypes registry
      Specified by:
      getRecipeType in interface IRecipeStorage
      Returns:
      The recipe type
    • getRecipeSource

      public net.minecraft.resources.ResourceLocation getRecipeSource()
      Description copied from interface: IRecipeStorage
      Source of the recipe, ie registry name.
      Specified by:
      getRecipeSource in interface IRecipeStorage
      Returns:
    • getAlternateOutputs

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getAlternateOutputs()
      Description copied from interface: IRecipeStorage
      Get a list of alternates to getPrimaryOutput
      Specified by:
      getAlternateOutputs in interface IRecipeStorage
      Returns:
      a list if Itemstacks that this recipe can produce instead of getPrimaryOutput
    • getCraftingToolsAndSecondaryOutputs

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getCraftingToolsAndSecondaryOutputs()
      Description copied from interface: IRecipeStorage
      Get the tools and Secondary Output (leave behind in grid)
      Specified by:
      getCraftingToolsAndSecondaryOutputs in interface IRecipeStorage
      Returns:
      list of items that weren't consumed during crafting
    • getLootTable

      public net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> getLootTable()
      Description copied from interface: IRecipeStorage
      Get the location/id of the Loot table used for optional outputs
      Specified by:
      getLootTable in interface IRecipeStorage
      Returns:
      the resource location for the table
    • getRequiredTool

      @NotNull public @NotNull EquipmentTypeEntry getRequiredTool()
      Description copied from interface: IRecipeStorage
      Get the additional tool needed beyond the recipe (if any)
      Specified by:
      getRequiredTool in interface IRecipeStorage
      Returns:
      the required tool
    • getCraftingTools

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getCraftingTools()
      Description copied from interface: IRecipeStorage
      Get the tools (leave behind in grid)
      Specified by:
      getCraftingTools in interface IRecipeStorage
      Returns:
      list of items that weren't consumed during crafting
    • getSecondaryOutputs

      @NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getSecondaryOutputs()
      Description copied from interface: IRecipeStorage
      Get the secondary (leave behind in grid) outputs
      Specified by:
      getSecondaryOutputs in interface IRecipeStorage
      Returns:
      list of items that weren't consumed during crafting