Package wtf.choco.alchema.crafting
Class CauldronIngredientItemStack
java.lang.Object
wtf.choco.alchema.crafting.CauldronIngredientItemStack
- All Implemented Interfaces:
CauldronIngredient
public class CauldronIngredientItemStack extends java.lang.Object implements CauldronIngredient
A
CauldronIngredient implementation wrapped around an ItemStack.
The item stack must match exactly in the cauldron (with the exception of the item
amount).- Author:
- Parker Hawke - Choco
-
Field Summary
Fields Modifier and Type Field Description static org.bukkit.NamespacedKeyKEYTheNamespacedKeyused for this ingredient type -
Constructor Summary
Constructors Constructor Description CauldronIngredientItemStack(@NotNull com.google.gson.JsonObject object)Construct a newCauldronIngredientItemStackdeserialized from the providedJsonObject.CauldronIngredientItemStack(@NotNull org.bukkit.inventory.ItemStack item)Construct a newCauldronIngredientItemStackwith an amount of 1.CauldronIngredientItemStack(@NotNull org.bukkit.inventory.ItemStack item, int amount)Construct a newCauldronIngredientItemStackwith a given amount. -
Method Summary
Modifier and Type Method Description @NotNull CauldronIngredientadjustAmountBy(int amount)Return a new cauldron ingredient with the amount changed by the specified amount.@NotNull org.bukkit.inventory.ItemStackasItemStack()Get this ingredient represented as anItemStack, if possible.booleanequals(java.lang.Object obj)intgetAmount()Get the amount of this ingredient.@NotNull org.bukkit.NamespacedKeygetKey()Get the key for this ingredient type.inthashCode()booleanisSimilar(@NotNull CauldronIngredient other)Check whether this ingredient is similar to the provided ingredient.@NotNull CauldronIngredientmerge(@NotNull CauldronIngredient other)Merge this ingredient with another ingredient.@NotNull com.google.gson.JsonObjecttoJson()Serialize this ingredient to aJsonObject.java.lang.StringtoString()Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface wtf.choco.alchema.crafting.CauldronIngredient
drop
-
Field Details
-
KEY
public static final org.bukkit.NamespacedKey KEYTheNamespacedKeyused for this ingredient type
-
-
Constructor Details
-
CauldronIngredientItemStack
public CauldronIngredientItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int amount)Construct a newCauldronIngredientItemStackwith a given amount.- Parameters:
item- the itemamount- the amount of material
-
CauldronIngredientItemStack
public CauldronIngredientItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack item)Construct a newCauldronIngredientItemStackwith an amount of 1.- Parameters:
item- the item
-
CauldronIngredientItemStack
public CauldronIngredientItemStack(@NotNull @NotNull com.google.gson.JsonObject object)Construct a newCauldronIngredientItemStackdeserialized from the providedJsonObject.- Parameters:
object- the object from which to deserialize
-
-
Method Details
-
getKey
@NotNull public @NotNull org.bukkit.NamespacedKey getKey()Description copied from interface:CauldronIngredientGet the key for this ingredient type.- Specified by:
getKeyin interfaceCauldronIngredient- Returns:
- the ingredient key
-
getAmount
public int getAmount()Description copied from interface:CauldronIngredientGet the amount of this ingredient.- Specified by:
getAmountin interfaceCauldronIngredient- Returns:
- the ingredient amount
-
asItemStack
@NotNull public @NotNull org.bukkit.inventory.ItemStack asItemStack()Description copied from interface:CauldronIngredientGet this ingredient represented as anItemStack, if possible.- Specified by:
asItemStackin interfaceCauldronIngredient- Returns:
- the item stack. null if no item stack representation
-
isSimilar
Description copied from interface:CauldronIngredientCheck whether this ingredient is similar to the provided ingredient. The ingredient amount is not taken into consideration when comparing.- Specified by:
isSimilarin interfaceCauldronIngredient- Parameters:
other- the other ingredient against which to compare- Returns:
- true if similar, false otherwise
-
merge
Description copied from interface:CauldronIngredientMerge this ingredient with another ingredient. The result of this method should be a new ingredient with the combined amounts of this ingredient and the one passed.- Specified by:
mergein interfaceCauldronIngredient- Parameters:
other- the other ingredient- Returns:
- the merged ingredient
-
adjustAmountBy
Description copied from interface:CauldronIngredientReturn a new cauldron ingredient with the amount changed by the specified amount. The amount can be either negative or positive but must not result in a negative or zero amount (i.e. ifgetAmount() - amountis 0 or negative, an exception will be thrown).- Specified by:
adjustAmountByin interfaceCauldronIngredient- Parameters:
amount- the change in amount to apply- Returns:
- the new ingredient
-
toJson
@NotNull public @NotNull com.google.gson.JsonObject toJson()Description copied from interface:CauldronIngredientSerialize this ingredient to aJsonObject.- Specified by:
toJsonin interfaceCauldronIngredient- Returns:
- the serialized json
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-