Class InventoryComponent<T extends IComponentHarness>
java.lang.Object
net.minecraftforge.items.ItemStackHandler
com.hrznstudio.titanium.component.inventory.InventoryComponent<T>
- All Implemented Interfaces:
IScreenAddonProvider,IContainerAddonProvider,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>,net.minecraftforge.items.IItemHandler,net.minecraftforge.items.IItemHandlerModifiable
- Direct Known Subclasses:
SidedInventoryComponent
public class InventoryComponent<T extends IComponentHarness>
extends net.minecraftforge.items.ItemStackHandler
implements IScreenAddonProvider, IContainerAddonProvider
-
Field Summary
Fields inherited from class net.minecraftforge.items.ItemStackHandler
stacks -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStackextractItem(int slot, int amount, boolean simulate) getColorForSlotRendering(int slot) List<IFactory<? extends IContainerAddon>>BiPredicate<net.minecraft.world.item.ItemStack,Integer> BiPredicate<net.minecraft.world.item.ItemStack,Integer> net.minecraft.world.item.ItemStackgetItemStackForSlotRendering(int slot) getName()BiConsumer<net.minecraft.world.item.ItemStack,Integer> List<IFactory<? extends IScreenAddon>>intgetSlotLimit(int slot) Gets the predicate to check if a slot is enabledintgetXPos()intgetXSize()intgetYPos()intgetYSize()net.minecraft.world.item.ItemStackinsertItem(int slot, net.minecraft.world.item.ItemStack stack, boolean simulate) booleanbooleanisItemValid(int slot, net.minecraft.world.item.ItemStack stack) protected voidonContentsChanged(int slot) setColorGuiEnabled(boolean colorGuiEnabled) setComponentHarness(T componentHarness) Sets the tile where the inventory is to allow markForUpdate automaticallysetInputFilter(BiPredicate<net.minecraft.world.item.ItemStack, Integer> predicate) Sets the predicate input filter to filter what items go into which slot.setOnSlotChanged(BiConsumer<net.minecraft.world.item.ItemStack, Integer> onSlotChanged) Sets the predicate slot changed that gets triggered when a slot is changed.setOutputFilter(BiPredicate<net.minecraft.world.item.ItemStack, Integer> predicate) Sets the predicate output filter to filter what can be extracted from which slot.setRange(int x, int y) Defines how many slots/row and slots/columnsetSlotLimit(int limit) Sets the default limit for all the slotssetSlotLimit(int slot, int limit) Sets the limit amount for a specific slot, this limit has priority instead of the slot limit for all the slotssetSlotPosition(Function<Integer, org.apache.commons.lang3.tuple.Pair<Integer, Integer>> slotPosition) setSlotToColorRender(int slot, int color) setSlotToColorRender(int slot, Color color) setSlotToColorRender(int slot, net.minecraft.world.item.DyeColor color) setSlotToItemStackRender(int slot, net.minecraft.world.item.ItemStack stack) setSlotVisiblePredicate(Predicate<Integer> slotVisiblePredicate) Sets the slot enabled predicate that allows to disable/enable slotsvoidsetXPos(int xPos) voidsetYPos(int yPos) Methods inherited from class net.minecraftforge.items.ItemStackHandler
deserializeNBT, getSlots, getStackInSlot, getStackLimit, onLoad, serializeNBT, setSize, setStackInSlot, validateSlotIndexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.hrznstudio.titanium.container.addon.IContainerAddonProvider
canInteract
-
Constructor Details
-
InventoryComponent
-
-
Method Details
-
setRange
Defines how many slots/row and slots/column- Parameters:
x- How many slots there are horizontallyy- How many slots there are vertically- Returns:
- itself
-
setComponentHarness
Sets the tile where the inventory is to allow markForUpdate automatically- Parameters:
componentHarness- the object which owns this component- Returns:
- itself
-
setInputFilter
public InventoryComponent<T> setInputFilter(BiPredicate<net.minecraft.world.item.ItemStack, Integer> predicate) Sets the predicate input filter to filter what items go into which slot.- Parameters:
predicate- A bi predicate where the itemstack is the item trying to be inserted and the slot where is trying to be inserted to- Returns:
- itself
-
setOutputFilter
public InventoryComponent<T> setOutputFilter(BiPredicate<net.minecraft.world.item.ItemStack, Integer> predicate) Sets the predicate output filter to filter what can be extracted from which slot.- Parameters:
predicate- A bi predicate where the itemstack is the item trying to be extracted and the slot where is trying to be extracted- Returns:
- itself
-
insertItem
@Nonnull public net.minecraft.world.item.ItemStack insertItem(int slot, @Nonnull net.minecraft.world.item.ItemStack stack, boolean simulate) - Specified by:
insertItemin interfacenet.minecraftforge.items.IItemHandler- Overrides:
insertItemin classnet.minecraftforge.items.ItemStackHandler
-
extractItem
@Nonnull public net.minecraft.world.item.ItemStack extractItem(int slot, int amount, boolean simulate) - Specified by:
extractItemin interfacenet.minecraftforge.items.IItemHandler- Overrides:
extractItemin classnet.minecraftforge.items.ItemStackHandler
-
onContentsChanged
protected void onContentsChanged(int slot) - Overrides:
onContentsChangedin classnet.minecraftforge.items.ItemStackHandler
-
getName
-
getXPos
public int getXPos() -
setXPos
public void setXPos(int xPos) -
getYPos
public int getYPos() -
setYPos
public void setYPos(int yPos) -
getXSize
public int getXSize() -
getYSize
public int getYSize() -
getComponentHarness
-
getInsertPredicate
-
getExtractPredicate
-
getOnSlotChanged
-
setColorGuiEnabled
-
isColorGuiEnabled
public boolean isColorGuiEnabled() -
getSlotToColorRenderMap
-
setOnSlotChanged
public InventoryComponent<T> setOnSlotChanged(BiConsumer<net.minecraft.world.item.ItemStack, Integer> onSlotChanged) Sets the predicate slot changed that gets triggered when a slot is changed.- Parameters:
onSlotChanged- A bi predicate where the itemstack and slot changed- Returns:
- itself
-
setSlotLimit
Sets the limit amount for a specific slot, this limit has priority instead of the slot limit for all the slots- Parameters:
slot- The slot to set the limit tolimit- The limit for the slot- Returns:
- itself
-
setSlotToItemStackRender
public InventoryComponent<T> setSlotToItemStackRender(int slot, net.minecraft.world.item.ItemStack stack) - Parameters:
slot- The slot to render the stack instack- The Itemstack to render in the slot- Returns:
- itself
-
setSlotToColorRender
- Parameters:
slot- Slot which color should be set.color- The color of the slot- Returns:
- Returns the inventorycomponent
-
setSlotToColorRender
public InventoryComponent<T> setSlotToColorRender(int slot, net.minecraft.world.item.DyeColor color) - Parameters:
slot- Slot which color should be set.color- The color of the slot- Returns:
- Returns the inventorycomponent
-
setSlotToColorRender
- Parameters:
slot- Slot which color should be set.color- The color of the slot- Returns:
- Returns the inventorycomponent
-
getItemStackForSlotRendering
public net.minecraft.world.item.ItemStack getItemStackForSlotRendering(int slot) - Parameters:
slot- Slot to get the Render Stack for- Returns:
- Returns the Itemstack to be rendered
-
getColorForSlotRendering
- Parameters:
slot- Slot to get the Render Color for- Returns:
- Returns the Color to be rendered
-
setSlotLimit
Sets the default limit for all the slots- Parameters:
limit- The default limit for all the slot that don't have specific limit- Returns:
- itself
-
getSlotVisiblePredicate
Gets the predicate to check if a slot is enabled- Returns:
- predicate
-
setSlotVisiblePredicate
Sets the slot enabled predicate that allows to disable/enable slots- Parameters:
slotVisiblePredicate- a int predicate that checks slot id- Returns:
- itself
-
getSlotLimit
public int getSlotLimit(int slot) - Specified by:
getSlotLimitin interfacenet.minecraftforge.items.IItemHandler- Overrides:
getSlotLimitin classnet.minecraftforge.items.ItemStackHandler
-
getSlotPosition
-
setSlotPosition
-
isItemValid
public boolean isItemValid(int slot, @Nonnull net.minecraft.world.item.ItemStack stack) - Specified by:
isItemValidin interfacenet.minecraftforge.items.IItemHandler- Overrides:
isItemValidin classnet.minecraftforge.items.ItemStackHandler
-
getScreenAddons
- Specified by:
getScreenAddonsin interfaceIScreenAddonProvider
-
getContainerAddons
- Specified by:
getContainerAddonsin interfaceIContainerAddonProvider
-