set

operator fun set(slot: Int, itemStack: ItemStack?)

Allows for array-like assignment to the virtual inventory's items using the bracket notation. This operator function delegates to the setItem method, enabling you to set items in the inventory using syntax like virtualInventoryslot = itemStack. If the provided itemStack is null, has an amount of 0, or is of type AIR, the specified slot will be cleared (set to null). Otherwise, the provided ItemStack will be set in the inventory at the specified slot. This provides a convenient way to modify items in the virtual inventory without needing to call setItem directly.

Parameters

slot

The index of the slot to update, which should be between 0 and size-1. If the slot index is out of bounds, the method will return without making any changes.

itemStack

The ItemStack to set in the specified slot. If this is null, has an amount of 0, or is of type AIR, the slot will be cleared (set to null). Otherwise, the provided ItemStack will be set in the inventory at the specified slot.