SlotChange

data class SlotChange(val physicalSlot: Int, val virtualSlot: Int, val oldItem: ItemStack?, val newItem: ItemStack?, val virtualInventory: VirtualInventory)

Represents a change to a specific slot in the virtual inventory as a result of an interaction. This class contains information about the physical slot that was interacted with, the corresponding virtual slot in the virtual inventory, the old item that was in the slot before the interaction, and the new item that will be in the slot after the interaction. It also provides helper properties to determine if the change is an addition, removal, update, or swap of items.

Parameters

physicalSlot

The physical slot index in the player's inventory that was interacted with.

virtualSlot

The corresponding virtual slot index in the virtual inventory that is affected by the interaction.

oldItem

The item that was in the slot before the interaction. This can be null if the slot was empty.

newItem

The item that will be in the slot after the interaction. This can be null if the slot will be empty after the interaction.

virtualInventory

The virtual inventory that is being interacted with. This is used to determine which virtual inventory the slot change belongs to, as there may be multiple virtual inventories in the GUI.

Constructors

Link copied to clipboard
constructor(physicalSlot: Int, virtualSlot: Int, oldItem: ItemStack?, newItem: ItemStack?, virtualInventory: VirtualInventory)

Properties

Link copied to clipboard

Helper property to determine if the change is an addition of an item to the slot (i.e., the old item was null and the new item is not null).

Link copied to clipboard

Helper property to determine if the change is a removal of an item from the slot (i.e., the old item was not null and the new item is null).

Link copied to clipboard

Helper property to determine if the change is a swap of items in the slot (i.e., both old and new items are not null and are not similar, meaning they are different types of items or have different metadata).

Link copied to clipboard

Helper property to determine if the change is an update of the item in the slot (i.e., both old and new items are not null and are similar, meaning they are the same type of item with the same metadata).

Link copied to clipboard
val newItem: ItemStack?
Link copied to clipboard
val oldItem: ItemStack?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard