Class ShulkerItemStackInvWrapper
- All Implemented Interfaces:
ICapabilityProvider
,IItemHandler
,IItemHandlerModifiable
-
Field Summary
Modifier and TypeFieldDescriptionprivate CompoundTag
private final LazyOptional<IItemHandler>
private NonNullList<ItemStack>
private final ItemStack
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable ICapabilityProvider
createDefaultProvider
(ItemStack itemStack) @NotNull ItemStack
extractItem
(int slot, int amount, boolean simulate) Extracts an ItemStack from the given slot.<T> @NotNull LazyOptional<T>
getCapability
(@NotNull Capability<T> cap, @Nullable Direction side) Retrieves the Optional handler for the capability requested on the specific side.private NonNullList<ItemStack>
int
getSlotLimit
(int slot) Retrieves the maximum stack size allowed to exist in the given slot.int
getSlots()
Returns the number of slots available@NotNull ItemStack
getStackInSlot
(int slot) Returns the ItemStack in a given slot.@NotNull ItemStack
insertItem
(int slot, @NotNull ItemStack stack, boolean simulate) Inserts an ItemStack into the given slot and return the remainder.boolean
isItemValid
(int slot, @NotNull ItemStack stack) This function re-implements the vanilla functionContainer.canPlaceItem(int, ItemStack)
.private NonNullList<ItemStack>
refreshItemList
(CompoundTag rootTag) private void
setItemList
(NonNullList<ItemStack> itemStacks) void
setStackInSlot
(int slot, @NotNull ItemStack stack) Overrides the stack in the given slot.private void
validateSlotIndex
(int slot) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
-
Field Details
-
stack
-
holder
-
cachedTag
-
itemStacksCache
-
-
Constructor Details
-
ShulkerItemStackInvWrapper
-
-
Method Details
-
createDefaultProvider
@Internal @Nullable public static @Nullable ICapabilityProvider createDefaultProvider(ItemStack itemStack) -
getSlots
public int getSlots()Description copied from interface:IItemHandler
Returns the number of slots available- Specified by:
getSlots
in interfaceIItemHandler
- Returns:
- The number of slots available
-
getStackInSlot
Description copied from interface:IItemHandler
Returns the ItemStack in a given slot. The result's stack size may be greater than the itemstack's max size. If the result is empty, then the slot is empty.IMPORTANT: This ItemStack MUST NOT be modified. This method is not for altering an inventory's contents. Any implementers who are able to detect modification through this method should throw an exception.
SERIOUSLY: DO NOT MODIFY THE RETURNED ITEMSTACK
- Specified by:
getStackInSlot
in interfaceIItemHandler
- Parameters:
slot
- Slot to query- Returns:
- ItemStack in given slot. Empty Itemstack if the slot is empty.
-
insertItem
@NotNull public @NotNull ItemStack insertItem(int slot, @NotNull @NotNull ItemStack stack, boolean simulate) Description copied from interface:IItemHandler
Inserts an ItemStack into the given slot and return the remainder. The ItemStack should not be modified in this function!
Note: This behaviour is subtly different fromIFluidHandler.fill(FluidStack, IFluidHandler.FluidAction)
- Specified by:
insertItem
in interfaceIItemHandler
- Parameters:
slot
- Slot to insert into.stack
- ItemStack to insert. This must not be modified by the item handler.simulate
- If true, the insertion is only simulated- Returns:
- The remaining ItemStack that was not inserted (if the entire stack is accepted, then return an empty ItemStack). May be the same as the input ItemStack if unchanged, otherwise a new ItemStack. The returned ItemStack can be safely modified after.
-
extractItem
Description copied from interface:IItemHandler
Extracts an ItemStack from the given slot.The returned value must be empty if nothing is extracted, otherwise its stack size must be less than or equal to
amount
andItemStack.getMaxStackSize()
.- Specified by:
extractItem
in interfaceIItemHandler
- Parameters:
slot
- Slot to extract from.amount
- Amount to extract (may be greater than the current stack's max limit)simulate
- If true, the extraction is only simulated- Returns:
- ItemStack extracted from the slot, must be empty if nothing can be extracted. The returned ItemStack can be safely modified after, so item handlers should return a new or copied stack.
-
validateSlotIndex
private void validateSlotIndex(int slot) -
getSlotLimit
public int getSlotLimit(int slot) Description copied from interface:IItemHandler
Retrieves the maximum stack size allowed to exist in the given slot.- Specified by:
getSlotLimit
in interfaceIItemHandler
- Parameters:
slot
- Slot to query.- Returns:
- The maximum stack size allowed in the slot.
-
isItemValid
Description copied from interface:IItemHandler
This function re-implements the vanilla function
Container.canPlaceItem(int, ItemStack)
. It should be used instead of simulated insertions in cases where the contents and state of the inventory are irrelevant, mainly for the purpose of automation and logic (for instance, testing if a minecart can wait to deposit its items into a full inventory, or if the items in the minecart can never be placed into the inventory and should move on).- isItemValid is false when insertion of the item is never valid.
- When isItemValid is true, no assumptions can be made and insertion must be simulated case-by-case.
- The actual items in the inventory, its fullness, or any other state are not considered by isItemValid.
- Specified by:
isItemValid
in interfaceIItemHandler
- Parameters:
slot
- Slot to query for validitystack
- Stack to test with for validity- Returns:
- true if the slot can insert the ItemStack, not considering the current state of the inventory. false if the slot can never insert the ItemStack in any situation.
-
setStackInSlot
Description copied from interface:IItemHandlerModifiable
Overrides the stack in the given slot. This method is used by the standard Forge helper methods and classes. It is not intended for general use by other mods, and the handler may throw an error if it is called unexpectedly.- Specified by:
setStackInSlot
in interfaceIItemHandlerModifiable
- Parameters:
slot
- Slot to modifystack
- ItemStack to set slot to (may be empty).
-
getItemList
-
refreshItemList
-
setItemList
-
getCapability
@NotNull public <T> @NotNull LazyOptional<T> getCapability(@NotNull @NotNull Capability<T> cap, @Nullable @Nullable Direction side) Description copied from interface:ICapabilityProvider
Retrieves the Optional handler for the capability requested on the specific side. The return value CAN be the same for multiple faces. Modders are encouraged to cache this value, using the listener capabilities of the Optional to be notified if the requested capability get lost.- Specified by:
getCapability
in interfaceICapabilityProvider
- Parameters:
cap
- The capability to checkside
- The Side to check from, CAN BE NULL. Null is defined to represent 'internal' or 'self'- Returns:
- The requested an optional holding the requested capability.
-