Class RecipeUtil.Ingredient

java.lang.Object
me.mehboss.utils.RecipeUtil.Ingredient
Enclosing class:
RecipeUtil

public static class RecipeUtil.Ingredient extends Object
Represents a single ingredient used in a recipe. An Ingredient may define a specific ItemStack, a base Material, a list of acceptable material choices, custom display/name matching options, and metadata such as slot position, amount, and model data.

Ingredients are created with an abbreviation (the shaped-crafting key character) and may be configured with additional properties depending on the recipe type.

This class acts as a data container. Matching logic is performed elsewhere when validating recipe input.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Ingredient(String abbreviation, org.bukkit.Material material)
    Parameterized constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addMaterialChoice(org.bukkit.Material material)
    Adds an additional valid Material for this ingredient.
    Getter for the abbreviation of the ingredient, like G for grass Used when shaping the recipe
    int
    Getter for the amount requirement
    int
    Getter for an ingredients model data
    Getter for the ingredient displayname
    Getter for an ingredients identifier
    org.bukkit.inventory.ItemStack
    Getter for an ingredient itemstack
    org.bukkit.Material
    Getter for the material of the ingredient
    List<org.bukkit.Material>
    Gets all additional materials that may satisfy this ingredient.
    org.bukkit.material.MaterialData
    Deprecated.
    Use modern RecipeChoice or Material APIs instead.
    int
    Getter for the ingredient slot
    Getter for if an ingredient has CMD
    boolean
    Getter for if the ingredient has a displayname set
    boolean
    Getter for if the ingredient has an identifier set
    boolean
    Checks whether this ingredient has multiple valid materials.
    boolean
    Deprecated.
    Use modern RecipeChoice or Material APIs instead.
    boolean
    Getter for checking if the ingredient is empty
    void
    setAmount(int amount)
    Setter for the amount requirement
    void
    Setter for an ingredients custom model data
    void
    setDisplayName(String displayName)
    Setter for the ingredients displayname
    void
    setIdentifier(String identifier)
    Setter for the identifier of the ingredient Requires the ingredient to be tagged with another Custom Recipe
    void
    setItem(org.bukkit.inventory.ItemStack item)
    Setter for the itemstack of the ingredient
    void
    setMaterial(org.bukkit.Material material)
    Setter for the material of the ingredient This should NEVER be used, except internally!
    void
    setMaterialData(org.bukkit.material.MaterialData data)
    Deprecated.
    Use modern RecipeChoice or Material APIs instead.
    void
    setSlot(int slot)
    Setter for the slot the ingredient is set to, not required for shapeless

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Ingredient

      public Ingredient(String abbreviation, org.bukkit.Material material)
      Parameterized constructor. Initializes an Ingredient object with specified abbreviation and material
      Parameters:
      abbreviation - the letter of the ingredient
      material - the Material type for the ingredient, can be null or air
  • Method Details

    • setItem

      public void setItem(org.bukkit.inventory.ItemStack item)
      Setter for the itemstack of the ingredient
      Parameters:
      item - the itemstack for the ingredient to have, not required
    • getItem

      public org.bukkit.inventory.ItemStack getItem()
      Getter for an ingredient itemstack
    • setDisplayName

      public void setDisplayName(String displayName)
      Setter for the ingredients displayname
      Parameters:
      displayname - the name the ingredient is required to have
    • setIdentifier

      public void setIdentifier(String identifier)
      Setter for the identifier of the ingredient Requires the ingredient to be tagged with another Custom Recipe
      Parameters:
      identifier - the identifier/tag the ingredient is required to have
    • getIdentifier

      public String getIdentifier()
      Getter for an ingredients identifier
    • hasIdentifier

      public boolean hasIdentifier()
      Getter for if the ingredient has an identifier set
    • setSlot

      public void setSlot(int slot)
      Setter for the slot the ingredient is set to, not required for shapeless
      Parameters:
      slot - the inventory slot the ingredient is set to
      Throws:
      ArrayIndexOutOfBoundsException - if the slot is not within 1-9
    • getSlot

      public int getSlot()
      Getter for the ingredient slot
    • setAmount

      public void setAmount(int amount)
      Setter for the amount requirement
      Parameters:
      amount - the amount of the ingredient the recipe requires
    • getAmount

      public int getAmount()
      Getter for the amount requirement
    • isEmpty

      public boolean isEmpty()
      Getter for checking if the ingredient is empty
    • getDisplayName

      public String getDisplayName()
      Getter for the ingredient displayname
    • hasDisplayName

      public boolean hasDisplayName()
      Getter for if the ingredient has a displayname set
    • getMaterial

      public org.bukkit.Material getMaterial()
      Getter for the material of the ingredient
    • setMaterial

      public void setMaterial(org.bukkit.Material material)
      Setter for the material of the ingredient This should NEVER be used, except internally!
      Parameters:
      material - the material to be used
    • getMaterialData

      @Deprecated public org.bukkit.material.MaterialData getMaterialData()
      Deprecated.
      Use modern RecipeChoice or Material APIs instead. MaterialData was removed after Minecraft 1.13.
      Gets the legacy MaterialData of this ingredient.

      Only valid on Minecraft versions prior to 1.13. On newer versions this will always return null.

      Returns:
      the legacy MaterialData, or null if not set
    • setMaterialData

      @Deprecated public void setMaterialData(org.bukkit.material.MaterialData data)
      Deprecated.
      Use modern RecipeChoice or Material APIs instead. MaterialData was removed after Minecraft 1.13.
      Sets the legacy MaterialData for this ingredient.

      Only valid on Minecraft versions prior to 1.13. On newer versions this call has no effect.

      Parameters:
      data - the legacy MaterialData
    • addMaterialChoice

      public void addMaterialChoice(org.bukkit.Material material)
      Adds an additional valid Material for this ingredient.

      When material choices are defined, the ingredient will match if the input item's material is any of those added here.

      Parameters:
      material - a valid material option for this ingredient
    • getMaterialChoices

      public List<org.bukkit.Material> getMaterialChoices()
      Gets all additional materials that may satisfy this ingredient.
      Returns:
      a list of valid material choices
    • hasMaterialData

      @Deprecated public boolean hasMaterialData()
      Deprecated.
      Use modern RecipeChoice or Material APIs instead. MaterialData was removed after Minecraft 1.13.
      Checks whether this ingredient has legacy MaterialData.

      Always returns false on Minecraft versions 1.13 and newer.

      Returns:
      true if legacy MaterialData is set and running on a legacy server, otherwise false
    • hasMaterialChoices

      public boolean hasMaterialChoices()
      Checks whether this ingredient has multiple valid materials.
      Returns:
      true if one or more material choices are defined
    • getAbbreviation

      public String getAbbreviation()
      Getter for the abbreviation of the ingredient, like G for grass Used when shaping the recipe
    • hasCustomModelData

      public Boolean hasCustomModelData()
      Getter for if an ingredient has CMD
    • setCustomModelData

      public void setCustomModelData(int data)
      Setter for an ingredients custom model data
      Parameters:
      data - the custom model data of the ingredient
    • getCustomModelData

      public int getCustomModelData()
      Getter for an ingredients model data