From 7b5dc61066c75dc1a4531f11b681fc51550e0dc1 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sat, 24 Oct 2020 10:56:57 +0300 Subject: Fix HUD widgets not ticking --- src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java index 9549b99..79111d2 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java @@ -2,6 +2,7 @@ package io.github.cottonmc.cotton.gui.client; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.Window; @@ -19,10 +20,15 @@ import java.util.Set; */ @Environment(EnvType.CLIENT) public enum CottonHud implements HudRenderCallback { - INSTANCE; + INSTANCE; // TODO (4.0): Migrate from singleton to static methods static { HudRenderCallback.EVENT.register(INSTANCE); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + for (WWidget widget : INSTANCE.widgets) { + widget.tick(); + } + }); } private final Set widgets = new HashSet<>(); -- cgit