[owo-ui] Hud does not work correctly when using f1, causing hud to persist after removing them
Zailer43 opened this issue · 1 comments
Description
Attempting to remove or add a Hud with F1 (hidden hud) causes the Hud to persist, making it so that there may be more than 1 when there should only be 1 or that there is 1 when it should be disabled.
Code
public static boolean hudActive = false;
KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.test", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_J, "key.category.test"));
Identifier hudIdentifier = new Identifier("test", "test-hud");
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (keyBinding.wasPressed()) {
if (hudActive) {
Hud.remove(hudIdentifier);
hudActive = false;
} else {
Hud.add(hudIdentifier, () -> Containers.horizontalFlow(Sizing.fill(100), Sizing.fill(100)).surface(Surface.VANILLA_TRANSLUCENT).positioning(Positioning.relative(0, 0)));
hudActive = true;
}
}
});
Reproduction steps
- Press F1 to hidde Hud
- Press J to active Hud
- Press J to desactive Hud
- Press F1 to enable Hud
- Bug, the Hud is active, if you press J again, there will be 2 Hud
Temporary solutions
If before calling Hud.remove or Hud.add you put
MinecraftClient.getInstance().options.hudHidden = false;
it will disable f1, although you can't enable it immediately afterwards since Hud works through events
Versions
owo_version=0.12.3+1.20.3
minecraft_version=1.20.4
fabric_version=0.93.1+1.20.4
Thanks for reporting this and bringing my attention to the Hud again - this whole pending addition/removal system was a bit... ill-guided from the start. I've made some changes in 0.12.5 (check the changelog) which should alleviate all the problems
Cheers