====== cWindow class ======
This class is the common ancestor for all window classes used by MCServer. It is inherited by the [[API:cLuaWindow|cLuaWindow]] class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window.

Note that one cWindow object can be used for multiple players at the same time, and therefore the slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and SetSlot() functions need to have the [[API:cPlayer|cPlayer]] parameter that specifies the player for which the contents are to be queried.
===== Constants =====
Use these constants instead of hard-coding numbers. These can be used in the dot notation: e. g. cWindow.Furnace .

These constants represent window type. Each window is of exactly one type.
^ Constant ^ Value ^ Meaning ^
| Inventory   | -1 | Player inventory window. This value is never actually sent to a client |
| Chest       | 0 | Both single-chest and double-chest windows have this type, they only differ in the number of slots |
| Workbench   | 1 | Crafting table window |
| Furnace     | 2 | |
| DropSpenser | 3 | Dropper or Dispenser |
| Enchantment | 4 | |
| Brewery     | 5 | The brewing stand window |
| NPCTrade    | 6 | Villager trading window |
| Beacon      | 7 | |
| Anvil       | 8 | |
| Hopper      | 9 | |

===== Functions =====
^ Function name ^ Parameters ^ Return value ^ Note ^
| GetSlot | [[API:cPlayer|cPlayer]], SlotNumber | [[API:cItem|cItem]] | Returns the item at the specified slot for the specified player. Returns nil if the slot number is invalid |
| GetWindowID | | number | Returns the ID of the window, as used by the network protocol |
| GetWindowTitle | | string | Returns the window title that will be displayed to the player |
| GetWindowType | | number | Returns the type of the window, one of the constants in the table above |
| IsSlotInPlayerHotbar | number | bool | Returns true if the specified slot number is in the player hotbar |
| IsSlotInPlayerInventory | number | bool | Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots! |
| IsSlotInPlayerMainInventory | number | bool | Returns true if the specified slot number is in the player's main inventory |
| SetSlot | [[API:cPlayer|cPlayer]], SlotNumber, [[API:cItem|cItem]] | | Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid |
| SetWindowTitle | string | | Sets the window title that will be displayed to the player |

Note that for windows created by MCServer, setting slot contents modifies the contents of the underlying storage block, if appropriate (e. g. chest window slots are mapped to the chest block entity slots).