From b8add1552717ec7a8079da18cecb9439c2be0f1a Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sat, 24 Oct 2020 10:57:49 +0300 Subject: Add simple HUD test --- .../cottonmc/test/client/LibGuiTestClient.java | 3 +++ .../io/github/cottonmc/test/client/WHudTest.java | 26 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java (limited to 'GuiTest') diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java index 5ef61c2..65efe75 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -1,5 +1,6 @@ package io.github.cottonmc.test.client; +import io.github.cottonmc.cotton.gui.client.CottonHud; import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen; import io.github.cottonmc.test.LibGuiTest; import io.github.cottonmc.test.TestDescription; @@ -14,6 +15,8 @@ public class LibGuiTestClient implements ClientModInitializer { LibGuiTest.GUI_SCREEN_HANDLER_TYPE, (desc, inventory, title) -> new CottonInventoryScreen<>(desc, inventory.player, title) ); + + CottonHud.INSTANCE.add(new WHudTest(), 10, -20, 10, 10); } } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java new file mode 100644 index 0000000..2cc1e4b --- /dev/null +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java @@ -0,0 +1,26 @@ +package io.github.cottonmc.test.client; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import net.minecraft.client.util.math.MatrixStack; + +import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.widget.WWidget; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Environment(EnvType.CLIENT) +public class WHudTest extends WWidget { + private static final Logger LOGGER = LogManager.getLogger(); + + @Override + public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { + ScreenDrawing.coloredRect(x, y, width, height, 0xFF_00FF00); + } + + @Override + public void tick() { + LOGGER.debug("tick!"); + } +} -- cgit