Class ModularSlot
java.lang.Object
net.minecraft.world.inventory.Slot
net.minecraftforge.items.SlotItemHandler
codechicken.lib.inventory.container.modular.ModularSlot
public class ModularSlot
extends net.minecraftforge.items.SlotItemHandler
A fully configurable inventory slot.
If there is anything this slot can not do... Let me know.
Created by brandon3055 on 10/09/2023
-
Field Summary
Fields inherited from class net.minecraft.world.inventory.Slot
container, x, y -
Constructor Summary
ConstructorsConstructorDescriptionModularSlot(net.minecraft.world.Container container, int index) ModularSlot(net.minecraft.world.Container container, int index, int xPos, int yPos) ModularSlot(net.minecraftforge.items.IItemHandler itemHandler, int index) ModularSlot(net.minecraftforge.items.IItemHandler itemHandler, int index, int xPos, int yPos) -
Method Summary
Modifier and TypeMethodDescriptionintgetMaxStackSize(net.minecraft.world.item.ItemStack itemStack) booleanisActive()booleanmayPickup(net.minecraft.world.entity.player.Player player) booleanmayPlace(net.minecraft.world.item.ItemStack itemStack) noCheck()Do not use the containers canPlaceItem when checking if an item can be placed.onSet(BiConsumer<net.minecraft.world.item.ItemStack, net.minecraft.world.item.ItemStack> onSet) Allows you to get a callback when the slot contents are set.output()Configure this slot as an output only slot.voidset(net.minecraft.world.item.ItemStack itemStack) setCanRemove(BiPredicate<net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack> canRemove) Allows you to attach a "can remove" predicate that can block removal of a stack from the slot by the player.setEnabled(boolean enabled) setEnabled(Supplier<Boolean> enabled) setStackLimit(Function<net.minecraft.world.item.ItemStack, Integer> stackLimit) Allows you to apply a stack size limit that (if smaller) will override the container and the item stack limits.setValidator(Predicate<net.minecraft.world.item.ItemStack> validator) Allows you to attach a validator to control what items are allowed in this slot.Methods inherited from class net.minecraftforge.items.SlotItemHandler
getItem, getItemHandler, getMaxStackSize, initialize, onQuickCraft, removeMethods inherited from class net.minecraft.world.inventory.Slot
allowModification, checkTakeAchievements, getContainerSlot, getNoItemIcon, getSlotIndex, hasItem, isHighlightable, isSameInventory, onQuickCraft, onSwapCraft, onTake, safeInsert, safeInsert, safeTake, setBackground, setByPlayer, setChanged, tryRemove
-
Constructor Details
-
ModularSlot
public ModularSlot(net.minecraft.world.Container container, int index) -
ModularSlot
public ModularSlot(net.minecraftforge.items.IItemHandler itemHandler, int index) -
ModularSlot
public ModularSlot(net.minecraft.world.Container container, int index, int xPos, int yPos) -
ModularSlot
public ModularSlot(net.minecraftforge.items.IItemHandler itemHandler, int index, int xPos, int yPos)
-
-
Method Details
-
output
Configure this slot as an output only slot. Items can not be placed in this slot by the player. -
noCheck
Do not use the containers canPlaceItem when checking if an item can be placed. -
setValidator
Allows you to attach a validator to control what items are allowed in this slot. You can also limit a slots allowed contents via theContainer.canPlaceItem(int, ItemStack)method of the container.- Parameters:
validator- The validator predicate, If the predicate returns false for a stack, the stack will not be placed.
-
onSet
public ModularSlot onSet(BiConsumer<net.minecraft.world.item.ItemStack, net.minecraft.world.item.ItemStack> onSet) Allows you to get a callback when the slot contents are set. Parameters given are Old stack then New stack. -
setStackLimit
Allows you to apply a stack size limit that (if smaller) will override the container and the item stack limits. -
setCanRemove
public ModularSlot setCanRemove(BiPredicate<net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack> canRemove) Allows you to attach a "can remove" predicate that can block removal of a stack from the slot by the player. -
setEnabled
-
setEnabled
-
mayPlace
public boolean mayPlace(net.minecraft.world.item.ItemStack itemStack) - Overrides:
mayPlacein classnet.minecraftforge.items.SlotItemHandler
-
mayPickup
public boolean mayPickup(net.minecraft.world.entity.player.Player player) - Overrides:
mayPickupin classnet.minecraftforge.items.SlotItemHandler
-
set
public void set(net.minecraft.world.item.ItemStack itemStack) - Overrides:
setin classnet.minecraftforge.items.SlotItemHandler
-
isActive
public boolean isActive()- Overrides:
isActivein classnet.minecraft.world.inventory.Slot
-
getMaxStackSize
public int getMaxStackSize(net.minecraft.world.item.ItemStack itemStack) - Overrides:
getMaxStackSizein classnet.minecraftforge.items.SlotItemHandler
-