Skip to content

Commit

Permalink
fix day count animation
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Jul 8, 2022
1 parent e5b6c29 commit fa72d27
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/moe/zapic/clockhud/render/DayCountRender.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package moe.zapic.clockhud.render;

import com.mojang.blaze3d.systems.RenderSystem;
import moe.zapic.clockhud.Main;
import moe.zapic.clockhud.Utils;
import net.minecraft.client.MinecraftClient;
Expand All @@ -12,8 +13,8 @@ public class DayCountRender {
public static boolean isTextRendering = false;
public static float renderTime = 0.0f;
public static long currentDay = -1;
public static float Duration = 200.0f;
public static int TextOpacity = 0;
public static float Duration = 100.0f;
public static int TextOpacity = 5;

public static void render(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
if(!Main.config.showDayCount) return;
Expand All @@ -27,18 +28,17 @@ public static void render(MatrixStack matrices, float tickDelta, CallbackInfo ci
setRenderStatus();
DrawableHelper.drawCenteredText(matrices, mc.textRenderer, new TranslatableText("text.clock-hud.new-day-tip", currentDay), mc.getWindow().getScaledWidth() / 2, 30, (TextOpacity << 24) + 0xffffff);
matrices.pop();
renderTime += tickDelta;
renderTime += mc.getLastFrameDuration();
if (renderTime >= Duration) {
isTextRendering = false;
renderTime = 0.0f;
TextOpacity = 0;
}
}

public static void setRenderStatus() {
if(renderTime <= 20) {
TextOpacity = (int) (0xff * (renderTime / 20));
} else if (renderTime >= 180) {
TextOpacity = Math.max((int) (0xff * (renderTime / 20)), 5);
} else if (renderTime >= 80) {
TextOpacity = (int) (0xff * (1 - renderTime / 20));
} else if (TextOpacity != 0xff) {
TextOpacity = 0xff;
Expand Down

0 comments on commit fa72d27

Please sign in to comment.