Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Attaches the jars (one per Minecraft version: 26.2 and 26.3) to the GitHub release whenever a release is
# published. Modrinth and CurseForge aren't set up yet; Shopping List's publish.yml shows how to add them.
# Publishes the mod to CurseForge and attaches the jars (one per Minecraft version: 26.2 and 26.3) to the GitHub
# release whenever a release is published. The release notes become the changelog, and CurseForge rejects files
# without one, so don't leave them empty. Modrinth isn't set up yet; Shopping List's publish.yml shows how to add it.
#
# Runs as three chained jobs: check the tag -> build (reusing build.yml) -> publish.
#
# Setup:
# 1. Create the project on CurseForge and add its Project ID as a repo secret named CURSEFORGE_ID.
# 2. Create a CurseForge API token (account settings > API tokens) and add it as a repo secret named
# CURSEFORGE_TOKEN.
# 3. The 26.3 jar goes to CurseForge only once it has been tested in a 26.3 client: then add a repo variable
# (Settings > Secrets and variables > Actions > Variables) named PUBLISH_26_3 set to true.

name: publish

Expand Down Expand Up @@ -39,13 +47,63 @@ jobs:
permissions:
contents: write
steps:
- name: checkout repository
uses: actions/checkout@v7

- name: download built jars
uses: actions/download-artifact@v8
with:
name: Artifacts
path: build/libs/

- name: read mod version
id: ver
run: echo "v=$(grep '^mod_version=' gradle.properties | cut -d= -f2 | tr -d '[:space:]')" >> "$GITHUB_OUTPUT"

- name: attach jars to the release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$GITHUB_REF_NAME" build/libs/huddable-*+26.2.jar build/libs/huddable-*+26.3.jar --clobber --repo "$GITHUB_REPOSITORY"

- name: publish 26.2 to curseforge
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ secrets.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

files: |
build/libs/huddable-${{ steps.ver.outputs.v }}+26.2.jar
name: Huddable ${{ steps.ver.outputs.v }} for 26.2
version: ${{ steps.ver.outputs.v }}+26.2
version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }}
loaders: fabric
game-versions: |
26.2
java: |
25
dependencies: |
fabric-api(required){curseforge:306612}
- name: publish 26.3 to curseforge
if: vars.PUBLISH_26_3 == 'true'
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ secrets.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

files: |
build/libs/huddable-${{ steps.ver.outputs.v }}+26.3.jar
name: Huddable ${{ steps.ver.outputs.v }} for 26.3
version: ${{ steps.ver.outputs.v }}+26.3
version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }}
loaders: fabric
game-versions: |
26.3
java: |
25
dependencies: |
fabric-api(required){curseforge:306612}
Binary file added Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ in game. v1 is the base: wrapping and moving the vanilla elements.
mixin (`mixin.meowdding`, applied only with meowdding-lib loaded) moves its draw call inside meowdding's
overlay loop. General Settings has an Advanced toggle to turn it off.
- 0.4.1: overlays switched off in their own mod aren't listed in the editor (they showed as empty boxes).
- 0.5.0: frames. A profile frame and per-element frames (or None): vanilla tooltip / popup / button art from the
top pack or a chosen enabled pack (`PackFrames`, shared with Shopping List), drawn around what each element draws
(framed vanilla elements and mod layers are measured four times a second), at screen size. API `frameInset` /
`drawFrame` for elements drawn from `placement` (Shopping List uses them); `push` draws the frame itself.
- 0.6.0: container screen art. The background picture of each vanilla container screen comes from a chosen enabled
pack, for all screens or per screen (`ContainerArtMixin` swaps the texture id in `GuiGraphicsExtractor.innerBlit`;
art loaded through `PackFrames.packTexture`).
- 0.6.1: closed chat can be framed, around the messages it shows (measured like other framed elements).

## Untested in game
- The whole editor: dragging, snapping, scaling, the options panel, and the profile buttons.
Expand All @@ -65,6 +73,13 @@ in game. v1 is the base: wrapping and moving the vanilla elements.
the Advanced toggle off and on, and meowdding's own editor still working alongside. 0.4.1: an overlay
switched off in SkyCubed leaves the list and comes back, at its saved position, when switched on.

- 0.5.0: frames in game: each kind from the top pack and from a lower pack (HD packs too), vanilla elements
appearing and disappearing (boss bar, title, effects) with their frame, Skyblocker layers and SkyCubed overlays
framed, Shopping List's panels taking the frame, share codes keeping frames, a disabled pack falling back.

