Class BaseItemStackHandler

java.lang.Object
net.minecraftforge.items.ItemStackHandler
org.moddingx.libx.inventory.BaseItemStackHandler
All Implemented Interfaces:
net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, net.minecraftforge.items.IItemHandler, net.minecraftforge.items.IItemHandlerModifiable, IAdvancedItemHandler, IAdvancedItemHandlerModifiable

public class BaseItemStackHandler extends net.minecraftforge.items.ItemStackHandler implements IAdvancedItemHandlerModifiable
An ItemStackHandler that can be configured with common things required for many inventories. To get a BaseItemStackHandler, use builder(int).
  • Method Details

    • insertItem

      @Nonnull public net.minecraft.world.item.ItemStack insertItem(int slot, @Nonnull net.minecraft.world.item.ItemStack stack, boolean simulate)
      Specified by:
      insertItem in interface net.minecraftforge.items.IItemHandler
      Overrides:
      insertItem in class net.minecraftforge.items.ItemStackHandler
    • extractItem

      @Nonnull public net.minecraft.world.item.ItemStack extractItem(int slot, int amount, boolean simulate)
      Specified by:
      extractItem in interface net.minecraftforge.items.IItemHandler
      Overrides:
      extractItem in class net.minecraftforge.items.ItemStackHandler
    • getSlotLimit

      public int getSlotLimit(int slot)
      Specified by:
      getSlotLimit in interface net.minecraftforge.items.IItemHandler
      Overrides:
      getSlotLimit in class net.minecraftforge.items.ItemStackHandler
    • isItemValid

      public boolean isItemValid(int slot, @Nonnull net.minecraft.world.item.ItemStack stack)
      Specified by:
      isItemValid in interface net.minecraftforge.items.IItemHandler
      Overrides:
      isItemValid in class net.minecraftforge.items.ItemStackHandler
    • onContentsChanged

      public void onContentsChanged(int slot)
      Overrides:
      onContentsChanged in class net.minecraftforge.items.ItemStackHandler
    • onLoad

      protected void onLoad()
      Overrides:
      onLoad in class net.minecraftforge.items.ItemStackHandler
    • toVanilla

      public net.minecraft.world.Container toVanilla()
      Gets a vanilla container that wraps around this item handler.
    • getUnrestricted

      public IAdvancedItemHandlerModifiable getUnrestricted()
      Gets an item handler that wraps around this item handler but has no checks on which items are valid for a slot.
    • createCapability

      public net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable> createCapability()
      Creates a new LazyOptional for this inventory.
    • createUnrestrictedCapability

      public net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable> createUnrestrictedCapability()
      Creates a new LazyOptional for this inventory but without slot validation.
      See Also:
    • createCapability

      public net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable> createCapability(@Nullable Predicate<Integer> extract, @Nullable BiPredicate<Integer,net.minecraft.world.item.ItemStack> insert)
      Creates a new LazyOptional for this inventory.
      Parameters:
      extract - A predicate on whether an item can be extracted through this LazyOptional. This gets passed the slot to extract from.
      insert - A predicate on whether an item can be inserted through this LazyOptional. This gets passed the slot to insert to and the stack that should be inserted.
    • builder

      public static BaseItemStackHandler.Builder builder(int size)
      Creates a new BaseItemStackHandler.Builder for an item handler with the given size.