Class ItemHandlerInventoryAccess

java.lang.Object
net.darkhax.bookshelf.impl.inventory.ItemHandlerInventoryAccess
All Implemented Interfaces:
IInventoryAccess

public class ItemHandlerInventoryAccess extends Object implements IInventoryAccess
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemHandlerInventoryAccess(net.minecraftforge.items.IItemHandler internal)
     
  • 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 stack, net.minecraft.core.Direction side, boolean modify)
    Attempts to insert an ItemStack into the given slot.
    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.

    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
  • Constructor Details

    • ItemHandlerInventoryAccess

      public ItemHandlerInventoryAccess(net.minecraftforge.items.IItemHandler 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 stack, 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.
      stack - 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.
    • 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.