Screen widgets
ScreenContent is a list of ScreenElements anchored to a screen. The hierarchy is sealed — five element types, each a final class with an explicit network format. You usually build content via the ScreenLayout DSL or Widgets helpers, but the raw element types are useful when you need pixel-precise control.
When to use it
Section titled “When to use it”- You’re hand-building a one-off layout and want direct access to the element constructors.
- You’re inspecting a deserialised screen and want to know which type to switch on.
- You’re authoring a custom widget that emits raw rects and text without going through
Widgets.
All elements live in me.zlex.conduit.screen and share ScreenElement as a sealed base:
public abstract sealed class ScreenElement permits TextElement, ImageElement, ButtonElement, RectElement, TextInputElement { public final float x; public final float y;}
public final class TextElement extends ScreenElement { public TextElement(float x, float y, String text, int color); public TextElement(float x, float y, String text, int color, float scale, boolean shadow); public TextElement(float x, float y, String text, int color, float scale, boolean shadow, boolean centered);}
public final class ImageElement extends ScreenElement { public ImageElement(float x, float y, float w, float h, String textureId);}
public final class ButtonElement extends ScreenElement { public ButtonElement(float x, float y, float w, float h, String buttonId, String label); // default style public ButtonElement(float x, float y, float w, float h, String buttonId, String label, int bgColor, int labelColor);}
public final class RectElement extends ScreenElement { public RectElement(float x, float y, float w, float h, int color);}
public final class TextInputElement extends ScreenElement { public TextInputElement(float x, float y, float w, float h, String fieldId, String value, String placeholder, String popupTitle, int maxLength, int bgColor, int textColor);}Positions are in screen UV space — (0, 0) top-left, (1, 1) bottom-right. Colours are packed ARGB. Text scale is world-units per font-pixel; 0.020f is the body default.
Example
Section titled “Example”import me.zlex.conduit.screen.ButtonElement;import me.zlex.conduit.screen.RectElement;import me.zlex.conduit.screen.ScreenContent;import me.zlex.conduit.screen.TextElement;
public final class MyHud {
public static ScreenContent buildScoreCard(int red, int blue) { return ScreenContent.builder() .background(0xCC000000) .add(new RectElement(0.00f, 0.00f, 1.00f, 0.18f, 0xFF223366)) .add(new TextElement(0.50f, 0.04f, "SCOREBOARD", 0xFFFFFFFF, 0.040f, true, true)) .add(new TextElement(0.20f, 0.30f, "RED " + red, 0xFFFF5555, 0.060f, true)) .add(new TextElement(0.20f, 0.50f, "BLUE " + blue, 0xFF5599FF, 0.060f, true)) .add(new ButtonElement(0.30f, 0.78f, 0.40f, 0.12f, "scoreboard-close", "CLOSE")) .build(); }}TextInputElementopens a small vanilla popup on click; the new value is delivered viaTextInputChangePayloadand routed to the handler registered withServerScreenManager.onTextInput.ButtonElement’s default constructor paints its own dark-blue background; if you’re stacking buttons over a swatch or panel and want them transparent, use the 8-arg constructor withbgColor = 0.ImageElementrequires a texture id registered with Minecraft’sTextureManager— usually shipped in a resource pack.