diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..7303e4f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,69 @@ +name: Bug report +description: Something in the mod doesn't work as expected. +title: "Bug: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for reporting. Please check the open issues first in case it's already known. + - type: input + id: mod-version + attributes: + label: Mod version + description: Shown in the mod list, or in the jar name (e.g. huddable-0.4.0+26.2.jar). + placeholder: "0.4.0" + validations: + required: true + - type: dropdown + id: mc-version + attributes: + label: Minecraft version + options: + - "26.2" + - "26.3" + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: What happened + description: What you saw, and what you expected instead. Screenshots help a lot. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: For example, which element you moved, its style or font, the Size mode, and the GUI Scale. + placeholder: | + 1. Open the HUD Designer from Mod Menu + 2. Drag the scoreboard to the left edge + 3. ... + validations: + required: false + - type: textarea + id: share-code + attributes: + label: Layout share code + description: If it's about a layout, copy it with the editor's Export button and paste the HUD1 code here. + render: text + validations: + required: false + - type: textarea + id: logs + attributes: + label: Log + description: | + If you can, paste the relevant part of `logs/latest.log` (or upload the file). Crash? Paste the crash + report instead. + render: text + validations: + required: false + - type: textarea + id: other-mods + attributes: + label: Other mods + description: Other client mods you run, especially ones with their own HUD (Skyblocker, SkyCubed, Jade, etc.). + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..c4fe668 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Readme + url: https://github.com/Toakan-Network/Huddable#readme + about: Features, settings and known limitations. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..094d881 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,38 @@ +name: Feature request +description: Suggest something new or a change to an existing feature. +title: "Feature request: " +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + Huddable is client-side and works on any server. It only changes where and how the HUD draws, so requests + that need server data or send anything to the server can't be added. + - type: textarea + id: summary + attributes: + label: Summary + description: What should the mod do? + validations: + required: true + - type: textarea + id: problem + attributes: + label: Problem or use case + description: What are you trying to lay out, and what gets in the way today? + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposal + description: How it could work, for example in the editor, an element's options panel, or General Settings. + validations: + required: false + - type: textarea + id: notes + attributes: + label: Notes or blockers + description: Anything already known, e.g. another mod involved, or alternatives you considered. + validations: + required: false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fbfa904 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +# Builds the mod (a jar per Minecraft version) on every push to main or dev and on pull requests, and uploads +# the jars. + +name: build +on: + push: + branches: [main, dev] + paths: + - 'src/**' + - 'versions/**' + - 'build.gradle' + - 'common.gradle' + - 'gradle.properties' + - 'settings.gradle' + pull_request: + paths: + - 'src/**' + - 'versions/**' + - 'build.gradle' + - 'common.gradle' + - 'gradle.properties' + - 'settings.gradle' + schedule: + - cron: '27 17 * * *' + workflow_call: + workflow_dispatch: + +# Only reads the repository; artifact uploads don't use the token. +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v7 + - name: validate gradle wrapper + uses: gradle/actions/wrapper-validation@v6 + - name: setup jdk 25 + uses: actions/setup-java@v6 + with: + java-version: 25 + distribution: 'microsoft' + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + uses: actions/upload-artifact@v7 + with: + name: Artifacts + path: build/libs/ diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e4de351 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,51 @@ +# 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. +# +# Runs as three chained jobs: check the tag -> build (reusing build.yml) -> publish. + +name: publish + +on: + release: + types: [published] + +# Read-only by default; only the publish job gets write access. +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v7 + + - name: check tag matches mod_version + run: | + v=$(grep '^mod_version=' gradle.properties | cut -d= -f2 | tr -d '[:space:]') + tag="${GITHUB_REF_NAME#v}" + if [ "$tag" != "$v" ]; then + echo "::error::Release tag $GITHUB_REF_NAME does not match mod_version $v in gradle.properties" + exit 1 + fi + + build: + needs: check + uses: ./.github/workflows/build.yml + + publish: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: download built jars + uses: actions/download-artifact@v8 + with: + name: Artifacts + path: build/libs/ + + - 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" diff --git a/CLAUDE.md b/CLAUDE.md index 8bcaa95..76bb0eb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,6 +19,13 @@ update it in the same commit when a step lands or an issue is found or fixed. `mixin.GuiToastsMixin`, wraps `Gui`'s one `ToastManager.extractRenderState` call: toasts aren't a Fabric HUD element, and Fancy Notify draws its notifications from a HEAD inject inside that call, so they move too. Add no other mixins without a reason like these. +- meowdding-lib overlays (`compat.MeowddingCompat`): meowdding draws every overlay in one loop + (`Overlays.onHudRender`) inside SkyblockAPI's `RenderHudEvent`, fired from vanilla's sleep overlay, so they + aren't Fabric layers. Each overlay is registered as an API part, and `mixin.meowdding.OverlaysMixin` wraps the + loop's `Overlay.extract` call. That mixin config (`huddable.meowdding.mixins.json`) is optional: its plugin + applies it only when meowdding-lib is loaded, with `defaultRequire: 0`, so a meowdding change only turns the + compat off. meowdding-lib is `compileOnly`; only that class and package may touch it. General Settings' + Advanced toggle (`meowddingOverlays`) turns it off. - Fonts (`HudFonts`): vanilla prepares text after an element draws, with the `Font` it was given, so an element's font is a wrapper `Font` (built through `mixin.FontAccessor`) that sends the default font to the chosen one. `mixin.HudFontMixin` hands it to vanilla's HUD classes in place of `Minecraft.font` while `HudWrapper` (or @@ -42,7 +49,7 @@ update it in the same commit when a step lands or an issue is found or fixed. types. - Fabric HUD API sources for checking names are in `..\.mc-sources\fabric-rendering-v1\\`; vanilla in `..\.mc-sources\\`. -- Dependencies: Fabric API only. Mod Menu is optional (`compileOnly`, `suggests`) and is the only way to open +- Dependencies: Fabric API only (meowdding-lib is compile-only, see above). Mod Menu is optional (`compileOnly`, `suggests`) and is the only way to open Huddable's screen (`HuddableScreen`: HUD Designer and General Settings); only `compat.ModMenuCompat` may touch its API. @@ -53,6 +60,15 @@ As in CraftingTracker: `./gradlew build` builds `:mc26.2` and `:mc26.3` from the - No `org.lwjgl.glfw`. Read `InputConstants` key and mouse codes with `HuddableClient.inputCode("MOUSE_BUTTON_LEFT")`; they differ between 26.2 and 26.3. +## Branches and CI +- Repo: `Toakan-Network/Huddable` (`origin`). Work happens on `dev`; `main` is what's released. Commit to `dev` + and leave merging into `main` to the user. +- `.github/workflows/build.yml` builds both jars on pushes to `main` and `dev`, on pull requests, nightly and by + hand, and uploads `build/libs` as the `Artifacts` artifact. +- `.github/workflows/publish.yml` runs when a GitHub release is published: the tag must equal `mod_version` + (`v` prefix allowed), then it builds and attaches the 26.2 and 26.3 jars to the release. GitHub only for now; + Modrinth and CurseForge can be added the way Shopping List's `publish.yml` does it. + ## Testing in game Mod Menu isn't in the dev client, so test the editor in the live instance (`G:\Games\Minecraft\Instances\Hypixel 26.2\`) or any instance with Mod Menu. Config is `config\huddable\`. diff --git a/ROADMAP.md b/ROADMAP.md index 6946a10..aa1df32 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -35,6 +35,10 @@ in game. v1 is the base: wrapping and moving the vanilla elements. (each toolbar drag step). - 0.3.10: `inputCode` looks each key code up once (same helper as ChatTabs and Shopping List). - 0.3.11: share codes import with line breaks or spaces in them (as Discord wraps long codes). +- 0.4.0: meowdding-lib overlays (SkyCubed, SkyOcean) placed one by one: each is an API part, and an optional + 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). ## Untested in game - The whole editor: dragging, snapping, scaling, the options panel, and the profile buttons. @@ -56,6 +60,11 @@ in game. v1 is the base: wrapping and moving the vanilla elements. toasts), the font list paging, a profile font from a disabled pack falling back, share codes keeping fonts, Font quality reloading once and surviving a restart. +- 0.4.0: meowdding overlays on SkyBlock with SkyCubed: listed with stable IDs, boxes matching what they draw + (RPG overlay, text overlays, alignment END/CENTER), moving, scaling and hiding them, the profile screen scale, + 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. + ## 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 diff --git a/common.gradle b/common.gradle index d433014..defeada 100644 --- a/common.gradle +++ b/common.gradle @@ -27,6 +27,10 @@ repositories { url = "https://maven.terraformersmc.com/releases" content { includeGroup "com.terraformersmc" } } + maven { + url = "https://maven.teamresourceful.com/repository/maven-public/" + content { includeGroupAndSubgroups "me.owdding" } + } } dependencies { @@ -39,6 +43,13 @@ dependencies { // uk.toakan.tad.huddable.compat.ModMenuCompat (fabric.mod.json entrypoint). compileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") { transitive = false } + // meowdding-lib (optional): its overlays are placed one by one. Only compat.MeowddingCompat and + // mixin.meowdding touch it, and that mixin config applies only when meowdding-lib is loaded. + compileOnly("me.owdding.meowdding-lib:meowdding-lib:${project.meowdding_lib_version}") { + transitive = false + capabilities { requireCapability("me.owdding.meowdding-lib:meowdding-lib-${project.minecraft_version}") } + } + // Unit tests for the plain logic (snapping, share codes); nothing here ships in the jar. testImplementation platform("org.junit:junit-bom:5.14.2") testImplementation "org.junit.jupiter:junit-jupiter" diff --git a/gradle.properties b/gradle.properties index 0128732..9aae0d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,6 @@ loader_version=0.19.5 # Minecraft, Fabric API and Mod Menu versions are per Minecraft version, in versions//gradle.properties. # Mod Properties -mod_version=0.3.11 +mod_version=0.4.1 maven_group=uk.toakan.tad archives_base_name=huddable diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/modrinth.md b/modrinth.md index 80f41b7..4a1f0e8 100644 --- a/modrinth.md +++ b/modrinth.md @@ -6,6 +6,7 @@ Rearrange the vanilla HUD in game, no resource packs needed. - Scale elements from 25% to 400%, resize chat and bars by their edges, or hide them - Place other mods' HUD elements too (anything added through Fabric API's HUD registry), and toasts, Fancy Notify's notifications included +- Place SkyCubed's and SkyOcean's overlays one by one (meowdding-lib overlays, can be turned off) - Window, GUI Scale or Fixed sizing for the whole HUD - 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 diff --git a/readme.md b/readme.md index fa563bc..d0f41d5 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,14 @@ resize too. Positions are kept in the profile even if you remove the mod. at the corner set in Fancy Notify's options, and Huddable moves it from there. Hiding toasts also pauses Fancy Notify's notifications until you show them again. +**meowdding overlays** (SkyCubed, SkyOcean and other mods built on meowdding-lib) are listed one by one under +their mod's name, for example `SkyCubed: Health`, and move, scale and hide like the rest. Their box is the one +meowdding's own overlay editor highlights. meowdding's own editor (dragging overlays with chat open) still works, but its +highlight and clicks stay where meowdding places the overlay, so pick one editor per overlay. SkyCubed's Moveable +Hotbar and Moveable Item Text aren't listed: SkyCubed draws those on the vanilla hotbar, which Huddable already +places. Overlays switched off in their own mod aren't listed; switch them on there and they come back with +their saved position. Turn this off under General Settings, Advanced. + Other mods that draw their HUD some other way can't be moved until they support Huddable. ### Fonts @@ -96,6 +104,9 @@ bar (armor only with armor on, air only underwater or while it refills). scales but uses more video memory. Players on the old 4x default were moved to Pack's own in 0.3.4. This applies to every TrueType font in the game, other mods' included, as Minecraft loads each font once for everyone. Changing it reloads the resource packs once when you leave the screen. +- **Advanced, meowdding overlays** (default on, only shown with meowdding-lib installed): list meowdding-lib's + overlays as their own elements (see Other mods' HUD elements). Turned off, they go back to where meowdding puts + them and leave the editor; their saved positions are kept for when you turn it on again. Saved in `config/huddable/settings.json`, which also remembers the active profile. diff --git a/src/main/java/uk/toakan/tad/huddable/ExternalPart.java b/src/main/java/uk/toakan/tad/huddable/ExternalPart.java index 56ca340..f63a73e 100644 --- a/src/main/java/uk/toakan/tad/huddable/ExternalPart.java +++ b/src/main/java/uk/toakan/tad/huddable/ExternalPart.java @@ -1,5 +1,6 @@ package uk.toakan.tad.huddable; +import java.util.function.BooleanSupplier; import uk.toakan.tad.huddable.api.HuddableApi; import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement; import net.minecraft.client.DeltaTracker; @@ -37,6 +38,8 @@ public final class ExternalPart implements HudPart { private int measuredWidth = -1; private int measuredHeight = -1; private long lastMeasure; + /** Listed in the editor only while true: false while the element's own mod has it switched off. */ + private BooleanSupplier listed = () -> true; private ExternalPart(Identifier id, Component label, HuddableApi.Spec spec) { this.id = id; @@ -52,6 +55,16 @@ public static ExternalPart api(Identifier id, Component label, HuddableApi.Spec return new ExternalPart(id, label, spec); } + /** Leaves the part out of the editor while {@code listed} is false; its saved layouts are kept. */ + public ExternalPart listedWhen(BooleanSupplier listed) { + this.listed = listed; + return this; + } + + public boolean listed() { + return listed.getAsBoolean(); + } + boolean isFabric() { return spec == null; } diff --git a/src/main/java/uk/toakan/tad/huddable/GeneralSettings.java b/src/main/java/uk/toakan/tad/huddable/GeneralSettings.java index 3a3509a..d0e965b 100644 --- a/src/main/java/uk/toakan/tad/huddable/GeneralSettings.java +++ b/src/main/java/uk/toakan/tad/huddable/GeneralSettings.java @@ -23,6 +23,8 @@ public final class GeneralSettings { public String active = Profiles.DEFAULT_NAME; /** Oversample for every TrueType font, or 0 for the pack's own. Read on font-loading threads. */ public volatile int fontOversample = DEFAULT_FONT_OVERSAMPLE; + /** Advanced: list meowdding-lib's overlays (SkyCubed, SkyOcean) as parts and move their drawing. */ + public boolean meowddingOverlays = true; /** * 0 in files from before 0.3.4, so their old default can be moved once. No initializer: Gson runs the * constructor, so one would also fill it in for old files. @@ -62,6 +64,7 @@ public static void save() { GeneralSettings copy = new GeneralSettings(); copy.active = s.active; copy.fontOversample = s.fontOversample; + copy.meowddingOverlays = s.meowddingOverlays; copy.settingsVersion = s.settingsVersion; JsonFiles.writeAsync(FILE, () -> copy); } diff --git a/src/main/java/uk/toakan/tad/huddable/GeneralSettingsScreen.java b/src/main/java/uk/toakan/tad/huddable/GeneralSettingsScreen.java index 1f27540..36d67fb 100644 --- a/src/main/java/uk/toakan/tad/huddable/GeneralSettingsScreen.java +++ b/src/main/java/uk/toakan/tad/huddable/GeneralSettingsScreen.java @@ -6,19 +6,25 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.options.OptionsSubScreen; import net.minecraft.network.chat.Component; +import uk.toakan.tad.huddable.compat.MeowddingCompat; /** * Huddable's settings for the whole game ({@link GeneralSettings}), in vanilla's options list. Font quality only * takes effect when the fonts are rebuilt, so closing the screen after changing it reloads the resource packs once. + * The Advanced section only shows options for mods that are installed. */ public class GeneralSettingsScreen extends OptionsSubScreen { private final int startOversample; private int oversample; + private final boolean startMeowdding; + private boolean meowdding; public GeneralSettingsScreen(Screen parent) { super(parent, Minecraft.getInstance().options, Component.translatable("huddable.general.title")); startOversample = GeneralSettings.get().fontOversample; oversample = startOversample; + startMeowdding = GeneralSettings.get().meowddingOverlays; + meowdding = startMeowdding; } @Override @@ -31,11 +37,27 @@ protected void addOptions() { new OptionInstance.IntRange(0, GeneralSettings.MAX_FONT_OVERSAMPLE), oversample, value -> oversample = value)); + if (MeowddingCompat.available()) { + list.addHeader(Component.translatable("huddable.general.advanced")); + list.addBig(OptionInstance.createBoolean("huddable.general.meowdding_overlays", + OptionInstance.cachedConstantTooltip(Component.translatable("huddable.general.meowdding_overlays.desc")), + meowdding, + value -> meowdding = value)); + } } @Override public void onClose() { super.onClose(); + if (meowdding != startMeowdding) { + GeneralSettings.get().meowddingOverlays = meowdding; + GeneralSettings.save(); + if (meowdding) { + MeowddingCompat.start(); + } else { + MeowddingCompat.stop(); + } + } if (oversample != startOversample) { GeneralSettings.get().fontOversample = oversample; GeneralSettings.save(); diff --git a/src/main/java/uk/toakan/tad/huddable/HuddableClient.java b/src/main/java/uk/toakan/tad/huddable/HuddableClient.java index f9f6338..775f517 100644 --- a/src/main/java/uk/toakan/tad/huddable/HuddableClient.java +++ b/src/main/java/uk/toakan/tad/huddable/HuddableClient.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.platform.InputConstants; import uk.toakan.tad.huddable.api.HuddablePlugin; +import uk.toakan.tad.huddable.compat.MeowddingCompat; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.resource.v1.ResourceLoader; @@ -47,7 +48,10 @@ public void onInitializeClient() { LOGGER.error("Huddable plugin from {} failed", plugin.getProvider().getMetadata().getId(), e); } } - ClientLifecycleEvents.CLIENT_STARTED.register(client -> HudDiscovery.discover()); + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + HudDiscovery.discover(); + MeowddingCompat.start(); + }); // Saves run on a background thread; make sure the last ones reach the disk before the game closes. ClientLifecycleEvents.CLIENT_STOPPING.register(client -> JsonFiles.flush()); // After the fonts reload (resource packs, F3+T, font quality), which fonts exist and their widths may change. diff --git a/src/main/java/uk/toakan/tad/huddable/Parts.java b/src/main/java/uk/toakan/tad/huddable/Parts.java index 4b6f33f..5b763ca 100644 --- a/src/main/java/uk/toakan/tad/huddable/Parts.java +++ b/src/main/java/uk/toakan/tad/huddable/Parts.java @@ -15,9 +15,12 @@ public final class Parts { private Parts() {} + /** The parts the editor shows: other mods' ones only while {@link ExternalPart#listed}. */ public static List all() { List parts = new ArrayList<>(List.of(Element.values())); - parts.addAll(EXTERNAL); + for (ExternalPart part : EXTERNAL) { + if (part.listed()) parts.add(part); + } return parts; } @@ -29,6 +32,12 @@ public static void add(ExternalPart part) { if (!part.isFabric()) CLAIMED.add(part.id); } + /** Takes a part out of the editor; its saved layouts stay in the profiles. */ + public static void remove(Identifier id) { + EXTERNAL.removeIf(p -> p.id.equals(id)); + CLAIMED.remove(id); + } + public static void ignore(Identifier fabricLayerId) { CLAIMED.add(fabricLayerId); } diff --git a/src/main/java/uk/toakan/tad/huddable/compat/MeowddingCompat.java b/src/main/java/uk/toakan/tad/huddable/compat/MeowddingCompat.java new file mode 100644 index 0000000..f7013e2 --- /dev/null +++ b/src/main/java/uk/toakan/tad/huddable/compat/MeowddingCompat.java @@ -0,0 +1,136 @@ +package uk.toakan.tad.huddable.compat; + +import java.util.IdentityHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import me.owdding.lib.overlays.Overlay; +import me.owdding.lib.overlays.Rect; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.contents.TranslatableContents; +import net.minecraft.resources.Identifier; +import org.joml.Matrix3x2f; +import org.joml.Matrix3x2fStack; +import uk.toakan.tad.huddable.ExternalPart; +import uk.toakan.tad.huddable.GeneralSettings; +import uk.toakan.tad.huddable.HuddableClient; +import uk.toakan.tad.huddable.Parts; +import uk.toakan.tad.huddable.api.HuddableApi; +import uk.toakan.tad.huddable.mixin.meowdding.OverlaysAccessor; + +/** + * Places meowdding-lib's overlays (SkyCubed, SkyOcean and the other meowdding mods) one by one. meowdding-lib + * draws them all in one loop inside SkyblockAPI's {@code RenderHudEvent}, which fires from vanilla's sleep + * overlay, so none is a Fabric HUD layer {@code HudDiscovery} could find. Each overlay is registered here as an + * API element, and {@code mixin.meowdding.OverlaysMixin} moves its draw call inside that loop. General Settings' + * Advanced toggle turns this off. Only this class and that mixin package touch meowdding-lib. Client thread only. + */ +public final class MeowddingCompat { + public static final String MOD_ID = "meowdding-lib"; + /** SkyCubed overlays drawn by SkyCubed's own mixins on the vanilla hotbar: their draw call draws nothing to place. */ + private static final Set SKIPPED = Set.of( + "tech.thatgravyboat.skycubed.features.overlays.vanilla.MovableHotbar", + "tech.thatgravyboat.skycubed.features.overlays.vanilla.MovableItemText"); + + private static final Map PARTS = new IdentityHashMap<>(); + private static boolean failed; + + private MeowddingCompat() {} + + /** True when meowdding-lib is installed and listing its overlays hasn't failed. */ + public static boolean available() { + return !failed && FabricLoader.getInstance().isModLoaded(MOD_ID); + } + + /** Lists every overlay registered by now as a part, when the General Settings toggle is on. */ + public static void start() { + if (!available() || !GeneralSettings.get().meowddingOverlays || !PARTS.isEmpty()) return; + try { + for (Overlay overlay : OverlaysAccessor.huddable$overlays()) { + if (SKIPPED.contains(overlay.getClass().getName())) continue; + Identifier id = uniqueId(overlay); + PARTS.put(overlay, id); + // An overlay its mod has switched off isn't listed until it's switched back on there. + Parts.add(ExternalPart.api(id, label(overlay), HuddableApi.Spec.of((w, h) -> box(overlay))) + .listedWhen(overlay::getEnabled)); + } + } catch (RuntimeException | LinkageError e) { + HuddableClient.LOGGER.warn("Couldn't list meowdding-lib's overlays; they can't be placed", e); + stop(); + failed = true; + return; + } + if (!PARTS.isEmpty()) HuddableClient.LOGGER.info("Placing {} meowdding-lib overlays: {}", PARTS.size(), PARTS.values()); + } + + /** Takes the overlays out of the editor; their saved positions stay in the profiles. */ + public static void stop() { + for (Identifier id : PARTS.values()) Parts.remove(id); + PARTS.clear(); + } + + /** + * Runs one overlay's draw call where the player put it. The pose already holds meowdding's own position and + * scale, so Huddable's move is applied on top of it, in screen space. + */ + public static void draw(Overlay overlay, GuiGraphicsExtractor graphics, Runnable draw) { + Identifier id = PARTS.get(overlay); + ExternalPart part = id == null ? null : Parts.external(id); + if (part == null) { + draw.run(); + return; + } + int w = graphics.guiWidth(); + int h = graphics.guiHeight(); + HuddableApi.Placement p = part.placement(w, h); + if (p.hidden()) return; + HuddableApi.Box box = part.defaultBox(w, h); + if (p.x() == box.x() && p.y() == box.y() && p.scale() == 1f) { + draw.run(); + return; + } + Matrix3x2fStack pose = graphics.pose(); + Matrix3x2f moved = new Matrix3x2f().translate(p.x(), p.y()).scale(p.scale(), p.scale()) + .translate(-box.x(), -box.y()).mul(pose); + pose.pushMatrix(); + pose.set(moved); + draw.run(); + pose.popMatrix(); + } + + /** Where meowdding draws the overlay now: the box its own editor highlights, in GUI pixels. */ + private static HuddableApi.Box box(Overlay overlay) { + Rect r = overlay.getEditBounds().times(overlay.getPosition().getScale()); + return new HuddableApi.Box(r.getX(), r.getY(), Math.max(1, r.getWidth()), Math.max(1, r.getHeight())); + } + + /** + * {@code modid:name}, from the overlay's translation key when it has one (stays the same in every language), + * else its text. Profiles store positions under it, so it must not change between starts. + */ + private static Identifier uniqueId(Overlay overlay) { + Component name = overlay.getName(); + String raw = name.getContents() instanceof TranslatableContents t ? t.getKey() : name.getString(); + String namespace = clean(overlay.getModId(), "[^a-z0-9_.-]"); + String path = clean(raw, "[^a-z0-9/._-]"); + Identifier id = Identifier.fromNamespaceAndPath(namespace, path); + for (int n = 2; PARTS.containsValue(id); n++) { + id = Identifier.fromNamespaceAndPath(namespace, path + "_" + n); + } + return id; + } + + private static String clean(String s, String illegal) { + String cleaned = s.toLowerCase(Locale.ROOT).replaceAll(illegal, "_"); + return cleaned.isEmpty() ? "overlay" : cleaned; + } + + /** "Mod Name: Overlay name", from the mod that registered it when there is one. */ + private static Component label(Overlay overlay) { + String mod = FabricLoader.getInstance().getModContainer(overlay.getModId()) + .map(c -> c.getMetadata().getName()).orElse(overlay.getModId()); + return Component.literal(mod + ": ").append(overlay.getName()); + } +} diff --git a/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/MeowddingMixinPlugin.java b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/MeowddingMixinPlugin.java new file mode 100644 index 0000000..04c1f32 --- /dev/null +++ b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/MeowddingMixinPlugin.java @@ -0,0 +1,43 @@ +package uk.toakan.tad.huddable.mixin.meowdding; + +import java.util.List; +import java.util.Set; +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import uk.toakan.tad.huddable.compat.MeowddingCompat; + +/** Applies the meowdding-lib mixins only when meowdding-lib is installed. */ +public final class MeowddingMixinPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FabricLoader.getInstance().isModLoaded(MeowddingCompat.MOD_ID); + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + } +} diff --git a/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysAccessor.java b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysAccessor.java new file mode 100644 index 0000000..91fa990 --- /dev/null +++ b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysAccessor.java @@ -0,0 +1,16 @@ +package uk.toakan.tad.huddable.mixin.meowdding; + +import java.util.List; +import me.owdding.lib.overlays.Overlay; +import me.owdding.lib.overlays.Overlays; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +/** meowdding-lib's list of registered overlays (a Kotlin object's private field, so static), read-only. */ +@Mixin(Overlays.class) +public interface OverlaysAccessor { + @Accessor("overlays") + static List huddable$overlays() { + throw new AssertionError(); + } +} diff --git a/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysMixin.java b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysMixin.java new file mode 100644 index 0000000..dc45c6e --- /dev/null +++ b/src/main/java/uk/toakan/tad/huddable/mixin/meowdding/OverlaysMixin.java @@ -0,0 +1,25 @@ +package uk.toakan.tad.huddable.mixin.meowdding; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import me.owdding.lib.overlays.Overlay; +import me.owdding.lib.overlays.Overlays; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import uk.toakan.tad.huddable.compat.MeowddingCompat; + +/** + * Moves, scales or hides each meowdding-lib overlay ({@link MeowddingCompat}). {@code onHudRender} loops over + * every overlay and calls its {@code extract} after setting meowdding's own position; wrapping that one call + * places each overlay on its own, while meowdding's hover outline and click-to-edit stay at its own position. + */ +@Mixin(Overlays.class) +abstract class OverlaysMixin { + @WrapOperation(method = "onHudRender", + at = @At(value = "INVOKE", target = "Lme/owdding/lib/overlays/Overlay;extract(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V")) + private void huddable$placeOverlay(Overlay overlay, GuiGraphicsExtractor graphics, int mouseX, int mouseY, + float partialTicks, Operation original) { + MeowddingCompat.draw(overlay, graphics, () -> original.call(overlay, graphics, mouseX, mouseY, partialTicks)); + } +} diff --git a/src/main/resources/assets/huddable/lang/en_us.json b/src/main/resources/assets/huddable/lang/en_us.json index 2940af5..706c922 100644 --- a/src/main/resources/assets/huddable/lang/en_us.json +++ b/src/main/resources/assets/huddable/lang/en_us.json @@ -5,6 +5,9 @@ "huddable.hub.general.tooltip": "Settings for the whole game, not one profile, such as font quality", "huddable.general.title": "Huddable: General Settings", + "huddable.general.advanced": "Advanced", + "huddable.general.meowdding_overlays": "meowdding overlays", + "huddable.general.meowdding_overlays.desc": "List each overlay from meowdding-lib mods (SkyCubed, SkyOcean) as its own element, so you can move, scale and hide it. Turn off if they misbehave or you'd rather place them with their own editor.", "huddable.general.font_quality": "Font quality", "huddable.general.font_quality.desc": "How sharp TrueType fonts from resource packs are drawn (their oversample). Higher is sharper at large GUI scales but uses more video memory; Pack's own uses each pack's setting. Applies to every mod's fonts, not just Huddable's, and reloads the resource packs when you leave.", "huddable.general.font_quality.pack": "Pack's own", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index cb25588..21d15fb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,7 +18,8 @@ ] }, "mixins": [ - "huddable.mixins.json" + "huddable.mixins.json", + "huddable.meowdding.mixins.json" ], "depends": { "fabricloader": ">=0.19.5", diff --git a/src/main/resources/huddable.meowdding.mixins.json b/src/main/resources/huddable.meowdding.mixins.json new file mode 100644 index 0000000..9fb082c --- /dev/null +++ b/src/main/resources/huddable.meowdding.mixins.json @@ -0,0 +1,14 @@ +{ + "required": false, + "minVersion": "0.8", + "package": "uk.toakan.tad.huddable.mixin.meowdding", + "plugin": "uk.toakan.tad.huddable.mixin.meowdding.MeowddingMixinPlugin", + "compatibilityLevel": "JAVA_25", + "client": [ + "OverlaysAccessor", + "OverlaysMixin" + ], + "injectors": { + "defaultRequire": 0 + } +} diff --git a/versions/26.2/gradle.properties b/versions/26.2/gradle.properties index 675dffc..34c58b3 100644 --- a/versions/26.2/gradle.properties +++ b/versions/26.2/gradle.properties @@ -3,3 +3,4 @@ minecraft_version=26.2 minecraft_range=~26.2 fabric_version=0.161.0+26.2 modmenu_version=20.0.3 +meowdding_lib_version=4.2.38 diff --git a/versions/26.3/gradle.properties b/versions/26.3/gradle.properties index ed3424e..66622c2 100644 --- a/versions/26.3/gradle.properties +++ b/versions/26.3/gradle.properties @@ -3,3 +3,4 @@ minecraft_version=26.3 minecraft_range=~26.3 fabric_version=0.161.0+26.3 modmenu_version=21.0.0 +meowdding_lib_version=4.2.38