net.kernelpanicsoft.archie.gui.item¶
Types¶
ComposeItemContainerMenu¶
abstract class ComposeItemContainerMenu<SELF : ComposeItemContainerMenu<SELF>>(
type: MenuType<SELF>,
id: Int,
playerInventory: Inventory,
itemAccess: ItemContainerAccess
) : ComposeContainerMenuBase<SELF> , SyncedItemHolder
Base class for net.minecraft.world.item.ItemStack-backed Compose container menus - e.g. a backpack/bag with its own GUI. The ComposeBlockContainerMenu equivalent for items.
ComposeItemState¶
class ComposeItemState(val containerId: Int)
Client- and server-side state holder for a ComposeItemContainerMenu's synchronized properties. The ComposeBlockEntityState equivalent for item-backed menus, keyed by containerId instead of a net.minecraft.core.BlockPos.
ItemContainerAccess¶
interface ItemContainerAccess
Locates the ItemStack backing a ComposeItemContainerMenu and reports whether it's still valid to keep the menu open.
ItemStateManager¶
object ItemStateManager
Server-side manager for currently-open ComposeItemContainerMenus: drives dirty-property sync packets each tick (mirroring net.kernelpanicsoft.archie.gui.blockentity.BlockEntityStateManager), and force-closes a menu whose ItemContainerAccess reports it's no longer valid - e.g. the backing item was consumed/dropped while the GUI was passively open. Vanilla's own stillValid polling only fires reactively on player-initiated clicks otherwise, so without this a stale menu could sit open indefinitely against a stack that no longer exists.
ItemStatePacket¶
@Serializable
data class ItemStatePacket(
val containerId: Int,
val updates: Map<String, BlockEntityStatePacket.SerializedValue> = emptyMap(),
val timestamp: Long = 0
)
A network packet that carries ComposeItemContainerMenu state changes from server to client - the item-backed-menu equivalent of BlockEntityStatePacket. containerId addresses the player's currently open menu directly rather than acting as a lookup key: an item-backed menu is inherently 1:1 with one player's session, so there's no position-keyed registry to look anything up in, unlike a block entity that can be watched by multiple players at once. It's checked purely as a staleness guard against a stray packet arriving after this player closed one item menu and opened another.
ItemStatePacketRegistry¶
object ItemStatePacketRegistry
Registers ItemStatePacket/ItemUpdatePacket handlers with ArchieNetworkChannel - the net.kernelpanicsoft.archie.gui.blockentity.BlockEntityStatePacketRegistry equivalent for item-backed menus.
ItemUpdatePacket¶
@Serializable
data class ItemUpdatePacket(val containerId: Int, val updates: Map<String, BlockEntityStatePacket.SerializedValue>)
A network packet that carries ComposeItemContainerMenu state updates from client to server - the item-backed-menu equivalent of net.kernelpanicsoft.archie.gui.blockentity.BlockEntityUpdatePacket. See ItemStatePacket for what containerId is used for.
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).
SyncedItemHolder¶
interface SyncedItemHolder
Implemented by whatever owns an net.kernelpanicsoft.archie.serialization.NBTHolder.item-backed holder that wants its @Sync-annotated fields to actually push updates somewhere, mirroring what net.minecraft.world.level.block.entity.BlockEntity gets automatically via net.kernelpanicsoft.archie.gui.blockentity.BlockEntityStateManager.
Properties¶
LocalItemState¶
val LocalItemState: ProvidableCompositionLocal<ComposeItemState?>
Provides the current ComposeItemContainerMenu's state to composables in the composition tree - the ComposeItemState equivalent of net.kernelpanicsoft.archie.gui.blockentity.LocalBlockEntityState. null when the current screen's menu isn't item-backed.
Functions¶
observeItemProperty¶
@Composable
inline fun <T> observeItemProperty(propertyName: String, initialValue: T? = null): MutableState<T?>
Observes a property on the current ComposeItemContainerMenu in the current composition context. The net.kernelpanicsoft.archie.gui.blockentity.observeProperty equivalent for item-backed menus.