]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/AbstractButton.java
Downgrade to 1.12.2
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / AbstractButton.java
1 package com.irtimaled.bbor.client.gui;
2
3 import net.minecraft.client.Minecraft;
4 import net.minecraft.client.gui.GuiButton;
5
6 abstract class AbstractButton extends GuiButton implements IRenderableControl {
7     AbstractButton(int id, int x, int y, int width, String name) {
8         super(id, x, y, width, 20, name);
9     }
10
11     AbstractButton(int id, int x, int y, int width, String name, boolean enabled) {
12         this(id, x, y, width, name);
13         this.enabled = enabled;
14     }
15
16     @Override
17     public void render(int mouseX, int mouseY) {
18         super.drawButton(Minecraft.getMinecraft(), mouseX, mouseY, 0f);
19     }
20
21     @Override
22     protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
23         renderBackground();
24     }
25
26     protected void renderBackground() {
27     }
28
29     @Override
30     protected int getHoverState(boolean p_getHoverState_1_) {
31         return getState();
32     }
33
34     protected int getState() {
35         return this.enabled ? this.hovered ? 2 : 1 : 0;
36     }
37
38     @Override
39     public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
40         if (super.mousePressed(mc, mouseX, mouseY)) {
41             onPressed();
42             return true;
43         }
44         return false;
45     }
46
47     protected abstract void onPressed();
48 }