Skip to content

Commit

Permalink
fix HUD part
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Jun 26, 2024
1 parent cf2c95f commit 29f0b9f
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Changelog
- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues)
- fix HUD part
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion fabric/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Changelog
- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues)
- fix HUD part
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion neoforge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Changelog
- port to 1.21 (Thanks Motschen improved backgrounds and fix crash issues)
- fix HUD part
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down

0 comments on commit 29f0b9f

Please sign in to comment.