- 0.6.0: container art in game: the inventory and chests (SkyBlock menus) from a lower pack, HD packs lining up
with slots, a per-screen choice over All screens, a disabled pack falling back, share codes keeping it.

## Next (ElvUI direction)
- Shopping List on Huddable: register its five panels through the API (resizable), hand its Move HUD to
Huddable's editor and ignore its `sandbox_widget` layer. Waiting for Huddable on Modrinth, so Shopping List's CI
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ loader_version=0.19.5
# Minecraft, Fabric API and Mod Menu versions are per Minecraft version, in versions/<mc>/gradle.properties.

# Mod Properties
mod_version=0.4.1
mod_version=0.6.1
maven_group=uk.toakan.tad
archives_base_name=huddable
3 changes: 3 additions & 0 deletions modrinth.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Rearrange the vanilla HUD in game, no resource packs needed.
- Restyle health, hunger, armor and air as bars or numbers, in your own colours
- Put the scoreboard, chat, tab list and other HUD text in any font from your resource packs, per profile or
per element, with a font quality setting
- Frame any element with your resource packs' tooltip, popup or button art, from the top pack or any enabled
pack, per profile or per element
- Pick which resource pack's inventory, chest and other container art you see, for all screens or one by one
- Named layout profiles, shared as copy-paste codes
- Client-side, works on any server

Expand Down
46 changes: 44 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ whatever you're placing; it stays where you left it until the game closes.
- **GUI** (default): follows Minecraft's GUI Scale, like vanilla.
- **Window:** grows and shrinks with the window height.
- **Fixed:** the same size on screen at any GUI Scale.

