FlexHUD

Quick rating

FlexHUD

No reviews yet

hud lib

API/Library
Mod Loaders
NeoForge
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Required
Server Unsupported

About

Project Details

Type
Mod
License
MIT License
Latest Version
flexhud-1.0+1.21.1-neoforge.jar
Authors
CurseForge
Modrinth

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID
Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

FlexHUD

show

An extensible HUD layout and rendering library built on NeoForge. It uses “RelativeRect + Anchor” to describe HUD element positions and sizes in a resolution‑independent way, provides an interactive config screen for drag/resize with constraints, and persists layout to client config while auto‑recomputing on screen size changes.

Goals

  • Describe HUD element position and size via RelativeRect and Anchor so layouts are stable across resolutions/aspect ratios.
  • Expose a simple registration API: implement Layer#render to plug in your custom HUD element.
  • Provide a visual configuration screen (FlexHudConfigScreen): drag to move, resize with handles; ResizeMode controls constraints (Free, Aspect, Horizontal, Vertical, Fixed).
  • Persistence and hot‑update: use NeoForge ModConfig to store and sync positions; changes apply immediately at runtime.

Quick Start

Register a freely resizable Hotbar HUD element:

public class BuiltInFlexHud {
    public static void registerHotbarHud() {
        ResourceLocation id = FlexHudApi.HOTBAR_ID; // unique element ID

        // Default relative rect: bottom-center anchor, width 182, height 22
        FlexHudApi.RelativeRect defaultRelativeRect = new FlexHudApi.RelativeRect(
                FlexHudApi.Anchor.BOTTOM_CENTER,
                0, 0,
                182, 22
        );

        // Render layer: draw using the computed absolute rect
        FlexHudApi.Layer hotbarLayer = (rect, guiGraphics, deltaTracker) -> {
            PoseStack pose = guiGraphics.pose();
            pose.pushPose();

            int screenWidth = guiGraphics.guiWidth();
            int screenHeight = guiGraphics.guiHeight();
            // Compute the vanilla hotbar default absolute rect from the default relative rect
            FlexHudApi.Rect defaultRect = defaultRelativeRect.toAbsolute(screenWidth, screenHeight);
            // Apply affine transform from defaultRect to the target rect for free move/scale
            pose.mulPose(defaultRect.transform(rect));

            ((GuiAccessor) Minecraft.getInstance().gui).callRenderHotbar(guiGraphics, deltaTracker);
            pose.popPose();
        };

        // Register with Free resize mode using the default relative rect and layer
        FlexHudApi.INSTANCE.register(id, FlexHudApi.ResizeMode.Free, defaultRelativeRect, hotbarLayer);
    }
}

At runtime, the library calls updateScreenDimensions() before rendering to convert each element’s RelativeRect into an absolute Rect for the current resolution and passes it to your Layer#render.

API Overview

  • FlexHudApi#register(ResourceLocation id, ResizeMode mode, RelativeRect defaultRect, Layer layer)
    • Register a HUD element; if a saved layout exists in config, it overrides the default.
  • FlexHudApi.Impl#updateElementRelativeRect(ResourceLocation id, RelativeRect newRect)
    • Update layout at runtime and persist; the config screen uses this.
  • FlexHudApi.Impl#updateScreenDimensions()
    • Recompute all absolute rects when screen size/aspect changes.
  • FlexHudApi.Layer#render(Rect rect, GuiGraphics g, DeltaTracker dt)
    • Render callback: draw using the provided absolute rect.
  • FlexHudApi.ResizeMode
    • Free, Aspect (keep ratio), Horizontal, Vertical, Fixed.
  • FlexHudApi.Anchor
    • Nine‑grid anchors: TOP_LEFT / TOP_CENTER / TOP_RIGHT / CENTER_LEFT / CENTER / CENTER_RIGHT / BOTTOM_LEFT / BOTTOM_CENTER / BOTTOM_RIGHT.
  • FlexHudApi.RelativeRect
    • Fields: anchor, offsetX, offsetY, width, height, useRelativeSize
    • Methods: toAbsolute(int w, int h) to convert to absolute; fromAbsolute(Rect rect, Anchor a, int w, int h) to infer relative.
  • FlexHudApi.Rect#transform(Rect to)
    • Affine transform from source rect to target rect (translate + scale) to map existing drawing logic to the new position/size.

Visual Configuration

  • Press Alt + H in game to open FlexHudConfigScreen.
  • Drag to move, resize with handles; ResizeMode determines constraints.
  • Changes are persisted to client config (NeoForge ModConfig), e.g.:
  [hud]
  relative_rects = [
    "flexhud:hotbar|BOTTOM_CENTER|-2.9042664|-37.03853|188.19147|22.961472|false"
  ]

Requirements

  • Minecraft 1.21.1
  • NeoForge 21.x (e.g. 21.1.213)
  • Java 21

