CommonStorageMenuSlot¶
class CommonStorageMenuSlot(
storage: CommonStorage<ItemResource>,
val filter: Predicate<ItemStack> = Predicate { true },
slot: Int,
x: Int,
y: Int,
owningMenu: ComposeContainerMenuBase<*>
) : Slot
A vanilla Slot over one slot of any CommonStorage of items, so net.minecraft.world.inventory machinery (shift-click, drag, hotbar swap, ...) can operate on a storage that is not an ArchieItemStorage.
ArchieItemMenuSlot is the specialisation for Archie's own storage, which can be read and written as an ItemStack directly. This one has only the StorageSlot contract to work with, so it phrases the same operations as extract/insert - which is exactly what lets a view over some larger structure (one kind's layer of a multi-kind storage, a filtered projection, a storage assembled from several others) appear in a menu at all. Without it such a storage silently contributes no slots, since ComposeContainerMenuBase can only build from what it recognises.
Parameters¶
- filter: Restricts which stacks
mayPlaceinto this slot.
Constructors¶
CommonStorageMenuSlot¶
constructor(
storage: CommonStorage<ItemResource>,
filter: Predicate<ItemStack> = Predicate { true },
slot: Int,
x: Int,
y: Int,
owningMenu: ComposeContainerMenuBase<*>
)
Parameters
- filter: Restricts which stacks
mayPlaceinto this slot.
Properties¶
container¶
val container: Container?
containerSlot¶
open val containerSlot: Int
filter¶
Parameters
- filter: Restricts which stacks
mayPlaceinto this slot.
index¶
isActive¶
isFake¶
isHighlightable¶
open val isHighlightable: Boolean
item¶
open override val item: ItemStack
maxStackSize¶
open override val maxStackSize: Int
noItemIcon¶
@get:
Nullable
open val noItemIcon: Pair<ResourceLocation?, ResourceLocation?>?
slotIndex¶
x¶
y¶
Functions¶
allowModification¶
open override fun allowModification(player: Player): Boolean
See ArchieItemMenuSlot.allowModification - the same reasoning, for the same reason.
getItem¶
open override fun getItem(): ItemStack
getMaxStackSize¶
open override fun getMaxStackSize(): Int
open override fun getMaxStackSize(stack: ItemStack): Int
hasItem¶
isSameInventory¶
open fun isSameInventory(other: Slot?): Boolean
mayPickup¶
mayPlace¶
onQuickCraft¶
open fun onQuickCraft(oldStack: ItemStack?, newStack: ItemStack?)
onTake¶
open fun onTake(player: Player?, stack: ItemStack?)
remove¶
safeInsert¶
open fun safeInsert(stack: ItemStack?): ItemStack?
open fun safeInsert(stack: ItemStack?, increment: Int): ItemStack?
safeTake¶
set¶
open override fun set(stack: ItemStack)
Replaces this slot's contents.
Phrased as "take out whatever is there, put this in", because a StorageSlot has no overwrite of its own - and that is the right meaning anyway: a storage that refuses part of stack keeps only what it accepted rather than being forced past its own limit.
setBackground¶
open fun setBackground(atlas: ResourceLocation?, sprite: ResourceLocation?): Slot?
setByPlayer¶
open fun setByPlayer(stack: ItemStack?)
open fun setByPlayer(newStack: ItemStack?, oldStack: ItemStack?)
setChanged¶
open override fun setChanged()
Only a storage that manages its own updates has anything to batch here; anything else persists through its own insert/extract.