Class GuiUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAllDescendants(SettingGroup group, Set<Setting<?>> set) Recursively adds all descendants of a SettingGroup to the given set.static floatanimateToward(float current, float target, float speed) Animate a float value toward a target at the given speed (per frame).static floatanimateTowardTimed(float current, float target, float deltaMs, float durationMs) Animate toward a target so the value effectively settles within the given duration.static intapplyAlpha(int argb, float opacity) Apply an opacity multiplier to the alpha channel of an ARGB color.static voiddrawShadowLg(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) Tailwind CSSshadow-lg, exactly:0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1).static voiddrawShadowMd(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) Tailwind CSSshadow-md, exactly:0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1).static voiddrawShadowModal(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit, float intensity) The confirm-dialog lift: exactlydrawShadowXl(net.minecraft.client.gui.GuiGraphics, int, int, int, int, float)'s shape, drawn a little darker so a modal still separates from the frosted, dimmed backdrop behind it (where a popover only has to separate from a flat card).static voiddrawShadowXl(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) static voiddrawShadowXl(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit, float intensity) drawShadowXl(net.minecraft.client.gui.GuiGraphics, int, int, int, int, float)scaled by anintensitymultiplier (0..1) on the penumbra alpha — so the shadow can fade in and out with a surface that is itself animating its opacity.static floateaseInOutCubic(float t) Ease-in-out cubic for smooth expand/collapse animation.static voidfillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color) Fill a rectangle whose top edge stays square but whose bottom two corners are rounded, drawn at physical-pixel resolution for smooth arcs.static voidfillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color, int trimPx) fillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int)withtrimPxunscaled (physical) pixels shaved off the bottom edge.static voidfillBottomRoundedRectPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, boolean roundBL, boolean roundBR, int color) Fills a rectangle rounding only the chosen bottom corners, at physical-pixel resolution.static voidfillCircleGui(net.minecraft.client.gui.GuiGraphics graphics, int cx, int cy, int r, int color) Fills a circle with one span per LOGICAL row — cheap enough for large radii (a radius-150 disc is ~300 quads, not thousands).static voidfillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int cornerPx, double cx, double cy, double radius, int color) Fills a circle clipped to a rounded rectangle (the ripple surface): per physical scanline, the circle's span is intersected with the rounded rect's span, so the ripple hugs the surface's rounded corners instead of painting past them.static voidfillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int topCornerPx, int botCornerPx, double cx, double cy, double radius, int color) Variant with independent top / bottom corner radii (e.g.static voidfillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int tlPx, int trPx, int blPx, int brPx, double cx, double cy, double radius, int color) Variant with independent per-corner radii (top-left, top-right, bottom-left, bottom-right).static voidfillCirclePhysical(net.minecraft.client.gui.GuiGraphics graphics, double res, float cx, float cy, float r, int color) Small anti-aliased-ish circle rasterized at physical-pixel rows — a port of HudPropertiesWindow'sfillCircleSmooth(slider thumbs, halos).static voidfillPillPhysical(net.minecraft.client.gui.GuiGraphics graphics, double res, float x1, float y1, float x2, float y2, int color, boolean roundRight) Pill (fully-rounded height/2 caps) rasterized at physical pixels — a port ofSliderPropComponent'sfillPillSmooth, for surfaces that draw a material track without a properties window to hang off.static voidfillRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color) Fill a rectangle with all four corners rounded, drawn at physical-pixel resolution for smooth arcs.static voidfillRoundedRectPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int color) LikefillRoundedRect(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int)but the cornerradiusPxis in physical pixels (unscaled) rather than GUI pixels — so a given radius looks the same regardless of the window GUI scale.static intfindWordBoundary(String text, int pos, int direction) Find the next word boundary in the given direction (-1 = left, +1 = right).static StringformatNumber(double value) static StringformatNumber(double value, double step) Formats a number with enough decimal places to represent the given step size.static inthslToRgb(float h, float s, float l) Converts HSL to packed 0xRRGGBB.static inthsvToRgb(float h, float s, float v) Convert HSV (h=0-360, s=0-1, v=0-1) to packed 0xRRGGBB.static intlerpColor(int a, int b, float t) Linearly interpolate between two ARGB colors by factor t (0 = a, 1 = b).static intpxRound(double v) First physical pixel a fill edge atvrasterizes into — equivalently the exclusive end of coverage for a fill ending atv(pixel centers at .5).static voidrenderEntityIsometric(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, net.minecraft.world.entity.Entity entity) True isometric GUI preview of any entity: Z-flip for gui space, slight downward pitch and a 45° yaw — the classic three-quarter view block items use.static float[]rgbToHsl(int r, int g, int b) Convert RGB (0-255 each) to HSL [h=0-360, s=0-1, l=0-1].static float[]rgbToHsv(int r, int g, int b) Convert RGB (0-255 each) to HSV [h=0-360, s=0-1, v=0-1].static voidringCircleGui(net.minecraft.client.gui.GuiGraphics graphics, int cx, int cy, int r, int thickness, int color) Draws a circle ring of the given logical thickness, two spans per row — the large-radius companion tofillCircleGui(net.minecraft.client.gui.GuiGraphics, int, int, int, int).static voidroundedRectBorderPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int fill, int border) Fills a rounded rect with a fill colour and a hairline border of exactly one physical pixel (unscaled), with the cornerradiusPxalso in physical pixels.static voidroundedRectOutlinePx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int color) Draws a 1-physical-pixel anti-aliased rounded outline (ring only, no fill) — for outlined buttons / transparent-bodied controls.static voidroundedRectOutlinePx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int thicknessPx, int color) Outline with a configurable thickness in physical pixels (single solid ring).static intspotlightDim(float factor) Spotlight dim color: the active theme's spotlight background color (+ base alpha) scaled byfactor(0..1).
-
Method Details
-
renderEntityIsometric
public static void renderEntityIsometric(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, net.minecraft.world.entity.Entity entity) True isometric GUI preview of any entity: Z-flip for gui space, slight downward pitch and a 45° yaw — the classic three-quarter view block items use. Living entities get their body squared to the camera (no mouse-follow) so every preview renders from the same fixed angle. The scale is normalized per entity so the whole projected model fits the box.Coordinates are absolute gui-space ints (pose-independent — transform first).
-
pxRound
public static int pxRound(double v) First physical pixel a fill edge atvrasterizes into — equivalently the exclusive end of coverage for a fill ending atv(pixel centers at .5). Use this instead ofMath.roundwhen anchoring physical-pixel chrome (borders, dividers, shadows) to scaled fills, so they can never detach. -
drawShadowMd
public static void drawShadowMd(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) Tailwind CSSshadow-md, exactly:0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1).Coordinates are physical pixels (call inside a pose scaled to 1/guiScale);
unitis how many physical pixels one CSS px maps to (panel/editor scale × gui scale), so the shadow scales with the surface it belongs to. Each layer is drawn as concentric 1-physical-px rings with linear falloff across the blur span; ring strips never overlap, so corners can't double-darken where the fades meet. Draw before the surface background — the interior ring segments are covered by the surface fill. -
drawShadowLg
public static void drawShadowLg(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) Tailwind CSSshadow-lg, exactly:0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1).Same conventions as
drawShadowMd(net.minecraft.client.gui.GuiGraphics, int, int, int, int, float); a larger, softer penumbra for surfaces that float clearly above the page (menus, autocomplete popups). Alpha bumped from the spec's 10% for legibility over busy backgrounds. -
drawShadowXl
public static void drawShadowXl(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit) -
drawShadowXl
public static void drawShadowXl(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit, float intensity) drawShadowXl(net.minecraft.client.gui.GuiGraphics, int, int, int, int, float)scaled by anintensitymultiplier (0..1) on the penumbra alpha — so the shadow can fade in and out with a surface that is itself animating its opacity. -
drawShadowModal
public static void drawShadowModal(net.minecraft.client.gui.GuiGraphics graphics, int x1, int y1, int x2, int y2, float unit, float intensity) The confirm-dialog lift: exactlydrawShadowXl(net.minecraft.client.gui.GuiGraphics, int, int, int, int, float)'s shape, drawn a little darker so a modal still separates from the frosted, dimmed backdrop behind it (where a popover only has to separate from a flat card). -
animateToward
public static float animateToward(float current, float target, float speed) Animate a float value toward a target at the given speed (per frame). Negative speed = snap. -
animateTowardTimed
public static float animateTowardTimed(float current, float target, float deltaMs, float durationMs) Animate toward a target so the value effectively settles within the given duration. Negative/zero duration or delta snaps immediately. -
spotlightDim
public static int spotlightDim(float factor) Spotlight dim color: the active theme's spotlight background color (+ base alpha) scaled byfactor(0..1). Falls back to the sharedGuiConstants.DIM_OVERLAY_BASEbefore the theme instance exists. -
easeInOutCubic
public static float easeInOutCubic(float t) Ease-in-out cubic for smooth expand/collapse animation. -
lerpColor
public static int lerpColor(int a, int b, float t) Linearly interpolate between two ARGB colors by factor t (0 = a, 1 = b). -
fillBottomRoundedRect
public static void fillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color) Fill a rectangle whose top edge stays square but whose bottom two corners are rounded, drawn at physical-pixel resolution for smooth arcs.Coordinates are in GUI space;
resis the window GUI scale so the arcs quantise to real pixels. Must be called outside any additionalpose.scale()transform (raw GUI space). -
fillBottomRoundedRect
public static void fillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color, int trimPx) fillBottomRoundedRect(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int)withtrimPxunscaled (physical) pixels shaved off the bottom edge. The trim is applied after scaling, so it stays a true hairline at any GUI scale (subtracting it from the GUI-spacey2instead would shaveresphysical pixels). -
fillRoundedRect
public static void fillRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radius, int color) Fill a rectangle with all four corners rounded, drawn at physical-pixel resolution for smooth arcs.Coordinates are in GUI space;
resis the window GUI scale so the arcs quantise to real pixels. Must be called outside any additionalpose.scale()transform (raw GUI space). -
fillRoundedRectPx
public static void fillRoundedRectPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int color) LikefillRoundedRect(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int)but the cornerradiusPxis in physical pixels (unscaled) rather than GUI pixels — so a given radius looks the same regardless of the window GUI scale. Coordinates stay in GUI space. Pass a very large radius for a full pill (clamped to half the shorter side). -
roundedRectBorderPx
public static void roundedRectBorderPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int fill, int border) Fills a rounded rect with a fill colour and a hairline border of exactly one physical pixel (unscaled), with the cornerradiusPxalso in physical pixels. Coordinates are GUI space. -
roundedRectOutlinePx
public static void roundedRectOutlinePx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int color) Draws a 1-physical-pixel anti-aliased rounded outline (ring only, no fill) — for outlined buttons / transparent-bodied controls. Radius in physical pixels; coordinates in GUI space. -
roundedRectOutlinePx
public static void roundedRectOutlinePx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, int thicknessPx, int color) Outline with a configurable thickness in physical pixels (single solid ring). -
fillCircleInRoundedRect
public static void fillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int cornerPx, double cx, double cy, double radius, int color) Fills a circle clipped to a rounded rectangle (the ripple surface): per physical scanline, the circle's span is intersected with the rounded rect's span, so the ripple hugs the surface's rounded corners instead of painting past them. All coordinates in GUI space;cornerPxin physical pixels. -
fillCircleInRoundedRect
public static void fillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int topCornerPx, int botCornerPx, double cx, double cy, double radius, int color) Variant with independent top / bottom corner radii (e.g. bottom-only rounding). -
fillCircleInRoundedRect
public static void fillCircleInRoundedRect(net.minecraft.client.gui.GuiGraphics graphics, double res, int rx1, int ry1, int rx2, int ry2, int tlPx, int trPx, int blPx, int brPx, double cx, double cy, double radius, int color) Variant with independent per-corner radii (top-left, top-right, bottom-left, bottom-right). -
fillBottomRoundedRectPx
public static void fillBottomRoundedRectPx(net.minecraft.client.gui.GuiGraphics graphics, double res, int x1, int y1, int x2, int y2, int radiusPx, boolean roundBL, boolean roundBR, int color) Fills a rectangle rounding only the chosen bottom corners, at physical-pixel resolution. Coordinates are logical;resis physical px per logical unit. Safe to call inside an outerpose.scale()(self-consistent, like the other*Pxhelpers). -
fillCircleGui
public static void fillCircleGui(net.minecraft.client.gui.GuiGraphics graphics, int cx, int cy, int r, int color) Fills a circle with one span per LOGICAL row — cheap enough for large radii (a radius-150 disc is ~300 quads, not thousands). No AA; use the physical-pixel helpers only for small shapes. -
fillCirclePhysical
public static void fillCirclePhysical(net.minecraft.client.gui.GuiGraphics graphics, double res, float cx, float cy, float r, int color) Small anti-aliased-ish circle rasterized at physical-pixel rows — a port of HudPropertiesWindow'sfillCircleSmooth(slider thumbs, halos). Coordinates and radius in logical units; cheap only for SMALL radii. -
fillPillPhysical
public static void fillPillPhysical(net.minecraft.client.gui.GuiGraphics graphics, double res, float x1, float y1, float x2, float y2, int color, boolean roundRight) Pill (fully-rounded height/2 caps) rasterized at physical pixels — a port ofSliderPropComponent'sfillPillSmooth, for surfaces that draw a material track without a properties window to hang off.roundRight=falsesquares the right end — used by slider progress so it terminates cleanly where the thumb sits instead of leaving a rounded nub mid-track. The cap radius is fixed by the height, never the width, so the shape doesn't morph as the fill narrows. Coordinates in logical units. -
ringCircleGui
public static void ringCircleGui(net.minecraft.client.gui.GuiGraphics graphics, int cx, int cy, int r, int thickness, int color) Draws a circle ring of the given logical thickness, two spans per row — the large-radius companion tofillCircleGui(net.minecraft.client.gui.GuiGraphics, int, int, int, int). -
applyAlpha
public static int applyAlpha(int argb, float opacity) Apply an opacity multiplier to the alpha channel of an ARGB color. -
formatNumber
-
formatNumber
Formats a number with enough decimal places to represent the given step size. -
findWordBoundary
Find the next word boundary in the given direction (-1 = left, +1 = right). -
hsvToRgb
public static int hsvToRgb(float h, float s, float v) Convert HSV (h=0-360, s=0-1, v=0-1) to packed 0xRRGGBB. -
rgbToHsv
public static float[] rgbToHsv(int r, int g, int b) Convert RGB (0-255 each) to HSV [h=0-360, s=0-1, v=0-1]. -
rgbToHsl
public static float[] rgbToHsl(int r, int g, int b) Convert RGB (0-255 each) to HSL [h=0-360, s=0-1, l=0-1]. -
hslToRgb
public static int hslToRgb(float h, float s, float l) Converts HSL to packed 0xRRGGBB. h=0-360, s/l=0-1. -
addAllDescendants
Recursively adds all descendants of a SettingGroup to the given set.
-