ScriptScreen
com.jsmacrosce.jsmacros.client.api.classes.render.ScriptScreen
The screen implementation returned by Hud.createScreen, exposed through IScreen.
js
const screen = Hud.createScreen("my screen", true);
// Hide the rendered title text without changing the screen's title.
screen.drawTitle = false;
Hud.openScreen(screen);Constructors
new ScriptScreen
Sets up a screen with the supplied literal title and both background effects enabled: the game's menu background overlay is drawn and the world behind it is blurred. The title must be non-null; an empty title is allowed. This constructor does not open the screen. Passing
null for title causes a NullPointerException.Parameters:
title: non-null literal screen title, not a translation keymenuBackground: whether to draw the game's menu background overlay
Sets up a screen with the supplied literal title and background effects. The title must be non-null; an empty title is allowed. This constructor does not open the screen. Passing
null for title causes a NullPointerException. The two effects are independent. The menu background is vanilla's darkened background: on the supported versions it is a flat translucent black overlay rather than a picture, so it only darkens what is behind the screen. The blurred background applies vanilla's menu blur to the world behind the screen. With both off, the world is shown unmodified.Parameters:
title: non-null literal screen title, not a translation keymenuBackground: whether to draw the game's menu background overlayblurredBackground: whether to blur the world behind the screen
Fields
drawTitle
Whether the screen title is drawn. Changing this field affects subsequent renders; it does not change the title returned by IScreen.getTitleText().
shouldCloseOnEsc
Whether this screen permits closing with Escape; an open overlay can still prevent closing.
shouldPause
Whether the game pauses while this screen is open.
Methods
extractRenderState
extractRenderState(GuiGraphicsExtractor drawContext, int mouseX, int mouseY, float delta): voidSince1.0.5#Renders this screen. The order is the background first if the screen asked for one, then the title if
drawTitle is on, then the widgets the game put on it, then the elements added through this screen's 2D overlay side, and then the function set with setOnRender(MethodWrapper). So the render callback is drawn over everything else and is the right place for something that should sit on top. Nothing here is called by a script; the game calls this once a frame while the screen is open. A callback that throws is logged and dropped, so the rest of the screen still draws.Parameters:
drawContext: the game's own graphics objectmouseX: the current mouse position, in the same space as the screen's elementsmouseY: the current mouse position, in the same space as the screen's elementsdelta: frame delta in game ticks; not limited to 0–1
isPauseScreen
Whether the game pauses while this screen is open.
Returns: whether the game pauses
onClose
Closes this screen, opening its parent if set; otherwise uses the superclass close behavior.
setOnRender
Sets a callback that draws after the screen's widgets and overlay elements. It runs on the render path with mouse coordinates and tick delta in a Pos3D, plus the graphics object. If the callback throws, the error is logged and the callback is cleared.
Parameters:
onRender: callback receiving mouse x, mouse y, and tick delta in a Pos3D, then the graphics object
setParent
Sets the screen opened when this screen closes; without a parent, close behavior returns to the game if a world is loaded, or to no screen otherwise.
Parameters:
parent: screen to open on close
shouldCloseOnEsc
Whether Escape closes this screen. The result also depends on the superclass, which prevents closing while an overlay is open.
Returns: whether this screen and its superclass permit Escape closing