Skip to content

Commit

Permalink
[ui] don't render owo-ui hud components while the hud is hidden accor…
Browse files Browse the repository at this point in the history
…ding to game options
  • Loading branch information
gliscowo committed Sep 15, 2024
1 parent d739f6e commit a2a5b0f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/io/wispforest/owo/ui/hud/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import io.wispforest.owo.ui.event.ClientRenderCallback;
import io.wispforest.owo.ui.event.WindowResizeCallback;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

Expand Down Expand Up @@ -82,7 +84,7 @@ public static boolean hasComponent(Identifier id) {
private static void initializeAdapter() {
var window = MinecraftClient.getInstance().getWindow();
adapter = OwoUIAdapter.createWithoutScreen(
0, 0, window.getScaledWidth(), window.getScaledHeight(), HudContainer::new
0, 0, window.getScaledWidth(), window.getScaledHeight(), HudContainer::new
);

adapter.inflateAndMount();
Expand All @@ -105,7 +107,7 @@ private static void initializeAdapter() {
});

HudRenderCallback.EVENT.register((context, tickDelta) -> {
if (adapter == null || suppress) return;
if (adapter == null || suppress || MinecraftClient.getInstance().options.hudHidden) return;

context.push().translate(0, 0, 100);
adapter.render(context, -69, -69, tickDelta.getTickDelta(false));
Expand Down

0 comments on commit a2a5b0f

Please sign in to comment.