Class ContainerInventoryAccess<T extends net.minecraft.world.Container>

java.lang.Object
net.darkhax.bookshelf.api.inventory.ContainerInventoryAccess<T>
All Implemented Interfaces:
IInventoryAccess
Direct Known Subclasses:
WorldlyContainerInventoryAccess

public class ContainerInventoryAccess<T extends net.minecraft.world.Container> extends Object implements IInventoryAccess
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final T
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
    extract(int slot, int amount, net.minecraft.core.Direction side, boolean modify)
    Attempts to extract items from the specified amount.
    int[]
    getAvailableSlots(net.minecraft.core.Direction side)
    Gets an array of accessible slot IDs for a given side of the inventory.
    int
    getSlotSize(int slot)
    Get the amount of items that can be held by a given slot.
    net.minecraft.world.item.ItemStack
    getStackInSlot(int slot)
    Gets the ItemStack in a given slot within the inventory.
    net.minecraft.world.item.ItemStack
    insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify)
    Attempts to insert an ItemStack into the given slot.
    net.minecraft.world.item.ItemStack
    insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify, boolean forceInsert)
     
    boolean
    isValidForSlot(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side)
    Checks if an ItemStack is the right type of item for a slot.
    protected void
    updateSlot(int slot, net.minecraft.world.item.ItemStack stack)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.darkhax.bookshelf.api.inventory.IInventoryAccess

    canExtract, canExtract, canInsert, canInsert, extract, extract, forEachSlot, getAvailableSlots, insert, insert, isValidForSlot
  • Field Details

    • internal

      protected final T extends net.minecraft.world.Container internal
  • Constructor Details

    • ContainerInventoryAccess

      public ContainerInventoryAccess(T internal)
  • Method Details

    • getAvailableSlots

      public int[] getAvailableSlots(net.minecraft.core.Direction side)
      Description copied from interface: IInventoryAccess
      Gets an array of accessible slot IDs for a given side of the inventory.
      Specified by:
      getAvailableSlots in interface IInventoryAccess
      Parameters:
      side - The side of the inventory being accessed. This is only relevant when accessing directional inventories.
      Returns:
      An array of accessible slot IDs.
    • getStackInSlot

      public net.minecraft.world.item.ItemStack getStackInSlot(int slot)
      Description copied from interface: IInventoryAccess
      Gets the ItemStack in a given slot within the inventory. The resulting ItemStack should be considered immutable.
      Specified by:
      getStackInSlot in interface IInventoryAccess
      Parameters:
      slot - The ID of the slot to access.
      Returns:
      The ItemStack in the given slot. This should be considered immutable.
    • insert

      public net.minecraft.world.item.ItemStack insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify)
      Description copied from interface: IInventoryAccess
      Attempts to insert an ItemStack into the given slot. If the ItemStack will not fully fit a partial insertion will be done instead.
      Specified by:
      insert in interface IInventoryAccess
      Parameters:
      slot - The ID of the slot to insert into.
      insertStack - The ItemStack to insert.
      side - The side of the inventory the item is being inserted through.
      modify - Should the contents of the inventory actually be modified?
      Returns:
      The remaining ItemStack that was not inserted. An empty stack indicates that the item was fully inserted.
    • insert

      public net.minecraft.world.item.ItemStack insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify, boolean forceInsert)
    • extract

      public net.minecraft.world.item.ItemStack extract(int slot, int amount, net.minecraft.core.Direction side, boolean modify)
      Description copied from interface: IInventoryAccess
      Attempts to extract items from the specified amount. You are not guaranteed to receive an item or as many of the item as you requested.
      Specified by:
      extract in interface IInventoryAccess
      Parameters:
      slot - The ID of the slot to extract from.
      amount - The amount of items to extract.
      side - The side the items are extracted from.
      modify - Should the contents of the inventory actually be modified?
      Returns:
      The extracted items.
    • getSlotSize

      public int getSlotSize(int slot)
      Description copied from interface: IInventoryAccess
      Get the amount of items that can be held by a given slot.
      Specified by:
      getSlotSize in interface IInventoryAccess
      Parameters:
      slot - The ID of the slot to query.
      Returns:
      The amount of items that can be held by the slot.
    • isValidForSlot

      public boolean isValidForSlot(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side)
      Description copied from interface: IInventoryAccess
      Checks if an ItemStack is the right type of item for a slot. This only validates the item and not the state of the inventory itself. For example a brewing stand fuel slot will return true on blaze powder even if the slot is full.

      This check is performed automatically when inserting an item.

      Specified by:
      isValidForSlot in interface IInventoryAccess
      Parameters:
      slot - The ID of the slot to query.
      stack - The stack to test.
      side - The side of the inventory being accessed.
      Returns:
      Whether the item is valid for the slot or not.
    • updateSlot

      protected void updateSlot(int slot, net.minecraft.world.item.ItemStack stack)