Class ItemHandlerInventoryState

java.lang.Object
org.cyclops.commoncapabilities.api.capability.inventorystate.ItemHandlerInventoryState
All Implemented Interfaces:
net.neoforged.neoforge.items.IItemHandler, IInventoryState
Direct Known Subclasses:
ItemHandlerModifiableInventoryState

public class ItemHandlerInventoryState extends Object implements IInventoryState, net.neoforged.neoforge.items.IItemHandler
An inventory state implementation that wraps around an IItemHandlerModifiable.
  • Constructor Details

    • ItemHandlerInventoryState

      public ItemHandlerInventoryState(net.neoforged.neoforge.items.IItemHandler itemHandler)
  • Method Details

    • setNewHash

      protected void setNewHash()
    • getState

      public int getState()
      Description copied from interface: IInventoryState
      Get a state value which represents the current state of an inventory. This method must be able to calculate the state very quickly. Ideally, this should be pre-calculated. If inventory contents change, this method is guaranteed to return a different result. A different state does however not necessarily guarantee an inventory change but it should in most cases since callers might gate expensive logic behind hash changes.
      Specified by:
      getState in interface IInventoryState
      Returns:
      A value representing the current state of an inventory.
    • getSlots

      public int getSlots()
      Specified by:
      getSlots in interface net.neoforged.neoforge.items.IItemHandler
    • getStackInSlot

      public net.minecraft.world.item.ItemStack getStackInSlot(int slot)
      Specified by:
      getStackInSlot in interface net.neoforged.neoforge.items.IItemHandler
    • insertItem

      public net.minecraft.world.item.ItemStack insertItem(int slot, net.minecraft.world.item.ItemStack stack, boolean simulate)
      Specified by:
      insertItem in interface net.neoforged.neoforge.items.IItemHandler
    • extractItem

      public net.minecraft.world.item.ItemStack extractItem(int slot, int amount, boolean simulate)
      Specified by:
      extractItem in interface net.neoforged.neoforge.items.IItemHandler
    • getSlotLimit

      public int getSlotLimit(int slot)
      Specified by:
      getSlotLimit in interface net.neoforged.neoforge.items.IItemHandler
    • isItemValid

      public boolean isItemValid(int slot, @Nonnull net.minecraft.world.item.ItemStack itemStack)
      Specified by:
      isItemValid in interface net.neoforged.neoforge.items.IItemHandler