aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/gui/buttons
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-04-29 01:06:57 -0400
committerbowser0000 <bowser0000@gmail.com>2021-04-29 01:06:57 -0400
commit01822bff56d23b98885227943bd1e042e4f9e946 (patch)
tree5931c2b8a3df8ca25a5747fdc273a06c6102fa48 /src/main/java/me/Danker/gui/buttons
parentb48dabaf8ab58773eb51a1c2077b880ee1f28675 (diff)
downloadSkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.tar.gz
SkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.tar.bz2
SkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.zip
Add giant hp display
Also make LocationButton easy to add
Diffstat (limited to 'src/main/java/me/Danker/gui/buttons')
-rw-r--r--src/main/java/me/Danker/gui/buttons/LocationButton.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/me/Danker/gui/buttons/LocationButton.java b/src/main/java/me/Danker/gui/buttons/LocationButton.java
index a8937fd..f328c58 100644
--- a/src/main/java/me/Danker/gui/buttons/LocationButton.java
+++ b/src/main/java/me/Danker/gui/buttons/LocationButton.java
@@ -13,21 +13,17 @@ public class LocationButton extends GuiButton {
private String text;
private String text2;
private Integer text2Offset;
+ private int longestText;
- public LocationButton(int buttonId, int x, int y, double width, double height, double scale, String text, String text2, Integer text2Offset) {
- super(buttonId, x, y, text);
+ public LocationButton(int x, int y, double scale, String text, String text2, Integer text2Offset) {
+ super(0, x, y, text);
this.x = x;
this.y = y;
- this.width = (int) width;
- this.height = (int) height;
this.scale = scale;
this.text = text;
this.text2 = text2;
this.text2Offset = text2Offset;
- }
-
- @Override
- public void drawButton(Minecraft mc, int mouseX, int mouseY) {
+
String[] splitText;
if (text2 == null) {
splitText = text.split("\n");
@@ -37,16 +33,23 @@ public class LocationButton extends GuiButton {
int longestText = -1;
for (String s : splitText) {
- int stringLength = mc.fontRendererObj.getStringWidth(s);
+ int stringLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s);
if (stringLength > longestText) {
longestText = stringLength;
}
}
-
+
+ this.longestText = longestText;
+ this.height = (int) ((splitText.length * 9 + 3) * scale);
+ this.width = (int) ((this.longestText + 3) * scale);
+ }
+
+ @Override
+ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (text2 == null) {
- drawRect(x - 2, y - 2, (int) (x + longestText * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3);
+ drawRect(x - 2, y - 2, x + width, y + height, 0x40D3D3D3);
} else {
- drawRect(x - 2, y - 2, (int) (x + (longestText + text2Offset) * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3);
+ drawRect(x - 2, y - 2, (int) (x + (longestText + text2Offset + 3) * scale), y + height, 0x40D3D3D3);
new TextRenderer(mc, text2, (int) (x + (text2Offset * scale)), y, scale);
}
new TextRenderer(mc, text, x, y, scale);