License

  • MIT (see build script / project config).

FlexHUD

show

An extensible HUD layout and rendering library built on NeoForge. It uses “RelativeRect + Anchor” to describe HUD element positions and sizes in a resolution‑independent way, provides an interactive config screen for drag/resize with constraints, and persists layout to client config while auto‑recomputing on screen size changes.

Goals

  • Describe HUD element position and size via RelativeRect and Anchor so layouts are stable across resolutions/aspect ratios.
  • Expose a simple registration API: implement Layer#render to plug in your custom HUD element.
  • Provide a visual configuration screen (FlexHudConfigScreen): drag to move, resize with handles; ResizeMode controls constraints (Free, Aspect, Horizontal, Vertical, Fixed).
  • Persistence and hot‑update: use NeoForge ModConfig to store and sync positions; changes apply immediately at runtime.

Quick Start

Register a freely resizable Hotbar HUD element:

public class BuiltInFlexHud {
    public static void registerHotbarHud() {
        ResourceLocation id = FlexHudApi.HOTBAR_ID; // unique element ID

        // Default relative rect: bottom-center anchor, width 182, height 22
        FlexHudApi.RelativeRect defaultRelativeRect = new FlexHudApi.RelativeRect(
                FlexHudApi.Anchor.BOTTOM_CENTER,
                0, 0,
                182, 22
        );

        // Render layer: draw using the computed absolute rect
        FlexHudApi.Layer hotbarLayer = (rect, guiGraphics, deltaTracker) -> {
            PoseStack pose = guiGraphics.pose();
            pose.pushPose();

            int screenWidth = guiGraphics.guiWidth();
            int screenHeight = guiGraphics.guiHeight();
            // Compute the vanilla hotbar default absolute rect from the default relative rect
            FlexHudApi.Rect defaultRect = defaultRelativeRect.toAbsolute(screenWidth, screenHeight);
            // Apply affine transform from defaultRect to the target rect for free move/scale
            pose.mulPose(defaultRect.transform(rect));

            ((GuiAccessor) Minecraft.getInstance().gui).callRenderHotbar(guiGraphics, deltaTracker);
            pose.popPose();
        };

        // Register with Free resize mode using the default relative rect and layer
        FlexHudApi.INSTANCE.register(id, FlexHudApi.ResizeMode.Free, defaultRelativeRect, hotbarLayer);
    }
}

At runtime, the library calls updateScreenDimensions() before rendering to convert each element’s RelativeRect into an absolute Rect for the current resolution and passes it to your Layer#render.

API Overview

  • FlexHudApi#register(ResourceLocation id, ResizeMode mode, RelativeRect defaultRect, Layer layer)
    • Register a HUD element; if a saved layout exists in config, it overrides the default.
    • FlexHudApi.Impl#updateElementRelativeRect(ResourceLocation id, RelativeRect newRect)
      • Update layout at runtime and persist; the config screen uses this.
    • FlexHudApi.Impl#updateScreenDimensions()
      • Recompute all absolute rects when screen size/aspect changes.
    • FlexHudApi.Layer#render(Rect rect, GuiGraphics g, DeltaTracker dt)
      • Render callback: draw using the provided absolute rect.
    • FlexHudApi.ResizeMode
      • Free, Aspect (keep ratio), Horizontal, Vertical, Fixed.
    • FlexHudApi.Anchor
      • Nine‑grid anchors: TOP_LEFT / TOP_CENTER / TOP_RIGHT / CENTER_LEFT / CENTER / CENTER_RIGHT / BOTTOM_LEFT / BOTTOM_CENTER / BOTTOM_RIGHT.
    • FlexHudApi.RelativeRect
      • Fields: anchor, offsetX, offsetY, width, height, useRelativeSize
      • Methods: toAbsolute(int w, int h) to convert to absolute; fromAbsolute(Rect rect, Anchor a, int w, int h) to infer relative.
    • FlexHudApi.Rect#transform(Rect to)
      • Affine transform from source rect to target rect (translate + scale) to map existing drawing logic to the new position/size.

Visual Configuration

  • Press Alt + H in game to open FlexHudConfigScreen.

  • Drag to move, resize with handles; ResizeMode determines constraints.

  • Changes are persisted to client config (NeoForge ModConfig), e.g.:

    [hud]
    relative_rects = [
      "flexhud:hotbar|BOTTOM_CENTER|-2.9042664|-37.03853|188.19147|22.961472|false"
    ]
    

Requirements

  • Minecraft 1.21.1
  • NeoForge 21.x (e.g. 21.1.213)
  • Java 21

License

  • MIT (see build script / project config).

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Total Downloads
CurseForge
<1,000
Modrinth
<1,000
Last Updated
CurseForge
Created
CurseForge
Modrinth
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works