Package com.minecolonies.api.crafting
Class ItemStorage
java.lang.Object
com.minecolonies.api.crafting.ItemStorage
- Direct Known Subclasses:
BuildingBuilderResource,ExactMatchItemStorage,ImmutableItemStorage
Used to store an stack with various informations to compare items later on.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanSet this to ignore the damage value in comparisons.protected final booleanSet this to ignore the damage value in comparisons. -
Constructor Summary
ConstructorsConstructorDescriptionItemStorage(net.minecraft.core.HolderLookup.Provider provider, @NotNull com.google.gson.JsonObject jObject) Creates an instance of the storage from JSONItemStorage(@NotNull net.minecraft.world.item.Item item) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.Item item, int amount) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue, boolean shouldIgnoreNBTValue) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack, int amount) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack, int amount, boolean ignoreDamageValue) Creates an instance of the storage.ItemStorage(@NotNull net.minecraft.world.item.ItemStack stack, int amount, boolean ignoreDamageValue, boolean ignoreNBTValue) Creates an instance of the storage. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Make a copy of the ItemStoragebooleanintGetter for the quantity.intGetter for the damage value.@NotNull net.minecraft.world.item.ItemgetItem()Getter for the stack.net.minecraft.world.item.ItemStackGet the itemStack from this itemStorage.static ItemStoragegetItemStackOfListMatchingPredicate(List<ItemStorage> list, Predicate<net.minecraft.world.item.ItemStack> predicate) Check a list for an ItemStack matching a predicate.intGetter for the remaining durability value.inthashCode()booleanGetter for the ignoreDamageValue.booleanGetter for the ignoreNBT.booleanisEmpty()Is this an empty ItemStoragebooleanEnsure that two ItemStorage have the same comparison defintionvoidsetAmount(int amount) Setter for the quantity.Get an immutable version of this item storagetoString()
-
Field Details
-
shouldIgnoreDamageValue
protected final boolean shouldIgnoreDamageValueSet this to ignore the damage value in comparisons. -
shouldIgnoreNBTValue
protected final boolean shouldIgnoreNBTValueSet this to ignore the damage value in comparisons.
-
-
Constructor Details
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, int amount, boolean ignoreDamageValue) Creates an instance of the storage.- Parameters:
stack- the stack.amount- the amount.ignoreDamageValue- should the damage value be ignored?
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, int amount, boolean ignoreDamageValue, boolean ignoreNBTValue) Creates an instance of the storage.- Parameters:
stack- the stack.amount- the amount.ignoreDamageValue- should the damage value be ignored?ignoreNBTValue- should the nbt value be ignored?
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, int amount) Creates an instance of the storage.- Parameters:
stack- the stack.amount- the amount.
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue, boolean shouldIgnoreNBTValue) Creates an instance of the storage.- Parameters:
stack- the stack.ignoreDamageValue- should the damage value be ignored?shouldIgnoreNBTValue- should the nbt value be ignored?
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue) Creates an instance of the storage.- Parameters:
stack- the stack.ignoreDamageValue- should the damage value be ignored?
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Creates an instance of the storage.- Parameters:
stack- the stack.
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.Item item, int amount) Creates an instance of the storage.- Parameters:
item- the item.amount- the number of items.
-
ItemStorage
public ItemStorage(@NotNull @NotNull net.minecraft.world.item.Item item) Creates an instance of the storage.- Parameters:
item- the item.
-
ItemStorage
public ItemStorage(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull com.google.gson.JsonObject jObject) Creates an instance of the storage from JSON- Parameters:
jObject- the JSON Object to parse
-
-
Method Details
-
getItemStackOfListMatchingPredicate
public static ItemStorage getItemStackOfListMatchingPredicate(List<ItemStorage> list, Predicate<net.minecraft.world.item.ItemStack> predicate) Check a list for an ItemStack matching a predicate.- Parameters:
list- the list to check.predicate- the predicate to test.- Returns:
- the matching stack or null if not found.
-
getItemStack
public net.minecraft.world.item.ItemStack getItemStack()Get the itemStack from this itemStorage.- Returns:
- the stack.
-
getAmount
public int getAmount()Getter for the quantity.- Returns:
- the amount.
-
setAmount
public void setAmount(int amount) Setter for the quantity.- Parameters:
amount- the amount.
-
ignoreDamageValue
public boolean ignoreDamageValue()Getter for the ignoreDamageValue.- Returns:
- true if should ignore.
-
ignoreNBT
public boolean ignoreNBT()Getter for the ignoreNBT.- Returns:
- true if should ignore.
-
toString
-
hashCode
public int hashCode() -
equals
-
matchDefinitionEquals
Ensure that two ItemStorage have the same comparison defintion- Parameters:
that- the item to compare to- Returns:
- true if the comparisons match
-
getItem
@NotNull public @NotNull net.minecraft.world.item.Item getItem()Getter for the stack.- Returns:
- the stack.
-
getDamageValue
public int getDamageValue()Getter for the damage value.- Returns:
- the damage value.
-
getRemainingDurablityValue
public int getRemainingDurablityValue()Getter for the remaining durability value.- Returns:
- the durability value.
-
isEmpty
public boolean isEmpty()Is this an empty ItemStorage- Returns:
- true if empty
-
copy
Make a copy of the ItemStorage- Returns:
- a copy
-
toImmutable
Get an immutable version of this item storage- Returns:
- immutable wrapper
-