Skip to content

PlayerInventoryItemAccess

class PlayerInventoryItemAccess(
    player: Player, 
    val slot: Int, 
    expectedItem: Item
) : ItemContainerAccess

An ItemContainerAccess for an item sitting in player's own inventory at slot (vanilla net.minecraft.world.entity.player.Inventory numbering: hotbar 0-8, main 9-35).

Parameters

  • expectedItem: Guards stillValid against the slot's contents having been swapped out for a different item entirely (e.g. dropped and something else picked up into the same slot index) while the menu was open.

Constructors

PlayerInventoryItemAccess

constructor(
    player: Player, 
    slot: Int, 
    expectedItem: Item
)

Parameters

  • expectedItem: Guards stillValid against the slot's contents having been swapped out for a different item entirely (e.g. dropped and something else picked up into the same slot index) while the menu was open.

Properties

slot

val slot: Int

Functions

getStack

open override fun getStack(): ItemStack

Resolves the current backing ItemStack. Must be re-resolved fresh on every call, not cached - the underlying stack reference can be swapped out from under the menu (e.g. by another mod replacing the inventory slot's stack wholesale), and a cached reference would silently go stale rather than reflect that.

stillValid

open override fun stillValid(player: Player): Boolean

Whether player should still be allowed to keep this menu open.