Class ItemStackItemContainer

java.lang.Object
com.hypixel.hytale.server.core.inventory.container.ItemContainer
com.hypixel.hytale.server.core.inventory.container.ItemStackItemContainer

public class ItemStackItemContainer extends ItemContainer
  • Field Details

    • CONTAINER_CODEC

      @Nonnull public static final KeyedCodec<org.bson.BsonDocument> CONTAINER_CODEC
    • CAPACITY_CODEC

      @Nonnull public static final KeyedCodec<Short> CAPACITY_CODEC
    • ITEMS_CODEC

      @Nonnull public static final KeyedCodec<ItemStack[]> ITEMS_CODEC
  • Method Details

    • getParentContainer

      public ItemContainer getParentContainer()
    • getItemStackSlot

      public short getItemStackSlot()
    • getOriginalItemStack

      public ItemStack getOriginalItemStack()
    • isItemStackValid

      public boolean isItemStackValid()
    • getCapacity

      public short getCapacity()
      Specified by:
      getCapacity in class ItemContainer
    • setGlobalFilter

      public void setGlobalFilter(@Nonnull FilterType globalFilter)
      Specified by:
      setGlobalFilter in class ItemContainer
    • setSlotFilter

      public void setSlotFilter(FilterActionType actionType, short slot, @Nullable SlotFilter filter)
      Specified by:
      setSlotFilter in class ItemContainer
    • clone

      public ItemContainer clone()
      Specified by:
      clone in class ItemContainer
    • isEmpty

      public boolean isEmpty()
      Overrides:
      isEmpty in class ItemContainer
    • getItemStack

      @Nullable public ItemStack getItemStack(short slot)
      Note: Optimized implementation since we have direct access to the lock.
      Overrides:
      getItemStack in class ItemContainer
    • writeToItemStack

      public static void writeToItemStack(@Nonnull ItemContainer itemContainer, short slot, ItemStack originalItemStack, ItemStack[] items)
      Writes the provided items array to an item stack in a container only if that item still matches the original item stack.
      Parameters:
      itemContainer - The container the item stack is in
      slot - The slot the item stack is in
      originalItemStack - The original item stack from this slot (what we expect to be there)
      items - The items to write into the item container stored on this item stack
    • getContainer

      @Nullable public static ItemStackItemContainer getContainer(@Nonnull ItemContainer itemContainer, short slot)
      Gets the container from an item stack stored in a container at the specified slot or null if the item doesn't have a container.
      Parameters:
      itemContainer - The item container the item stack is in
      slot - The slot in the container the item stack is in
      Returns:
      The container stored in the item at the specified slot or null if the item doesn't have a container
    • makeContainerWithCapacity

      @Nonnull public static ItemStackItemContainer makeContainerWithCapacity(@Nonnull ItemContainer itemContainer, short slot, short capacity)
      Creates an item container in the item stack at the specified slot in the item container with the specified capacity as long as the item doesn't already have a container already.
      Parameters:
      itemContainer - The item container the item stack is in
      slot - The slot in the container the item stack is in
      capacity - The capacity of the container to create in the item stack
      Returns:
      The item container created in the specified item stack
      Throws:
      IllegalArgumentException - If the item stack at the specified slot is "Empty"
      IllegalStateException - If the specified item stack already has a container
    • ensureContainer

      @Nullable public static ItemStackItemContainer ensureContainer(@Nonnull ItemContainer itemContainer, short slot, short capacity)
      Ensures the item stack at the specified slot has an item container. If the item stack does have a container it is returned (without modifying the capacity). If it does not then one is crated with the provided capacity.
      Parameters:
      itemContainer - The item container the item stack is in
      slot - The slot in the container the item stack is in
      capacity - The capacity of the container to create in the item stack if needed
      Returns:
      The item container in the item stack
    • ensureConfiguredContainer

      @Nullable public static ItemStackItemContainer ensureConfiguredContainer(@Nonnull ItemContainer itemContainer, short slot, @Nonnull ItemStackContainerConfig config)