Skip to content

UI Windows

Windows are used for inventory and container interfaces — a different system from custom pages. See Player Inventory for the inventory API and ItemStack documentation.

TypePurpose
ContainerGeneric container with slots
PocketCrafting2x2 crafting grid
BasicCrafting3x3 crafting grid
DiagramCraftingRecipe book interface
StructuralCraftingBuilding/structure crafting
ProcessingFurnace-like processing
MemoriesMemory storage UI
Player player = store.getComponent(ref, Player.getComponentType());
WindowManager windowManager = player.getWindowManager();
ItemContainer container = new ItemContainer(27);
ContainerWindow window = new ContainerWindow(container);
windowManager.openWindow(ref, window, store);
// close by window ID
windowManager.closeWindow(ref, windowId, store);
// close all windows
windowManager.closeAllWindows(ref, store);

Windows can validate they’re still valid (player in range, block still exists):

public class MyWindow extends ContainerWindow implements ValidatedWindow {
@Override
public boolean validate(Ref<EntityStore> ref, ComponentAccessor<EntityStore> accessor) {
// return false to auto-close the window
return this.block.exists() && this.isPlayerInRange(ref, accessor);
}
}

Windows work with ItemContainer for slot management:

ItemContainer container = new ItemContainer(slotCount);
// get/set items
ItemStack item = container.getItem(slot);
container.setItem(slot, itemStack);
// listen for changes
container.addListener((slot, oldItem, newItem) -> {
// slot changed
});

Handle player interactions:

ActionPurpose
CraftRecipeActionCraft a recipe
TierUpgradeActionUpgrade item tier
SelectSlotActionSelect a slot

For windows attached to blocks (chests, furnaces):

public class ChestWindow extends ContainerBlockWindow {
public ChestWindow(BlockRef blockRef, ItemContainer container) {
super(blockRef, container);
}
// window auto-closes if block is destroyed
}

ContainerWindow opens an item container that the player can move items into and out of. Use this for actual item storage — chests, crates, shared stashes.

ItemContainer storage = new ItemContainer(27);
ContainerWindow window = new ContainerWindow(storage);
player.getPageManager().setPageWithWindows(ref, store, Page.Bench, true, window);
window.registerCloseEvent(event -> {
// save contents, clean up, etc.
});

setPageWithWindows() opens the window and switches the client to the Bench page. The player can move items between the window container and their inventory.

Crafting windows extend CraftingWindow. See Crafting & Recipes for the full recipe system, bench types, and crafting events.

Window ClassBench TypeDescription
SimpleCraftingWindowCraftingGrid-based, any-order ingredients
DiagramCraftingWindowDiagramCraftingSlot-based with diagrams
StructuralCraftingWindowStructuralCrafting1 input -> multiple output options
ProcessingBenchWindowProcessingFuel-based, runs without player