Class RecipeUtil.Ingredient
java.lang.Object
me.mehboss.utils.RecipeUtil.Ingredient
- Enclosing class:
RecipeUtil
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
ConstructorsConstructorDescriptionIngredient(String abbreviation, org.bukkit.Material material) Parameterized constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMaterialChoice(org.bukkit.Material material) Adds an additional validMaterialfor this ingredient.Getter for the abbreviation of the ingredient, like G for grass Used when shaping the recipeintGetter for the amount requirementintGetter for an ingredients model dataGetter for the ingredient displaynameGetter for an ingredients identifierorg.bukkit.inventory.ItemStackgetItem()Getter for an ingredient itemstackorg.bukkit.MaterialGetter for the material of the ingredientList<org.bukkit.Material> Gets all additional materials that may satisfy this ingredient.org.bukkit.material.MaterialDataDeprecated.intgetSlot()Getter for the ingredient slotGetter for if an ingredient has CMDbooleanGetter for if the ingredient has a displayname setbooleanGetter for if the ingredient has an identifier setbooleanChecks whether this ingredient has multiple valid materials.booleanDeprecated.Use modernRecipeChoiceorMaterialAPIs instead.booleanisEmpty()Getter for checking if the ingredient is emptyvoidsetAmount(int amount) Setter for the amount requirementvoidsetCustomModelData(int data) Setter for an ingredients custom model datavoidsetDisplayName(String displayName) Setter for the ingredients displaynamevoidsetIdentifier(String identifier) Setter for the identifier of the ingredient Requires the ingredient to be tagged with another Custom RecipevoidsetItem(org.bukkit.inventory.ItemStack item) Setter for the itemstack of the ingredientvoidsetMaterial(org.bukkit.Material material) Setter for the material of the ingredient This should NEVER be used, except internally!voidsetMaterialData(org.bukkit.material.MaterialData data) Deprecated.Use modernRecipeChoiceorMaterialAPIs instead.voidsetSlot(int slot) Setter for the slot the ingredient is set to, not required for shapeless
-
Constructor Details
-
Ingredient
Parameterized constructor. Initializes an Ingredient object with specified abbreviation and material- Parameters:
abbreviation- the letter of the ingredientmaterial- 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
Setter for the ingredients displayname- Parameters:
displayname- the name the ingredient is required to have
-
setIdentifier
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
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
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.Use modernRecipeChoiceorMaterialAPIs instead. MaterialData was removed after Minecraft 1.13.Gets the legacyMaterialDataof this ingredient.Only valid on Minecraft versions prior to 1.13. On newer versions this will always return
null.- Returns:
- the legacy
MaterialData, ornullif not set
-
setMaterialData
Deprecated.Use modernRecipeChoiceorMaterialAPIs instead. MaterialData was removed after Minecraft 1.13.Sets the legacyMaterialDatafor this ingredient.Only valid on Minecraft versions prior to 1.13. On newer versions this call has no effect.
- Parameters:
data- the legacyMaterialData
-
addMaterialChoice
public void addMaterialChoice(org.bukkit.Material material) Adds an additional validMaterialfor 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
Gets all additional materials that may satisfy this ingredient.- Returns:
- a list of valid material choices
-
hasMaterialData
Deprecated.Use modernRecipeChoiceorMaterialAPIs instead. MaterialData was removed after Minecraft 1.13.Checks whether this ingredient has legacyMaterialData.Always returns
falseon Minecraft versions 1.13 and newer.- Returns:
trueif legacyMaterialDatais set and running on a legacy server, otherwisefalse
-
hasMaterialChoices
public boolean hasMaterialChoices()Checks whether this ingredient has multiple valid materials.- Returns:
- true if one or more material choices are defined
-
getAbbreviation
Getter for the abbreviation of the ingredient, like G for grass Used when shaping the recipe -
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
-
RecipeChoiceorMaterialAPIs instead.