Class CustomRecipe

java.lang.Object
com.minecolonies.core.colony.crafting.CustomRecipe

public class CustomRecipe extends Object
This class represents a recipe loaded from custom data that is available to a crafter but not to a player
  • Field Details

    • RECIPE_TYPE_PROP

      public static final String RECIPE_TYPE_PROP
      The property name that indicates type for the recipe
      See Also:
    • RECIPE_TYPE_RECIPE

      public static final String RECIPE_TYPE_RECIPE
      The recipe type
      See Also:
    • RECIPE_TYPE_RECIPE_MULT_OUT

      public static final String RECIPE_TYPE_RECIPE_MULT_OUT
      The multiple output recipe type
      See Also:
    • RECIPE_TYPE_RECIPE_MULT_IN

      public static final String RECIPE_TYPE_RECIPE_MULT_IN
      The multiple input recipe type
      See Also:
    • RECIPE_TYPE_TEMPLATE

      public static final String RECIPE_TYPE_TEMPLATE
      The recipe template type
      See Also:
    • RECIPE_TYPE_REMOVE

      public static final String RECIPE_TYPE_REMOVE
      The remove type
      See Also:
    • RECIPE_ID_TO_REMOVE_PROP

      public static final String RECIPE_ID_TO_REMOVE_PROP
      The property name that indicates the recipe to remove
      See Also:
    • RECIPE_CRAFTER_PROP

      public static final String RECIPE_CRAFTER_PROP
      The property name that indicates crafter type for the recipe
      See Also:
    • RECIPE_INPUTS_PROP

      public static final String RECIPE_INPUTS_PROP
      The property name for the inputs array
      See Also:
    • RECIPE_SECONDARY_PROP

      public static final String RECIPE_SECONDARY_PROP
      The property name for the inputs array
      See Also:
    • RECIPE_ALTERNATE_PROP

      public static final String RECIPE_ALTERNATE_PROP
      The property name for the alternate output array
      See Also:
    • RECIPE_RESULT_PROP

      public static final String RECIPE_RESULT_PROP
      The property name for the result item
      See Also:
    • RECIPE_LOOTTABLE_PROP

      public static final String RECIPE_LOOTTABLE_PROP
      The property namefor the result loottable
      See Also:
    • RECIPE_TOOL_PROP

      public static final String RECIPE_TOOL_PROP
      The property name for the required tool
      See Also:
    • RECIPE_INTERMEDIATE_PROP

      public static final String RECIPE_INTERMEDIATE_PROP
      The property name for the intermediate block ID
      See Also:
    • RECIPE_RESEARCHID_PROP

      public static final String RECIPE_RESEARCHID_PROP
      The property name for the required research id
      See Also:
    • RECIPE_EXCLUDED_RESEARCHID_PROP

      public static final String RECIPE_EXCLUDED_RESEARCHID_PROP
      The property name for the research id that invalidates this recipe
      See Also:
    • RECIPE_BUILDING_MIN_LEVEL_PROP

      public static final String RECIPE_BUILDING_MIN_LEVEL_PROP
      The property name for the minimum level the building must be
      See Also:
    • RECIPE_BUILDING_MAX_LEVEL_PROP

      public static final String RECIPE_BUILDING_MAX_LEVEL_PROP
      The property name for the maximum level the building can be
      See Also:
    • RECIPE_MUST_EXIST

      public static final String RECIPE_MUST_EXIST
      The property name for if a recipe of the inputs must exist for the recipe to be valid
      See Also:
    • RECIPE_SHOW_TOOLTIP

      public static final String RECIPE_SHOW_TOOLTIP
      The property name to enable tooltip display (and transmission to the client).
      See Also:
    • RECIPE_TAG

      public static final String RECIPE_TAG
      The property name for a recipe template tag.
      See Also:
    • RECIPE_FILTER

      public static final String RECIPE_FILTER
      The property name for a recipe template filter.
      See Also:
  • Constructor Details

    • CustomRecipe

      public CustomRecipe(String crafter, int minBldgLevel, int maxBldgLevel, boolean mustExist, boolean showTooltip, net.minecraft.resources.ResourceLocation recipeId, Set<net.minecraft.resources.ResourceLocation> researchReqs, Set<net.minecraft.resources.ResourceLocation> researchExcludes, @Nullable @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTable, EquipmentTypeEntry requiredTool, List<ItemStorage> inputs, net.minecraft.world.item.ItemStack primaryOutput, List<net.minecraft.world.item.ItemStack> secondaryOutput, List<net.minecraft.world.item.ItemStack> altOutputs, net.minecraft.world.level.block.Block intermediate)
      Creates a custom recipe from its components.
      Parameters:
      crafter - The crafter for the recipe.
      minBldgLevel - Minimum level before the recipe can be learned.
      maxBldgLevel - Maximum level before buildings in the colony will remove the recipe, if learned.
      mustExist - If true, the custom recipe will only be learned if another recipe with the same output is taught to the building.
      showTooltip - If a tooltip describing the recipe should be attached to the item. Only one recipe per output should have showTooltip set to true.
      recipeId - The identifier for the recipe, as a resource location.
      researchReqs - Research IDs that the colony must have to begin the research.
      researchExcludes - Research IDs that will cause buildings in the colony to remove the recipe, if learned.
      lootTable - The loot table's resource location, if one is present.
      requiredTool - The tool required for this craft, if any. (In addition to any tools inferred from the recipe itself.)
      inputs - The consumed items, as ItemStorages.
      primaryOutput - The primary output of the recipe.
      secondaryOutput - The secondary outputs of the recipe. Most often items like buckets or tools.
      altOutputs - Alternative outputs of the recipe. Used to allow one taught recipe to result in multiple effective choices for the request system.
  • Method Details

    • parse

      public static CustomRecipe parse(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.resources.ResourceLocation recipeId, @NotNull @NotNull com.google.gson.JsonObject recipeJson)
      Parse a Json object into a Custom recipe
      Parameters:
      recipeId - the recipe id
      recipeJson - the json representing the recipe
      Returns:
      new instance of CustomRecipe
    • parseTemplate

      @NotNull public static @NotNull List<CustomRecipe> parseTemplate(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.resources.ResourceLocation baseId, @NotNull @NotNull com.google.gson.JsonObject templateJson)
      Parse a recipe template into a list of recipes. See ItemStackUtils.parseIdTemplate(java.lang.String, net.minecraft.resources.ResourceLocation) for details on the template replacement format.
      Parameters:
      baseId - the base recipe path
      templateJson - the recipe template
      Returns:
      a list of recipes for items discovered from the template
    • getCrafter

      public String getCrafter()
      Get the name of the crafter this recipe applies to
      Returns:
      crafter name
    • getRecipeId

      public net.minecraft.resources.ResourceLocation getRecipeId()
      Get the ID for this recipe
      Returns:
      Recipe Resource Location
    • getInputs

      public List<ItemStorage> getInputs()
      Gets the input items for this recipe
      Returns:
      input ItemStorages
    • getPrimaryOutput

      public net.minecraft.world.item.ItemStack getPrimaryOutput()
      Get the primary output for the recipe
      Returns:
      primary output ItemStack
    • getSecondaryOutput

      public List<net.minecraft.world.item.ItemStack> getSecondaryOutput()
      Get the secondary outputs for the recipe.
      Returns:
      secondary output ItemStacks
    • getAltOutputs

      public List<net.minecraft.world.item.ItemStack> getAltOutputs()
      Get the alternative outputs for the recipe.
      Returns:
      alternative output ItemStacks
    • getLootTable

      public net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> getLootTable()
      Get the Loot Table, if one is present.
      Returns:
      Loot Table resource location
    • getRequiredTool

      @NotNull public @NotNull EquipmentTypeEntry getRequiredTool()
      Get the required tool, if any.
      Returns:
      the tool required to perform this craft
    • getRequiredResearchIds

      public Set<net.minecraft.resources.ResourceLocation> getRequiredResearchIds()
      Get the IDs of research required before this recipe is valid. All researches must be done before this recipe is valid.
      Returns:
      The research IDs or empty if there is no such requirement.
    • getExcludedResearchIds

      public Set<net.minecraft.resources.ResourceLocation> getExcludedResearchIds()
      Get the IDs of research after which this recipe is no longer valid. All researches must be done before this recipe is no longer valid.
      Returns:
      The research IDs or empty if there is no such requirement.
    • getMinBuildingLevel

      public int getMinBuildingLevel()
      Get the minimum (inclusive) building level required before this recipe is valid.
      Returns:
      The minimum building level (0 means no such requirement).
    • getMaxBuildingLevel

      public int getMaxBuildingLevel()
      Get the maximum (inclusive) building level required to still consider this recipe valid.
      Returns:
      The maximum building level (the recipe is no longer valid at higher levels).
    • isValidForBuilding

      public boolean isValidForBuilding(IBuilding building)
      Check to see if the recipe is currently valid for the building This does research checks, to verify that the appropriate researches are in the correct states
      Parameters:
      building - Building to check recipe against.
    • getRecipeStorage

      public IRecipeStorage getRecipeStorage()
      Get the recipe storage represented by this recipe
      Returns:
      Recipe Storage
    • hashCode

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

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

      public boolean getMustExist()
      Does this require it to already be there?
    • getIntermediate

      public net.minecraft.world.level.block.Block getIntermediate()
      What is the intermediate block for this recipe?
    • getShowTooltip

      public boolean getShowTooltip()
      Should tooltip information be displayed on the client in inventory and JEI?
    • serialize

      public void serialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf packetBuffer)
      Serialize to network.
      Parameters:
      packetBuffer - buffer to serialize into.
    • deserialize

      public static CustomRecipe deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Deserialize from network.
      Parameters:
      buffer - network buffer.
      Returns:
      deserialized recipe.