Skip to content

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 mayPlace into 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 mayPlace into this slot.

Properties

container

val container: Container?

containerSlot

open val containerSlot: Int

filter

val filter: Predicate<ItemStack>

Parameters

  • filter: Restricts which stacks mayPlace into this slot.

index

var index: Int

isActive

open override fun isActive(): Boolean
open override val isActive: Boolean

isFake

open val isFake: Boolean

isHighlightable

item

open override val item: ItemStack

maxStackSize

open override val maxStackSize: Int

noItemIcon

@get:



Nullable



open val noItemIcon: Pair<ResourceLocation?, ResourceLocation?>?

slotIndex

open val slotIndex: Int

x

var x: Int

y

var y: Int

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

open fun hasItem(): Boolean

isSameInventory

open fun isSameInventory(other: Slot?): Boolean

mayPickup

open fun mayPickup(player: Player?): Boolean

mayPlace

open override fun mayPlace(stack: ItemStack): Boolean

onQuickCraft

open fun onQuickCraft(oldStack: ItemStack?, newStack: ItemStack?)

onTake

open fun onTake(player: Player?, stack: ItemStack?)

remove

open override fun remove(amount: Int): ItemStack

safeInsert

open fun safeInsert(stack: ItemStack?): ItemStack?
open fun safeInsert(stack: ItemStack?, increment: Int): ItemStack?

safeTake

open fun safeTake(
    count: Int, 
    decrement: Int, 
    player: Player?
): ItemStack?

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.

tryRemove

open fun tryRemove(
    count: Int, 
    decrement: Int, 
    player: Player?
): Optional<ItemStack?>?