Class CombinedItemHandler
java.lang.Object
com.minecolonies.api.inventory.api.CombinedItemHandler
- All Implemented Interfaces:
IWorldNameableModifiable,net.minecraft.world.Nameable,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>,net.minecraftforge.items.IItemHandler,net.minecraftforge.items.IItemHandlerModifiable
public class CombinedItemHandler
extends Object
implements net.minecraftforge.items.IItemHandlerModifiable, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, IWorldNameableModifiable
Abstract class wrapping around multiple IItemHandler.
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedItemHandler(@NotNull String defaultName, @NotNull String customName, @NotNull net.minecraftforge.items.IItemHandlerModifiable... handlers) Method to create a new combinedCombinedItemHandlerwith a given custom name.CombinedItemHandler(@NotNull String defaultName, @NotNull net.minecraftforge.items.IItemHandlerModifiable... handlers) Method to create a newCombinedItemHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeNBT(net.minecraft.nbt.CompoundTag nbt) boolean@NotNull net.minecraft.world.item.ItemStackextractItem(int slot, int amount, boolean simulate) Extracts an ItemStack from the given slot.protected net.minecraftforge.items.IItemHandlerModifiable[]intgetLastIndex(int slot) Get last index of the current itemHandler a slot belongs to.@NotNull net.minecraft.network.chat.ComponentgetName()intgetSlotLimit(int slot) intgetSlots()Returns the number of slots available.@NotNull net.minecraft.world.item.ItemStackgetStackInSlot(int slot) Returns the ItemStack in a given slot.inthashCode()@NotNull net.minecraft.world.item.ItemStackinsertItem(int slot, @NotNull net.minecraft.world.item.ItemStack stack, boolean simulate) Inserts an ItemStack into the given slot and return the remainder.booleanisItemValid(int slot, net.minecraft.world.item.ItemStack stack) net.minecraft.nbt.CompoundTagvoidMethod to set the name of thisNameable.voidsetStackInSlot(int slot, net.minecraft.world.item.ItemStack stack) Overrides the stack in the given slot.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.Nameable
getCustomName, getDisplayName, hasCustomName
-
Constructor Details
-
CombinedItemHandler
public CombinedItemHandler(@NotNull @NotNull String defaultName, @NotNull @NotNull net.minecraftforge.items.IItemHandlerModifiable... handlers) Method to create a newCombinedItemHandler.- Parameters:
defaultName- The default name of thisCombinedItemHandler.handlers- The combiningIItemHandlerModifiable.
-
CombinedItemHandler
public CombinedItemHandler(@NotNull @NotNull String defaultName, @NotNull @NotNull String customName, @NotNull @NotNull net.minecraftforge.items.IItemHandlerModifiable... handlers) Method to create a new combinedCombinedItemHandlerwith a given custom name.- Parameters:
defaultName- The name of thisCombinedItemHandler.customName- The preset custom name of thisCombinedItemHandler.handlers- The combingingIItemHandlerModifiable.
-
-
Method Details
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()- Specified by:
serializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt) - Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
setStackInSlot
public void setStackInSlot(int slot, net.minecraft.world.item.ItemStack stack) 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:
setStackInSlotin interfacenet.minecraftforge.items.IItemHandlerModifiable- Parameters:
slot- Slot to modifystack- ItemStack to set slot to (may be null)- Throws:
RuntimeException- if the handler is called in a way that the handler was not expecting.
-
getLastIndex
public int getLastIndex(int slot) Get last index of the current itemHandler a slot belongs to.- Parameters:
slot- the slot of an itemHandler.- Returns:
- the last index.
-
getSlots
public int getSlots()Returns the number of slots available.- Specified by:
getSlotsin interfacenet.minecraftforge.items.IItemHandler- Returns:
- The number of slots available
-
getStackInSlot
@NotNull public @NotNull net.minecraft.world.item.ItemStack getStackInSlot(int slot) Returns the ItemStack in a given slot.The result's stack size may be greater than the itemstacks max size.
If the result is null, then the slot is empty. If the result is not null but the stack size is zero, then it represents an empty slot that will only accept* a specific itemstack.
IMPORTANT: This ItemStack MUST NOT be modified. This method is not for altering an inventories 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:
getStackInSlotin interfacenet.minecraftforge.items.IItemHandler- Parameters:
slot- Slot to query- Returns:
- ItemStack in given slot. May be null.
-
insertItem
@NotNull public @NotNull net.minecraft.world.item.ItemStack insertItem(int slot, @NotNull @NotNull net.minecraft.world.item.ItemStack stack, boolean simulate) 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 from IFluidHandlers.fill()- Specified by:
insertItemin interfacenet.minecraftforge.items.IItemHandler- Parameters:
slot- Slot to insert into.stack- ItemStack to insert.simulate- If true, the insertion is only simulated- Returns:
- The remaining ItemStack that was not inserted (if the entire stack is accepted, then return null). May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
-
extractItem
@NotNull public @NotNull net.minecraft.world.item.ItemStack extractItem(int slot, int amount, boolean simulate) Extracts an ItemStack from the given slot. The returned value must be null if nothing is extracted, otherwise it's stack size must not be greater than amount or the itemstacks getMaxStackSize().- Specified by:
extractItemin interfacenet.minecraftforge.items.IItemHandler- Parameters:
slot- Slot to extract from.amount- Amount to extract (may be greater than the current stacks max limit)simulate- If true, the extraction is only simulated- Returns:
- ItemStack extracted from the slot, must be null, if nothing can be extracted
-
getSlotLimit
public int getSlotLimit(int slot) - Specified by:
getSlotLimitin interfacenet.minecraftforge.items.IItemHandler
-
isItemValid
public boolean isItemValid(int slot, @Nonnull net.minecraft.world.item.ItemStack stack) - Specified by:
isItemValidin interfacenet.minecraftforge.items.IItemHandler
-
getHandlers
protected net.minecraftforge.items.IItemHandlerModifiable[] getHandlers() -
setName
Description copied from interface:IWorldNameableModifiableMethod to set the name of thisNameable.- Specified by:
setNamein interfaceIWorldNameableModifiable- Parameters:
name- The new name of thisNameable, or null to reset it to its default.
-
getName
@NotNull public @NotNull net.minecraft.network.chat.Component getName()- Specified by:
getNamein interfacenet.minecraft.world.Nameable
-
equals
-
hashCode
public int hashCode()
-