Skip to content

ScriptScreen ​

com.jsmacrosce.jsmacros.client.api.classes.render.ScriptScreen

Since1.0.5

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 ​

new ScriptScreen(String title, boolean menuBackground)#
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 key
  • menuBackground: whether to draw the game's menu background overlay
new ScriptScreen(String title, boolean menuBackground, boolean blurredBackground)Since2.1.0#
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 key
  • menuBackground: whether to draw the game's menu background overlay
  • blurredBackground: whether to blur the world behind the screen

Fields ​

drawTitle ​

drawTitle: booleanSince1.0.5#
Whether the screen title is drawn. Changing this field affects subsequent renders; it does not change the title returned by IScreen.getTitleText().

shouldCloseOnEsc ​

shouldCloseOnEsc: booleanSince1.8.4#
Whether this screen permits closing with Escape; an open overlay can still prevent closing.

shouldPause ​

shouldPause: booleanSince1.8.4#
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 object
  • mouseX: the current mouse position, in the same space as the screen's elements
  • mouseY: the current mouse position, in the same space as the screen's elements
  • delta: frame delta in game ticks; not limited to 0–1

isPauseScreen ​

isPauseScreen(): booleanSince1.0.5#
Whether the game pauses while this screen is open.
Returns: whether the game pauses

onClose ​

onClose(): voidSince1.0.5#
Closes this screen, opening its parent if set; otherwise uses the superclass close behavior.

setOnRender ​

setOnRender(MethodWrapper<Pos3D, GuiGraphicsExtractor, Object, ?> onRender): voidSince1.4.0#
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 ​

setParent(IScreen parent): voidSince1.4.0#
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
setParent(Screen parent): void#
Sets the screen used as this screen's navigation parent; this does not open or display it.

Parameters:

  • parent: parent screen, or null when there is no parent

shouldCloseOnEsc ​

shouldCloseOnEsc(): booleanSince1.0.5#
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