From 29f0b9fecfca0bc508a5fc140120b69a69fa9f58 Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Wed, 26 Jun 2024 11:35:29 +0800 Subject: [PATCH] fix HUD part --- CHANGELOG.md | 2 +- .../src/main/java/org/thinkingstudio/obsidianui/hud/Hud.java | 3 ++- .../java/org/thinkingstudio/obsidianui/hud/HudComponent.java | 3 ++- .../obsidianui/hud/component/TextHudComponent.java | 3 ++- fabric/CHANGELOG.md | 2 +- .../thinkingstudio/obsidianui/fabric/ObsidianUIFabric.java | 2 +- gradle.properties | 4 ++-- neoforge/CHANGELOG.md | 2 +- .../obsidianui/neoforge/ObsidianUINeoForge.java | 5 +++-- 9 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5fecac..2fef80c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,2 @@ ## Changelog -- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues) +- fix HUD part diff --git a/common/src/main/java/org/thinkingstudio/obsidianui/hud/Hud.java b/common/src/main/java/org/thinkingstudio/obsidianui/hud/Hud.java index c56d7ae..46acd3e 100644 --- a/common/src/main/java/org/thinkingstudio/obsidianui/hud/Hud.java +++ b/common/src/main/java/org/thinkingstudio/obsidianui/hud/Hud.java @@ -13,6 +13,7 @@ import com.google.common.collect.ImmutableList; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.thinkingstudio.obsidianui.util.Identifiable; @@ -100,7 +101,7 @@ public void init(@NotNull MinecraftClient client, int screenWidth, int screenHei * @param tickDelta Progress for linearly interpolating between the previous and current game state. * @see #isEnabled() */ - public void render(DrawContext drawContext, float tickDelta) { + public void render(DrawContext drawContext, RenderTickCounter tickDelta) { this.components.stream().filter(HudComponent::isEnabled).forEach(component -> component.render(drawContext, tickDelta)); } diff --git a/common/src/main/java/org/thinkingstudio/obsidianui/hud/HudComponent.java b/common/src/main/java/org/thinkingstudio/obsidianui/hud/HudComponent.java index 7bd39ea..f40f82b 100644 --- a/common/src/main/java/org/thinkingstudio/obsidianui/hud/HudComponent.java +++ b/common/src/main/java/org/thinkingstudio/obsidianui/hud/HudComponent.java @@ -11,6 +11,7 @@ package org.thinkingstudio.obsidianui.hud; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.thinkingstudio.obsidianui.util.Identifiable; @@ -67,7 +68,7 @@ public void setEnabled(boolean enabled) { * @param tickDelta Progress for linearly interpolating between the previous and current game state. * @see #isEnabled() */ - public abstract void render(DrawContext drawContext, float tickDelta); + public abstract void render(DrawContext drawContext, RenderTickCounter tickDelta); /** * Updates the HUD each tick if enabled and has tick updates. diff --git a/common/src/main/java/org/thinkingstudio/obsidianui/hud/component/TextHudComponent.java b/common/src/main/java/org/thinkingstudio/obsidianui/hud/component/TextHudComponent.java index 30075f1..499d6f2 100644 --- a/common/src/main/java/org/thinkingstudio/obsidianui/hud/component/TextHudComponent.java +++ b/common/src/main/java/org/thinkingstudio/obsidianui/hud/component/TextHudComponent.java @@ -12,6 +12,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import org.thinkingstudio.obsidianui.hud.HudComponent; @@ -76,7 +77,7 @@ public void setColor(int color) { } @Override - public void render(DrawContext drawContext, float tickDelta) { + public void render(DrawContext drawContext, RenderTickCounter tickDelta) { drawContext.drawTextWithShadow(this.client.textRenderer, this.text, this.x, this.y, this.color); } } diff --git a/fabric/CHANGELOG.md b/fabric/CHANGELOG.md index b5fecac..2fef80c 100644 --- a/fabric/CHANGELOG.md +++ b/fabric/CHANGELOG.md @@ -1,2 +1,2 @@ ## Changelog -- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues) +- fix HUD part diff --git a/fabric/src/main/java/org/thinkingstudio/obsidianui/fabric/ObsidianUIFabric.java b/fabric/src/main/java/org/thinkingstudio/obsidianui/fabric/ObsidianUIFabric.java index f9a09f6..d503c92 100644 --- a/fabric/src/main/java/org/thinkingstudio/obsidianui/fabric/ObsidianUIFabric.java +++ b/fabric/src/main/java/org/thinkingstudio/obsidianui/fabric/ObsidianUIFabric.java @@ -23,7 +23,7 @@ public void onInitializeClient() { HudRenderCallback.EVENT.register((drawContext, tickDelta) -> { HudManager.HUDS.forEach((id, hud) -> { if (hud.isEnabled() && hud.isVisible()) - hud.render(drawContext, tickDelta.getTickDelta(true)); + hud.render(drawContext, tickDelta); }); }); ClientTickEvents.END_CLIENT_TICK.register(client -> { diff --git a/gradle.properties b/gradle.properties index a0bd312..65e9630 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,11 +2,11 @@ org.gradle.jvmargs=-Xmx2G minecraft_version=1.21 enabled_platforms=fabric,neoforge -yarn_mappings=1.21+build.1 +yarn_mappings=1.21+build.2 mappings_patch=1.21+build.4 archives_base_name=ObsidianUI -mod_version=0.2.6 +mod_version=0.2.7 maven_group=org.thinkingstudio.obsidianui fabric_loader_version=0.15.11 diff --git a/neoforge/CHANGELOG.md b/neoforge/CHANGELOG.md index b5fecac..2fef80c 100644 --- a/neoforge/CHANGELOG.md +++ b/neoforge/CHANGELOG.md @@ -1,2 +1,2 @@ ## Changelog -- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues) +- fix HUD part diff --git a/neoforge/src/main/java/org/thinkingstudio/obsidianui/neoforge/ObsidianUINeoForge.java b/neoforge/src/main/java/org/thinkingstudio/obsidianui/neoforge/ObsidianUINeoForge.java index ad75885..628cf2b 100644 --- a/neoforge/src/main/java/org/thinkingstudio/obsidianui/neoforge/ObsidianUINeoForge.java +++ b/neoforge/src/main/java/org/thinkingstudio/obsidianui/neoforge/ObsidianUINeoForge.java @@ -12,6 +12,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; @@ -31,8 +32,8 @@ public ObsidianUINeoForge() { if (FMLLoader.getDist().isClient()) { forgeEventBus.addListener(EventPriority.HIGHEST, RenderGuiEvent.Post.class, event -> { - DrawContext drawContext = event.getGuiGraphics(); - float tickDelta = event.getPartialTick().getTickDelta(true); + var drawContext = event.getGuiGraphics(); + var tickDelta = event.getPartialTick(); HudManager.HUDS.forEach((id, hud) -> { if (hud.isEnabled() && hud.isVisible())