diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java index 765a271..68e25f6 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -3,8 +3,13 @@ package io.polyfrost.oneconfig.gui.elements; import io.polyfrost.oneconfig.lwjgl.RenderManager; import io.polyfrost.oneconfig.utils.ColorUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.ChatComponentText; import org.lwjgl.input.Mouse; +import java.lang.reflect.Method; +import java.util.function.Consumer; + public class BasicElement { protected int width, height; protected int colorPalette; @@ -46,13 +51,20 @@ public class BasicElement { int buttonBottom = y + height; hovered = mouseX > x - hitBoxX && mouseY > y - hitBoxY && mouseX < buttonRight + hitBoxX && mouseY < buttonBottom + hitBoxY; - if (Mouse.isButtonDown(0) && clicked) { - toggled = !toggled; + if (hovered) { + if (Mouse.isButtonDown(0) && !clicked) { + toggled = !toggled; + onClick(); + } + clicked = Mouse.isButtonDown(0); } - clicked = Mouse.isButtonDown(0) && hovered; } + public void onClick() { + + } + public void setCustomHitbox(int x, int y) { hitBoxX = x; hitBoxY = y; |