Skip to content

gui

Window

Python
Window(
    window_id: int,
    window_type: str,
    title: Message,
    slot_count: int,
)

Represents a GUI window containing multiple item slots.

Windows are containers like chests, inventories, or crafting tables that hold items in organized slots. Each window has a type, title, and fixed number of slots.

ATTRIBUTE DESCRIPTION
id

The window's unique identifier.

TYPE: int

type

Window type classification.

TYPE: str

title

Window's display title as a Message object.

TYPE: Message

slot_count

Total number of available slots.

TYPE: int

slots

List of all slots in this window.

TYPE: List[Slot]

properties

Window-specific properties (furnace progress, etc.).

TYPE: Dict[int, Any]

_action_counter

Counter for generating unique action numbers for window clicks.

TYPE: int

get_next_action_number

Python
get_next_action_number() -> int

Generate the next unique action number for window clicks.

Each window click needs a unique action number that the server uses to send back confirmation packets. This counter starts at 1 and increments for each action.

RETURNS DESCRIPTION
int

Unique action number for this window

set_slot

Python
set_slot(slot_index: int, item: Optional[ItemData]) -> Slot

Set an item in a specific slot.

Updates the slot at the given index with item data. If item is None, the slot is cleared. The slot's item and item_count are updated accordingly.

PARAMETER DESCRIPTION
slot_index

Index of the slot to modify (0-based)

TYPE: int

item

Item data to place in slot, or None to clear the slot Expected keys: 'item_id', 'item_damage', 'nbt', 'item_count'

TYPE: Optional[ItemData]

RETURNS DESCRIPTION
Slot

The modified slot object

RAISES DESCRIPTION
IndexError

If slot_index is out of bounds (< 0 or >= slot_count)

get_slot

Python
get_slot(slot_id: int) -> Optional[Slot]

Retrieve a slot by its index.

PARAMETER DESCRIPTION
slot_id

Index of the slot to retrieve (0-based)

TYPE: int

RETURNS DESCRIPTION
Optional[Slot]

The slot at the given index, or None if index is out of bounds

set_property

Python
set_property(property_id: int, value: int) -> None

Set a window-specific property.

Properties are used for window-specific data like furnace cooking progress, enchantment table seed, etc. The meaning depends on the window type.

PARAMETER DESCRIPTION
property_id

Identifier for the property type

TYPE: int

value

New value for the property

TYPE: int


Slot

Python
Slot(index: int)

Represents a single inventory slot that can hold an item.

A slot is identified by an index and can contain an item with a specific count. Slots can be empty (no item or zero count).

ATTRIBUTE DESCRIPTION
index

The slot's position index in the container

TYPE: int

item

The item currently in this slot, None if empty

TYPE: Optional[Item]

is_empty property

Python
is_empty: bool

Check if the slot is empty.

A slot is considered empty if it has no item or the item count is zero or negative.

RETURNS DESCRIPTION
bool

True if slot is empty (no item or count <= 0), False otherwise