Package org.moddingx.libx.inventory
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)
.-
Nested Class Summary
-
Field Summary
Fields inherited from class net.minecraftforge.items.ItemStackHandler
stacks
-
Method Summary
Modifier and TypeMethodDescriptionstatic BaseItemStackHandler.Builder
builder
(int size) Creates a newBaseItemStackHandler.Builder
for an item handler with the given size.net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable>
Creates a newLazyOptional
for this inventory.net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable>
createCapability
(Predicate<Integer> extract, BiPredicate<Integer, net.minecraft.world.item.ItemStack> insert) Creates a newLazyOptional
for this inventory.net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable>
Creates a newLazyOptional
for this inventory but without slot validation.net.minecraft.world.item.ItemStack
extractItem
(int slot, int amount, boolean simulate) int
getSlotLimit
(int slot) Gets an item handler that wraps around this item handler but has no checks on which items are valid for a slot.net.minecraft.world.item.ItemStack
insertItem
(int slot, net.minecraft.world.item.ItemStack stack, boolean simulate) boolean
isItemValid
(int slot, net.minecraft.world.item.ItemStack stack) void
onContentsChanged
(int slot) protected void
onLoad()
net.minecraft.world.Container
Gets a vanilla container that wraps around this item handler.Methods inherited from class net.minecraftforge.items.ItemStackHandler
deserializeNBT, getSlots, getStackInSlot, getStackLimit, serializeNBT, setSize, setStackInSlot, validateSlotIndex
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moddingx.libx.inventory.IAdvancedItemHandler
extractItem, extractItem, hasSpaceFor, hasSpaceFor, insertItem
Methods inherited from interface org.moddingx.libx.inventory.IAdvancedItemHandlerModifiable
clear, clear
Methods inherited from interface net.minecraftforge.items.IItemHandler
getSlots, getStackInSlot
Methods inherited from interface net.minecraftforge.items.IItemHandlerModifiable
setStackInSlot
-
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 interfacenet.minecraftforge.items.IItemHandler
- Overrides:
insertItem
in classnet.minecraftforge.items.ItemStackHandler
-
extractItem
@Nonnull public net.minecraft.world.item.ItemStack extractItem(int slot, int amount, boolean simulate) - Specified by:
extractItem
in interfacenet.minecraftforge.items.IItemHandler
- Overrides:
extractItem
in classnet.minecraftforge.items.ItemStackHandler
-
getSlotLimit
public int getSlotLimit(int slot) - Specified by:
getSlotLimit
in interfacenet.minecraftforge.items.IItemHandler
- Overrides:
getSlotLimit
in classnet.minecraftforge.items.ItemStackHandler
-
isItemValid
- Specified by:
isItemValid
in interfacenet.minecraftforge.items.IItemHandler
- Overrides:
isItemValid
in classnet.minecraftforge.items.ItemStackHandler
-
onContentsChanged
public void onContentsChanged(int slot) - Overrides:
onContentsChanged
in classnet.minecraftforge.items.ItemStackHandler
-
onLoad
protected void onLoad()- Overrides:
onLoad
in classnet.minecraftforge.items.ItemStackHandler
-
toVanilla
public net.minecraft.world.Container toVanilla()Gets a vanilla container that wraps around this item handler. -
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 newLazyOptional
for this inventory. -
createUnrestrictedCapability
public net.minecraftforge.common.util.LazyOptional<IAdvancedItemHandlerModifiable> createUnrestrictedCapability()Creates a newLazyOptional
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 newLazyOptional
for this inventory.- Parameters:
extract
- A predicate on whether an item can be extracted through thisLazyOptional
. This gets passed the slot to extract from.insert
- A predicate on whether an item can be inserted through thisLazyOptional
. This gets passed the slot to insert to and the stack that should be inserted.
-
builder
Creates a newBaseItemStackHandler.Builder
for an item handler with the given size.
-