# LayoutBehavior > How a layout behaves once it is more than a picture: when it opens, when it closes, and what the player can still do while it is up. `gg.lode.lecternapi.api.ui.LayoutBehavior` --- ## Signature ```java public class LayoutBehavior ``` --- ## Notes A `HudLayout` on its own is geometry and animation, the server decides when to play it. A layout authored in the UI editor can instead carry its own rules, and this is them: the command that opens it, whether it opens on join, whether taking a hit closes it. That turns a layout from something a plugin has to drive into something a server owner can drop in a folder and use. Read off the `behavior` block of an exported layout by `LayoutPageSerializer`, so a server owner never writes one of these by hand, though a plugin may, to open a page under rules of its own. ```java LayoutPage page = api.getLayoutManager().getPage("stats"); if (page.getBehavior().getMode() == Mode.GUI) { api.getLayoutManager().open(player, "stats"); } ``` --- ## Variants | Type | Description | |---|---| | `Mode` | Whether the layout sits over gameplay or takes the screen. `HUD` draws on top of the world and the player keeps playing. `GUI` opens a screen: the mouse becomes a cursor, movement stops, and elements can be clicked, which is what makes `LayoutAction` triggers other than open and close reachable at all. Values: `HUD`, `GUI` | --- ## Methods ### mode ```java public LayoutBehavior mode(Mode mode) ``` | Parameter | Type | |---|---| | `mode` | `Mode` | --- ### openOnJoin ```java public LayoutBehavior openOnJoin(boolean openOnJoin) ``` Opens the layout for a player as they join. | Parameter | Type | |---|---| | `openOnJoin` | `boolean` | --- ### openDelayTicks ```java public LayoutBehavior openDelayTicks(int ticks) ``` Ticks to wait after join before opening. Worth setting for anything that reads player state: on the join tick a player's position, inventory and scoreboard are still settling, so a layout opened immediately can show values that are correct for a moment and then wrong. | Parameter | Type | |---|---| | `ticks` | `int` | --- ### command ```java public LayoutBehavior command(String command) ``` The command that opens this layout, without its leading slash. Empty registers nothing. | Parameter | Type | |---|---| | `command` | `String` | --- ### closeOnDeath ```java public LayoutBehavior closeOnDeath(boolean closeOnDeath) ``` | Parameter | Type | |---|---| | `closeOnDeath` | `boolean` | --- ### closeOnDamage ```java public LayoutBehavior closeOnDamage(boolean closeOnDamage) ``` | Parameter | Type | |---|---| | `closeOnDamage` | `boolean` | --- ### keepOpen ```java public LayoutBehavior keepOpen(boolean keepOpen) ``` Keeps this layout up when another one opens, instead of being replaced by it. | Parameter | Type | |---|---| | `keepOpen` | `boolean` | --- ### closeReversed ```java public LayoutBehavior closeReversed(boolean closeReversed) ``` Plays the open animation backwards on close, rather than cutting to nothing. | Parameter | Type | |---|---| | `closeReversed` | `boolean` | --- ### moveWhileClosing ```java public LayoutBehavior moveWhileClosing(boolean moveWhileClosing) ``` Lets the player move while a GUI layout's closing animation plays. | Parameter | Type | |---|---| | `moveWhileClosing` | `boolean` | --- ### displayHotbar ```java public LayoutBehavior displayHotbar(boolean displayHotbar) ``` | Parameter | Type | |---|---| | `displayHotbar` | `boolean` | --- ### displayHand ```java public LayoutBehavior displayHand(boolean displayHand) ``` | Parameter | Type | |---|---| | `displayHand` | `boolean` | --- ### topmost ```java public LayoutBehavior topmost(boolean topmost) ``` Draws the layout above Minecraft's own HUD, including chat, the scoreboard and the tab list. Off by default, and deliberately so: Lectern draws before the vanilla HUD precisely so a badge can sit behind the scoreboard rather than over the top of it. A layout that is the whole screen for a moment (a cutscene, a title card) wants the opposite, and this is it. | Parameter | Type | |---|---| | `topmost` | `boolean` | --- ### index ```java public LayoutBehavior index(int index) ``` Where this layout sits when more than one is on screen at once. A higher index draws above, is hit-tested first, and is the one whose settings apply, what is hidden, whether the hotbar shows, whether the world blurs. The layout underneath keeps playing the whole time and takes its own settings back the moment the one above it stops, so a page opened over a permanent HUD is a page opened over it rather than in place of it. Zero is the base and the default. Settings do not merge: the top layout answers for all of them, because a page that wants the hotbar back has no way to say so to a page below that hid it. | Parameter | Type | |---|---| | `index` | `int` | --- ### hideHud ```java public LayoutBehavior hideHud(boolean hideHud) ``` Hides the vanilla HUD for as long as the layout is up, the way F1 does. The layout itself keeps drawing, this suppresses Minecraft's own interface, not Lectern's, so a cutscene or a full-screen page can own the view without the player's hearts and hotbar showing through it. Nothing is toggled on the player's settings: the moment the layout stops, the HUD is back exactly as they left it. | Parameter | Type | |---|---| | `hideHud` | `boolean` | --- ### hideHudElements ```java public LayoutBehavior hideHudElements(java.util.Collection<String> elements) ``` Hides individual vanilla HUD elements rather than all of them. Recognised names are `hotbar`, `hearts`, `hunger`, `armor`, `oxygen` and `experience`, anything else is ignored rather than rejected, so a layout naming an element a newer client knows about still loads here. | Parameter | Type | |---|---| | `elements` | `java.util.Collection<String>` | --- ### hudOnClose ```java public LayoutBehavior hudOnClose(boolean hudOnClose) ``` Leaves the layout drawing as a HUD overlay once the GUI screen closes. | Parameter | Type | |---|---| | `hudOnClose` | `boolean` | --- ### cursorSize ```java public LayoutBehavior cursorSize(float cursorSize) ``` Cursor size in GUI mode. 10 is the recommended default. | Parameter | Type | |---|---| | `cursorSize` | `float` | --- ### cursorSpeed ```java public LayoutBehavior cursorSpeed(float cursorSpeed) ``` Cursor speed multiplier in GUI mode. | Parameter | Type | |---|---| | `cursorSpeed` | `float` | --- ### getMode ```java public Mode getMode() ``` --- ### isOpenOnJoin ```java public boolean isOpenOnJoin() ``` --- ### getOpenDelayTicks ```java public int getOpenDelayTicks() ``` --- ### getCommand ```java public String getCommand() ``` --- ### isCloseOnDeath ```java public boolean isCloseOnDeath() ``` --- ### isCloseOnDamage ```java public boolean isCloseOnDamage() ``` --- ### isKeepOpen ```java public boolean isKeepOpen() ``` --- ### isCloseReversed ```java public boolean isCloseReversed() ``` --- ### isMoveWhileClosing ```java public boolean isMoveWhileClosing() ``` --- ### isDisplayHotbar ```java public boolean isDisplayHotbar() ``` --- ### isDisplayHand ```java public boolean isDisplayHand() ``` --- ### isHudOnClose ```java public boolean isHudOnClose() ``` --- ### isHideHud ```java public boolean isHideHud() ``` --- ### isTopmost ```java public boolean isTopmost() ``` --- ### getIndex ```java public int getIndex() ``` --- ### getHiddenHudElements ```java public java.util.Set<String> getHiddenHudElements() ``` Unmodifiable; edit through `hideHudElements(java.util.Collection)`. --- ### getCursorSize ```java public float getCursorSize() ``` --- ### getCursorSpeed ```java public float getCursorSpeed() ``` --- ### hasCommand ```java public boolean hasCommand() ``` Whether this layout registers a command of its own. --- ### copy ```java public LayoutBehavior copy() ``` An independent copy, so a page's stored behaviour cannot be edited through a handed-out reference. ---