aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java8
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/Utils.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java1
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java9
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java30
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java23
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java44
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java237
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java336
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java25
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java22
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java19
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java36
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java148
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java79
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java31
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java97
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java34
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java55
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java89
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java1
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java7
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java6
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java66
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java8
-rw-r--r--src/main/resources/assets/skyblockhud/data/trackers.json6
41 files changed, 780 insertions, 907 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index 1cb00bb..7e1f215 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -129,21 +129,19 @@ public class SkyblockHud {
// DISABLE UNTIL NEW SYSTEM
@EventHandler
- public void loadComplete(FMLLoadCompleteEvent event){
+ public void loadComplete(FMLLoadCompleteEvent event) {
TrackerFileLoader.loadTrackersFile();
- if (TrackerFileLoader.loadTrackerStatsFile(configDirectory)){
+ if (TrackerFileLoader.loadTrackerStatsFile(configDirectory)) {
TrackerFileLoader.saveTrackerStatsFile(configDirectory);
}
}
@SubscribeEvent
- public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event){
+ public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
TrackerFileLoader.saveTrackerStatsFile(configDirectory);
}
-
-
public static boolean hasSkyblockScoreboard() {
Minecraft mc = Minecraft.getMinecraft();
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
index 157077b..f65af86 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
@@ -361,6 +361,6 @@ public class Utils {
public static String formattedNumber(int number, int numberToFormatAt) {
DecimalFormat formatter = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA));
formatter.setRoundingMode(RoundingMode.FLOOR);
- return number > numberToFormatAt-1 ? formatter.format((double) number / 1000) + "k" : String.valueOf(number);
+ return number > numberToFormatAt - 1 ? formatter.format((double) number / 1000) + "k" : String.valueOf(number);
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java
index 15fb01a..61f8d82 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java
@@ -7,6 +7,7 @@ import net.minecraftforge.fml.common.eventhandler.Event;
public class SkyBlockEntityKilled extends Event {
public String id;
+
@Nullable
public Entity entity;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java
index 8dc63c8..bb14e5d 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java
@@ -21,17 +21,14 @@ public class EntityTypeHelper {
return false;
}
- public static boolean isCrypt(Entity entity){
+ public static boolean isCrypt(Entity entity) {
if (entity instanceof EntityZombie) {
EntityZombie zombie = ((EntityZombie) entity);
double maxHealthBase = zombie.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue();
if (maxHealthBase != 2000d) return false;
- if (zombie.getEquipmentInSlot(0) == null || !zombie.getEquipmentInSlot(0).getItem().equals(Items.iron_sword))
- return false;
- if (zombie.getEquipmentInSlot(1) == null || !zombie.getEquipmentInSlot(1).getItem().equals(Items.chainmail_boots))
- return false;
- if (zombie.getEquipmentInSlot(2) == null || !zombie.getEquipmentInSlot(2).getItem().equals(Items.chainmail_leggings))
- return false;
+ if (zombie.getEquipmentInSlot(0) == null || !zombie.getEquipmentInSlot(0).getItem().equals(Items.iron_sword)) return false;
+ if (zombie.getEquipmentInSlot(1) == null || !zombie.getEquipmentInSlot(1).getItem().equals(Items.chainmail_boots)) return false;
+ if (zombie.getEquipmentInSlot(2) == null || !zombie.getEquipmentInSlot(2).getItem().equals(Items.chainmail_leggings)) return false;
return zombie.getEquipmentInSlot(3) != null && zombie.getEquipmentInSlot(3).getItem().equals(Items.chainmail_chestplate);
}
return false;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
index 9b42192..04d4a8c 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
@@ -96,13 +96,8 @@ public class SBHConfig extends Config {
public boolean hideScoreboard = false;
@Expose
- @ConfigOption(
- name = "Bar Textures",
- desc = "Change the style of bars. Dont change this unless the pack ur using tells you can."
- )
- @ConfigEditorDropdown(
- values = {"Style 1", "Style 2"}
- )
+ @ConfigOption(name = "Bar Textures", desc = "Change the style of bars. Dont change this unless the pack ur using tells you can.")
+ @ConfigEditorDropdown(values = { "Style 1", "Style 2" })
public int barTexture = 0;
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
index 90325f8..1130370 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
@@ -1,5 +1,8 @@
package com.thatgravyboat.skyblockhud.config;
+import static com.thatgravyboat.skyblockhud.GuiTextures.DISCORD;
+import static com.thatgravyboat.skyblockhud.GuiTextures.TWITTER;
+
import com.google.common.collect.Lists;
import com.thatgravyboat.skyblockhud.core.GlScissorStack;
import com.thatgravyboat.skyblockhud.core.GuiElement;
@@ -13,8 +16,8 @@ import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
import com.thatgravyboat.skyblockhud.core.util.render.TextRenderUtils;
import java.awt.*;
import java.net.URI;
-import java.util.List;
import java.util.*;
+import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -25,9 +28,6 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static com.thatgravyboat.skyblockhud.GuiTextures.DISCORD;
-import static com.thatgravyboat.skyblockhud.GuiTextures.TWITTER;
-
public class SBHConfigEditor extends GuiElement {
private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD, TWITTER };
@@ -237,11 +237,11 @@ public class SBHConfigEditor extends GuiElement {
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
if (option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2 * innerPadding)*(accordionDepth + 1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
@@ -253,7 +253,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -300,7 +300,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -431,7 +431,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -491,7 +491,7 @@ public class SBHConfigEditor extends GuiElement {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
@@ -503,7 +503,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -528,7 +528,7 @@ public class SBHConfigEditor extends GuiElement {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
@@ -540,7 +540,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -586,7 +586,7 @@ public class SBHConfigEditor extends GuiElement {
if (accordion.getToggled()) {
int accordionDepth = 0;
if (option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
@@ -599,4 +599,4 @@ public class SBHConfigEditor extends GuiElement {
return true;
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
index f143b97..64f04fe 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
@@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL30;
public class BackgroundBlur {
private static class OutputStuff {
+
public Framebuffer framebuffer;
public Shader blurShaderHorz = null;
public Shader blurShaderVert = null;
@@ -41,8 +42,9 @@ public class BackgroundBlur {
private static int fogColour = 0;
private static boolean registered = false;
+
public static void registerListener() {
- if(!registered) {
+ if (!registered) {
registered = true;
MinecraftForge.EVENT_BUS.register(new BackgroundBlur());
}
@@ -69,18 +71,21 @@ public class BackgroundBlur {
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
- Framebuffer fb = new Framebuffer(width, height, false);
- fb.setFramebufferFilter(GL11.GL_NEAREST);
- return new OutputStuff(fb, null, null);
- });
+ OutputStuff output = blurOutput.computeIfAbsent(
+ blur,
+ k -> {
+ Framebuffer fb = new Framebuffer(width, height, false);
+ fb.setFramebufferFilter(GL11.GL_NEAREST);
+ return new OutputStuff(fb, null, null);
+ }
+ );
- if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ if (output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
output.framebuffer.createBindFramebuffer(width, height);
- if(output.blurShaderHorz != null) {
+ if (output.blurShaderHorz != null) {
output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
}
- if(output.blurShaderVert != null) {
+ if (output.blurShaderVert != null) {
output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
}
}
@@ -105,7 +110,7 @@ public class BackgroundBlur {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onScreenRender(RenderGameOverlayEvent.Pre event) {
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
processBlurs();
}
}
@@ -141,7 +146,7 @@ public class BackgroundBlur {
}
private static void blurBackground(OutputStuff output, float blurFactor) {
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
@@ -153,36 +158,34 @@ public class BackgroundBlur {
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, 0.0F, -2000.0F);
- if(blurOutputHorz == null) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz == null || output == null) {
+ if (blurOutputHorz == null || output == null) {
return;
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
blurOutputHorz.createBindFramebuffer(width, height);
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(output.blurShaderHorz == null) {
+ if (output.blurShaderHorz == null) {
try {
- output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- output.framebuffer, blurOutputHorz);
+ output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", output.framebuffer, blurOutputHorz);
output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception ignored) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderVert == null) {
+ if (output.blurShaderVert == null) {
try {
- output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, output.framebuffer);
+ output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output.framebuffer);
output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception ignored) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderHorz != null && output.blurShaderVert != null) {
- if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ if (output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if (output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
//Corrupted shader?
return;
}
@@ -193,9 +196,7 @@ public class BackgroundBlur {
GL11.glPushMatrix();
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject);
- GL30.glBlitFramebuffer(0, 0, width, height,
- 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
+ GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
output.blurShaderHorz.loadShader(0);
output.blurShaderVert.loadShader(0);
@@ -228,7 +229,7 @@ public class BackgroundBlur {
if (blurOutput.isEmpty()) return;
OutputStuff out = blurOutput.get(blurStrength);
- if(out == null) {
+ if (out == null) {
out = blurOutput.values().iterator().next();
}
@@ -245,5 +246,4 @@ public class BackgroundBlur {
out.framebuffer.unbindFramebufferTexture();
GlStateManager.depthMask(true);
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
index b9f4e79..d43e8b9 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
@@ -25,9 +25,8 @@ public class ChromaColour {
int[] arr = new int[split.length];
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
}
return arr;
}
@@ -48,15 +47,16 @@ public class ChromaColour {
}
public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
+ return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
}
private static final int MIN_CHROMA_SECS = 1;
private static final int MAX_CHROMA_SECS = 60;
public static long startTime = -1;
+
public static int specialToChromaRGB(String special) {
- if(startTime < 0) startTime = System.currentTimeMillis();
+ if (startTime < 0) startTime = System.currentTimeMillis();
int[] d = decompose(special);
int chr = d[4];
@@ -67,11 +67,11 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- if(chr > 0) {
+ if (chr > 0) {
float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
+ if (hsv[0] < 0) hsv[0] += 1;
}
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
@@ -85,11 +85,9 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- hsv[0] += degrees/360f;
+ hsv[0] += degrees / 360f;
hsv[0] %= 1;
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
index 6f21e9a..0e1694e 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
@@ -1,14 +1,14 @@
package com.thatgravyboat.skyblockhud.core;
+import java.util.LinkedList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.GL11;
-import java.util.LinkedList;
-
public class GlScissorStack {
private static class Bounds {
+
int left;
int top;
int right;
@@ -27,10 +27,10 @@ public class GlScissorStack {
right = Math.min(right, this.right);
bottom = Math.min(bottom, this.bottom);
- if(top > bottom) {
+ if (top > bottom) {
top = bottom;
}
- if(left > right) {
+ if (left > right) {
left = right;
}
@@ -40,39 +40,39 @@ public class GlScissorStack {
public void set(ScaledResolution scaledResolution) {
int height = Minecraft.getMinecraft().displayHeight;
int scale = scaledResolution.getScaleFactor();
- GL11.glScissor(left*scale, height-bottom*scale, (right-left)*scale, (bottom-top)*scale);
+ GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale);
}
}
private static final LinkedList<Bounds> boundsStack = new LinkedList<>();
public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) {
- if(right < left) {
+ if (right < left) {
int temp = right;
right = left;
left = temp;
}
- if(bottom < top) {
+ if (bottom < top) {
int temp = bottom;
bottom = top;
top = temp;
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
boundsStack.push(new Bounds(left, top, right, bottom));
} else {
boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom));
}
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.peek().set(scaledResolution);
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
}
public static void pop(ScaledResolution scaledResolution) {
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.pop();
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
} else {
boundsStack.peek().set(scaledResolution);
@@ -83,5 +83,4 @@ public class GlScissorStack {
boundsStack.clear();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
index ff817cf..e8d9d62 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
@@ -2,9 +2,11 @@ package com.thatgravyboat.skyblockhud.core;
import net.minecraft.client.gui.Gui;
-public abstract class GuiElement extends Gui {
+public abstract class GuiElement extends Gui {
public abstract void render();
+
public abstract boolean mouseInput(int mouseX, int mouseY);
+
public abstract boolean keyboardInput();
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
index 7c401ed..8daf4b1 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
@@ -37,7 +37,7 @@ public class GuiElementBoolean extends GuiElement {
this.toggleCallback = toggleCallback;
this.lastMillis = System.currentTimeMillis();
- if(value) animation = 36;
+ if (value) animation = 36;
}
@Override
@@ -51,58 +51,56 @@ public class GuiElementBoolean extends GuiElement {
long deltaMillis = currentMillis - lastMillis;
lastMillis = currentMillis;
boolean passedLimit = false;
- if(previewValue != value) {
- if((previewValue && animation > 12) ||
- (!previewValue && animation < 24)) {
+ if (previewValue != value) {
+ if ((previewValue && animation > 12) || (!previewValue && animation < 24)) {
passedLimit = true;
}
}
- if(previewValue != passedLimit) {
- animation += deltaMillis/10;
+ if (previewValue != passedLimit) {
+ animation += deltaMillis / 10;
} else {
- animation -= deltaMillis/10;
+ animation -= deltaMillis / 10;
}
- lastMillis -= deltaMillis%10;
+ lastMillis -= deltaMillis % 10;
- if(previewValue == value) {
+ if (previewValue == value) {
animation = Math.max(0, Math.min(36, animation));
- } else if(!passedLimit) {
- if(previewValue) {
+ } else if (!passedLimit) {
+ if (previewValue) {
animation = Math.max(0, Math.min(12, animation));
} else {
animation = Math.max(24, Math.min(36, animation));
}
} else {
- if(previewValue) {
+ if (previewValue) {
animation = Math.max(12, animation);
} else {
animation = Math.min(24, animation);
}
}
- int animation = (int)(LerpUtils.sigmoidZeroOne(this.animation/36f)*36);
- if(animation < 3) {
+ int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36);
+ if (animation < 3) {
buttonLoc = GuiTextures.OFF;
- } else if(animation < 13) {
+ } else if (animation < 13) {
buttonLoc = GuiTextures.ONE;
- } else if(animation < 23) {
+ } else if (animation < 23) {
buttonLoc = GuiTextures.TWO;
- } else if(animation < 33) {
+ } else if (animation < 33) {
buttonLoc = GuiTextures.THREE;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc);
- RenderUtils.drawTexturedRect(x+animation, y, 12, 14);
+ RenderUtils.drawTexturedRect(x + animation, y, 12, 14);
}
@Override
public boolean mouseInput(int mouseX, int mouseY) {
- if(mouseX > x-clickRadius && mouseX < x+xSize+clickRadius &&
- mouseY > y-clickRadius && mouseY < y+ySize+clickRadius) {
- if(Mouse.getEventButton() == 0) {
- if(Mouse.getEventButtonState()) {
+ if (mouseX > x - clickRadius && mouseX < x + xSize + clickRadius && mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) {
+ if (Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState()) {
previewValue = !value;
- } else if(previewValue == !value) {
+ } else if (previewValue == !value) {
value = !value;
toggleCallback.accept(value);
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
index e2d3e0a..27a1d84 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
@@ -45,17 +45,15 @@ public class GuiElementColour extends GuiElement {
private final boolean opacitySlider;
private final boolean valueSlider;
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback,
- Runnable closeCallback) {
+ public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback) {
this(x, y, initialColour, colourChangedCallback, closeCallback, true, true);
}
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback,
- Runnable closeCallback, boolean opacitySlider, boolean valueSlider) {
+ public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback, boolean opacitySlider, boolean valueSlider) {
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight()-ySize-10, y));
- this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth()-xSize-10, x));
+ this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y));
+ this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x));
this.colour = initialColour;
this.colourChangedCallback = colourChangedCallback;
@@ -69,13 +67,13 @@ public class GuiElementColour extends GuiElement {
this.opacitySlider = opacitySlider;
this.valueSlider = valueSlider;
- if(!valueSlider) xSize -= 15;
- if(!opacitySlider) xSize -= 15;
+ if (!valueSlider) xSize -= 15;
+ if (!opacitySlider) xSize -= 15;
}
public void updateAngleAndRadius(float[] hsv) {
this.wheelRadius = hsv[1];
- this.wheelAngle = hsv[0]*360;
+ this.wheelAngle = hsv[0] * 360;
}
public void render() {
@@ -87,79 +85,76 @@ public class GuiElementColour extends GuiElement {
BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB);
float borderRadius = 0.05f;
- if(Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
- for(int x=-16; x<272; x++) {
- for(int y=-16; y<272; y++) {
- float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f);
- float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2);
- if(y < 128) angle += 180;
- if(radius <= 1) {
- int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB();
- bufferedImage.setRGB(x+16, y+16, rgb);
- } else if(radius <= 1+borderRadius) {
- float invBlackAlpha = Math.abs(radius-1-borderRadius/2)/borderRadius*2;
- float blackAlpha = 1-invBlackAlpha;
-
- if(radius > 1+borderRadius/2) {
- bufferedImage.setRGB(x+16, y+16, (int)(blackAlpha*255) << 24);
+ if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
+ for (int x = -16; x < 272; x++) {
+ for (int y = -16; y < 272; y++) {
+ float radius = (float) Math.sqrt(((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f);
+ float angle = (float) Math.toDegrees(Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2);
+ if (y < 128) angle += 180;
+ if (radius <= 1) {
+ int rgb = Color.getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]).getRGB();
+ bufferedImage.setRGB(x + 16, y + 16, rgb);
+ } else if (radius <= 1 + borderRadius) {
+ float invBlackAlpha = Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2;
+ float blackAlpha = 1 - invBlackAlpha;
+
+ if (radius > 1 + borderRadius / 2) {
+ bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24);
} else {
- Color col = Color.getHSBColor(angle/360f, 1, hsv[2]);
- int rgb = (int)(col.getRed()*invBlackAlpha) << 16 |
- (int)(col.getGreen()*invBlackAlpha) << 8 |
- (int)(col.getBlue()*invBlackAlpha);
- bufferedImage.setRGB(x+16, y+16, 0xff000000 | rgb);
+ Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]);
+ int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | (int) (col.getGreen() * invBlackAlpha) << 8 | (int) (col.getBlue() * invBlackAlpha);
+ bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb);
}
-
}
}
}
BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
- int rgb = Color.getHSBColor(wheelAngle/360, wheelRadius, (64-y)/64f).getRGB();
+ int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f).getRGB();
bufferedImageValue.setRGB(x, y, rgb);
}
}
BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
- int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64-y)*4) << 24);
+ int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64 - y) * 4) << 24);
bufferedImageOpacity.setRGB(x, y, rgb);
}
}
- float selradius = (float)Math.pow(wheelRadius, 1/1.5f)*32;
- int selx = (int)(Math.cos(Math.toRadians(wheelAngle))*selradius);
- int sely = (int)(Math.sin(Math.toRadians(wheelAngle))*selradius);
+ float selradius = (float) Math.pow(wheelRadius, 1 / 1.5f) * 32;
+ int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius);
+ int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius);
int valueOffset = 0;
- if(valueSlider) {
+ if (valueSlider) {
valueOffset = 15;
Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue));
Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
}
int opacityOffset = 0;
- if(opacitySlider) {
+ if (opacitySlider) {
opacityOffset = 15;
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
-
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
+
Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity));
Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
}
int chromaSpeed = ChromaColour.getSpeed(colour);
@@ -167,139 +162,120 @@ public class GuiElementColour extends GuiElement {
Color cChroma = new Color(currentColourChroma, true);
float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
- if(chromaSpeed > 0) {
- Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+1,
- x+5+64+valueOffset+opacityOffset+5+10-1, y+5+64-1,
- Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f));
+ if (chromaSpeed > 0) {
+ Gui.drawRect(x + 5 + 64 + valueOffset + opacityOffset + 5 + 1, y + 5 + 1, x + 5 + 64 + valueOffset + opacityOffset + 5 + 10 - 1, y + 5 + 64 - 1, Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f));
} else {
- Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+27+1,
- x+5+64+valueOffset+opacityOffset+5+10-1, y+5+37-1,
- Color.HSBtoRGB((hsvChroma[0]+(System.currentTimeMillis()-ChromaColour.startTime)/1000f)%1, 0.8f, 0.8f));
+ Gui.drawRect(x + 5 + 64 + valueOffset + opacityOffset + 5 + 1, y + 5 + 27 + 1, x + 5 + 64 + valueOffset + opacityOffset + 5 + 10 - 1, y + 5 + 37 - 1, Color.HSBtoRGB((hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f));
}
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar);
GlStateManager.color(1, 1, 1, 1);
- if(valueSlider) RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST);
- if(opacitySlider) RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
+ if (valueSlider) RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
+ if (opacitySlider) RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
- if(chromaSpeed > 0) {
- RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5, 10, 64, GL11.GL_NEAREST);
+ if (chromaSpeed > 0) {
+ RenderUtils.drawTexturedRect(x + 5 + 64 + valueOffset + opacityOffset + 5, y + 5, 10, 64, GL11.GL_NEAREST);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma);
- RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5+27, 10, 10, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + valueOffset + opacityOffset + 5, y + 5 + 27, 10, 10, GL11.GL_NEAREST);
}
- if(valueSlider) Gui.drawRect(x+5+64+5, y+5+64-(int)(64*hsv[2]),
- x+5+64+valueOffset, y+5+64-(int)(64*hsv[2])+1, 0xFF000000);
- if(opacitySlider) Gui.drawRect(x+5+64+5+valueOffset, y+5+64-c.getAlpha()/4,
- x+5+64+valueOffset+opacityOffset, y+5+64-c.getAlpha()/4-1, 0xFF000000);
- if(chromaSpeed > 0) {
- Gui.drawRect(x+5+64+valueOffset+opacityOffset+5,
- y+5+64-(int)(chromaSpeed/255f*64),
- x+5+64+valueOffset+opacityOffset+5+10,
- y+5+64-(int)(chromaSpeed/255f*64)+1, 0xFF000000);
+ if (valueSlider) Gui.drawRect(x + 5 + 64 + 5, y + 5 + 64 - (int) (64 * hsv[2]), x + 5 + 64 + valueOffset, y + 5 + 64 - (int) (64 * hsv[2]) + 1, 0xFF000000);
+ if (opacitySlider) Gui.drawRect(x + 5 + 64 + 5 + valueOffset, y + 5 + 64 - c.getAlpha() / 4, x + 5 + 64 + valueOffset + opacityOffset, y + 5 + 64 - c.getAlpha() / 4 - 1, 0xFF000000);
+ if (chromaSpeed > 0) {
+ Gui.drawRect(x + 5 + 64 + valueOffset + opacityOffset + 5, y + 5 + 64 - (int) (chromaSpeed / 255f * 64), x + 5 + 64 + valueOffset + opacityOffset + 5 + 10, y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, 0xFF000000);
}
Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage));
Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+1, y+1, 72, 72, GL11.GL_LINEAR);
+ RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR);
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+32+selx-4, y+5+32+sely-4, 8, 8, GL11.GL_NEAREST);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(hsv[2]*100)+"",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+5-(Math.round(hsv[2]*100)==100?1:0), y+5+64+5+5, true, 13, -1);
- if(opacitySlider) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+valueOffset+5, y+5+64+5+5, true, 13, -1);
+ RenderUtils.drawTexturedRect(x + 5 + 32 + selx - 4, y + 5 + 32 + sely - 4, 8, 8, GL11.GL_NEAREST);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), y + 5 + 64 + 5 + 5, true, 13, -1);
+ if (opacitySlider) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + valueOffset + 5, y + 5 + 64 + 5 + 5, true, 13, -1);
}
- if(chromaSpeed > 0) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+
- (int)ChromaColour.getSecondsForSpeed(chromaSpeed)+"s",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+valueOffset+opacityOffset+6, y+5+64+5+5, true, 13, -1);
+ if (chromaSpeed > 0) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + valueOffset + opacityOffset + 6, y + 5 + 64 + 5 + 5, true, 13, -1);
}
hexField.setSize(48, 10);
- if(!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase());
+ if (!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase());
- StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY+"#");
- for(int i=0; i<6-hexField.getText().length(); i++) {
+ StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY + "#");
+ for (int i = 0; i < 6 - hexField.getText().length(); i++) {
sb.append("0");
}
sb.append(EnumChatFormatting.WHITE);
hexField.setPrependText(sb.toString());
- hexField.render(x+5+8, y+5+64+5);
+ hexField.render(x + 5 + 8, y + 5 + 64 + 5);
}
public boolean mouseInput(int mouseX, int mouseY) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- float mouseXF = (float)(Mouse.getX() * scaledResolution.getScaledWidth_double() /
- Minecraft.getMinecraft().displayWidth);
- float mouseYF = (float)(scaledResolution.getScaledHeight_double() - Mouse.getY() *
- scaledResolution.getScaledHeight_double() / Minecraft.getMinecraft().displayHeight - 1);
-
- if((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) {
- if(mouseX > x+5+8 && mouseX < x+5+8+48) {
- if(mouseY > y+5+64+5 && mouseY < y+5+64+5+10) {
+ float mouseXF = (float) (Mouse.getX() * scaledResolution.getScaledWidth_double() / Minecraft.getMinecraft().displayWidth);
+ float mouseYF = (float) (scaledResolution.getScaledHeight_double() - Mouse.getY() * scaledResolution.getScaledHeight_double() / Minecraft.getMinecraft().displayHeight - 1);
+
+ if ((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) {
+ if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) {
+ if (mouseY > y + 5 + 64 + 5 && mouseY < y + 5 + 64 + 5 + 10) {
hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
clickedComponent = -1;
return true;
}
}
}
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
clickedComponent = -1;
}
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(mouseX >= x && mouseX <= x+119 &&
- mouseY >= y && mouseY <= y+89) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (mouseX >= x && mouseX <= x + 119 && mouseY >= y && mouseY <= y + 89) {
hexField.unfocus();
int xWheel = mouseX - x - 5;
int yWheel = mouseY - y - 5;
- if(xWheel > 0 && xWheel < 64) {
- if(yWheel > 0 && yWheel < 64) {
+ if (xWheel > 0 && xWheel < 64) {
+ if (yWheel > 0 && yWheel < 64) {
clickedComponent = 0;
}
}
- int xValue = mouseX - (x+5+64+5);
+ int xValue = mouseX - (x + 5 + 64 + 5);
int y = mouseY - this.y - 5;
int opacityOffset = opacitySlider ? 15 : 0;
int valueOffset = valueSlider ? 15 : 0;
- if(y > -5 && y <= 69) {
- if(valueSlider) {
- if(xValue > 0 && xValue < 10) {
+ if (y > -5 && y <= 69) {
+ if (valueSlider) {
+ if (xValue > 0 && xValue < 10) {
clickedComponent = 1;
}
}
- if(opacitySlider) {
- int xOpacity = mouseX - (x+5+64+5+valueOffset);
+ if (opacitySlider) {
+ int xOpacity = mouseX - (x + 5 + 64 + 5 + valueOffset);
- if(xOpacity > 0 && xOpacity < 10) {
+ if (xOpacity > 0 && xOpacity < 10) {
clickedComponent = 2;
}
}
}
int chromaSpeed = ChromaColour.getSpeed(colour);
- int xChroma = mouseX - (x+5+64+valueOffset+opacityOffset+5);
- if(xChroma > 0 && xChroma < 10) {
- if(chromaSpeed > 0) {
- if(y > -5 && y <= 69) {
+ int xChroma = mouseX - (x + 5 + 64 + valueOffset + opacityOffset + 5);
+ if (xChroma > 0 && xChroma < 10) {
+ if (chromaSpeed > 0) {
+ if (y > -5 && y <= 69) {
clickedComponent = 3;
}
- } else if(mouseY > this.y+5+27 && mouseY < this.y+5+37) {
+ } else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) {
int currentColour = ChromaColour.specialToSimpleRGB(colour);
Color c = new Color(currentColour, true);
colour = ChromaColour.special(200, c.getAlpha(), currentColour);
@@ -312,7 +288,7 @@ public class GuiElementColour extends GuiElement {
return false;
}
}
- if(Mouse.isButtonDown(0) && clickedComponent >= 0) {
+ if (Mouse.isButtonDown(0) && clickedComponent >= 0) {
int currentColour = ChromaColour.specialToSimpleRGB(colour);
Color c = new Color(currentColour, true);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
@@ -320,16 +296,16 @@ public class GuiElementColour extends GuiElement {
float xWheel = mouseXF - x - 5;
float yWheel = mouseYF - y - 5;
- if(clickedComponent == 0) {
- float angle = (float) Math.toDegrees(Math.atan((32-xWheel)/(yWheel-32+1E-5))+Math.PI/2);
+ if (clickedComponent == 0) {
+ float angle = (float) Math.toDegrees(Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + Math.PI / 2);
xWheel = Math.max(0, Math.min(64, xWheel));
yWheel = Math.max(0, Math.min(64, yWheel));
- float radius = (float) Math.sqrt(((xWheel-32)*(xWheel-32)+(yWheel-32)*(yWheel-32))/1024f);
- if(yWheel < 32) angle += 180;
+ float radius = (float) Math.sqrt(((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / 1024f);
+ if (yWheel < 32) angle += 180;
this.wheelAngle = angle;
- this.wheelRadius = (float)Math.pow(Math.min(1, radius), 1.5f);
- int rgb = Color.getHSBColor(angle/360f, wheelRadius, hsv[2]).getRGB();
+ this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f);
+ int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB();
colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
colourChangedCallback.accept(colour);
return true;
@@ -339,22 +315,21 @@ public class GuiElementColour extends GuiElement {
y = Math.max(0, Math.min(64, y));
System.out.println(y);
- if(clickedComponent == 1) {
- int rgb = Color.getHSBColor(wheelAngle/360, wheelRadius, 1-y/64f).getRGB();
+ if (clickedComponent == 1) {
+ int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f).getRGB();
colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
colourChangedCallback.accept(colour);
return true;
}
- if(clickedComponent == 2) {
- colour = ChromaColour.special(ChromaColour.getSpeed(colour),
- 255-Math.round(y/64f*255), currentColour);
+ if (clickedComponent == 2) {
+ colour = ChromaColour.special(ChromaColour.getSpeed(colour), 255 - Math.round(y / 64f * 255), currentColour);
colourChangedCallback.accept(colour);
return true;
}
- if(clickedComponent == 3) {
- colour = ChromaColour.special(255-Math.round(y/64f*255), c.getAlpha(), currentColour);
+ if (clickedComponent == 3) {
+ colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour);
colourChangedCallback.accept(colour);
}
return true;
@@ -363,7 +338,7 @@ public class GuiElementColour extends GuiElement {
}
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && hexField.getFocus()) {
+ if (Keyboard.getEventKeyState() && hexField.getFocus()) {
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
hexField.unfocus();
return true;
@@ -372,7 +347,7 @@ public class GuiElementColour extends GuiElement {
hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(hexField.getText().length() > 6) {
+ if (hexField.getText().length() > 6) {
hexField.setText(old);
} else {
try {
@@ -386,13 +361,11 @@ public class GuiElementColour extends GuiElement {
Color c = new Color(rgb);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
updateAngleAndRadius(hsv);
- } catch(Exception e) {};
+ } catch (Exception e) {}
}
return true;
}
return false;
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java
index b16f672..bbb29ee 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java
@@ -37,8 +37,7 @@ public class GuiElementTextField {
private String prependText = "";
private int customTextColour = 0xffffffff;
- private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
- 0 , 0, 0, 0);
+ private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, 0, 0, 0, 0);
private int customBorderColour = -1;
@@ -74,11 +73,11 @@ public class GuiElementTextField {
public String getTextDisplay() {
String textNoColour = getText();
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find()) break;
+ if (!matcher.find()) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
return textNoColour;
@@ -89,13 +88,13 @@ public class GuiElementTextField {
}
public void setText(String text) {
- if(textField.getText() == null || !textField.getText().equals(text)) {
+ if (textField.getText() == null || !textField.getText().equals(text)) {
textField.setText(text);
}
}
public void setSize(int searchBarXSize, int searchBarYSize) {
- this.searchBarXSize = searchBarXSize;
+ this.searchBarXSize = searchBarXSize;
this.searchBarYSize = searchBarYSize;
}
@@ -110,34 +109,35 @@ public class GuiElementTextField {
public void setFocus(boolean focus) {
this.focus = focus;
- if(!focus) {
+ if (!focus) {
textField.setCursorPosition(textField.getCursorPosition());
}
}
+
public boolean getFocus() {
return focus;
}
public int getHeight() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
- int numLines = org.apache.commons.lang3.StringUtils.countMatches(textField.getText(), "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = searchBarYSize + extraSize*(numLines-1);
+ int numLines = org.apache.commons.lang3.StringUtils.countMatches(textField.getText(), "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = searchBarYSize + extraSize * (numLines - 1);
- return bottomTextBox + paddingUnscaled*2;
+ return bottomTextBox + paddingUnscaled * 2;
}
public int getWidth() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
- return searchBarXSize + paddingUnscaled*2;
+ return searchBarXSize + paddingUnscaled * 2;
}
private float getScaleFactor(String str) {
- return Math.min(1, (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
+ return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
}
private boolean isScaling() {
@@ -150,60 +150,60 @@ public class GuiElementTextField {
int xComp = mouseX - x;
int yComp = mouseY - y;
- int extraSize = (searchBarYSize-8)/2+8;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
String renderText = prependText + textField.getText();
- int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
+ int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize);
String text = renderText;
String textNoColour = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
}
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
int currentLine = 0;
int cursorIndex = 0;
- for(; cursorIndex<textNoColour.length(); cursorIndex++) {
- if(currentLine == lineNum) break;
- if(textNoColour.charAt(cursorIndex) == '\n') {
+ for (; cursorIndex < textNoColour.length(); cursorIndex++) {
+ if (currentLine == lineNum) break;
+ if (textNoColour.charAt(cursorIndex) == '\n') {
currentLine++;
}
}
String textNC = textNoColour.substring(0, cursorIndex);
int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNC, "\u00B6");
- String line = text.substring(cursorIndex+(((options & COLOUR) != 0)?colorCodes*2:0)).split("\n")[0];
- int padding = Math.min(5, searchBarXSize-strLenNoColor(line))/2;
- String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp-padding);
+ String line = text.substring(cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)).split("\n")[0];
+ int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2;
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp - padding);
int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(line)) {
+ if (linePos != strLenNoColor(line)) {
char after = line.charAt(linePos);
int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < xComp-padding) {
+ if (trimmedWidth + charWidth / 2 < xComp - padding) {
linePos++;
}
}
cursorIndex += linePos;
int pre = StringUtils.cleanColour(prependText).length();
- if(cursorIndex < pre) {
+ if (cursorIndex < pre) {
cursorIndex = 0;
} else {
cursorIndex -= pre;
@@ -213,7 +213,7 @@ public class GuiElementTextField {
}
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 1) {
+ if (mouseButton == 1) {
textField.setText("");
} else {
textField.setCursorPosition(getCursorPos(mouseX, mouseY));
@@ -231,46 +231,46 @@ public class GuiElementTextField {
}
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(focus) {
+ if (focus) {
textField.setSelectionPos(getCursorPos(mouseX, mouseY));
}
}
public void keyTyped(char typedChar, int keyCode) {
- if(focus) {
- if((options & MULTILINE) != 0) { //Carriage return
+ if (focus) {
+ if ((options & MULTILINE) != 0) { //Carriage return
Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n]|$)(?!\\u00B6)");
String text = textField.getText();
String textNoColour = textField.getText();
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
- if(keyCode == 28) {
+ if (keyCode == 28) {
String before = textField.getText().substring(0, textField.getCursorPosition());
String after = textField.getText().substring(textField.getCursorPosition());
int pos = textField.getCursorPosition();
textField.setText(before + "\n" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
return;
- } else if(keyCode == 200) { //Up
+ } else if (keyCode == 200) { //Up
String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
@@ -278,74 +278,70 @@ public class GuiElementTextField {
int textBeforeCursorWidth;
String lineBefore;
String thisLineBeforeCursor;
- if(split.length == numLinesBeforeCursor && split.length > 0) {
+ if (split.length == numLinesBeforeCursor && split.length > 0) {
textBeforeCursorWidth = 0;
- lineBefore = split[split.length-1];
+ lineBefore = split[split.length - 1];
thisLineBeforeCursor = "";
- } else if(split.length > 1) {
- thisLineBeforeCursor = split[split.length-1];
- lineBefore = split[split.length-2];
+ } else if (split.length > 1) {
+ thisLineBeforeCursor = split[split.length - 1];
+ lineBefore = split[split.length - 2];
textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
} else {
return;
}
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineBefore, textBeforeCursorWidth);
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(lineBefore, textBeforeCursorWidth);
int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineBefore)) {
+ if (linePos != strLenNoColor(lineBefore)) {
char after = lineBefore.charAt(linePos);
int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- -strLenNoColor(lineBefore)-1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) - strLenNoColor(lineBefore) - 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
}
- } else if(keyCode == 208) { //Down
+ } else if (keyCode == 208) { //Down
String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
String[] split = textBeforeCursor.split("\n");
String thisLineBeforeCursor;
int textBeforeCursorWidth;
- if(split.length == numLinesBeforeCursor) {
+ if (split.length == numLinesBeforeCursor) {
thisLineBeforeCursor = "";
textBeforeCursorWidth = 0;
- } else if(split.length > 0) {
- thisLineBeforeCursor = split[split.length-1];
+ } else if (split.length > 0) {
+ thisLineBeforeCursor = split[split.length - 1];
textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
} else {
return;
}
String[] split2 = textNoColour.split("\n");
- if(split2.length > numLinesBeforeCursor+1) {
- String lineAfter = split2[numLinesBeforeCursor+1];
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineAfter, textBeforeCursorWidth);
+ if (split2.length > numLinesBeforeCursor + 1) {
+ String lineAfter = split2[numLinesBeforeCursor + 1];
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(lineAfter, textBeforeCursorWidth);
int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineAfter)) {
+ if (linePos != strLenNoColor(lineAfter)) {
char after = lineAfter.charAt(linePos);
int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- +strLenNoColor(split2[numLinesBeforeCursor])+1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
@@ -355,47 +351,47 @@ public class GuiElementTextField {
}
String old = textField.getText();
- if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
- if((options & NO_SPACE) != 0 && typedChar == ' ') return;
+ if ((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
+ if ((options & NO_SPACE) != 0 && typedChar == ' ') return;
- if(typedChar == '\u00B6') {
+ if (typedChar == '\u00B6') {
typedChar = '\u00A7';
}
textField.setFocused(true);
textField.textboxKeyTyped(typedChar, keyCode);
- if((options & COLOUR) != 0) {
- if(typedChar == '&') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '&') {
+ if ((options & COLOUR) != 0) {
+ if (typedChar == '&') {
+ int pos = textField.getCursorPosition() - 2;
+ if (pos >= 0 && pos < textField.getText().length()) {
+ if (textField.getText().charAt(pos) == '&') {
String before = textField.getText().substring(0, pos);
String after = "";
- if(pos+2 < textField.getText().length()) {
- after = textField.getText().substring(pos+2);
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
}
textField.setText(before + "\u00A7" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
}
}
- } else if(typedChar == '*') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '*') {
+ } else if (typedChar == '*') {
+ int pos = textField.getCursorPosition() - 2;
+ if (pos >= 0 && pos < textField.getText().length()) {
+ if (textField.getText().charAt(pos) == '*') {
String before = textField.getText().substring(0, pos);
String after = "";
- if(pos+2 < textField.getText().length()) {
- after = textField.getText().substring(pos+2);
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
}
textField.setText(before + "\u272A" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
}
}
}
}
- if((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
+ if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
}
}
@@ -405,8 +401,7 @@ public class GuiElementTextField {
drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus);
}
- private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding,
- GuiTextField textField, boolean focus) {
+ private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding, GuiTextField textField, boolean focus) {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
String renderText = prependText + textField.getText();
@@ -415,140 +410,120 @@ public class GuiElementTextField {
/**
* Search bar
*/
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+ if (paddingUnscaled < 1) paddingUnscaled = 1;
- int numLines = org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = y + searchBarYSize + extraSize*(numLines-1);
+ int numLines = org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1);
int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB();
- if(customBorderColour != -1) {
+ if (customBorderColour != -1) {
borderColour = customBorderColour;
}
- if((options & DISABLE_BG) == 0) {
+ if ((options & DISABLE_BG) == 0) {
//bar background
- Gui.drawRect(x - paddingUnscaled,
- y - paddingUnscaled,
- x + searchBarXSize + paddingUnscaled,
- bottomTextBox + paddingUnscaled, borderColour);
- Gui.drawRect(x,
- y,
- x + searchBarXSize,
- bottomTextBox, Color.BLACK.getRGB());
+ Gui.drawRect(x - paddingUnscaled, y - paddingUnscaled, x + searchBarXSize + paddingUnscaled, bottomTextBox + paddingUnscaled, borderColour);
+ Gui.drawRect(x, y, x + searchBarXSize, bottomTextBox, Color.BLACK.getRGB());
}
//bar text
String text = renderText;
String textNoColor = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
}
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColor);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColor = matcher.replaceFirst("\u00B6"+code);
+ textNoColor = matcher.replaceFirst("\u00B6" + code);
}
int xStartOffset = 5;
float scale = 1;
String[] texts = text.split("\n");
- for(int yOffI = 0; yOffI < texts.length; yOffI++) {
- int yOff = yOffI*extraSize;
-
- if(isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])>searchBarXSize-10) {
- scale = (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
- if(scale > 1) scale=1;
- float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])*scale;
- xStartOffset = (int)((searchBarXSize-newLen)/2f);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x+searchBarXSize/2f,
- y+searchBarYSize/2f+yOff, false,
- searchBarXSize-2, customTextColour);
+ for (int yOffI = 0; yOffI < texts.length; yOffI++) {
+ int yOff = yOffI * extraSize;
+
+ if (isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10) {
+ scale = (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
+ if (scale > 1) scale = 1;
+ float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale;
+ xStartOffset = (int) ((searchBarXSize - newLen) / 2f);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x + searchBarXSize / 2f, y + searchBarYSize / 2f + yOff, false, searchBarXSize - 2, customTextColour);
} else {
- if((options & SCISSOR_TEXT) != 0) {
- GlScissorStack.push(x+5, 0, x+searchBarXSize, scaledresolution.getScaledHeight(), scaledresolution);
- Minecraft.getMinecraft().fontRendererObj.drawString(texts[yOffI], x + 5,
- y+(searchBarYSize-8)/2+yOff, customTextColour);
+ if ((options & SCISSOR_TEXT) != 0) {
+ GlScissorStack.push(x + 5, 0, x + searchBarXSize, scaledresolution.getScaledHeight(), scaledresolution);
+ Minecraft.getMinecraft().fontRendererObj.drawString(texts[yOffI], x + 5, y + (searchBarYSize - 8) / 2 + yOff, customTextColour);
GlScissorStack.pop(scaledresolution);
} else {
- String toRender = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(texts[yOffI], searchBarXSize-10);
- Minecraft.getMinecraft().fontRendererObj.drawString(toRender, x + 5,
- y+(searchBarYSize-8)/2+yOff, customTextColour);
+ String toRender = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(texts[yOffI], searchBarXSize - 10);
+ Minecraft.getMinecraft().fontRendererObj.drawString(toRender, x + 5, y + (searchBarYSize - 8) / 2 + yOff, customTextColour);
}
-
}
}
- if(focus && System.currentTimeMillis()%1000>500) {
- String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()+prependText.length());
+ if (focus && System.currentTimeMillis() % 1000 > 500) {
+ String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition() + prependText.length());
int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getCursorPosition()+prependText.length()+(((options & COLOUR) != 0) ? colorCodes*2 : 0));
+ String textBeforeCursor = text.substring(0, textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0));
int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
- int yOff = numLinesBeforeCursor*extraSize;
+ int yOff = numLinesBeforeCursor * extraSize;
String[] split = textBeforeCursor.split("\n");
int textBeforeCursorWidth;
- if(split.length <= numLinesBeforeCursor || split.length == 0) {
+ if (split.length <= numLinesBeforeCursor || split.length == 0) {
textBeforeCursorWidth = 0;
} else {
- textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
+ textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]) * scale);
}
- Gui.drawRect(x + xStartOffset + textBeforeCursorWidth,
- y+(searchBarYSize-8)/2-1 + yOff,
- x + xStartOffset + textBeforeCursorWidth+1,
- y+(searchBarYSize-8)/2+9 + yOff, Color.WHITE.getRGB());
+ Gui.drawRect(x + xStartOffset + textBeforeCursorWidth, y + (searchBarYSize - 8) / 2 - 1 + yOff, x + xStartOffset + textBeforeCursorWidth + 1, y + (searchBarYSize - 8) / 2 + 9 + yOff, Color.WHITE.getRGB());
}
String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
- int leftIndex = Math.min(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
- int rightIndex = Math.max(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
+ if (!selectedText.isEmpty()) {
+ int leftIndex = Math.min(textField.getCursorPosition() + prependText.length(), textField.getSelectionEnd() + prependText.length());
+ int rightIndex = Math.max(textField.getCursorPosition() + prependText.length(), textField.getSelectionEnd() + prependText.length());
float texX = 0;
int texY = 0;
boolean sectionSignPrev = false;
boolean ignoreNext = false;
boolean bold = false;
- for(int i=0; i<textNoColor.length(); i++) {
- if(ignoreNext) {
+ for (int i = 0; i < textNoColor.length(); i++) {
+ if (ignoreNext) {
ignoreNext = false;
continue;
}
char c = textNoColor.charAt(i);
- if(sectionSignPrev) {
- if(c != 'k' && c != 'K'
- && c != 'm' && c != 'M'
- && c != 'n' && c != 'N'
- && c != 'o' && c != 'O') {
+ if (sectionSignPrev) {
+ if (c != 'k' && c != 'K' && c != 'm' && c != 'M' && c != 'n' && c != 'N' && c != 'o' && c != 'O') {
bold = c == 'l' || c == 'L';
}
sectionSignPrev = false;
- if(i < prependText.length()) continue;
+ if (i < prependText.length()) continue;
}
- if(c == '\u00B6') {
+ if (c == '\u00B6') {
sectionSignPrev = true;
- if(i < prependText.length()) continue;
+ if (i < prependText.length()) continue;
}
- if(c == '\n') {
- if(i >= leftIndex && i < rightIndex) {
- Gui.drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)texX + 3,
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
+ if (c == '\n') {
+ if (i >= leftIndex && i < rightIndex) {
+ Gui.drawRect(x + xStartOffset + (int) texX, y + (searchBarYSize - 8) / 2 - 1 + texY, x + xStartOffset + (int) texX + 3, y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB());
}
texX = 0;
@@ -557,24 +532,17 @@ public class GuiElementTextField {
}
int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
- if(bold) len++;
- if(i >= leftIndex && i < rightIndex) {
- Gui.drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)(texX + len*scale),
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
-
- TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
- if(bold) {
- TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX + 1,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
+ if (bold) len++;
+ if (i >= leftIndex && i < rightIndex) {
+ Gui.drawRect(x + xStartOffset + (int) texX, y + (searchBarYSize - 8) / 2 - 1 + texY, x + xStartOffset + (int) (texX + len * scale), y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB());
+
+ TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, x + xStartOffset + texX, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale);
+ if (bold) {
+ TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, x + xStartOffset + texX + 1, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale);
}
}
- texX += len*scale;
+ texX += len * scale;
}
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java
index 40f8c0e..dbbca74 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java
@@ -2,7 +2,5 @@ package com.thatgravyboat.skyblockhud.core.config;
public class Config {
- public void executeRunnable(String runnableId) {
- }
-
+ public void executeRunnable(String runnableId) {}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java
index dfd16be..7470b6c 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java
@@ -6,17 +6,17 @@ import org.lwjgl.input.Mouse;
public class KeybindHelper {
public static String getKeyName(int keyCode) {
- if(keyCode == 0) {
+ if (keyCode == 0) {
return "NONE";
- } else if(keyCode < 0) {
- return "Button "+(keyCode+101);
+ } else if (keyCode < 0) {
+ return "Button " + (keyCode + 101);
} else {
String keyName = Keyboard.getKeyName(keyCode);
- if(keyName == null) {
+ if (keyName == null) {
keyName = "???";
- } else if(keyName.equalsIgnoreCase("LMENU")) {
+ } else if (keyName.equalsIgnoreCase("LMENU")) {
keyName = "LALT";
- } else if(keyName.equalsIgnoreCase("RMENU")) {
+ } else if (keyName.equalsIgnoreCase("RMENU")) {
keyName = "RALT";
}
return keyName;
@@ -28,23 +28,22 @@ public class KeybindHelper {
}
public static boolean isKeyDown(int keyCode) {
- if(!isKeyValid(keyCode)) {
+ if (!isKeyValid(keyCode)) {
return false;
- } else if(keyCode < 0) {
- return Mouse.isButtonDown(keyCode+100);
+ } else if (keyCode < 0) {
+ return Mouse.isButtonDown(keyCode + 100);
} else {
return Keyboard.isKeyDown(keyCode);
}
}
public static boolean isKeyPressed(int keyCode) {
- if(!isKeyValid(keyCode)) {
+ if (!isKeyValid(keyCode)) {
return false;
- } else if(keyCode < 0) {
- return Mouse.getEventButtonState() && Mouse.getEventButton() == keyCode+100;
+ } else if (keyCode < 0) {
+ return Mouse.getEventButtonState() && Mouse.getEventButton() == keyCode + 100;
} else {
return Keyboard.getEventKeyState() && Keyboard.getEventKey() == keyCode;
}
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java
index 48c12cb..e8e55f1 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java
@@ -8,7 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorKeybind {
-
int defaultKey();
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java
index 9c7e468..927bebf 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java
@@ -21,28 +21,27 @@ public abstract class GuiOptionEditor {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
RenderUtils.drawFloatingRectDark(x, y, width, height, true);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name,
- fr, x+width/6, y+13, true, width/3-10, 0xc0c0c0);
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name, fr, x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0);
int maxLines = 5;
float scale = 1;
- int lineCount = fr.listFormattedStringToWidth(option.desc, width*2/3-10).size();
+ int lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size();
- if(lineCount <= 0) return;
+ if (lineCount <= 0) return;
float paraHeight = 9 * lineCount - 1;
- while(paraHeight >= HEIGHT-10) {
- scale -= 1/8f;
- lineCount = fr.listFormattedStringToWidth(option.desc, (int)(width*2/3/scale-10)).size();
- paraHeight = (int)(9*scale * lineCount - 1*scale);
+ while (paraHeight >= HEIGHT - 10) {
+ scale -= 1 / 8f;
+ lineCount = fr.listFormattedStringToWidth(option.desc, (int) (width * 2 / 3 / scale - 10)).size();
+ paraHeight = (int) (9 * scale * lineCount - 1 * scale);
}
GlStateManager.pushMatrix();
- GlStateManager.translate(x+5+width/3f, y+HEIGHT/2f-paraHeight/2, 0);
+ GlStateManager.translate(x + 5 + width / 3f, y + HEIGHT / 2f - paraHeight / 2, 0);
GlStateManager.scale(scale, scale, 1);
- fr.drawSplitString(option.desc, 0, 0, (int)(width*2/3/scale-10), 0xc0c0c0);
+ fr.drawSplitString(option.desc, 0, 0, (int) (width * 2 / 3 / scale - 10), 0xc0c0c0);
GlStateManager.popMatrix();
}
@@ -52,11 +51,12 @@ public abstract class GuiOptionEditor {
}
public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY);
+
public abstract boolean keyboardInput();
public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
return false;
}
- public void renderOverlay(int x, int y, int width) {};
+ public void renderOverlay(int x, int y, int width) {}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java
index c2b129d..dad85a6 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java
@@ -47,27 +47,25 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor {
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(1, 1, 1, 1);
worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
- if(accordionToggled) {
- worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex();
- worldrenderer.pos((double)x+9.75f, (double)y+13.5f, 0.0D).endVertex();
- worldrenderer.pos((double)x+13.5f, (double)y+6, 0.0D).endVertex();
+ if (accordionToggled) {
+ worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex();
} else {
- worldrenderer.pos((double)x+6, (double)y+13.5f, 0.0D).endVertex();
- worldrenderer.pos((double)x+13.5f, (double)y+9.75f, 0.0D).endVertex();
- worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 13.5f, (double) y + 9.75f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex();
}
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
- TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj,
- x+18, y+6, false, width-10, 0xc0c0c0);
+ TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj, x + 18, y + 6, false, width - 10, 0xc0c0c0);
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState() && mouseX > x && mouseX < x+ width &&
- mouseY > y && mouseY < y+getHeight()) {
+ if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + getHeight()) {
accordionToggled = !accordionToggled;
return true;
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java
index 3ea70c0..4167e06 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java
@@ -9,8 +9,7 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor {
public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) {
super(option);
-
- bool = new GuiElementBoolean(0, 0, (boolean)option.get(), 10, option::set);
+ bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, option::set);
}
@Override
@@ -18,16 +17,16 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- bool.x = x+width/6-24;
- bool.y = y+height-7-14;
+ bool.x = x + width / 6 - 24;
+ bool.y = y + height - 7 - 14;
bool.render();
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- bool.x = x+width/6-24;
- bool.y = y+height-7-14;
+ bool.x = x + width / 6 - 24;
+ bool.y = y + height - 7 - 14;
return bool.mouseInput(mouseX, mouseY);
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java
index cbd450f..9cc76c2 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java
@@ -1,5 +1,7 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
+import static com.thatgravyboat.skyblockhud.GuiTextures.button_tex;
+
import com.thatgravyboat.skyblockhud.core.config.Config;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
@@ -8,8 +10,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
-import static com.thatgravyboat.skyblockhud.GuiTextures.button_tex;
-
public class GuiOptionEditorButton extends GuiOptionEditor {
private String runnableId;
@@ -22,7 +22,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor {
this.config = config;
this.buttonText = buttonText;
- if(this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
+ if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
}
@Override
@@ -33,21 +33,18 @@ public class GuiOptionEditorButton extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
- if(buttonText != null) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
- false, 44, 0xFF303030);
+ if (buttonText != null) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj, x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030);
}
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
int height = getHeight();
- if(mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
+ if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
config.executeRunnable(runnableId);
return true;
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java
index 950ab87..c916fef 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java
@@ -1,5 +1,6 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
+import static com.thatgravyboat.skyblockhud.GuiTextures.*;
import com.thatgravyboat.skyblockhud.core.ChromaColour;
import com.thatgravyboat.skyblockhud.core.GuiElementColour;
@@ -9,8 +10,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
-import static com.thatgravyboat.skyblockhud.GuiTextures.*;
-
public class GuiOptionEditorColour extends GuiOptionEditor {
private String chromaColour;
@@ -18,8 +17,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
super(option);
-
- this.chromaColour = (String)option.get();
+ this.chromaColour = (String) option.get();
}
@Override
@@ -31,21 +29,21 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
int r = (argb >> 16) & 0xFF;
int g = (argb >> 8) & 0xFF;
int b = argb & 0xFF;
- GlStateManager.color(r/255f, g/255f, b/255f, 1);
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_white);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
}
@Override
public void renderOverlay(int x, int y, int width) {
- if(colourElement != null) {
+ if (colourElement != null) {
colourElement.render();
}
}
@Override
public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
- if(colourElement != null && colourElement.mouseInput(mouseX, mouseY)) {
+ if (colourElement != null && colourElement.mouseInput(mouseX, mouseY)) {
return true;
}
return false;
@@ -55,13 +53,18 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
- mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
- colourElement = new GuiElementColour(mouseX, mouseY, (String) option.get(), (val) -> {
- option.set(val);
- chromaColour = val;
- }, () -> colourElement = null);
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 && mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
+ colourElement =
+ new GuiElementColour(
+ mouseX,
+ mouseY,
+ (String) option.get(),
+ val -> {
+ option.set(val);
+ chromaColour = val;
+ },
+ () -> colourElement = null
+ );
}
return false;
@@ -69,11 +72,10 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(colourElement != null && colourElement.keyboardInput()) {
+ if (colourElement != null && colourElement.keyboardInput()) {
return true;
}
return false;
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java
index 9cefbe1..16df6c2 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java
@@ -1,5 +1,7 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
+import static com.thatgravyboat.skyblockhud.GuiTextures.*;
+
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.lerp.LerpUtils;
@@ -17,8 +19,6 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static com.thatgravyboat.skyblockhud.GuiTextures.*;
-
public class GuiOptionEditorDraggableList extends GuiOptionEditor {
private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png");
@@ -37,7 +37,6 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public GuiOptionEditorDraggableList(ConfigProcessor.ProcessedOption option, String[] exampleText) {
super(option);
-
this.exampleText = exampleText;
this.activeText = (List<Integer>) option.get();
}
@@ -46,7 +45,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public int getHeight() {
int height = super.getHeight() + 13;
- for(int strIndex : activeText) {
+ for (int strIndex : activeText) {
String str = exampleText[strIndex];
height += 10 * str.split("\n").length;
}
@@ -62,42 +61,39 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+45-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + 45 - 7 - 14, 48, 16);
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+45-7-6,
- false, 44, 0xFF303030);
+ TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj, x + width / 6, y + 45 - 7 - 6, false, 44, 0xFF303030);
long currentTime = System.currentTimeMillis();
- if(trashHoverTime < 0) {
- float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime)/250f);
+ if (trashHoverTime < 0) {
+ float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f);
GlStateManager.color(1, greenBlue, greenBlue, 1);
} else {
- float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime)/250f);
+ float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f);
GlStateManager.color(1, greenBlue, greenBlue, 1);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE);
- Utils.drawTexturedRect(x+width/6+27, y+45-7-13, 11, 14, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + width / 6 + 27, y + 45 - 7 - 13, 11, 14, GL11.GL_NEAREST);
- Gui.drawRect(x+5, y+45, x+width-5, y+height-5, 0xffdddddd);
- Gui.drawRect(x+6, y+46, x+width-6, y+height-6, 0xff000000);
+ Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd);
+ Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000);
int i = 0;
- int yOff=0;
- for(int strIndex : activeText) {
+ int yOff = 0;
+ for (int strIndex : activeText) {
String str = exampleText[strIndex];
String[] multilines = str.split("\n");
int ySize = multilines.length * 10;
- if(i++ != dragStartIndex) {
- for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) {
+ if (i++ != dragStartIndex) {
+ for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) {
String line = multilines[multilineIndex];
- Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj,
- x+20, y+50+yOff+multilineIndex*10, true, width-20, 0xffffffff);
+ Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, x + 20, y + 50 + yOff + multilineIndex * 10, true, width - 20, 0xffffffff);
}
- Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x+10, y+50+yOff + ySize/2 - 4, 0xffffff, true);
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2 - 4, 0xffffff, true);
}
yOff += ySize;
@@ -108,50 +104,49 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public void renderOverlay(int x, int y, int width) {
super.renderOverlay(x, y, width);
- if(dropdownOpen) {
+ if (dropdownOpen) {
List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
+ for (int i = 0; i < exampleText.length; i++) {
remaining.add(i);
}
remaining.removeAll(activeText);
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/2-10, 150);
+ int dropdownWidth = Math.min(width / 2 - 10, 150);
int left = dragOffsetX;
int top = dragOffsetY;
- int dropdownHeight = -1 + 12*remaining.size();
+ int dropdownHeight = -1 + 12 * remaining.size();
int main = 0xff202026;
int outline = 0xff404046;
- Gui.drawRect(left, top, left+1, top+dropdownHeight, outline); //Left
- Gui.drawRect(left+1, top, left+dropdownWidth, top+1, outline); //Top
- Gui.drawRect(left+dropdownWidth-1, top+1, left+dropdownWidth, top+dropdownHeight, outline); //Right
- Gui.drawRect(left+1, top+dropdownHeight-1, left+dropdownWidth-1, top+dropdownHeight, outline); //Bottom
- Gui.drawRect(left+1, top+1, left+dropdownWidth-1, top+dropdownHeight-1, main); //Middle
+ Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left
+ Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top
+ Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, outline); //Right
+ Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, outline); //Bottom
+ Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle
int dropdownY = -1;
- for(int strIndex : remaining) {
+ for (int strIndex : remaining) {
String str = exampleText[strIndex];
- if(str.isEmpty()) {
+ if (str.isEmpty()) {
str = "<NONE>";
}
- TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."),
- fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
+ TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."), fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0);
dropdownY += 12;
}
- } else if(currentDragging >= 0) {
+ } else if (currentDragging >= 0) {
int opacity = 0x80;
long currentTime = System.currentTimeMillis();
- if(trashHoverTime < 0) {
- float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime)/250f);
- opacity = (int)(opacity * greenBlue);
+ if (trashHoverTime < 0) {
+ float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f);
+ opacity = (int) (opacity * greenBlue);
} else {
- float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime)/250f);
- opacity = (int)(opacity * greenBlue);
+ float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f);
+ opacity = (int) (opacity * greenBlue);
}
- if(opacity < 20) return;
+ if (opacity < 20) return;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
@@ -162,67 +157,58 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
String[] multilines = str.split("\n");
GlStateManager.enableBlend();
- for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) {
+ for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) {
String line = multilines[multilineIndex];
- Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj,
- dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex*10, true, width-20, 0xffffff | (opacity << 24));
+ Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex * 10, true, width - 20, 0xffffff | (opacity << 24));
}
int ySize = multilines.length * 10;
- Minecraft.getMinecraft().fontRendererObj.drawString("\u2261",
- dragOffsetX + mouseX,
- dragOffsetY + mouseY + ySize/2 - 4, 0xffffff, true);
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", dragOffsetX + mouseX, dragOffsetY + mouseY + ySize / 2 - 4, 0xffffff, true);
}
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(!Mouse.getEventButtonState() && !dropdownOpen &&
- dragStartIndex >= 0 && Mouse.getEventButton() == 0 &&
- mouseX >= x+width/6+27-3 && mouseX <= x+width/6+27+11+3 &&
- mouseY >= y+45-7-13-3 && mouseY <= y+45-7-13+14+3) {
+ if (!Mouse.getEventButtonState() && !dropdownOpen && dragStartIndex >= 0 && Mouse.getEventButton() == 0 && mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) {
activeText.remove(dragStartIndex);
currentDragging = -1;
dragStartIndex = -1;
return false;
}
- if(!Mouse.isButtonDown(0) || dropdownOpen) {
+ if (!Mouse.isButtonDown(0) || dropdownOpen) {
currentDragging = -1;
dragStartIndex = -1;
- if(trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
- } else if(currentDragging >= 0 &&
- mouseX >= x+width/6+27-3 && mouseX <= x+width/6+27+11+3 &&
- mouseY >= y+45-7-13-3 && mouseY <= y+45-7-13+14+3) {
- if(trashHoverTime < 0) trashHoverTime = System.currentTimeMillis();
+ if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
+ } else if (currentDragging >= 0 && mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) {
+ if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis();
} else {
- if(trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
+ if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
int height = getHeight();
- if(dropdownOpen) {
+ if (dropdownOpen) {
List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
+ for (int i = 0; i < exampleText.length; i++) {
remaining.add(i);
}
remaining.removeAll(activeText);
- int dropdownWidth = Math.min(width/2-10, 150);
+ int dropdownWidth = Math.min(width / 2 - 10, 150);
int left = dragOffsetX;
int top = dragOffsetY;
- int dropdownHeight = -1 + 12*remaining.size();
+ int dropdownHeight = -1 + 12 * remaining.size();
- if(mouseX > left && mouseX < left+dropdownWidth &&
- mouseY > top && mouseY < top + dropdownHeight) {
+ if (mouseX > left && mouseX < left + dropdownWidth && mouseY > top && mouseY < top + dropdownHeight) {
int dropdownY = -1;
- for(int strIndex : remaining) {
- if(mouseY < top+dropdownY+12) {
+ for (int strIndex : remaining) {
+ if (mouseY < top + dropdownY + 12) {
activeText.add(0, strIndex);
- if(remaining.size() == 1) dropdownOpen = false;
+ if (remaining.size() == 1) dropdownOpen = false;
return true;
}
@@ -234,25 +220,21 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
return true;
}
- if(activeText.size() < exampleText.length &&
- mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+45-7-14 && mouseY < y+45-7+2) {
+ if (activeText.size() < exampleText.length && mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + 45 - 7 - 14 && mouseY < y + 45 - 7 + 2) {
dropdownOpen = !dropdownOpen;
dragOffsetX = mouseX;
dragOffsetY = mouseY;
return true;
}
- if(Mouse.getEventButton() == 0 &&
- mouseX > x+5 && mouseX < x+width-5 &&
- mouseY > y+45 && mouseY < y+height-6) {
- int yOff=0;
+ if (Mouse.getEventButton() == 0 && mouseX > x + 5 && mouseX < x + width - 5 && mouseY > y + 45 && mouseY < y + height - 6) {
+ int yOff = 0;
int i = 0;
- for(int strIndex : activeText) {
+ for (int strIndex : activeText) {
int ySize = 10 * exampleText[strIndex].split("\n").length;
- if(mouseY < y+50+yOff+ySize) {
- dragOffsetX = x+10 - mouseX;
- dragOffsetY = y+50+yOff - mouseY;
+ if (mouseY < y + 50 + yOff + ySize) {
+ dragOffsetX = x + 10 - mouseX;
+ dragOffsetY = y + 50 + yOff - mouseY;
currentDragging = strIndex;
dragStartIndex = i;
@@ -262,11 +244,11 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
i++;
}
}
- } else if(Mouse.getEventButton() == -1 && currentDragging >= 0) {
- int yOff=0;
+ } else if (Mouse.getEventButton() == -1 && currentDragging >= 0) {
+ int yOff = 0;
int i = 0;
- for(int strIndex : activeText) {
- if(dragOffsetY + mouseY + 4 < y+50+yOff+10) {
+ for (int strIndex : activeText) {
+ if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) {
activeText.remove(dragStartIndex);
activeText.add(i, currentDragging);
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java
index 2b7a654..92c1a0f 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java
@@ -17,7 +17,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public GuiOptionEditorDropdown(ConfigProcessor.ProcessedOption option, String[] values, int selected, boolean useOrdinal) {
super(option);
- if(selected >= values.length) selected = values.length;
+ if (selected >= values.length) selected = values.length;
this.values = values;
this.selected = selected;
this.useOrdinal = useOrdinal;
@@ -27,68 +27,65 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public void render(int x, int y, int width) {
super.render(x, y, width);
- if(!open) {
+ if (!open) {
int height = getHeight();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/3-10, 80);
- int left = x+width/6-dropdownWidth/2;
- int top = y+height-7-14;
+ int dropdownWidth = Math.min(width / 3 - 10, 80);
+ int left = x + width / 6 - dropdownWidth / 2;
+ int top = y + height - 7 - 14;
String selectedString = " - Select - ";
- if(selected >= 0 && selected < values.length) {
+ if (selected >= 0 && selected < values.length) {
selectedString = values[selected];
}
RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false);
- TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2);
+ TextRenderUtils.drawStringScaled("\u25BC", fr, left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2);
- TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false,
- dropdownWidth-16, 0xffa0a0a0);
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0);
}
}
@Override
public void renderOverlay(int x, int y, int width) {
- if(open) {
+ if (open) {
String selectedString = " - Select - ";
- if(selected >= 0 && selected < values.length) {
+ if (selected >= 0 && selected < values.length) {
selectedString = values[selected];
}
int height = getHeight();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/3-10, 80);
- int left = x+width/6-dropdownWidth/2;
- int top = y+height-7-14;
+ int dropdownWidth = Math.min(width / 3 - 10, 80);
+ int left = x + width / 6 - dropdownWidth / 2;
+ int top = y + height - 7 - 14;
- int dropdownHeight = 13 + 12*values.length;
+ int dropdownHeight = 13 + 12 * values.length;
int main = 0xff202026;
int blue = 0xff2355ad;
- Gui.drawRect(left, top, left+1, top+dropdownHeight, blue); //Left
- Gui.drawRect(left+1, top, left+dropdownWidth, top+1, blue); //Top
- Gui.drawRect(left+dropdownWidth-1, top+1, left+dropdownWidth, top+dropdownHeight, blue); //Right
- Gui.drawRect(left+1, top+dropdownHeight-1, left+dropdownWidth-1, top+dropdownHeight, blue); //Bottom
- Gui.drawRect(left+1, top+1, left+dropdownWidth-1, top+dropdownHeight-1, main); //Middle
+ Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left
+ Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top
+ Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, blue); //Right
+ Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, blue); //Bottom
+ Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle
- Gui.drawRect(left+1, top+14-1, left+dropdownWidth-1, top+14, blue); //Bar
+ Gui.drawRect(left + 1, top + 14 - 1, left + dropdownWidth - 1, top + 14, blue); //Bar
int dropdownY = 13;
- for(String option : values) {
- if(option.isEmpty()) {
+ for (String option : values) {
+ if (option.isEmpty()) {
option = "<NONE>";
}
- TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
+ TextRenderUtils.drawStringScaledMaxWidth(option, fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0);
dropdownY += 12;
}
- TextRenderUtils.drawStringScaled("\u25B2", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2);
+ TextRenderUtils.drawStringScaled("\u25B2", fr, left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2);
-
- TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false,
- dropdownWidth-16, 0xffa0a0a0);
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0);
}
}
@@ -96,12 +93,11 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- int left = x+width/6-40;
- int top = y+height-7-14;
+ int left = x + width / 6 - 40;
+ int top = y + height - 7 - 14;
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(mouseX >= left && mouseX <= left+80 &&
- mouseY >= top && mouseY <= top+14) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (mouseX >= left && mouseX <= left + 80 && mouseY >= top && mouseY <= top + 14) {
open = !open;
return true;
}
@@ -114,19 +110,18 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- int left = x+width/6-40;
- int top = y+height-7-14;
+ int left = x + width / 6 - 40;
+ int top = y + height - 7 - 14;
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(!(mouseX >= left && mouseX <= left+80 &&
- mouseY >= top && mouseY <= top+14) && open) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (!(mouseX >= left && mouseX <= left + 80 && mouseY >= top && mouseY <= top + 14) && open) {
open = false;
- if(mouseX >= left && mouseX <= left+80) {
+ if (mouseX >= left && mouseX <= left + 80) {
int dropdownY = 13;
- for(int ordinal=0; ordinal < values.length; ordinal++) {
- if(mouseY >= top+3+dropdownY && mouseY <= top+3+dropdownY+12) {
+ for (int ordinal = 0; ordinal < values.length; ordinal++) {
+ if (mouseY >= top + 3 + dropdownY && mouseY <= top + 3 + dropdownY + 12) {
selected = ordinal;
- if(useOrdinal) {
+ if (useOrdinal) {
option.set(selected);
} else {
option.set(values[selected]);
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java
index 13175a6..ecdaa3a 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java
@@ -1,5 +1,7 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
+import static com.thatgravyboat.skyblockhud.GuiTextures.*;
+
import com.thatgravyboat.skyblockhud.core.config.KeybindHelper;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
@@ -11,8 +13,6 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static com.thatgravyboat.skyblockhud.GuiTextures.*;
-
public class GuiOptionEditorKeybind extends GuiOptionEditor {
private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
@@ -35,38 +35,33 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
String keyName = KeybindHelper.getKeyName(keyCode);
- String text = editingKeycode ? "> "+keyName+" <" : keyName;
- TextRenderUtils.drawStringCenteredScaledMaxWidth(text,
- Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
- false, 40, 0xFF303030);
+ String text = editingKeycode ? "> " + keyName + " <" : keyName;
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(text, Minecraft.getMinecraft().fontRendererObj, x + width / 6, y + height - 7 - 6, false, 40, 0xFF303030);
Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+width/6-24+48+3, y+height-7-14+3, 10, 11, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24 + 48 + 3, y + height - 7 - 14 + 3, 10, 11, GL11.GL_NEAREST);
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
editingKeycode = false;
- keyCode = Mouse.getEventButton()-100;
+ keyCode = Mouse.getEventButton() - 100;
option.set(keyCode);
return true;
}
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
int height = getHeight();
- if(mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
+ if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
editingKeycode = true;
return true;
}
- if(mouseX > x+width/6-24+48+3 && mouseX < x+width/6-24+48+13 &&
- mouseY > y+height-7-14+3 && mouseY < y+height-7-14+3+11) {
+ if (mouseX > x + width / 6 - 24 + 48 + 3 && mouseX < x + width / 6 - 24 + 48 + 13 && mouseY > y + height - 7 - 14 + 3 && mouseY < y + height - 7 - 14 + 3 + 11) {
keyCode = defaultKeyCode;
option.set(keyCode);
return true;
@@ -78,9 +73,9 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(editingKeycode) {
+ if (editingKeycode) {
editingKeycode = false;
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
keyCode = 0;
} else {
keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java
index 0321e34..ad96a4f 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java
@@ -14,33 +14,42 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) {
super(option);
- if(minStep < 0) minStep = 0.01f;
+ if (minStep < 0) minStep = 0.01f;
- float floatVal = ((Number)option.get()).floatValue();
+ float floatVal = ((Number) option.get()).floatValue();
{
String strVal;
- if(floatVal % 1 == 0) {
- strVal = Integer.toString((int)floatVal);
+ if (floatVal % 1 == 0) {
+ strVal = Integer.toString((int) floatVal);
} else {
strVal = Float.toString(floatVal);
}
- textField = new GuiElementTextField(strVal,
- GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
+ textField = new GuiElementTextField(strVal, GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
}
- slider = new GuiElementSlider(0, 0, 80, minValue, maxValue, minStep, floatVal, (val) -> {
- option.set(val);
-
- String strVal;
- if(val % 1 == 0) {
- strVal = Integer.toString(val.intValue());
- } else {
- strVal = Float.toString(val);
- strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
- strVal = strVal.replaceAll("0+$", "");
- }
- textField.setText(strVal);
- });
+ slider =
+ new GuiElementSlider(
+ 0,
+ 0,
+ 80,
+ minValue,
+ maxValue,
+ minStep,
+ floatVal,
+ val -> {
+ option.set(val);
+
+ String strVal;
+ if (val % 1 == 0) {
+ strVal = Integer.toString(val.intValue());
+ } else {
+ strVal = Float.toString(val);
+ strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
+ strVal = strVal.replaceAll("0+$", "");
+ }
+ textField.setText(strVal);
+ }
+ );
}
@Override
@@ -48,54 +57,52 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- int fullWidth = Math.min(width/3-10, 80);
- int sliderWidth = (fullWidth-5)*3/4;
- int textFieldWidth = (fullWidth-5)/4;
+ int fullWidth = Math.min(width / 3 - 10, 80);
+ int sliderWidth = (fullWidth - 5) * 3 / 4;
+ int textFieldWidth = (fullWidth - 5) / 4;
- slider.x = x+width/6-fullWidth/2;
- slider.y = y+height-7-14;
+ slider.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
slider.width = sliderWidth;
slider.render();
- if(textField.getFocus()) {
+ if (textField.getFocus()) {
textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY);
- textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10,
- 16);
+ textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10, 16);
} else {
textField.setSize(textFieldWidth, 16);
textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
}
- textField.render(x+width/6-fullWidth/2+sliderWidth+5, y+height-7-14);
+ textField.render(x + width / 6 - fullWidth / 2 + sliderWidth + 5, y + height - 7 - 14);
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- int fullWidth = Math.min(width/3-10, 80);
- int sliderWidth = (fullWidth-5)*3/4;
- int textFieldWidth = (fullWidth-5)/4;
+ int fullWidth = Math.min(width / 3 - 10, 80);
+ int sliderWidth = (fullWidth - 5) * 3 / 4;
+ int textFieldWidth = (fullWidth - 5) / 4;
- slider.x = x+width/6-fullWidth/2;
- slider.y = y+height-7-14;
+ slider.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
slider.width = sliderWidth;
- if(slider.mouseInput(mouseX, mouseY)) {
+ if (slider.mouseInput(mouseX, mouseY)) {
textField.unfocus();
return true;
}
- if(textField.getFocus()) {
- textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10;
+ if (textField.getFocus()) {
+ textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10;
}
- int textFieldX = x+width/6-fullWidth/2+sliderWidth+5;
- int textFieldY = y+height-7-14;
+ int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5;
+ int textFieldY = y + height - 7 - 14;
textField.setSize(textFieldWidth, 16);
- if(Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
- if(mouseX > textFieldX && mouseX < textFieldX+textFieldWidth &&
- mouseY > textFieldY && mouseY < textFieldY+16) {
+ if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
+ if (mouseX > textFieldX && mouseX < textFieldX + textFieldWidth && mouseY > textFieldY && mouseY < textFieldY + 16) {
textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
return true;
}
@@ -107,18 +114,18 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
+ if (Keyboard.getEventKeyState() && textField.getFocus()) {
textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
try {
textField.setCustomBorderColour(0xffffffff);
float f = Float.parseFloat(textField.getText());
- if(option.set(f)) {
+ if (option.set(f)) {
slider.setValue(f);
} else {
textField.setCustomBorderColour(0xff0000ff);
}
- } catch(Exception e) {
+ } catch (Exception e) {
textField.setCustomBorderColour(0xffff0000);
}
@@ -126,6 +133,4 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
}
return false;
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java
index 1f8355e..c68deaf 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java
@@ -12,8 +12,7 @@ public class GuiOptionEditorText extends GuiOptionEditor {
public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) {
super(option);
-
- textField = new GuiElementTextField((String)option.get(), 0);
+ textField = new GuiElementTextField((String) option.get(), 0);
}
@Override
@@ -21,36 +20,35 @@ public class GuiOptionEditorText extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- int fullWidth = Math.min(width/3-10, 80);
+ int fullWidth = Math.min(width / 3 - 10, 80);
- int textFieldX = x+width/6-fullWidth/2;
- if(textField.getFocus()) {
- fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10);
+ int textFieldX = x + width / 6 - fullWidth / 2;
+ if (textField.getFocus()) {
+ fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10);
}
textField.setSize(fullWidth, 16);
- textField.render(textFieldX, y+height-7-14);
+ textField.render(textFieldX, y + height - 7 - 14);
}
@Override
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
int height = getHeight();
- int fullWidth = Math.min(width/3-10, 80);
+ int fullWidth = Math.min(width / 3 - 10, 80);
- int textFieldX = x+width/6-fullWidth/2;
+ int textFieldX = x + width / 6 - fullWidth / 2;
- if(textField.getFocus()) {
- fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10);
+ if (textField.getFocus()) {
+ fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10);
}
- int textFieldY = y+height-7-14;
+ int textFieldY = y + height - 7 - 14;
textField.setSize(fullWidth, 16);
- if(Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
- if(mouseX > textFieldX && mouseX < textFieldX+fullWidth &&
- mouseY > textFieldY && mouseY < textFieldY+16) {
+ if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
+ if (mouseX > textFieldX && mouseX < textFieldX + fullWidth && mouseY > textFieldY && mouseY < textFieldY + 16) {
textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
return true;
}
@@ -62,14 +60,14 @@ public class GuiOptionEditorText extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
+ if (Keyboard.getEventKeyState() && textField.getFocus()) {
Keyboard.enableRepeatEvents(true);
textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
try {
textField.setCustomBorderColour(0xffffffff);
option.set(textField.getText());
- } catch(Exception e) {
+ } catch (Exception e) {
textField.setCustomBorderColour(0xffff0000);
}
@@ -77,6 +75,4 @@ public class GuiOptionEditorText extends GuiOptionEditor {
}
return false;
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java
index 6aeb847..cabd342 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java
@@ -1,6 +1,5 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
-
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.core.config.Position;
import java.io.IOException;
@@ -26,10 +25,7 @@ public class GuiPositionEditor extends GuiScreen {
private int guiScaleOverride = -1;
- public GuiPositionEditor(Position position, int elementWidth, int elementHeight,
- Runnable renderCallback,
- Runnable positionChangedCallback,
- Runnable closedCallback) {
+ public GuiPositionEditor(Position position, int elementWidth, int elementHeight, Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback) {
this.position = position;
this.originalPosition = position.clone();
this.elementWidth = elementWidth;
@@ -54,7 +50,7 @@ public class GuiPositionEditor extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -67,7 +63,7 @@ public class GuiPositionEditor extends GuiScreen {
drawDefaultBackground();
- if(clicked) {
+ if (clicked) {
grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
}
@@ -77,28 +73,26 @@ public class GuiPositionEditor extends GuiScreen {
int x = position.getAbsX(scaledResolution, elementWidth);
int y = position.getAbsY(scaledResolution, elementHeight);
- if(position.isCenterX()) x -= elementWidth/2;
- if(position.isCenterY()) y -= elementHeight/2;
- Gui.drawRect(x, y, x+elementWidth, y+elementHeight, 0x80404040);
+ if (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
+ Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040);
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
Utils.pushGuiScale(-1);
}
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2, 8, true, 0xffffff);
- Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2, 18, true, 0xffffff);
+ Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff);
+ Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
- if(mouseButton == 0) {
+ if (mouseButton == 0) {
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -108,17 +102,16 @@ public class GuiPositionEditor extends GuiScreen {
int x = position.getAbsX(scaledResolution, elementWidth);
int y = position.getAbsY(scaledResolution, elementHeight);
- if(position.isCenterX()) x -= elementWidth/2;
- if(position.isCenterY()) y -= elementHeight/2;
+ if (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
- if(mouseX >= x && mouseY >= y &&
- mouseX <= x+elementWidth && mouseY <= y+elementHeight) {
+ if (mouseX >= x && mouseY >= y && mouseX <= x + elementWidth && mouseY <= y + elementHeight) {
clicked = true;
grabbedX = mouseX;
grabbedY = mouseY;
}
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
Utils.pushGuiScale(-1);
}
}
@@ -128,18 +121,18 @@ public class GuiPositionEditor extends GuiScreen {
protected void keyTyped(char typedChar, int keyCode) throws IOException {
Keyboard.enableRepeatEvents(true);
- if(keyCode == Keyboard.KEY_R) {
+ if (keyCode == Keyboard.KEY_R) {
position.set(originalPosition);
- } else if(!clicked) {
+ } else if (!clicked) {
boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
int dist = shiftHeld ? 10 : 1;
- if(keyCode == Keyboard.KEY_DOWN) {
+ if (keyCode == Keyboard.KEY_DOWN) {
position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_UP) {
+ } else if (keyCode == Keyboard.KEY_UP) {
position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_LEFT) {
+ } else if (keyCode == Keyboard.KEY_LEFT) {
position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_RIGHT) {
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
}
}
@@ -156,9 +149,9 @@ public class GuiPositionEditor extends GuiScreen {
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(clicked) {
+ if (clicked) {
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -170,7 +163,7 @@ public class GuiPositionEditor extends GuiScreen {
grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
positionChangedCallback.run();
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
Utils.pushGuiScale(-1);
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java
index 725c846..50cb894 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java
@@ -11,6 +11,7 @@ import java.util.List;
public class ConfigProcessor {
public static class ProcessedCategory {
+
public final String name;
public final String desc;
public final LinkedHashMap<String, ProcessedOption> options = new LinkedHashMap<>();
@@ -22,6 +23,7 @@ public class ConfigProcessor {
}
public static class ProcessedOption {
+
public final String name;
public final String desc;
public final int subcategoryId;
@@ -44,20 +46,20 @@ public class ConfigProcessor {
public Object get() {
try {
return field.get(container);
- } catch(Exception e) {
+ } catch (Exception e) {
return null;
}
}
public boolean set(Object value) {
try {
- if(field.getType() == int.class && value instanceof Number) {
- field.set(container, ((Number)value).intValue());
+ if (field.getType() == int.class && value instanceof Number) {
+ field.set(container, ((Number) value).intValue());
} else {
field.set(container, value);
}
return true;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
return false;
}
@@ -66,102 +68,86 @@ public class ConfigProcessor {
public static LinkedHashMap<String, ProcessedCategory> create(Config config) {
LinkedHashMap<String, ProcessedCategory> processedConfig = new LinkedHashMap<>();
- for(Field categoryField : config.getClass().getDeclaredFields()) {
+ for (Field categoryField : config.getClass().getDeclaredFields()) {
boolean exposePresent = categoryField.isAnnotationPresent(Expose.class);
boolean categoryPresent = categoryField.isAnnotationPresent(Category.class);
- if(exposePresent && categoryPresent) {
+ if (exposePresent && categoryPresent) {
Object categoryObj;
try {
categoryObj = categoryField.get(config);
- } catch(Exception e) {
+ } catch (Exception e) {
//System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName());
continue;
}
Category categoryAnnotation = categoryField.getAnnotation(Category.class);
- ProcessedCategory cat = new ProcessedCategory(
- categoryAnnotation.name(),
- categoryAnnotation.desc()
- );
+ ProcessedCategory cat = new ProcessedCategory(categoryAnnotation.name(), categoryAnnotation.desc());
processedConfig.put(categoryField.getName(), cat);
- for(Field optionField : categoryObj.getClass().getDeclaredFields()) {
+ for (Field optionField : categoryObj.getClass().getDeclaredFields()) {
boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class);
- if(optionPresent) {
+ if (optionPresent) {
ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class);
- ProcessedOption option = new ProcessedOption(
- optionAnnotation.name(),
- optionAnnotation.desc(),
- optionAnnotation.subcategoryId(),
- optionField,
- categoryObj
- );
- if(optionField.isAnnotationPresent(ConfigAccordionId.class)) {
+ ProcessedOption option = new ProcessedOption(optionAnnotation.name(), optionAnnotation.desc(), optionAnnotation.subcategoryId(), optionField, categoryObj);
+ if (optionField.isAnnotationPresent(ConfigAccordionId.class)) {
ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class);
option.accordionId = annotation.id();
}
GuiOptionEditor editor = null;
Class<?> optionType = optionField.getType();
- if(optionType.isAssignableFrom(int.class) &&
- optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
+ if (optionType.isAssignableFrom(int.class) && optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class);
- editor = new GuiOptionEditorKeybind(option, (int)option.get(), configEditorAnnotation.defaultKey());
+ editor = new GuiOptionEditorKeybind(option, (int) option.get(), configEditorAnnotation.defaultKey());
}
- if(optionField.isAnnotationPresent(ConfigEditorButton.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorButton.class)) {
ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class);
editor = new GuiOptionEditorButton(option, configEditorAnnotation.runnableId(), configEditorAnnotation.buttonText(), config);
}
- if(optionType.isAssignableFrom(boolean.class) &&
- optionField.isAnnotationPresent(ConfigEditorBoolean.class)) {
+ if (optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorBoolean.class)) {
editor = new GuiOptionEditorBoolean(option);
}
- if(optionType.isAssignableFrom(boolean.class) &&
- optionField.isAnnotationPresent(ConfigEditorAccordion.class)) {
+ if (optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorAccordion.class)) {
ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class);
editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id());
}
- if(optionType.isAssignableFrom(int.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ if (optionType.isAssignableFrom(int.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int)option.get(), true);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int) option.get(), true);
}
}
- if(optionType.isAssignableFrom(List.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) {
+ if (optionType.isAssignableFrom(List.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) {
ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation(ConfigEditorDraggableList.class);
editor = new GuiOptionEditorDraggableList(option, configEditorAnnotation.exampleText());
}
}
- if(optionType.isAssignableFrom(String.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ if (optionType.isAssignableFrom(String.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(),
- configEditorAnnotation.initialIndex(), false);
- } else if(optionField.isAnnotationPresent(ConfigEditorColour.class)) {
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), configEditorAnnotation.initialIndex(), false);
+ } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) {
editor = new GuiOptionEditorColour(option);
- } else if(optionField.isAnnotationPresent(ConfigEditorText.class)) {
+ } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) {
editor = new GuiOptionEditorText(option);
}
}
- if(optionType.isAssignableFrom(int.class) ||
- optionType.isAssignableFrom(float.class) ||
- optionType.isAssignableFrom(double.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorSlider.class)) {
+ if (optionType.isAssignableFrom(int.class) || optionType.isAssignableFrom(float.class) || optionType.isAssignableFrom(double.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) {
ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class);
- editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(),
- configEditorAnnotation.maxValue(), configEditorAnnotation.minStep());
+ editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(), configEditorAnnotation.maxValue(), configEditorAnnotation.minStep());
}
}
- if(optionType.isAssignableFrom(String.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ if (optionType.isAssignableFrom(String.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0,false);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false);
}
}
- if(editor == null) {
+ if (editor == null) {
//System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName());
continue;
}
@@ -169,11 +155,10 @@ public class ConfigProcessor {
cat.options.put(optionField.getName(), option);
}
}
- } else if(exposePresent || categoryPresent) {
+ } else if (exposePresent || categoryPresent) {
//System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName());
}
}
return processedConfig;
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java
index 32b0236..674ffe4 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java
@@ -1,5 +1,7 @@
package com.thatgravyboat.skyblockhud.core.util;
+import static com.thatgravyboat.skyblockhud.GuiTextures.*;
+
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.core.GuiElement;
import java.util.function.Consumer;
@@ -9,8 +11,6 @@ import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static com.thatgravyboat.skyblockhud.GuiTextures.*;
-
public class GuiElementSlider extends GuiElement {
public int x;
@@ -27,9 +27,8 @@ public class GuiElementSlider extends GuiElement {
private boolean clicked = false;
- public GuiElementSlider(int x, int y, int width, float minValue, float maxValue, float minStep,
- float value, Consumer<Float> setCallback) {
- if(minStep < 0) minStep = 0.01f;
+ public GuiElementSlider(int x, int y, int width, float minValue, float maxValue, float minStep, float value, Consumer<Float> setCallback) {
+ if (minStep < 0) minStep = 0.01f;
this.x = x;
this.y = y;
@@ -51,62 +50,62 @@ public class GuiElementSlider extends GuiElement {
int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
float value = this.value;
- if(clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
+ if (clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
value = Math.max(minValue, Math.min(maxValue, value));
- value = Math.round(value/minStep)*minStep;
+ value = Math.round(value / minStep) * minStep;
}
- float sliderAmount = Math.max(0, Math.min(1, (value-minValue)/(maxValue-minValue)));
- int sliderAmountI = (int)(width*sliderAmount);
+ float sliderAmount = Math.max(0, Math.min(1, (value - minValue) / (maxValue - minValue)));
+ int sliderAmountI = (int) (width * sliderAmount);
GlStateManager.color(1f, 1f, 1f, 1f);
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap);
Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST);
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_cap);
- Utils.drawTexturedRect(x+width-4, y, 4, HEIGHT, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST);
- if(sliderAmountI > 5) {
+ if (sliderAmountI > 5) {
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_segment);
- Utils.drawTexturedRect(x+4, y, sliderAmountI-4, HEIGHT, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + 4, y, sliderAmountI - 4, HEIGHT, GL11.GL_NEAREST);
}
- if(sliderAmountI < width-5) {
+ if (sliderAmountI < width - 5) {
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_segment);
- Utils.drawTexturedRect(x+sliderAmountI, y, width-4-sliderAmountI, HEIGHT, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + sliderAmountI, y, width - 4 - sliderAmountI, HEIGHT, GL11.GL_NEAREST);
}
- for(int i=1; i<4; i++) {
- int notchX = x+width*i/4-1;
- Minecraft.getMinecraft().getTextureManager().bindTexture(notchX > x+sliderAmountI ? slider_off_notch : slider_on_notch);
- Utils.drawTexturedRect(notchX, y+(HEIGHT-4f)/2, 2, 4, GL11.GL_NEAREST);
+ for (int i = 1; i < 4; i++) {
+ int notchX = x + width * i / 4 - 1;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch);
+ Utils.drawTexturedRect(notchX, y + (HEIGHT - 4f) / 2, 2, 4, GL11.GL_NEAREST);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new);
- Utils.drawTexturedRect(x+sliderAmountI-4, y, 8, HEIGHT, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + sliderAmountI - 4, y, 8, HEIGHT, GL11.GL_NEAREST);
}
@Override
public boolean mouseInput(int mouseX, int mouseY) {
- if(!Mouse.isButtonDown(0)) {
+ if (!Mouse.isButtonDown(0)) {
clicked = false;
}
- if(Mouse.getEventButton() == 0) {
- clicked = Mouse.getEventButtonState() && mouseX > x && mouseX < x+width && mouseY > y && mouseY < y+HEIGHT;
- if(clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
+ if (Mouse.getEventButton() == 0) {
+ clicked = Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + HEIGHT;
+ if (clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
value = Math.max(minValue, Math.min(maxValue, value));
- value = (float)(Math.round(value/minStep)*(double)minStep);
+ value = (float) (Math.round(value / minStep) * (double) minStep);
setCallback.accept(value);
return true;
}
}
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
value = Math.max(minValue, Math.min(maxValue, value));
- value = Math.round(value/minStep)*minStep;
+ value = Math.round(value / minStep) * minStep;
setCallback.accept(value);
return true;
}
@@ -118,5 +117,4 @@ public class GuiElementSlider extends GuiElement {
public boolean keyboardInput() {
return false;
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java
index 734d845..06506ee 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java
@@ -5,5 +5,4 @@ public class StringUtils {
public static String cleanColour(String in) {
return in.replaceAll("(?i)\\u00A7.", "");
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java
index e742ab1..1b88f5a 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java
@@ -7,20 +7,19 @@ public class LerpUtils {
}
public static float sigmoid(float val) {
- return (float)(1/(1 + Math.exp(-val)));
+ return (float) (1 / (1 + Math.exp(-val)));
}
private static final float sigmoidStr = 8;
- private static final float sigmoidA = -1/(sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr));
- private static final float sigmoidB = sigmoidA*sigmoid(-0.5f * sigmoidStr);
+ private static final float sigmoidA = -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr));
+ private static final float sigmoidB = sigmoidA * sigmoid(-0.5f * sigmoidStr);
+
public static float sigmoidZeroOne(float f) {
f = clampZeroOne(f);
- return sigmoidA*sigmoid(sigmoidStr*(f-0.5f))-sigmoidB;
+ return sigmoidA * sigmoid(sigmoidStr * (f - 0.5f)) - sigmoidB;
}
public static float lerp(float a, float b, float amount) {
return b + (a - b) * clampZeroOne(amount);
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java
index 4831956..edf129b 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java
@@ -22,23 +22,23 @@ public class LerpingFloat {
int lastTimeSpent = timeSpent;
this.timeSpent += System.currentTimeMillis() - lastMillis;
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
- float startValue = lerpValue - (targetValue - lerpValue)/fac;
+ float startValue = lerpValue - (targetValue - lerpValue) / fac;
float dist = targetValue - startValue;
- if(dist == 0) return;
+ if (dist == 0) return;
float oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
+ if (distPercentToTarget >= 1) {
lerpValue = targetValue;
} else {
- lerpValue = startValue + dist*distPercentToTarget;
+ lerpValue = startValue + dist * distPercentToTarget;
}
- if(lerpValue == oldLerpValue) {
+ if (lerpValue == oldLerpValue) {
timeSpent = lastTimeSpent;
} else {
this.lastMillis = System.currentTimeMillis();
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java
index 48ae5ad..0bae869 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java
@@ -22,23 +22,23 @@ public class LerpingInteger {
int lastTimeSpent = timeSpent;
this.timeSpent += System.currentTimeMillis() - lastMillis;
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
- int startValue = lerpValue - (int)((targetValue - lerpValue)/fac);
+ int startValue = lerpValue - (int) ((targetValue - lerpValue) / fac);
int dist = targetValue - startValue;
- if(dist == 0) return;
+ if (dist == 0) return;
int oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
+ if (distPercentToTarget >= 1) {
lerpValue = targetValue;
} else {
- lerpValue = startValue + (int)(dist*distPercentToTarget);
+ lerpValue = startValue + (int) (dist * distPercentToTarget);
}
- if(lerpValue == oldLerpValue) {
+ if (lerpValue == oldLerpValue) {
timeSpent = lastTimeSpent;
} else {
this.lastMillis = System.currentTimeMillis();
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java
index 85e67e7..1fc09c2 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java
@@ -9,7 +9,7 @@ import net.minecraft.client.renderer.RenderHelper;
public class TextRenderUtils {
public static int getCharVertLen(char c) {
- if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
return 5;
} else {
return 7;
@@ -18,7 +18,7 @@ public class TextRenderUtils {
public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
drawStringScaled(str, fr, x, y, shadow, colour, factor);
@@ -26,19 +26,19 @@ public class TextRenderUtils {
public static void drawStringScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor) {
GlStateManager.scale(factor, factor, 1);
- fr.drawString(str, x/factor, y/factor, colour, shadow);
- GlStateManager.scale(1/factor, 1/factor, 1);
+ fr.drawString(str, x / factor, y / factor, colour, shadow);
+ GlStateManager.scale(1 / factor, 1 / factor, 1);
}
public static void drawStringCenteredScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
int newLen = Math.min(strLen, len);
- float fontHeight = 8*factor;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, factor);
+ drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor);
}
public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) {
@@ -63,8 +63,9 @@ public class TextRenderUtils {
int tooltipX = mouseX + 12;
if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
tooltipX = mouseX - 16 - tooltipTextWidth;
- if (tooltipX < 4) // if the tooltip doesn't fit on the screen
- {
+ if (
+ tooltipX < 4
+ ) { // if the tooltip doesn't fit on the screen
if (mouseX > screenWidth / 2) {
tooltipTextWidth = mouseX - 12 - 8;
} else {
@@ -153,5 +154,4 @@ public class TextRenderUtils {
}
GlStateManager.disableLighting();
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
index 1584ff4..519aef4 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
@@ -122,8 +122,8 @@ public class SlayerHandler {
public void onChatMessage(ClientChatReceivedEvent event) {
if (event.type != 2) {
Matcher slayerMatcher = SLAYER_PATTERN.matcher(Utils.removeColor(event.message.getUnformattedText()));
- if (slayerMatcher.find()){
- MinecraftForge.EVENT_BUS.post(new SkyBlockEntityKilled(slayerMatcher.group(1).toUpperCase(Locale.ENGLISH)+"_SLAYER", null));
+ if (slayerMatcher.find()) {
+ MinecraftForge.EVENT_BUS.post(new SkyBlockEntityKilled(slayerMatcher.group(1).toUpperCase(Locale.ENGLISH) + "_SLAYER", null));
}
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
index d4af191..40f3334 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
@@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public class MixinNetHandlerPlayClient {
@Inject(method = "handleSetSlot", at = @At("HEAD"))
- public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci){
+ public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
if (SkyblockHud.hasSkyblockScoreboard()) {
Minecraft mc = Minecraft.getMinecraft();
PacketThreadUtil.checkThreadAndEnqueue(packetIn, mc.getNetHandler(), mc);
@@ -39,7 +39,10 @@ public class MixinNetHandlerPlayClient {
if (extraAttributes.hasKey("enchantments")) {
NBTTagCompound enchantments = extraAttributes.getCompoundTag("enchantments");
if (enchantments.getKeySet().size() == 1) {
- for (String e : enchantments.getKeySet()) { specialId = e; break; }
+ for (String e : enchantments.getKeySet()) {
+ specialId = e;
+ break;
+ }
if (specialId != null) number = enchantments.getInteger(specialId);
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
index fc918db..880e2ea 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
@@ -32,7 +32,7 @@ public class GenericOverlays extends Gui {
public static void drawSmallBar(Minecraft mc, int x, int y, double percentage, double max, int fullColor, int loadingColor, int barStyle) {
if (SkyblockHud.hasSkyblockScoreboard()) {
updateBar();
- mc.renderEngine.bindTexture(bars);;
+ mc.renderEngine.bindTexture(bars);
Color color = new Color(percentage == max ? fullColor : loadingColor);
GlStateManager.enableBlend();
RenderUtils.drawTexturedModalRect(x, y, 0, 35, 62, 5);
@@ -48,9 +48,7 @@ public class GenericOverlays extends Gui {
public static void updateBar() {
if (lastBar != SkyblockHud.config.misc.barTexture) {
lastBar = SkyblockHud.config.misc.barTexture;
- if (lastBar == 0) bars = new ResourceLocation("skyblockhud", "bars.png");
- else bars = new ResourceLocation("skyblockhud", "bars_"+lastBar+".png");
+ if (lastBar == 0) bars = new ResourceLocation("skyblockhud", "bars.png"); else bars = new ResourceLocation("skyblockhud", "bars_" + lastBar + ".png");
}
-
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
index 804ac60..81e8ed1 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
@@ -18,12 +18,17 @@ public class TrackerFileLoader {
for (JsonElement element : object.get("trackers").getAsJsonArray()) {
JsonObject tracker = element.getAsJsonObject();
EnumSet<Locations> locations = EnumSet.noneOf(Locations.class);
- tracker.get("location").getAsJsonArray().forEach(l -> {
- Locations location = Locations.get(l.getAsString().toUpperCase(Locale.ENGLISH));
- if (location != Locations.DEFAULT){
- locations.add(location);
- }
- });
+ tracker
+ .get("location")
+ .getAsJsonArray()
+ .forEach(
+ l -> {
+ Locations location = Locations.get(l.getAsString().toUpperCase(Locale.ENGLISH));
+ if (location != Locations.DEFAULT) {
+ locations.add(location);
+ }
+ }
+ );
if (tracker.has("drops")) {
for (JsonElement drop : tracker.get("drops").getAsJsonArray()) {
TrackerHandler.trackerObjects.add(new TrackerObject(drop.getAsJsonObject(), locations));
@@ -38,16 +43,15 @@ public class TrackerFileLoader {
for (TrackerObject trackerObject : TrackerHandler.trackerObjects) {
for (Locations location : trackerObject.getLocations()) {
- if (TrackerHandler.trackers.containsKey(location)){
+ if (TrackerHandler.trackers.containsKey(location)) {
TrackerHandler.trackers.get(location).put(trackerObject.getInternalId(), trackerObject);
- }else {
+ } else {
HashMap<String, TrackerObject> value = new HashMap<>();
value.put(trackerObject.getInternalId(), trackerObject);
TrackerHandler.trackers.put(location, value);
}
}
}
-
}
public static void loadTrackersFile() {
@@ -65,17 +69,19 @@ public class TrackerFileLoader {
private static JsonElement getTrackerFile() {
JsonArray stats = new JsonArray();
- TrackerHandler.trackerObjects.forEach((trackerObject) ->{
- if (trackerObject.getCount() > 0) {
- JsonObject jsonObject = new JsonObject();
- JsonArray locations = new JsonArray();
- trackerObject.getLocations().forEach(l -> locations.add(new JsonPrimitive(l.toString().toUpperCase(Locale.ENGLISH))));
- jsonObject.add("id", new JsonPrimitive(trackerObject.getInternalId()));
- jsonObject.add("locations", locations);
- jsonObject.add("count", new JsonPrimitive(trackerObject.getCount()));
- stats.add(jsonObject);
+ TrackerHandler.trackerObjects.forEach(
+ trackerObject -> {
+ if (trackerObject.getCount() > 0) {
+ JsonObject jsonObject = new JsonObject();
+ JsonArray locations = new JsonArray();
+ trackerObject.getLocations().forEach(l -> locations.add(new JsonPrimitive(l.toString().toUpperCase(Locale.ENGLISH))));
+ jsonObject.add("id", new JsonPrimitive(trackerObject.getInternalId()));
+ jsonObject.add("locations", locations);
+ jsonObject.add("count", new JsonPrimitive(trackerObject.getCount()));
+ stats.add(jsonObject);
+ }
}
- });
+ );
return stats;
}
@@ -90,7 +96,10 @@ public class TrackerFileLoader {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
JsonObject json = gson.fromJson(reader, JsonObject.class);
if (json.has("trackerStats")) {
- json.getAsJsonArray("trackerStats").forEach(element -> {
+ json
+ .getAsJsonArray("trackerStats")
+ .forEach(
+ element -> {
if (element.isJsonObject()) {
JsonObject object = element.getAsJsonObject();
JsonArray locations = object.get("locations").getAsJsonArray();
@@ -100,19 +109,18 @@ public class TrackerFileLoader {
if (!firstLocation.equals(Locations.DEFAULT)) break;
}
- if (firstLocation != null && !firstLocation.equals(Locations.DEFAULT)){
+ if (firstLocation != null && !firstLocation.equals(Locations.DEFAULT)) {
TrackerHandler.trackers.get(firstLocation).get(object.get("id").getAsString()).setCount(object.get("count").getAsInt());
}
}
- });
-
- TrackerHandler.trackers.forEach((location, map) -> {
- TrackerHandler.trackers.put(location,
- TrackerHandler.sortTrackers(map,
- (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())
- )
+ }
);
- });
+
+ TrackerHandler.trackers.forEach(
+ (location, map) -> {
+ TrackerHandler.trackers.put(location, TrackerHandler.sortTrackers(map, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())));
+ }
+ );
}
}
} catch (Exception ignored) {}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
index 9832c4b..50dd04c 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
@@ -21,7 +21,7 @@ public class TrackerHandler extends Gui {
public static Set<TrackerObject> trackerObjects = new HashSet<>();
public static Map<Locations, Map<String, TrackerObject>> trackers = new HashMap<>();
- public static <K,V> Map<K, V> sortTrackers(Map<K, V> map, Comparator<? super Map.Entry<K, V>> comparator) {
+ public static <K, V> Map<K, V> sortTrackers(Map<K, V> map, Comparator<? super Map.Entry<K, V>> comparator) {
List<Map.Entry<K, V>> list = new ArrayList<>(map.entrySet());
list.sort(comparator);
@@ -46,7 +46,6 @@ public class TrackerHandler extends Gui {
object.increaseCount(amount);
trackers.put(LocationHandler.getCurrentLocation(), sortTrackers(trackerMap, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())));
}
-
}
}
@@ -61,12 +60,12 @@ public class TrackerHandler extends Gui {
}
@SubscribeEvent
- public void onSbEntityDeath(SkyBlockEntityKilled event){
+ public void onSbEntityDeath(SkyBlockEntityKilled event) {
System.out.println(event.id);
if (SkyblockHud.hasSkyblockScoreboard() && trackers.containsKey(LocationHandler.getCurrentLocation())) {
Map<String, TrackerObject> trackerMap = trackers.get(LocationHandler.getCurrentLocation());
- if (trackerMap.containsKey("ENTITY:"+event.id)){
- TrackerObject object = trackerMap.get("ENTITY:"+event.id);
+ if (trackerMap.containsKey("ENTITY:" + event.id)) {
+ TrackerObject object = trackerMap.get("ENTITY:" + event.id);
object.increaseCount();
trackers.put(LocationHandler.getCurrentLocation(), sortTrackers(trackerMap, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())));
}
@@ -75,7 +74,7 @@ public class TrackerHandler extends Gui {
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
- if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackers.containsKey(LocationHandler.getCurrentLocation()),!SkyblockHud.config.trackers.hideTracker)) {
+ if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackers.containsKey(LocationHandler.getCurrentLocation()), !SkyblockHud.config.trackers.hideTracker)) {
Map<String, TrackerObject> tracker = trackers.get(LocationHandler.getCurrentLocation());
Minecraft mc = Minecraft.getMinecraft();
@@ -87,7 +86,7 @@ public class TrackerHandler extends Gui {
Gui.drawRect(startPos, y, startPos + 130, y + 10, -1072689136);
mc.fontRendererObj.drawString("Tracker", startPos + 4, y + 1, 0xffffff, false);
y += 10;
- Gui.drawRect(startPos, y, startPos + (tracker.size() >= 6 ? 130 : (tracker.size() * 20)+10), (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), 1610612736);
+ Gui.drawRect(startPos, y, startPos + (tracker.size() >= 6 ? 130 : (tracker.size() * 20) + 10), (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), 1610612736);
int x = startPos + 5;
for (TrackerObject object : tracker.values()) {
String s = Utils.formattedNumber(object.getCount(), 1000);
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java
index 58034d5..6013b09 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java
@@ -19,14 +19,14 @@ public class TrackerObject {
private final boolean isEntity;
private int count;
- public TrackerObject(JsonObject jsonObject, EnumSet<Locations> locations){
+ public TrackerObject(JsonObject jsonObject, EnumSet<Locations> locations) {
this.stack = decodeToItemStack(jsonObject);
this.internalId = jsonObject.get("id").getAsString();
this.isEntity = jsonObject.get("id").getAsString().contains("entity:");
this.locations = locations;
}
- public static ItemStack decodeToItemStack(JsonObject jsonObject){
+ public static ItemStack decodeToItemStack(JsonObject jsonObject) {
jsonObject = jsonObject.getAsJsonObject("displayItem");
int meta = jsonObject.get("meta").getAsInt();
ResourceLocation itemid = new ResourceLocation(jsonObject.get("item").getAsString());
@@ -59,7 +59,7 @@ public class TrackerObject {
}
public void increaseCount(int amount) {
- count+=amount;
+ count += amount;
}
public void increaseCount() {
@@ -89,6 +89,4 @@ public class TrackerObject {
public boolean isEntity() {
return isEntity;
}
-
-
}
diff --git a/src/main/resources/assets/skyblockhud/data/trackers.json b/src/main/resources/assets/skyblockhud/data/trackers.json
index 0832319..b051d0b 100644
--- a/src/main/resources/assets/skyblockhud/data/trackers.json
+++ b/src/main/resources/assets/skyblockhud/data/trackers.json
@@ -156,7 +156,7 @@
}
}
],
- "mobs" : [
+ "mobs": [
{
"id": "entity:WOLF_SLAYER",
"displayItem": {
@@ -235,7 +235,7 @@
}
}
],
- "mobs" : [
+ "mobs": [
{
"id": "entity:SPIDER_SLAYER",
"displayItem": {
@@ -350,7 +350,7 @@
}
}
],
- "mobs" : [
+ "mobs": [
{
"id": "entity:ZOMBIE_SLAYER",
"displayItem": {