With Window and Fixed, positions move with the size too, so the layout keeps its shape when the window or GUI
Scale changes. Switching mode in the editor keeps elements where they are and only changes their size.
- **Font:** the profile's font, picked from every font your resource packs provide (each shown in itself).
Every element that draws text uses it unless you give that element its own (see Fonts below).
- **Frame:** the profile's frame, drawn around every element unless you give that element its own or None (see
Frames below).
- **Screens:** which resource pack's art the inventory, chests and other container screens use (see Container
screens below).
- **Move:** drag an element. It snaps to the screen edges and centre and to other elements' edges and centres
(cyan guide lines); hold Shift to place it freely.
- **Scale:** drag one of an element's gold corner handles (25% to 400%). The element keeps its shape.
Expand All @@ -44,6 +51,7 @@ whatever you're placing; it stays where you left it until the game closes.
- Colour (for the non-vanilla styles).
- Bar width, height and text (Bar style).
- Font, for elements that draw text: Profile (the profile's font), Vanilla, or any pack font.
- Frame: Profile (the profile's frame), None, or any frame from the list.
- Reset element.
- **Done** saves, **Cancel** or Esc drops your changes.

Expand Down Expand Up @@ -89,6 +97,38 @@ and share codes keep the font for players who have the pack.
Chat in a new font re-wraps its lines to fit. Toasts drawn by another mod (Fancy Notify, for example) keep that
mod's font; vanilla's toasts change.

### Frames
A frame is Minecraft's own tooltip, popup or button art drawn around an element, so a resource pack that decorates
those (corner pieces, patterned edges) decorates your HUD too. The list has each kind from the top pack (what the
rest of the game shows), then from every enabled pack that has its own art, for example "Tooltip (Faithful 64x)".
To use one pack's frame without its other textures, enable it and move it to the bottom of the pack list. Pick a
frame for the whole profile with the toolbar's **Frame** button, or per element in its options; an element set to
None has no frame even when the profile has one.

Frames follow what each element draws: a boss bar, title or other mod's layer that isn't showing has no frame, and
one that grows (the scoreboard, a mod's list) has its frame grow with it, checked four times a second for framed
elements only. Frame art is drawn at screen size, so frames match across elements of any scale. Closed chat is
framed around the messages showing, so its frame goes when they fade; the open chat (T) has none. Toasts and the
crosshair have no frame; full-screen mod layers get none either. If a frame's pack is turned off, the top
pack's art is drawn until it's back, and share codes keep the choice for players who have the pack.

Shopping List's panels use a Huddable frame in place of their own when one is set for them (it keeps its own look
otherwise). Other mods can do the same through the API (`frameInset`, `drawFrame`).

### Container screens
Each container screen (inventory, chest, furnace, anvil and the rest) is one picture with the slots painted in,
and normally the top resource pack's picture is shown. The toolbar's **Screens** list picks another enabled pack's
picture instead: **All screens** for every screen, then a row for each screen that more than one of your packs
has art for, to give it its own choice (Profile follows All screens). Click a row for the next pack. For example,
keep a texture pack on top but use Faithful's inventory. Open a screen after Done to see it.

- Server menus such as Hypixel's are chests, so they follow the Chest choice.
- Only the background picture changes. Small pieces drawn over it (the furnace's flame and arrow, the recipe book
button) still come from the top pack.
- Art drawn by other mods (tabs and side panels around the inventory) isn't changed.
- A screen the chosen pack has no art for, or a pack you've turned off, shows the top pack's picture. Share codes
keep the choice.

### Styles
- **Bar:** a filled bar with the value written on it. Health shows absorption and hunger shows saturation as a
thin strip along the top.
Expand Down Expand Up @@ -117,7 +157,8 @@ The top button in the editor's window shows the active profile; click it to swit
- **Delete:** press twice.
- **Export:** copies the layout to the clipboard as a code starting `HUD1:`.
- **Import:** reads a code from the clipboard into a new profile.
- **Reset:** puts every element, the Size mode and the profile font back to vanilla.
- **Reset:** puts every element, the Size mode, the profile font and frame, and the container screens back to
vanilla.

Profile actions save your current edits first. Profiles are in `config/huddable/profiles/`.

Expand Down Expand Up @@ -151,7 +192,8 @@ public final class HuddableCompat implements HuddablePlugin {
HuddableApi.register(PANEL, Component.literal("Example panel"),
HuddableApi.Spec.of((screenWidth, screenHeight) -> new HuddableApi.Box(10, 10, 120, 40))
.withBaseScale(() -> MyHud.scale()) // optional: your own HUD scale
.resizable(60, 20)); // optional: edge grips, with a minimum size
.resizable(60, 20) // optional: edge grips, with a minimum size
.listedWhen(() -> MyHud.enabled())); // optional: left out of the editor while switched off
// If the element is also a Fabric HUD layer, keep Huddable from wrapping that layer as well:
// HuddableApi.ignoreLayer(MY_FABRIC_LAYER_ID);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/uk/toakan/tad/huddable/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public boolean restyleable() {
return restyleable;
}

/** Toasts aren't drawn through {@link HudWrapper}; a frame on a crosshair is no use. Chat is framed while closed. */
@Override
public boolean frameable() {
return this != TOASTS && this != CROSSHAIR;
}

/** Chat sizes itself to vanilla's chat width and height options; a Bar-style status bar to its bar size. */
@Override
public boolean resizable(ElementLayout layout) {
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/uk/toakan/tad/huddable/ElementLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public final class ElementLayout {
* or null for the profile's font ({@link HudFonts}).
*/
public String font;
/** Frame id ({@link HudFrames}), {@code none} for no frame even when the profile has one, or null for the profile's. */
public String frame;

public ElementLayout copy() {
ElementLayout c = new ElementLayout();
Expand All @@ -49,26 +51,29 @@ public ElementLayout copy() {
c.width = width;
c.height = height;
c.font = font;
c.frame = frame;
return c;
}

/** True when this draws exactly like vanilla, so it needn't be saved. */
/** True when this draws exactly like vanilla (or as the profile says), so it needn't be saved. */
public boolean isDefault() {
return !hidden && dx == 0 && dy == 0 && scale == 100 && style == Style.VANILLA && width == 0 && height == 0
&& font == null;
&& font == null && frame == null;
}

/** Puts every field in range; a style or font the element can't use falls back to vanilla. */
/** Puts every field in range; a style, font or frame the element can't use falls back to vanilla. */
public void clamp(HudPart part) {
clamp(part.restyleable(), part.movable());
if (!HudFonts.fontable(part)) font = null;
if (!part.frameable()) frame = null;
}

/** As {@link #clamp(HudPart)}, for another mod's element that isn't loaded now (kept, not restyleable). */
public void clamp(boolean restyleable, boolean movable) {
// An id that isn't loaded now is kept (a share code from someone with another pack); it draws as vanilla.
font = HudFonts.cleanId(font);
scale = Math.clamp(scale, MIN_SCALE, MAX_SCALE);
frame = HudFrames.cleanId(frame);
scale =Math.clamp(scale, MIN_SCALE, MAX_SCALE);
barWidth = Math.clamp(barWidth, MIN_BAR_WIDTH, MAX_BAR_WIDTH);
barHeight = Math.clamp(barHeight, MIN_BAR_HEIGHT, MAX_BAR_HEIGHT);
// Far enough to leave any screen, small enough that the maths can't overflow.
Expand Down
33 changes: 24 additions & 9 deletions src/main/java/uk/toakan/tad/huddable/ExternalPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
public final class ExternalPart implements HudPart {
/** How often an element that drew nothing is measured again, while it matters. */
private static final long RETRY_MILLIS = 1000;
/** How often a framed layer is measured, so its frame follows what it draws. */
static final long FRAME_MILLIS = 250;

public final Identifier id;
private final Component label;
Expand All @@ -38,6 +40,8 @@ public final class ExternalPart implements HudPart {
private int measuredWidth = -1;
private int measuredHeight = -1;
private long lastMeasure;
/** Fabric layers only: whether the last measure found anything drawn (the frame is left off while not). */
private boolean drawing;
/** Listed in the editor only while true: false while the element's own mod has it switched off. */
private BooleanSupplier listed = () -> true;

Expand Down Expand Up @@ -145,36 +149,47 @@ public HuddableApi.Placement placement(int w, int h) {
Minecraft mc = Minecraft.getInstance();
Geometry g = geometry(mc, w, h);
int[] size = size(mc, g, layout);
return new HuddableApi.Placement(g.x() + layout.dx, g.y() + layout.dy, size[0], size[1],
float offsetScale = HudWrapper.offsetScale();
return new HuddableApi.Placement(g.x() + Math.round(layout.dx * offsetScale),
g.y() + Math.round(layout.dy * offsetScale), size[0], size[1],
HudWrapper.scale(this, layout), layout.hidden);
}

/**
* Fabric layers: measures the box when the screen size changed, when nothing was found yet and it matters
* ({@code wanted}), and once a second while the editor is open (the element may have grown or moved).
* ({@code wanted}), once a second while the editor is open (the element may have grown or moved), and four
* times a second while it has a frame ({@code framed}), so the frame follows it.
*/
void measureIfNeeded(GuiGraphicsExtractor graphics, DeltaTracker delta, boolean wanted) {
void measureIfNeeded(GuiGraphicsExtractor graphics, DeltaTracker delta, boolean wanted, boolean framed) {
int w = graphics.guiWidth();
int h = graphics.guiHeight();
long now = Util.getMillis();
boolean resized = measured != null && (w != measuredWidth || h != measuredHeight);
boolean retry = (measured == null && wanted || Profiles.editing()) && now - lastMeasure >= RETRY_MILLIS;
long since = now - lastMeasure;
boolean retry = (measured == null && wanted || Profiles.editing()) && since >= RETRY_MILLIS
|| framed && since >= FRAME_MILLIS;
if (!resized && !retry) return;
lastMeasure = now;
measuredWidth = w;
measuredHeight = h;
HuddableApi.Box box = measure(delta);
HuddableApi.Box box = measure(original, delta, id);
drawing = box != null;
if (box != null || resized) measured = box;
}

/** Draws the layer, unmoved, into a scratch render state and returns the bounds of what it drew. */
private HuddableApi.Box measure(DeltaTracker delta) {
/** Fabric layers: the unmoved box it drew at the last measure, or null when it drew nothing then. */
HuddableApi.Box drawnBox() {
return drawing ? measured : null;
}

/** Draws {@code layer}, unmoved, into a scratch render state and returns the bounds of what it drew. */
static HuddableApi.Box measure(HudElement layer, DeltaTracker delta, Object name) {
Minecraft mc = Minecraft.getInstance();
GuiRenderState state = new GuiRenderState();
try {
original.extractRenderState(new GuiGraphicsExtractor(mc, state, -1, -1), delta);
layer.extractRenderState(new GuiGraphicsExtractor(mc, state, -1, -1), delta);
} catch (RuntimeException e) {
HuddableClient.LOGGER.warn("Couldn't measure HUD element {}", id, e);
HuddableClient.LOGGER.warn("Couldn't measure HUD element {}", name, e);
return null;
}
int[] b = {Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE};
Expand Down
Loading
Loading