From a097d3229a940f1164786e3037ca6c3890a8ddcc Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Sat, 21 Nov 2026 15:56:48 -0500 Subject: [PATCH] fix(hud): show new HUD item icons on their first frame --- .../java/org/polyfrost/oneconfig/internal/OneConfig.java | 6 ++++-- .../internal/ui/compose/impls/HudEditorUIScreen.kt | 3 ++- .../internal/ui/compose/impls/OneConfigUIScreen.kt | 2 ++ .../main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java index 9a027c00e..73981e511 100644 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java +++ b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java @@ -66,6 +66,7 @@ //? if >= 1.21.11 import org.polyfrost.compose.minecraft.render.blaze.BlazeHud; import org.polyfrost.compose.minecraft.render.gl.GlHost; +import org.polyfrost.compose.minecraft.mc.McItemIcons; import org.polyfrost.oneconfig.internal.ui.compose.impls.HudEditorUIScreen; import org.polyfrost.oneconfig.internal.ui.compose.impls.OneConfigUIScreen; import org.polyfrost.oneconfig.internal.ui.hud.BuiltinHudRegistrar; @@ -249,13 +250,14 @@ public static void prepareHud() { if (HudManager.isConfigUiOpen) { HudManager.INSTANCE.prepare(sw, sh); + McItemIcons.renderPending(); HudManager.invalidate(); return; } //? if >= 1.21.11 { - if (HudManager.INSTANCE.beginFrame(sw, sh, null, true, true)) BlazeHud.markDirty(); + if (HudManager.INSTANCE.beginFrame(sw, sh, McItemIcons::renderPending, true, true)) BlazeHud.markDirty(); //?} else { - /*if (HudManager.INSTANCE.beginFrame(sw, sh, null, false)) { + /*if (HudManager.INSTANCE.beginFrame(sw, sh, McItemIcons::renderPending, false)) { GlHost.INSTANCE.drawHudGl((ctx, volatileCtx) -> { HudManager.INSTANCE.render(ctx, sw, sh, volatileCtx); return Unit.INSTANCE; diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt index 8e4dd3f73..e18f8d0e2 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt @@ -19,6 +19,7 @@ import org.polyfrost.oneconfig.internal.OneConfigConfig import org.polyfrost.oneconfig.internal.ThemeConfig import org.polyfrost.oneconfig.internal.ui.components.BackdropUsers import org.polyfrost.oneconfig.internal.ui.components.RetainedVisibility +import org.polyfrost.compose.minecraft.mc.McItemIcons import org.polyfrost.compose.minecraft.screen.ComposeScreen import org.polyfrost.oneconfig.internal.ui.compose.OneConfigComposeHooks //? if >= 1.21.11 @@ -73,7 +74,7 @@ class HudEditorUIScreen private constructor() : ComposeScreen(options = OneConfi HudManager.inWorld = false HudManager.guiScreenWidth = sw HudManager.guiScreenHeight = sh - return HudManager.beginFrame(sw, sh, null, true, true) + return HudManager.beginFrame(sw, sh, McItemIcons::renderPending, true, true) } // in a world the game's HUD pass draws the HUDs before the blur, so off it they're drawn the same way here diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt index 3c35a2f8d..13ad85e3a 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt @@ -34,6 +34,7 @@ import org.apache.logging.log4j.LogManager import org.polyfrost.compose.backend.PolyCanvas import org.polyfrost.compose.backend.PolyCompose import org.polyfrost.compose.host.LocalComposeOptions +import org.polyfrost.compose.minecraft.mc.McItemIcons import org.polyfrost.compose.render.PolyBitmap import org.polyfrost.compose.render.PolyGlyphPage import org.polyfrost.compose.render.PolyRenderer @@ -476,6 +477,7 @@ class OneConfigUIScreen @JvmOverloads constructor( HudManager.guiScreenWidth = sw HudManager.guiScreenHeight = sh HudManager.prepare(sw, sh) + McItemIcons.renderPending() } HudEditorViewport.update(Platform.screen().windowWidth(), Platform.screen().windowHeight()) //? if > 1.8.9 { diff --git a/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt b/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt index b21a089fc..5a0c179a9 100644 --- a/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt +++ b/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt @@ -40,6 +40,7 @@ import org.jetbrains.annotations.MustBeInvokedByOverriders import org.polyfrost.compose.composables.PolyModifier import org.polyfrost.compose.composables.background import org.polyfrost.compose.composables.border +import org.polyfrost.compose.host.LocalContentScale import org.polyfrost.compose.layout.PolyAlign import org.polyfrost.compose.render.PolyColor import org.polyfrost.compose.runtime.PolyComposeRuntime @@ -1695,7 +1696,7 @@ public abstract class Hud( get() = _runtime ?: PolyComposeRuntime().also { _runtime = it it.setContent { - CompositionLocalProvider(LocalHud provides this) { + CompositionLocalProvider(LocalHud provides this, LocalContentScale provides effectiveScale) { Content() } }