Package wtf.choco.alchema.crafting
Class CauldronIngredientEntityEssence
java.lang.Object
wtf.choco.alchema.crafting.CauldronIngredientEntityEssence
- All Implemented Interfaces:
CauldronIngredient
public class CauldronIngredientEntityEssence extends java.lang.Object implements CauldronIngredient
A
CauldronIngredient
implementation wrapped around an EntityEssenceData
.
The item stack must match that of a vial of entity essence.- Author:
- Parker Hawke - Choco
-
Field Summary
Fields Modifier and Type Field Description static org.bukkit.NamespacedKey
KEY
TheNamespacedKey
used for this ingredient type -
Constructor Summary
Constructors Constructor Description CauldronIngredientEntityEssence(@NotNull com.google.gson.JsonObject object, @NotNull EntityEssenceEffectRegistry essenceEffectRegistry)
Construct a newCauldronIngredientItemStack
deserialized from the providedJsonObject
.CauldronIngredientEntityEssence(@NotNull org.bukkit.entity.EntityType entityType, @NotNull EntityEssenceEffectRegistry essenceEffectRegistry)
Construct a newCauldronIngredientEntityEssence
with an amount of 1CauldronIngredientEntityEssence(@NotNull org.bukkit.entity.EntityType entityType, @NotNull EntityEssenceEffectRegistry essenceEffectRegistry, int amount)
Construct a newCauldronIngredientEntityEssence
with a given amount. -
Method Summary
Modifier and Type Method Description @NotNull CauldronIngredient
adjustAmountBy(int amount)
Return a new cauldron ingredient with the amount changed by the specified amount.@Nullable org.bukkit.inventory.ItemStack
asItemStack()
Get this ingredient represented as anItemStack
, if possible.@NotNull java.util.List<@NotNull org.bukkit.entity.Item>
drop(@NotNull AlchemicalCauldron cauldron, @NotNull org.bukkit.World world, @NotNull org.bukkit.Location location)
Drop this ingredient as one or moreItem
from the provided cauldron.boolean
equals(java.lang.Object obj)
int
getAmount()
Get the amount of this ingredient.@NotNull org.bukkit.NamespacedKey
getKey()
Get the key for this ingredient type.int
hashCode()
boolean
isSimilar(@NotNull CauldronIngredient other)
Check whether this ingredient is similar to the provided ingredient.@NotNull CauldronIngredient
merge(@NotNull CauldronIngredient other)
Merge this ingredient with another ingredient.@NotNull com.google.gson.JsonObject
toJson()
Serialize this ingredient to aJsonObject
.java.lang.String
toString()
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
KEY
public static final org.bukkit.NamespacedKey KEYTheNamespacedKey
used for this ingredient type
-
-
Constructor Details
-
CauldronIngredientEntityEssence
public CauldronIngredientEntityEssence(@NotNull @NotNull org.bukkit.entity.EntityType entityType, @NotNull @NotNull EntityEssenceEffectRegistry essenceEffectRegistry, int amount)Construct a newCauldronIngredientEntityEssence
with a given amount.- Parameters:
entityType
- the type of entity essenceessenceEffectRegistry
- the effect registryamount
- the amount of essence
-
CauldronIngredientEntityEssence
public CauldronIngredientEntityEssence(@NotNull @NotNull org.bukkit.entity.EntityType entityType, @NotNull @NotNull EntityEssenceEffectRegistry essenceEffectRegistry)Construct a newCauldronIngredientEntityEssence
with an amount of 1- Parameters:
entityType
- the type of entity essenceessenceEffectRegistry
- the effect registry
-
CauldronIngredientEntityEssence
public CauldronIngredientEntityEssence(@NotNull @NotNull com.google.gson.JsonObject object, @NotNull @NotNull EntityEssenceEffectRegistry essenceEffectRegistry)Construct a newCauldronIngredientItemStack
deserialized from the providedJsonObject
.- Parameters:
object
- the object from which to deserializeessenceEffectRegistry
- the effect registry
-
-
Method Details
-
getKey
@NotNull public @NotNull org.bukkit.NamespacedKey getKey()Description copied from interface:CauldronIngredient
Get the key for this ingredient type.- Specified by:
getKey
in interfaceCauldronIngredient
- Returns:
- the ingredient key
-
getAmount
public int getAmount()Description copied from interface:CauldronIngredient
Get the amount of this ingredient.- Specified by:
getAmount
in interfaceCauldronIngredient
- Returns:
- the ingredient amount
-
asItemStack
@Nullable public @Nullable org.bukkit.inventory.ItemStack asItemStack()Description copied from interface:CauldronIngredient
Get this ingredient represented as anItemStack
, if possible.- Specified by:
asItemStack
in interfaceCauldronIngredient
- Returns:
- the item stack. null if no item stack representation
-
isSimilar
Description copied from interface:CauldronIngredient
Check whether this ingredient is similar to the provided ingredient. The ingredient amount is not taken into consideration when comparing.- Specified by:
isSimilar
in interfaceCauldronIngredient
- Parameters:
other
- the other ingredient against which to compare- Returns:
- true if similar, false otherwise
-
merge
Description copied from interface:CauldronIngredient
Merge 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:
merge
in interfaceCauldronIngredient
- Parameters:
other
- the other ingredient- Returns:
- the merged ingredient
-
adjustAmountBy
Description copied from interface:CauldronIngredient
Return 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() - amount
is 0 or negative, an exception will be thrown).- Specified by:
adjustAmountBy
in interfaceCauldronIngredient
- Parameters:
amount
- the change in amount to apply- Returns:
- the new ingredient
-
drop
@NotNull public @NotNull java.util.List<@NotNull org.bukkit.entity.Item> drop(@NotNull @NotNull AlchemicalCauldron cauldron, @NotNull @NotNull org.bukkit.World world, @NotNull @NotNull org.bukkit.Location location)Description copied from interface:CauldronIngredient
Drop this ingredient as one or moreItem
from the provided cauldron.Default implementation of this method will, if not null, drop the result of
CauldronIngredient.asItemStack()
.- Specified by:
drop
in interfaceCauldronIngredient
- Parameters:
cauldron
- the cauldron from which to drop the ingredientsworld
- the world in which the cauldron resideslocation
- the location at which the items should be dropped- Returns:
- the list of Item entities that were dropped. If none, the returned list should be empty, never null
-
toJson
@NotNull public @NotNull com.google.gson.JsonObject toJson()Description copied from interface:CauldronIngredient
Serialize this ingredient to aJsonObject
.- Specified by:
toJson
in interfaceCauldronIngredient
- Returns:
- the serialized json
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-