Class GhostStackHandler
java.lang.Object
top.girlkisser.lazuli.api.inventory.GhostStackHandler
- All Implemented Interfaces:
net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>,net.neoforged.neoforge.items.IItemHandler,net.neoforged.neoforge.items.IItemHandlerModifiable
@ParametersAreNonnullByDefault
public class GhostStackHandler
extends Object
implements net.neoforged.neoforge.items.IItemHandler, net.neoforged.neoforge.items.IItemHandlerModifiable, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
A "fake item stack handler." Extracted items are cleared instead of given and inserted
items are copied and not consumed.
This is useful for filter-style blocks and items where you want to specify item filters without needing to consume an item or use a weird UI.
TODO: EMI/JEI/REI/other recipe viewers drag-n-drop support
This is useful for filter-style blocks and items where you want to specify item filters without needing to consume an item or use a weird UI.
TODO: EMI/JEI/REI/other recipe viewers drag-n-drop support
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<net.minecraft.core.NonNullList<GhostItemStack>> A codec for anet.minecraft.core.NonNullList<GhostItemStack>.protected net.minecraft.core.NonNullList<GhostItemStack> The contained ghost stacks. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a ghost stack handler with a single slot.GhostStackHandler(int slots) A "fake item stack handler." Extracted items are cleared instead of given and inserted items are copied and not consumed.GhostStackHandler(Collection<GhostItemStack> stacks) Create a ghost stack handler with the given stacks. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeNBT(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.nbt.CompoundTag tag) net.minecraft.world.item.ItemStackextractItem(int i, int maxCount, boolean simulate) Use instead.get(int i) Get an item from the slot.intgetSlotLimit(int i) intgetSlots()net.minecraft.world.item.ItemStackgetStackInSlot(int i) net.minecraft.world.item.ItemStackinsertItem(int i, net.minecraft.world.item.ItemStack stack, boolean simulate) Use instead.booleanisItemValid(int i, net.minecraft.world.item.ItemStack arg) voidonContentsChanged(int slot) Invoked any time the contents of the ghost stack handler change.net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.core.HolderLookup.Provider registries) voidsetStackInSlot(int i, net.minecraft.world.item.ItemStack stack)
-
Field Details
-
LIST_CODEC
public static final com.mojang.serialization.Codec<net.minecraft.core.NonNullList<GhostItemStack>> LIST_CODECA codec for anet.minecraft.core.NonNullList<GhostItemStack>. -
stacks
The contained ghost stacks.
-
-
Constructor Details
-
GhostStackHandler
public GhostStackHandler()Create a ghost stack handler with a single slot. -
GhostStackHandler
public GhostStackHandler(int slots) A "fake item stack handler." Extracted items are cleared instead of given and inserted items are copied and not consumed.
This is useful for filter-style blocks and items where you want to specify item filters without needing to consume an item or use a weird UI.- Parameters:
slots- The amount of slots for the inventory.
-
GhostStackHandler
Create a ghost stack handler with the given stacks.- Parameters:
stacks- The stacks.
-
-
Method Details
-
onContentsChanged
public void onContentsChanged(int slot) Invoked any time the contents of the ghost stack handler change.- Parameters:
slot- The slot that changed.
-
get
Get an item from the slot.- Parameters:
i- The index to get an item from.- Returns:
- The ghost item stack.
-
setStackInSlot
public void setStackInSlot(int i, net.minecraft.world.item.ItemStack stack) - Specified by:
setStackInSlotin interfacenet.neoforged.neoforge.items.IItemHandlerModifiable
-
getSlots
public int getSlots()- Specified by:
getSlotsin interfacenet.neoforged.neoforge.items.IItemHandler
-
getStackInSlot
public net.minecraft.world.item.ItemStack getStackInSlot(int i) - Specified by:
getStackInSlotin interfacenet.neoforged.neoforge.items.IItemHandler
-
insertItem
@Obsolete public net.minecraft.world.item.ItemStack insertItem(int i, net.minecraft.world.item.ItemStack stack, boolean simulate) Use instead.- Specified by:
insertItemin interfacenet.neoforged.neoforge.items.IItemHandler
-
extractItem
@Obsolete public net.minecraft.world.item.ItemStack extractItem(int i, int maxCount, boolean simulate) Use instead.- Specified by:
extractItemin interfacenet.neoforged.neoforge.items.IItemHandler
-
getSlotLimit
public int getSlotLimit(int i) - Specified by:
getSlotLimitin interfacenet.neoforged.neoforge.items.IItemHandler
-
isItemValid
public boolean isItemValid(int i, net.minecraft.world.item.ItemStack arg) - Specified by:
isItemValidin interfacenet.neoforged.neoforge.items.IItemHandler
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(net.minecraft.core.HolderLookup.Provider registries) - Specified by:
serializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
deserializeNBT
public void deserializeNBT(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.nbt.CompoundTag tag) - Specified by:
deserializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-