Class ItemStorage

java.lang.Object
com.minecolonies.api.crafting.ItemStorage
Direct Known Subclasses:
BuildingBuilderResource, ExactMatchItemStorage, ImmutableItemStorage

public class ItemStorage extends Object
Used to store an stack with various informations to compare items later on.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
    Set this to ignore the damage value in comparisons.
    protected final boolean
    Set this to ignore the damage value in comparisons.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemStorage(@NotNull com.google.gson.JsonObject jObject)
    Creates an instance of the storage from JSON
    ItemStorage(@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 Type
    Method
    Description
    Make a copy of the ItemStorage
    boolean
     
    int
    Getter for the quantity.
    int
    Getter for the damage value.
    @NotNull net.minecraft.world.item.Item
    Getter for the stack.
    net.minecraft.world.item.ItemStack
    Get the itemStack from this itemStorage.
    getItemStackOfListMatchingPredicate(List<ItemStorage> list, Predicate<net.minecraft.world.item.ItemStack> predicate)
    Check a list for an ItemStack matching a predicate.
    int
    Getter for the remaining durability value.
    int
     
    boolean
    Getter for the ignoreDamageValue.
    boolean
    Getter for the ignoreNBT.
    boolean
    Is this an empty ItemStorage
    boolean
    Ensure that two ItemStorage have the same comparison defintion
    void
    setAmount(int amount)
    Setter for the quantity.
    Get an immutable version of this item storage
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • shouldIgnoreDamageValue

      protected final boolean shouldIgnoreDamageValue
      Set this to ignore the damage value in comparisons.
    • shouldIgnoreNBTValue

      protected final boolean shouldIgnoreNBTValue
      Set 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 @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

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • matchDefinitionEquals

      public boolean matchDefinitionEquals(ItemStorage that)
      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

      public ItemStorage copy()
      Make a copy of the ItemStorage
      Returns:
      a copy
    • toImmutable

      public ImmutableItemStorage toImmutable()
      Get an immutable version of this item storage
      Returns:
      immutable wrapper