aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java1
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/Utils.java10
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java5
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java18
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java27
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java83
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java118
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java26
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java23
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java6
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java44
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java283
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java383
-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.java50
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java14
-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.java22
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java43
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java151
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java81
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java93
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java98
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java36
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java90
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java103
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java8
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java28
-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.java74
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java15
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java22
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java167
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java99
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java94
-rw-r--r--src/main/resources/assets/skyblockhud/data/trackers.json58
-rw-r--r--src/main/resources/assets/skyblockhud/stats.pngbin7673 -> 7709 bytes
-rw-r--r--src/main/resources/mixins.skyblockhud.json1
50 files changed, 1512 insertions, 1126 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java
index cd8c25f..280a18d 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java
@@ -31,7 +31,6 @@ public class GuiTextures {
public static final ResourceLocation overlay = new ResourceLocation("skyblockhud", "stats.png");
public static final ResourceLocation dungeon = new ResourceLocation("skyblockhud", "dungeon.png");
public static final ResourceLocation playerStat = new ResourceLocation("skyblockhud", "playerstats.png");
- public static final ResourceLocation bars = new ResourceLocation("skyblockhud", "bars.png");
public static final ResourceLocation mapOverlay = new ResourceLocation("skyblockhud", "maps/map_overlay.png");
public static final ResourceLocation mining = new ResourceLocation("skyblockhud", "mines.png");
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index 539a42f..1cb00bb 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -3,6 +3,7 @@ package com.thatgravyboat.skyblockhud;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.thatgravyboat.skyblockhud.api.KillTracking;
import com.thatgravyboat.skyblockhud.api.LeaderboardGetter;
import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
import com.thatgravyboat.skyblockhud.commands.Commands;
@@ -17,6 +18,8 @@ import com.thatgravyboat.skyblockhud.overlay.OverlayHud;
import com.thatgravyboat.skyblockhud.overlay.RPGHud;
import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing;
import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler;
+import com.thatgravyboat.skyblockhud.tracker.TrackerFileLoader;
+import com.thatgravyboat.skyblockhud.tracker.TrackerHandler;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.io.*;
@@ -32,11 +35,13 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
+import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import org.lwjgl.input.Keyboard;
@Mod(modid = SkyblockHud.MODID, version = SkyblockHud.VERSION)
@@ -69,10 +74,9 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new MinesHandler());
MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler());
- /* DISABLE UNTIL NEW SYSTEM
MinecraftForge.EVENT_BUS.register(new TrackerHandler());
- MinecraftForge.EVENT_BUS.register(new KillTrackerHandler());
- */
+ MinecraftForge.EVENT_BUS.register(new KillTracking());
+
MinecraftForge.EVENT_BUS.register(new HeldItemHandler());
ClientRegistry.registerKeyBinding(KeyBindings.map);
@@ -99,7 +103,7 @@ public class SkyblockHud {
configDirectory = event.getModConfigurationDirectory();
Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig));
- //Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory())));
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory())));
}
public void saveConfig() {
@@ -122,7 +126,7 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new MiningHud());
}
- /* DISABLE UNTIL NEW SYSTEM
+ // DISABLE UNTIL NEW SYSTEM
@EventHandler
public void loadComplete(FMLLoadCompleteEvent event){
@@ -138,7 +142,7 @@ public class SkyblockHud {
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 b80d5ae..157077b 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
@@ -1,9 +1,13 @@
package com.thatgravyboat.skyblockhud;
+import java.math.RoundingMode;
import java.nio.FloatBuffer;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
+import java.util.Locale;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
@@ -353,4 +357,10 @@ public class Utils {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
+
+ 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);
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java
index 32feb1b..c13a7b8 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java
@@ -7,6 +7,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import net.minecraft.client.Minecraft;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
@@ -32,7 +33,9 @@ public class KillTracking {
System.out.println("----------------------------------------------------------------------------------------------------------------");
System.out.println("Name : " + event.entity.getName());
System.out.println("UUID : " + event.entity.getUniqueID());
- System.out.println("Tag : " + event.entity.serializeNBT());
+ NBTTagCompound compound = new NBTTagCompound();
+ event.entity.writeToNBT(compound);
+ System.out.println("Tag : " + compound);
System.out.println("Damage : " + getDamageSourceString(event.source));
System.out.println("SBH Entity ID: " + EntityTypeRegistry.getEntityId(event.entity));
System.out.println("----------------------------------------------------------------------------------------------------------------");
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 325781c..15fb01a 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java
@@ -1,14 +1,16 @@
package com.thatgravyboat.skyblockhud.api.events;
+import javax.annotation.Nullable;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.common.eventhandler.Event;
public class SkyBlockEntityKilled extends Event {
public String id;
+ @Nullable
public Entity entity;
- public SkyBlockEntityKilled(String id, Entity entity) {
+ public SkyBlockEntityKilled(String id, @Nullable Entity entity) {
this.id = id;
this.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 d1ad8d2..8dc63c8 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java
@@ -4,7 +4,9 @@ import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.location.Locations;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman;
+import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
public class EntityTypeHelper {
@@ -18,4 +20,20 @@ public class EntityTypeHelper {
}
return false;
}
+
+ 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;
+ return zombie.getEquipmentInSlot(3) != null && zombie.getEquipmentInSlot(3).getItem().equals(Items.chainmail_chestplate);
+ }
+ return false;
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java
index 952aaa7..6ff88fa 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java
@@ -6,13 +6,15 @@ import java.util.List;
import java.util.Map;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman;
+import net.minecraft.entity.monster.EntityZombie;
public class EntityTypeRegistry {
private static final Map<Class<? extends Entity>, List<SkyBlockEntity>> entities = Maps.newHashMap();
static {
- entities.put(EntityEnderman.class, ImmutableList.of(SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot)));
+ entities.put(EntityEnderman.class, ImmutableList.of(SkyBlockEntity.of("ZEALOT", EntityTypeHelper::isZealot)));
+ entities.put(EntityZombie.class, ImmutableList.of(SkyBlockEntity.of("CRYPT_GHOUL", EntityTypeHelper::isCrypt)));
}
public static String getEntityId(Entity entity) {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
index 8d84833..9b42192 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
@@ -50,9 +50,9 @@ public class SBHConfig extends Config {
case "map":
editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition);
return;
- // case "tracker":
- // editOverlay(activeConfigCategory, 120, 70, trackers.trackerPosition);
- // return;
+ case "tracker":
+ editOverlay(activeConfigCategory, 130, 70, trackers.trackerPosition);
+ return;
}
}
@@ -84,17 +84,26 @@ public class SBHConfig extends Config {
@Category(name = "Mining", desc = "All Options for the Mining Stuff.")
public Mining mining = new Mining();
- //TODO ENABLED WHEN TRACKER GETS ADDED BACK
- // @Expose
- // @Category(name = "Tracker", desc = "All Options for the Trackers.")
- // public Trackers trackers = new Trackers();
+ @Expose
+ @Category(name = "Tracker", desc = "All Options for the Trackers.")
+ public Trackers trackers = new Trackers();
public static class Misc {
@Expose
- @ConfigOption(name = "Hide Scoreboard", desc = "Hides the scoreboard when in skyblock.")
+ @ConfigOption(name = "Hide Scoreboard", desc = "Hides the scoreboard when in Skyblock.")
@ConfigEditorBoolean
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"}
+ )
+ public int barTexture = 0;
}
public static class MainHud {
@@ -342,6 +351,6 @@ public class SBHConfig extends Config {
@Expose
@ConfigOption(name = "Hide Tracker", desc = "It will still track the data just in case.")
@ConfigEditorBoolean
- public boolean hideTracker = false;
+ public boolean hideTracker = true;
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
index 8bbeaa7..90325f8 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java
@@ -1,8 +1,5 @@
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;
@@ -16,8 +13,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.*;
import java.util.List;
+import java.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -28,6 +25,9 @@ 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 };
@@ -41,6 +41,7 @@ public class SBHConfigEditor extends GuiElement {
private final LerpingInteger categoryScroll = new LerpingInteger(0, 150);
private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig;
+ private TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>();
private HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption = new HashMap<>();
public SBHConfigEditor(Config config) {
@@ -232,14 +233,15 @@ public class SBHConfigEditor extends GuiElement {
ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
int optionWidthDefault = innerRight - innerLeft - 20;
GlStateManager.enableDepth();
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if(!activeAccordions.containsKey(option.accordionId)) {
continue;
}
- optionWidth = optionWidthDefault - 2 * innerPadding;
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding)*(accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
@@ -249,7 +251,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
int optionHeight = editor.getHeight();
@@ -274,14 +280,15 @@ public class SBHConfigEditor extends GuiElement {
GlStateManager.translate(0, 0, 10);
GlStateManager.enableDepth();
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
- optionWidth = optionWidthDefault - 2 * innerPadding;
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
@@ -291,7 +298,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
int optionHeight = editor.getHeight();
@@ -403,10 +414,10 @@ public class SBHConfigEditor extends GuiElement {
int optionY = -newTarget;
if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
}
@@ -418,7 +429,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
optionY += editor.getHeight() + 5;
@@ -468,14 +483,15 @@ public class SBHConfigEditor extends GuiElement {
if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
int optionWidthDefault = innerRight - innerLeft - 20;
ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
- optionWidth = optionWidthDefault - 2 * innerPadding;
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
}
GuiOptionEditor editor = option.editor;
@@ -485,7 +501,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
if (editor.mouseInputOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) {
@@ -500,14 +520,15 @@ public class SBHConfigEditor extends GuiElement {
if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
int optionWidthDefault = innerRight - innerLeft - 20;
ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
- optionWidth = optionWidthDefault - 2 * innerPadding;
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
}
GuiOptionEditor editor = option.editor;
@@ -517,7 +538,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
if (editor.mouseInput((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) {
@@ -544,10 +569,10 @@ public class SBHConfigEditor extends GuiElement {
if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- Set<Integer> activeAccordions = new HashSet<>();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
if (option.accordionId >= 0) {
- if (!activeAccordions.contains(option.accordionId)) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
}
@@ -559,7 +584,11 @@ public class SBHConfigEditor extends GuiElement {
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
- activeAccordions.add(accordion.getAccordionId());
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId)+1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
if (editor.keyboardInput()) {
@@ -570,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 a9d9d5d..f143b97 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
@@ -18,19 +18,31 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL30;
public class BackgroundBlur {
- private static HashMap<Float, Framebuffer> blurOutput = new HashMap<>();
- private static HashMap<Float, Long> lastBlurUse = new HashMap<>();
+ private static class OutputStuff {
+ public Framebuffer framebuffer;
+ public Shader blurShaderHorz = null;
+ public Shader blurShaderVert = null;
+
+ public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) {
+ this.framebuffer = framebuffer;
+ this.blurShaderHorz = blurShaderHorz;
+ this.blurShaderVert = blurShaderVert;
+ }
+ }
+
+ private static final HashMap<Float, OutputStuff> blurOutput = new HashMap<>();
+ private static final HashMap<Float, Long> lastBlurUse = new HashMap<>();
private static long lastBlur = 0;
- private static HashSet<Float> requestedBlurs = new HashSet<>();
+ private static final HashSet<Float> requestedBlurs = new HashSet<>();
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());
}
@@ -57,17 +69,21 @@ public class BackgroundBlur {
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- Framebuffer output = blurOutput.computeIfAbsent(
- blur,
- k -> {
- Framebuffer fb = new Framebuffer(width, height, false);
- fb.setFramebufferFilter(GL11.GL_NEAREST);
- return fb;
- }
- );
+ OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
+ Framebuffer fb = new Framebuffer(width, height, false);
+ fb.setFramebufferFilter(GL11.GL_NEAREST);
+ return new OutputStuff(fb, null, null);
+ });
- output.framebufferWidth = output.framebufferTextureWidth = width;
- output.framebufferHeight = output.framebufferTextureHeight = height;
+ if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ output.framebuffer.createBindFramebuffer(width, height);
+ if(output.blurShaderHorz != null) {
+ output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ if(output.blurShaderVert != null) {
+ output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ }
blurBackground(output, blur);
}
@@ -89,7 +105,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();
}
}
@@ -102,8 +118,6 @@ public class BackgroundBlur {
fogColour |= (int) (event.blue * 255) & 0xFF;
}
- private static Shader blurShaderHorz = null;
- private static Shader blurShaderVert = null;
private static Framebuffer blurOutputHorz = null;
/**
@@ -126,8 +140,8 @@ public class BackgroundBlur {
return projMatrix;
}
- private static void blurBackground(Framebuffer output, float blurFactor) {
- if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ private static void blurBackground(OutputStuff output, float blurFactor) {
+ if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
@@ -139,47 +153,52 @@ 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);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch (Exception ignored) {}
- try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch (Exception ignored) {}
- if (blurShaderHorz != null && blurShaderVert != null) {
- if (blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ if(output.blurShaderHorz == null) {
+ try {
+ 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) { }
+ }
+ if(output.blurShaderVert == null) {
+ try {
+ 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) { }
+ }
+ if(output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
//Corrupted shader?
return;
}
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+ output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+ output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
GL11.glPushMatrix();
- /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
- GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject);
+ 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.framebufferWidth, output.framebufferHeight,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);*/
+ 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
+ GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
- blurShaderHorz.loadShader(0);
- blurShaderVert.loadShader(0);
+ output.blurShaderHorz.loadShader(0);
+ output.blurShaderVert.loadShader(0);
GlStateManager.enableDepth();
GL11.glPopMatrix();
@@ -208,9 +227,9 @@ public class BackgroundBlur {
if (blurOutput.isEmpty()) return;
- Framebuffer fb = blurOutput.get(blurStrength);
- if (fb == null) {
- fb = blurOutput.values().iterator().next();
+ OutputStuff out = blurOutput.get(blurStrength);
+ if(out == null) {
+ out = blurOutput.values().iterator().next();
}
float uMin = x / (float) screenWidth;
@@ -220,10 +239,11 @@ public class BackgroundBlur {
GlStateManager.depthMask(false);
Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour);
- fb.bindFramebufferTexture();
+ out.framebuffer.bindFramebufferTexture();
GlStateManager.color(1f, 1f, 1f, 1f);
RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- fb.unbindFramebufferTexture();
+ 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 3137153..b9f4e79 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
@@ -25,8 +25,9 @@ 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;
}
@@ -39,7 +40,7 @@ public class ChromaColour {
int a = d[3];
int chr = d[4];
- return ((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF));
+ return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
}
public static int getSpeed(String special) {
@@ -47,16 +48,15 @@ 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,14 +67,14 @@ 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));
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
}
public static int rotateHue(int argb, int degrees) {
@@ -85,9 +85,11 @@ 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));
+ 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 0e1694e..6f21e9a 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,4 +83,5 @@ 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 cb9b15a..ff817cf 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
@@ -1,10 +1,10 @@
package com.thatgravyboat.skyblockhud.core;
-public abstract class GuiElement {
+import net.minecraft.client.gui.Gui;
- public abstract void render();
+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 8daf4b1..7c401ed 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,56 +51,58 @@ 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 2092b31..e2d3e0a 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
@@ -18,10 +18,10 @@ import org.lwjgl.opengl.GL11;
public class GuiElementColour extends GuiElement {
- public static final ResourceLocation colour_selector_dot = new ResourceLocation("skyblockhud:core/colour_selector_dot.png");
- public static final ResourceLocation colour_selector_bar = new ResourceLocation("skyblockhud:core/colour_selector_bar.png");
- public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("skyblockhud:core/colour_selector_bar_alpha.png");
- public static final ResourceLocation colour_selector_chroma = new ResourceLocation("skyblockhud:core/colour_selector_chroma.png");
+ public static final ResourceLocation colour_selector_dot = new ResourceLocation("notenoughupdates:core/colour_selector_dot.png");
+ public static final ResourceLocation colour_selector_bar = new ResourceLocation("notenoughupdates:core/colour_selector_bar.png");
+ public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("notenoughupdates:core/colour_selector_bar_alpha.png");
+ public static final ResourceLocation colour_selector_chroma = new ResourceLocation("notenoughupdates:core/colour_selector_chroma.png");
private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker");
private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation("mbcore:dynamic/colourpickervalue");
@@ -30,8 +30,8 @@ public class GuiElementColour extends GuiElement {
private int x;
private int y;
- private final int xSize = 119;
- private final int ySize = 89;
+ private int xSize = 119;
+ private int ySize = 89;
private float wheelAngle = 0;
private float wheelRadius = 0;
@@ -42,11 +42,20 @@ public class GuiElementColour extends GuiElement {
private Runnable closeCallback;
private String colour;
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback) {
+ private final boolean opacitySlider;
+ private final boolean valueSlider;
+
+ 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) {
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;
@@ -56,11 +65,17 @@ public class GuiElementColour extends GuiElement {
Color c = new Color(colour);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
updateAngleAndRadius(hsv);
+
+ this.opacitySlider = opacitySlider;
+ this.valueSlider = valueSlider;
+
+ 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() {
@@ -72,178 +87,219 @@ 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);
- Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
+ int valueOffset = 0;
+ 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);
+ 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);
+ }
- 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 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
+ int opacityOffset = 0;
+ 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);
+
+ 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);
+ }
int chromaSpeed = ChromaColour.getSpeed(colour);
int currentColourChroma = ChromaColour.specialToChromaRGB(colour);
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 + 5 + 10 + 5 + 10 + 5 + 1, y + 5 + 1, x + 5 + 64 + 5 + 10 + 5 + 10 + 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 + 5 + 10 + 5 + 10 + 5 + 1, y + 5 + 27 + 1, x + 5 + 64 + 5 + 10 + 5 + 10 + 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);
- RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
- RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, 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 + 5 + 10 + 5 + 10 + 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 + 5 + 10 + 5 + 10 + 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);
}
- Gui.drawRect(x + 5 + 64 + 5, y + 5 + 64 - (int) (64 * hsv[2]), x + 5 + 64 + 5 + 10, y + 5 + 64 - (int) (64 * hsv[2]) + 1, 0xFF000000);
- Gui.drawRect(x + 5 + 64 + 5 + 10 + 5, y + 5 + 64 - c.getAlpha() / 4, x + 5 + 64 + 5 + 10 + 5 + 10, y + 5 + 64 - c.getAlpha() / 4 - 1, 0xFF000000);
- if (chromaSpeed > 0) {
- Gui.drawRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5, y + 5 + 64 - (int) (chromaSpeed / 255f * 64), x + 5 + 64 + 5 + 10 + 5 + 10 + 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);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 15 + 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 + 30 + 6, 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);
}
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;
- if (y > -5 && y <= 69) {
- if (xValue > 0 && xValue < 10) {
- clickedComponent = 1;
+ int opacityOffset = opacitySlider ? 15 : 0;
+ int valueOffset = valueSlider ? 15 : 0;
+
+ if(y > -5 && y <= 69) {
+ if(valueSlider) {
+ if(xValue > 0 && xValue < 10) {
+ clickedComponent = 1;
+ }
}
- int xOpacity = mouseX - (x + 5 + 64 + 5 + 10 + 5);
+ if(opacitySlider) {
+ int xOpacity = mouseX - (x+5+64+5+valueOffset);
- if (xOpacity > 0 && xOpacity < 10) {
- clickedComponent = 2;
+ if(xOpacity > 0 && xOpacity < 10) {
+ clickedComponent = 2;
+ }
}
}
int chromaSpeed = ChromaColour.getSpeed(colour);
- int xChroma = mouseX - (x + 5 + 64 + 5 + 10 + 5 + 10 + 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);
@@ -256,7 +312,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);
@@ -264,16 +320,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;
@@ -283,21 +339,22 @@ 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;
@@ -306,7 +363,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;
@@ -315,7 +372,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 {
@@ -329,11 +386,13 @@ 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 867efc1..b16f672 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java
@@ -14,6 +14,8 @@ import net.minecraft.client.renderer.GlStateManager;
public class GuiElementTextField {
+ public static final int SCISSOR_TEXT = 0b10000000;
+ public static final int DISABLE_BG = 0b1000000;
public static final int SCALE_TEXT = 0b100000;
public static final int NUM_ONLY = 0b10000;
public static final int NO_SPACE = 0b01000;
@@ -33,8 +35,10 @@ public class GuiElementTextField {
private int y;
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;
@@ -60,22 +64,38 @@ public class GuiElementTextField {
this.customBorderColour = colour;
}
+ public void setCustomTextColour(int colour) {
+ this.customTextColour = colour;
+ }
+
public String getText() {
return textField.getText();
}
+ public String getTextDisplay() {
+ String textNoColour = getText();
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
+ if(!matcher.find()) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6"+code);
+ }
+
+ return textNoColour;
+ }
+
public void setPrependText(String text) {
this.prependText = text;
}
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;
}
@@ -90,101 +110,100 @@ public class GuiElementTextField {
public void setFocus(boolean focus) {
this.focus = 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() {
return (options & SCALE_TEXT) != 0;
}
- private float getStringWidth(String str) {
- if (isScaling()) {
- return (Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * getScaleFactor(str));
- } else {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
- }
- }
+ private static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)");
public int getCursorPos(int mouseX, int mouseY) {
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);
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)");
String text = renderText;
String textNoColour = renderText;
- if ((options & COLOUR) != 0) {
- while (true) {
- Matcher matcher = patternControlCode.matcher(text);
- if (!matcher.find() || matcher.groupCount() < 1) break;
+ if((options & COLOUR) != 0) {
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
+ if(!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ if(code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ }
}
}
- while (true) {
- Matcher matcher = patternControlCode.matcher(textNoColour);
- if (!matcher.find() || matcher.groupCount() < 1) break;
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
+ 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;
@@ -194,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));
@@ -212,42 +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
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
+ 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);
- text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ if(code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ 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");
@@ -255,70 +278,74 @@ 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);
@@ -328,30 +355,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') {
+ 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) == '*') {
+ String before = textField.getText().substring(0, pos);
+ String after = "";
+ if(pos+2 < textField.getText().length()) {
+ after = textField.getText().substring(pos+2);
+ }
+ textField.setText(before + "\u272A" + after);
+ 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);
}
}
@@ -361,7 +405,8 @@ 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();
@@ -370,110 +415,140 @@ 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;
}
- //bar background
- Gui.drawRect(x - paddingUnscaled, y - paddingUnscaled, x + searchBarXSize + paddingUnscaled, bottomTextBox + paddingUnscaled, borderColour);
- Gui.drawRect(x, y, x + searchBarXSize, bottomTextBox, Color.BLACK.getRGB());
+ 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());
+ }
//bar text
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
-
String text = renderText;
String textNoColor = renderText;
- if ((options & COLOUR) != 0) {
- while (true) {
- Matcher matcher = patternControlCode.matcher(text);
- if (!matcher.find() || matcher.groupCount() < 1) break;
+ if((options & COLOUR) != 0) {
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
+ if(!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ if(code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ }
}
}
- while (true) {
- Matcher matcher = patternControlCode.matcher(textNoColor);
- if (!matcher.find() || matcher.groupCount() < 1) break;
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColor);
+ 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, Color.WHITE.getRGB());
+ 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 {
- Minecraft.getMinecraft().fontRendererObj.drawString(StringUtils.trimToWidth(texts[yOffI], searchBarXSize - 10), x + 5, y + (searchBarYSize - 8) / 2 + yOff, Color.WHITE.getRGB());
+ 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);
+ }
+
}
}
- 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()) {
- System.out.println("Start");
- 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;
@@ -481,21 +556,25 @@ public class GuiElementTextField {
continue;
}
- //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c;
-
- System.out.println("Adding len for char:" + c + ":" + Integer.toHexString(c));
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 dbbca74..40f8c0e 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java
@@ -2,5 +2,7 @@ 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
new file mode 100644
index 0000000..dfd16be
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java
@@ -0,0 +1,50 @@
+package com.thatgravyboat.skyblockhud.core.config;
+
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+
+public class KeybindHelper {
+
+ public static String getKeyName(int keyCode) {
+ if(keyCode == 0) {
+ return "NONE";
+ } else if(keyCode < 0) {
+ return "Button "+(keyCode+101);
+ } else {
+ String keyName = Keyboard.getKeyName(keyCode);
+ if(keyName == null) {
+ keyName = "???";
+ } else if(keyName.equalsIgnoreCase("LMENU")) {
+ keyName = "LALT";
+ } else if(keyName.equalsIgnoreCase("RMENU")) {
+ keyName = "RALT";
+ }
+ return keyName;
+ }
+ }
+
+ public static boolean isKeyValid(int keyCode) {
+ return keyCode != 0;
+ }
+
+ public static boolean isKeyDown(int keyCode) {
+ if(!isKeyValid(keyCode)) {
+ return false;
+ } else if(keyCode < 0) {
+ return Mouse.isButtonDown(keyCode+100);
+ } else {
+ return Keyboard.isKeyDown(keyCode);
+ }
+ }
+
+ public static boolean isKeyPressed(int keyCode) {
+ if(!isKeyValid(keyCode)) {
+ return false;
+ } 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
new file mode 100644
index 0000000..48c12cb
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java
@@ -0,0 +1,14 @@
+package com.thatgravyboat.skyblockhud.core.config.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+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 6cae226..9c7e468 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,27 +21,28 @@ public abstract class GuiOptionEditor {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
RenderUtils.drawFloatingRectDark(x, y, width, height, true);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name, fr, x + width / 6f, 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();
}
@@ -51,12 +52,11 @@ 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 dad85a6..c2b129d 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,25 +47,27 @@ 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 4167e06..3ea70c0 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,7 +9,8 @@ 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
@@ -17,16 +18,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 1950c27..cbd450f 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,8 +1,5 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
-import static com.thatgravyboat.skyblockhud.GuiTextures.button_tex;
-
-import com.thatgravyboat.skyblockhud.core.ChromaColour;
import com.thatgravyboat.skyblockhud.core.config.Config;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
@@ -11,9 +8,11 @@ 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 final String runnableId;
+ private String runnableId;
private String buttonText;
private Config config;
@@ -23,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
@@ -34,18 +33,21 @@ 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 95bc868..950ab87 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,6 +1,5 @@
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;
@@ -10,6 +9,8 @@ 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;
@@ -17,7 +18,8 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
super(option);
- this.chromaColour = (String) option.get();
+
+ this.chromaColour = (String)option.get();
}
@Override
@@ -29,39 +31,37 @@ 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 / 6f - 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) {
- return (colourElement != null && colourElement.mouseInput(mouseX, mouseY));
+ if(colourElement != null && colourElement.mouseInput(mouseX, mouseY)) {
+ return true;
+ }
+ return false;
}
@Override
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,6 +69,11 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- return 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 e0a9064..9cefbe1 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,7 +1,5 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
-import static com.thatgravyboat.skyblockhud.GuiTextures.button_tex;
-
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.lerp.LerpUtils;
@@ -19,6 +17,8 @@ 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,6 +37,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public GuiOptionEditorDraggableList(ConfigProcessor.ProcessedOption option, String[] exampleText) {
super(option);
+
this.exampleText = exampleText;
this.activeText = (List<Integer>) option.get();
}
@@ -45,7 +46,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;
}
@@ -61,34 +62,42 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x + width / 6f - 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 / 6f, 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();
- float greenBlue = LerpUtils.clampZeroOne(((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f);
- GlStateManager.color(1, greenBlue, greenBlue, 1);
+ 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);
+ GlStateManager.color(1, greenBlue, greenBlue, 1);
+ }
Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE);
- Utils.drawTexturedRect(x + width / 6f + 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 / 2f - 4, 0xffffff, true);
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x+10, y+50+yOff + ySize/2 - 4, 0xffffff, true);
}
yOff += ySize;
@@ -99,49 +108,50 @@ 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;
@@ -152,58 +162,67 @@ 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 / 2f - 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;
}
@@ -215,21 +234,25 @@ 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;
@@ -239,11 +262,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 260c2ad..2b7a654 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
@@ -6,9 +6,7 @@ import com.thatgravyboat.skyblockhud.core.util.render.TextRenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
-import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.GL11;
public class GuiOptionEditorDropdown extends GuiOptionEditor {
@@ -19,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;
@@ -29,65 +27,68 @@ 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);
}
}
@@ -95,11 +96,12 @@ 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;
}
@@ -112,18 +114,19 @@ 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
new file mode 100644
index 0000000..13175a6
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java
@@ -0,0 +1,93 @@
+package com.thatgravyboat.skyblockhud.core.config.gui;
+
+import com.thatgravyboat.skyblockhud.core.config.KeybindHelper;
+import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
+import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
+import com.thatgravyboat.skyblockhud.core.util.render.TextRenderUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ResourceLocation;
+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");
+
+ private int keyCode;
+ private int defaultKeyCode;
+ private boolean editingKeycode;
+
+ public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int keyCode, int defaultKeyCode) {
+ super(option);
+ this.keyCode = keyCode;
+ this.defaultKeyCode = defaultKeyCode;
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+
+ int height = getHeight();
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
+ 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);
+
+ 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);
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if(Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
+ editingKeycode = false;
+ keyCode = Mouse.getEventButton()-100;
+ option.set(keyCode);
+ return true;
+ }
+
+ 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) {
+ 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) {
+ keyCode = defaultKeyCode;
+ option.set(keyCode);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if(editingKeycode) {
+ editingKeycode = false;
+ if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ keyCode = 0;
+ } else {
+ keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
+ }
+ option.set(keyCode);
+ return true;
+ }
+ return false;
+ }
+}
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 49376e4..0321e34 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
@@ -1,6 +1,5 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
-import com.thatgravyboat.skyblockhud.core.GuiElementBoolean;
import com.thatgravyboat.skyblockhud.core.GuiElementTextField;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
import com.thatgravyboat.skyblockhud.core.util.GuiElementSlider;
@@ -15,42 +14,33 @@ 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
@@ -58,52 +48,54 @@ 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;
}
@@ -115,18 +107,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);
}
@@ -134,4 +126,6 @@ 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 e2f96f9..1f8355e 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
@@ -1,9 +1,7 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
-import com.thatgravyboat.skyblockhud.core.GuiElementBoolean;
import com.thatgravyboat.skyblockhud.core.GuiElementTextField;
import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor;
-import com.thatgravyboat.skyblockhud.core.util.GuiElementSlider;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -14,7 +12,8 @@ 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
@@ -22,35 +21,36 @@ 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 +62,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,4 +77,6 @@ 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 1f31ec7..6aeb847 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,5 +1,6 @@
package com.thatgravyboat.skyblockhud.core.config.gui;
+
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.core.config.Position;
import java.io.IOException;
@@ -7,7 +8,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -26,10 +26,13 @@ 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 == -1 ? this.width : elementWidth;
+ this.elementWidth = elementWidth;
this.elementHeight = elementHeight;
this.renderCallback = renderCallback;
this.positionChangedCallback = positionChangedCallback;
@@ -51,7 +54,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());
@@ -64,7 +67,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);
}
@@ -74,26 +77,28 @@ 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() / 2f, 8, true, 0xffffff);
- Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth() / 2f, 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());
@@ -103,16 +108,17 @@ 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);
}
}
@@ -122,18 +128,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()));
}
}
@@ -150,9 +156,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());
@@ -164,7 +170,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 f1f8733..725c846 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
@@ -2,7 +2,6 @@ package com.thatgravyboat.skyblockhud.core.config.struct;
import com.google.gson.annotations.Expose;
import com.thatgravyboat.skyblockhud.core.config.Config;
-import com.thatgravyboat.skyblockhud.core.config.Config;
import com.thatgravyboat.skyblockhud.core.config.annotations.*;
import com.thatgravyboat.skyblockhud.core.config.gui.*;
import java.lang.reflect.Field;
@@ -12,7 +11,6 @@ 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<>();
@@ -24,7 +22,6 @@ public class ConfigProcessor {
}
public static class ProcessedOption {
-
public final String name;
public final String desc;
public final int subcategoryId;
@@ -47,20 +44,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;
}
@@ -69,82 +66,102 @@ 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 (optionField.isAnnotationPresent(ConfigEditorButton.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());
+ }
+ 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;
}
@@ -152,10 +169,11 @@ 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 9d9fcbd..32b0236 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java
@@ -1,7 +1,5 @@
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;
@@ -11,6 +9,8 @@ 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,8 +27,9 @@ 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;
@@ -50,62 +51,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 - 4) / 2f, 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;
}
@@ -117,4 +118,5 @@ public class GuiElementSlider extends GuiElement {
public boolean keyboardInput() {
return false;
}
+
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java
deleted file mode 100644
index 0ee34a1..0000000
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.thatgravyboat.skyblockhud.core.util;
-
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.IntBuffer;
-import java.nio.file.Files;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import javax.imageio.ImageIO;
-import net.minecraft.client.Minecraft;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.BufferUtils;
-import org.lwjgl.input.Cursor;
-import org.lwjgl.input.Mouse;
-
-public class MiscUtils {
-
- public static void copyToClipboard(String str) {
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(str), null);
- }
-
- private static void unzip(InputStream src, File dest) {
- //buffer for read and write data to file
- byte[] buffer = new byte[1024];
- try {
- ZipInputStream zis = new ZipInputStream(src);
- ZipEntry ze = zis.getNextEntry();
- while (ze != null) {
- if (!ze.isDirectory()) {
- String fileName = ze.getName();
- File newFile = new File(dest, fileName);
- //create directories for sub directories in zip
- new File(newFile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- }
- //close this ZipEntry
- zis.closeEntry();
- ze = zis.getNextEntry();
- }
- //close last ZipEntry
- zis.closeEntry();
- zis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static void recursiveDelete(File file) {
- if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
- for (File child : file.listFiles()) {
- recursiveDelete(child);
- }
- }
- file.delete();
- }
-
- private static String currentCursor = null;
-
- public static void resetCursor() {
- if (currentCursor == null) {
- return;
- }
- currentCursor = null;
- try {
- Mouse.setNativeCursor(null);
- } catch (Exception ignored) {}
- }
-
- public static void setCursor(ResourceLocation loc, int hotspotX, int hotspotY) {
- if (currentCursor != null && loc.getResourcePath().equals(currentCursor)) {
- return;
- }
- currentCursor = loc.getResourcePath();
- try {
- BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream());
- int maxSize = Cursor.getMaxCursorSize();
- IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize);
- for (int i = 0; i < maxSize * maxSize; i++) {
- int cursorX = i % maxSize;
- int cursorY = i / maxSize;
- if (cursorX >= image.getWidth() || cursorY >= image.getHeight()) {
- buffer.put(0x00000000);
- } else {
- buffer.put(image.getRGB(cursorX, image.getHeight() - 1 - cursorY));
- }
- }
- buffer.flip();
- Mouse.setNativeCursor(new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1, buffer, null));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java
deleted file mode 100644
index f13fbc7..0000000
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.thatgravyboat.skyblockhud.core.util;
-
-import com.google.common.base.Splitter;
-
-public class Splitters {
-
- public static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');
-}
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 5b34cb1..734d845 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java
@@ -1,37 +1,9 @@
package com.thatgravyboat.skyblockhud.core.util;
-import com.google.common.collect.Sets;
-import java.util.Set;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-
public class StringUtils {
- public static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https");
-
public static String cleanColour(String in) {
return in.replaceAll("(?i)\\u00A7.", "");
}
- public static String cleanColourNotModifiers(String in) {
- return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r");
- }
-
- public static String trimToWidth(String str, int len) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- String trim = fr.trimStringToWidth(str, len);
-
- if (str.length() != trim.length() && !trim.endsWith(" ")) {
- char next = str.charAt(trim.length());
- if (next != ' ') {
- String[] split = trim.split(" ");
- String last = split[split.length - 1];
- if (last.length() < 8) {
- trim = trim.substring(0, trim.length() - last.length());
- }
- }
- }
-
- return trim;
- }
}
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 1b88f5a..e742ab1 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,19 +7,20 @@ 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 edf129b..4831956 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 0bae869..48ae5ad 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 7745562..85e67e7 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
@@ -1,100 +1,44 @@
package com.thatgravyboat.skyblockhud.core.util.render;
-import com.thatgravyboat.skyblockhud.core.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-import org.lwjgl.opengl.GL11;
public class TextRenderUtils {
public static int getCharVertLen(char c) {
- if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
return 5;
} else {
return 7;
}
}
- public static float getVerticalHeight(String str) {
- str = StringUtils.cleanColour(str);
- float height = 0;
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
- height += charHeight + 1.5f;
- }
- return height;
- }
-
- public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- String format = FontRenderer.getFormatFromString(str);
- str = StringUtils.cleanColour(str);
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
-
- int charHeight = getCharVertLen(c);
- int charWidth = fr.getCharWidth(c);
- fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow);
-
- y += charHeight + 1.5f;
- }
- }
-
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);
}
- public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- int strLen = fr.getStringWidth(str);
-
- float x2 = x - strLen / 2f;
- float y2 = y - fr.FONT_HEIGHT / 2f;
-
- GL11.glTranslatef(x2, y2, 0);
- fr.drawString(str, 0, 0, colour, shadow);
- GL11.glTranslatef(-x2, -y2, 0);
- }
-
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;
-
- drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor);
- }
-
- public static void renderToolTip(ItemStack stack, int mouseX, int mouseY, int screenWidth, int screenHeight, FontRenderer fontStd) {
- List<String> list = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
+ float fontHeight = 8*factor;
- for (int i = 0; i < list.size(); ++i) {
- if (i == 0) {
- list.set(i, stack.getRarity().rarityColor + list.get(i));
- } else {
- list.set(i, EnumChatFormatting.GRAY + list.get(i));
- }
- }
-
- FontRenderer font = stack.getItem().getFontRenderer(stack);
- drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font);
+ 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) {
@@ -119,7 +63,8 @@ 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 {
@@ -208,4 +153,5 @@ public class TextRenderUtils {
}
GlStateManager.disableLighting();
}
+
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java
index d6e4fd6..4e9c6c0 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java
@@ -28,7 +28,7 @@ public class CrystalWaypoints {
public static final HashMap<String, BlockPos> waypoints = new HashMap<>();
- private static final Set<Locations> IMPORTANT_WAYPOINTS = Sets.newHashSet(Locations.GOBLINQUEENSDEN, Locations.LOSTPRECURSORCITY, Locations.JUNGLETEMPLE, Locations.MINESOFDIVAN);
+ private static final Set<Locations> IMPORTANT_WAYPOINTS = Sets.newHashSet(Locations.GOBLINQUEENSDEN, Locations.LOSTPRECURSORCITY, Locations.JUNGLETEMPLE, Locations.MINESOFDIVAN, Locations.KHAZADDM, Locations.FAIRYGROTTO);
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
index 49b2928..1584ff4 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java
@@ -3,15 +3,20 @@ package com.thatgravyboat.skyblockhud.handlers;
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
+import com.thatgravyboat.skyblockhud.api.events.SkyBlockEntityKilled;
import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class SlayerHandler {
private static final Pattern KILLS_REGEX = Pattern.compile("(\\d+)/(\\d+) kills?");
+ private static final Pattern SLAYER_PATTERN = Pattern.compile("Talk to Maddox to claim your ([A-Za-z]+) Slayer XP!");
public enum slayerTypes {
ZOMBIE(34, "Revenant Horror"),
@@ -112,4 +117,14 @@ public class SlayerHandler {
}
}
}
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ 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));
+ }
+ }
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
index d8f9d7b..35791e8 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
@@ -105,7 +105,7 @@ public class MinesHandler {
if (event.formattedLine.equalsIgnoreCase("wind compass")) {
MinesHandler.currentEvent = Event.WIND;
}
- if (event.formattedLine.equalsIgnoreCase("nearby players")) {
+ if (event.formattedLine.toLowerCase(Locale.ENGLISH).contains("nearby players")) {
MinesHandler.currentEvent = Event.TOGETHER;
try {
MinesHandler.eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("nearby players", ""));
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
index b6cdb32..d4af191 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
@@ -1,6 +1,13 @@
package com.thatgravyboat.skyblockhud.mixins;
+import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.tracker.TrackerHandler;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.PacketThreadUtil;
+import net.minecraft.network.play.server.S2FPacketSetSlot;
import net.minecraft.network.play.server.S3EPacketTeams;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.scoreboard.Scoreboard;
@@ -13,7 +20,6 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(NetHandlerPlayClient.class)
public class MixinNetHandlerPlayClient {
- /* DISABLE UNTIL NEW SYSTEM
@Inject(method = "handleSetSlot", at = @At("HEAD"))
public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci){
if (SkyblockHud.hasSkyblockScoreboard()) {
@@ -28,22 +34,21 @@ public class MixinNetHandlerPlayClient {
String id = extraAttributes.getString("id");
ItemStack slotStack = Minecraft.getMinecraft().thePlayer.inventoryContainer.getSlot(packetIn.func_149173_d()).getStack();
int changeAmount = stack.stackSize - (slotStack == null ? 0 : slotStack.stackSize);
- String eId = null;
- int eLvl = -1;
+ String specialId = null;
+ int number = -1;
if (extraAttributes.hasKey("enchantments")) {
NBTTagCompound enchantments = extraAttributes.getCompoundTag("enchantments");
if (enchantments.getKeySet().size() == 1) {
- for (String e : enchantments.getKeySet()) { eId = e; break; }
- if (eId != null) eLvl = enchantments.getInteger(eId);
+ for (String e : enchantments.getKeySet()) { specialId = e; break; }
+ if (specialId != null) number = enchantments.getInteger(specialId);
}
}
- TrackerHandler.onItemAdded(id, changeAmount, eId, eLvl);
+ TrackerHandler.onItemAdded(id, changeAmount, specialId, number);
}
}
}
}
}
- */
@Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
public void handleTeams(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard) {
@@ -53,6 +58,7 @@ public class MixinNetHandlerPlayClient {
@Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 6, shift = At.Shift.BEFORE), cancellable = true)
public void handleTeamRemove(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard, ScorePlayerTeam scoreplayerteam) {
+ //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things.
if (scoreplayerteam == null) ci.cancel();
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
index eeb48e1..fc918db 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java
@@ -1,18 +1,22 @@
package com.thatgravyboat.skyblockhud.overlay;
-import com.thatgravyboat.skyblockhud.GuiTextures;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils;
-import java.awt.Color;
+import java.awt.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ResourceLocation;
public class GenericOverlays extends Gui {
+ public static int lastBar = 0;
+ public static ResourceLocation bars = new ResourceLocation("skyblockhud", "bars.png");
+
public static void drawLargeBar(Minecraft mc, int x, int y, float percentage, float max, int fullColor, int loadingColor, int barStyle) {
if (SkyblockHud.hasSkyblockScoreboard()) {
- mc.renderEngine.bindTexture(GuiTextures.bars);
+ updateBar();
+ mc.renderEngine.bindTexture(bars);
Color color = new Color(percentage == max ? fullColor : loadingColor);
RenderUtils.drawTexturedModalRect(x, y, 0, 0, 182, 5);
@@ -27,7 +31,8 @@ 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()) {
- mc.renderEngine.bindTexture(GuiTextures.bars);
+ updateBar();
+ mc.renderEngine.bindTexture(bars);;
Color color = new Color(percentage == max ? fullColor : loadingColor);
GlStateManager.enableBlend();
RenderUtils.drawTexturedModalRect(x, y, 0, 35, 62, 5);
@@ -39,4 +44,13 @@ 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");
+ }
+
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
index 624ca60..804ac60 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
@@ -4,108 +4,55 @@ import com.google.gson.*;
import com.thatgravyboat.skyblockhud.location.Locations;
import java.io.*;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.Locale;
import net.minecraft.client.Minecraft;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTBase;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
public class TrackerFileLoader {
private static final Gson gson = new GsonBuilder().create();
- public static ItemStack getDisplayItem(JsonObject jsonObject) {
- int meta = jsonObject.get("meta").getAsInt();
- String displayItemId = jsonObject.get("item").getAsString();
- Item item = Item.itemRegistry.getObject(new ResourceLocation(displayItemId));
- ItemStack stack = new ItemStack(item, 0, meta);
- if (jsonObject.has("skullData") && displayItemId.equals("minecraft:skull") && meta == 3) {
- stack.setTagInfo("SkullOwner", getSkullTag(jsonObject.getAsJsonObject("skullData")));
- }
- if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) stack.setTagInfo("ench", new NBTTagList());
- return stack;
- }
-
- public static NBTBase getSkullTag(JsonObject skullObject) {
- NBTTagCompound skullOwner = new NBTTagCompound();
- NBTTagCompound properties = new NBTTagCompound();
- NBTTagList textures = new NBTTagList();
- NBTTagCompound value = new NBTTagCompound();
-
- skullOwner.setString("Id", skullObject.get("id").getAsString());
-
- value.setString("Value", skullObject.get("texture").getAsString());
- textures.appendTag(value);
-
- properties.setTag("textures", textures);
-
- skullOwner.setTag("Properties", properties);
- return skullOwner;
- }
-
private static void loadTrackers(JsonObject object) {
for (JsonElement element : object.get("trackers").getAsJsonArray()) {
JsonObject tracker = element.getAsJsonObject();
- StringBuilder builder = new StringBuilder();
- tracker.get("location").getAsJsonArray().forEach(loc -> builder.append(loc.getAsString()));
- String location = builder.toString();
-
- Map<String, ItemStack> stacks = new HashMap<>();
- for (JsonElement drop : tracker.get("drops").getAsJsonArray()) {
- JsonObject dropObject = drop.getAsJsonObject();
-
- //Display Item Creation
- ItemStack stack = getDisplayItem(dropObject.getAsJsonObject("displayItem"));
- String itemId = dropObject.get("id").getAsString();
-
- stacks.put(itemId, stack);
+ 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);
+ }
+ });
+ if (tracker.has("drops")) {
+ for (JsonElement drop : tracker.get("drops").getAsJsonArray()) {
+ TrackerHandler.trackerObjects.add(new TrackerObject(drop.getAsJsonObject(), locations));
+ }
}
-
- String event = tracker.has("event") ? tracker.get("event").getAsString() : null;
-
- Map<String, Map<String, ItemStack>> events = new HashMap<>();
- events.put(event, stacks);
-
- if (TrackerHandler.trackers.containsKey(location)) {
- TrackerHandler.trackers.get(location).dropTrackers.put(event, stacks);
- } else {
- TrackerHandler.trackers.putIfAbsent(location, new TrackerHandler.TrackerData(events));
+ if (tracker.has("mobs")) {
+ for (JsonElement mob : tracker.get("mobs").getAsJsonArray()) {
+ TrackerHandler.trackerObjects.add(new TrackerObject(mob.getAsJsonObject(), locations));
+ }
}
+ }
- tracker.get("location").getAsJsonArray().forEach(loc -> TrackerHandler.trackerIds.put(Locations.get(loc.getAsString()), location));
+ for (TrackerObject trackerObject : TrackerHandler.trackerObjects) {
+ for (Locations location : trackerObject.getLocations()) {
+ if (TrackerHandler.trackers.containsKey(location)){
+ TrackerHandler.trackers.get(location).put(trackerObject.getInternalId(), trackerObject);
+ }else {
+ HashMap<String, TrackerObject> value = new HashMap<>();
+ value.put(trackerObject.getInternalId(), trackerObject);
+ TrackerHandler.trackers.put(location, value);
+ }
+ }
}
- }
- private static JsonElement getTrackerFile() {
- List<JsonObject> trackerStats = new ArrayList<>();
- TrackerHandler.trackers.forEach(
- (locations, trackerData) ->
- trackerData.dropTrackers.forEach(
- (event, drops) -> {
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty("location", locations);
-
- if (event == null) jsonObject.add("event", new JsonNull()); else jsonObject.addProperty("event", event);
-
- JsonObject dropsData = new JsonObject();
- drops.forEach((s, stack) -> dropsData.addProperty(s, stack.stackSize));
- jsonObject.add("drops", dropsData);
- trackerStats.add(jsonObject);
- }
- )
- );
- JsonArray stats = new JsonArray();
- trackerStats.forEach(stats::add);
- return stats;
}
public static void loadTrackersFile() {
+ TrackerHandler.trackers.clear();
+ TrackerHandler.trackerObjects.clear();
try {
ResourceLocation trackers = new ResourceLocation("skyblockhud:data/trackers.json");
InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(trackers).getInputStream();
@@ -116,6 +63,22 @@ public class TrackerFileLoader {
} catch (Exception ignored) {}
}
+ 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);
+ }
+ });
+ return stats;
+ }
+
public static boolean loadTrackerStatsFile(File configDirectory) {
File configFile = new File(configDirectory, "sbh-trackers-stats.json");
@@ -127,31 +90,29 @@ 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();
- String location = object.get("location").getAsString();
- Map<String, Map<String, ItemStack>> trackers = TrackerHandler.trackers.get(location).dropTrackers;
-
- JsonElement event = object.get("event");
- String eventString = event == null || event.isJsonNull() ? null : event.getAsString();
- Map<String, ItemStack> drops = trackers.get(eventString);
-
- if (drops != null) {
- for (Map.Entry<String, JsonElement> drop : object.getAsJsonObject("drops").entrySet()) {
- if (drops.containsKey(drop.getKey())) {
- drops.get(drop.getKey()).stackSize = drop.getValue().getAsInt();
- }
- }
- drops = TrackerHandler.sortTrackers(drops);
- trackers.put(eventString, drops);
+ JsonArray locations = object.get("locations").getAsJsonArray();
+ Locations firstLocation = null;
+ for (JsonElement location : locations) {
+ firstLocation = Locations.get(location.getAsString());
+ if (!firstLocation.equals(Locations.DEFAULT)) break;
+ }
+
+ 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())
+ )
);
+ });
}
}
} 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 c40924a..9832c4b 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
@@ -2,10 +2,10 @@ package com.thatgravyboat.skyblockhud.tracker;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.Utils;
+import com.thatgravyboat.skyblockhud.api.events.SkyBlockEntityKilled;
import com.thatgravyboat.skyblockhud.core.config.Position;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.location.Locations;
-import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler;
import java.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
@@ -16,57 +16,37 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-public class TrackerHandler {
+public class TrackerHandler extends Gui {
- public static class TrackerData {
+ public static Set<TrackerObject> trackerObjects = new HashSet<>();
+ public static Map<Locations, Map<String, TrackerObject>> trackers = new HashMap<>();
- public Map<String, Map<String, ItemStack>> dropTrackers;
+ 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);
- public TrackerData(Map<String, Map<String, ItemStack>> trackers) {
- this.dropTrackers = trackers;
- }
-
- public String getDropId(String event) {
- if (event == null || event.isEmpty() || !eventGoing() || !dropTrackers.containsKey(event.toLowerCase().trim())) return null;
- return event.toLowerCase().trim();
- }
-
- private boolean eventGoing() {
- return SeasonDateHandler.getCurrentEventTime().trim().toLowerCase().contains("ends in");
- }
- }
-
- public static Map<String, TrackerData> trackers = new HashMap<>();
- public static Map<Locations, String> trackerIds = new HashMap<>();
-
- public static Map<String, ItemStack> sortTrackers(Map<String, ItemStack> map) {
- List<Map.Entry<String, ItemStack>> list = new ArrayList<>(map.entrySet());
- list.sort((entry1, entry2) -> Integer.compare(entry2.getValue().stackSize, entry1.getValue().stackSize));
-
- Map<String, ItemStack> result = new LinkedHashMap<>();
- for (Map.Entry<String, ItemStack> entry : list) {
+ Map<K, V> result = new LinkedHashMap<>();
+ for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
- public static void onItemAdded(String id, int amount, String enchant, int level) {
- if (SkyblockHud.hasSkyblockScoreboard() && trackerIds.containsKey(LocationHandler.getCurrentLocation())) {
- String trackerId = trackerIds.get(LocationHandler.getCurrentLocation());
- TrackerData tracked = trackers.get(trackerId);
- String dropTrackerId = tracked.getDropId(SeasonDateHandler.getCurrentEvent());
- Map<String, ItemStack> tracker = tracked.dropTrackers.get(dropTrackerId);
+ public static void onItemAdded(String id, int amount, String specialId, int number) {
+ if (SkyblockHud.hasSkyblockScoreboard() && trackers.containsKey(LocationHandler.getCurrentLocation())) {
+ Map<String, TrackerObject> trackerMap = trackers.get(LocationHandler.getCurrentLocation());
String dropId = id;
- if (enchant != null) {
- dropId = enchant.toUpperCase() + ";" + level;
+ if (specialId != null) {
+ dropId = specialId.toUpperCase() + ";" + number;
}
- if (tracker != null && tracker.containsKey(dropId)) {
- ItemStack stack = tracker.get(dropId);
- stack.stackSize += amount;
- tracked.dropTrackers.put(dropTrackerId, sortTrackers(tracker));
+ if (trackerMap != null && trackerMap.containsKey(dropId)) {
+ TrackerObject object = trackerMap.get(dropId);
+ object.increaseCount(amount);
+ trackers.put(LocationHandler.getCurrentLocation(), sortTrackers(trackerMap, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())));
}
+
}
}
@@ -81,36 +61,47 @@ public class TrackerHandler {
}
@SubscribeEvent
+ 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);
+ object.increaseCount();
+ trackers.put(LocationHandler.getCurrentLocation(), sortTrackers(trackerMap, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount())));
+ }
+ }
+ }
+
+ @SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
- if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackerIds.containsKey(LocationHandler.getCurrentLocation())/*,!SkyblockHud.config.trackers.hideTracker*/)) {
- String trackerId = trackerIds.get(LocationHandler.getCurrentLocation());
+ 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();
- TrackerData tracked = trackers.get(trackerId);
- Map<String, ItemStack> tracker = tracked.dropTrackers.get(tracked.getDropId(SeasonDateHandler.getCurrentEvent()));
if (tracker != null) {
- Position pos = null; // SkyblockHud.config.trackers.trackerPosition;
- int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 120 : tracker.size() * 20));
+ Position pos = SkyblockHud.config.trackers.trackerPosition;
+ int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 130 : tracker.size() * 20));
int y = pos.getAbsY(event.resolution, (int) (10 + Math.ceil(tracker.size() / 5d) * 20));
- Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136);
+ 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 ? 120 : tracker.size() * 20), (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), 1610612736);
- int x = startPos;
- for (ItemStack stack : tracker.values()) {
- String s = String.valueOf(stack.stackSize);
+ 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);
GlStateManager.disableLighting();
GlStateManager.enableDepth();
- drawItemStack(stack, x, y);
+ drawItemStack(object.getDisplayStack(), x, y);
GlStateManager.disableDepth();
GlStateManager.disableBlend();
- mc.fontRendererObj.drawStringWithShadow(s, (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), (float) (y + 9), stack.stackSize < 1 ? 16733525 : 16777215);
+ mc.fontRendererObj.drawStringWithShadow(s, (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), (float) (y + 9), object.getCount() < 1 ? 16733525 : 16777215);
GlStateManager.enableBlend();
GlStateManager.enableDepth();
- if ((x - startPos) / 20 == 5) {
- x = startPos;
+ if ((x - startPos + 5) / 20 == 5) {
+ x = startPos + 5;
y += 20;
} else {
x += 20;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java
new file mode 100644
index 0000000..58034d5
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java
@@ -0,0 +1,94 @@
+package com.thatgravyboat.skyblockhud.tracker;
+
+import com.google.gson.JsonObject;
+import com.thatgravyboat.skyblockhud.location.Locations;
+import java.util.EnumSet;
+import java.util.Locale;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.ResourceLocation;
+
+public class TrackerObject {
+
+ private final ItemStack stack;
+ private final String internalId;
+ private final EnumSet<Locations> locations;
+ private final boolean isEntity;
+ private int count;
+
+ 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){
+ jsonObject = jsonObject.getAsJsonObject("displayItem");
+ int meta = jsonObject.get("meta").getAsInt();
+ ResourceLocation itemid = new ResourceLocation(jsonObject.get("item").getAsString());
+ ItemStack stack = new ItemStack(Item.itemRegistry.getObject(itemid), 0, meta);
+ if (jsonObject.has("displayName")) stack.setStackDisplayName(jsonObject.get("displayName").getAsString());
+ if (jsonObject.has("skullData") && itemid.getResourcePath().equals("skull") && meta == 3) {
+ stack.setTagInfo("SkullOwner", getSkullTag(jsonObject.getAsJsonObject("skullData")));
+ }
+ if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) {
+ stack.setTagInfo("ench", new NBTTagList());
+ }
+ return stack;
+ }
+
+ public static NBTBase getSkullTag(JsonObject skullObject) {
+ NBTTagCompound skullOwner = new NBTTagCompound();
+ NBTTagCompound properties = new NBTTagCompound();
+ NBTTagList textures = new NBTTagList();
+ NBTTagCompound value = new NBTTagCompound();
+
+ skullOwner.setString("Id", skullObject.get("id").getAsString());
+
+ value.setString("Value", skullObject.get("texture").getAsString());
+ textures.appendTag(value);
+
+ properties.setTag("textures", textures);
+
+ skullOwner.setTag("Properties", properties);
+ return skullOwner;
+ }
+
+ public void increaseCount(int amount) {
+ count+=amount;
+ }
+
+ public void increaseCount() {
+ count++;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public ItemStack getDisplayStack() {
+ return stack;
+ }
+
+ public EnumSet<Locations> getLocations() {
+ return locations;
+ }
+
+ public String getInternalId() {
+ return internalId.toUpperCase(Locale.ENGLISH);
+ }
+
+ 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 7966687..0832319 100644
--- a/src/main/resources/assets/skyblockhud/data/trackers.json
+++ b/src/main/resources/assets/skyblockhud/data/trackers.json
@@ -155,6 +155,19 @@
"enchanted": true
}
}
+ ],
+ "mobs" : [
+ {
+ "id": "entity:WOLF_SLAYER",
+ "displayItem": {
+ "item": "minecraft:skull",
+ "meta": 3,
+ "skullData": {
+ "id": "42482f09-bf1b-452e-aa91-0b9f9dc6868f",
+ "texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGQxYWE3ZTNiOTU2NGIzODQ2ZjFkZWExNGYxYjFjY2JmMzk5YmJiMjNiOTUyZGJkN2VlYzQxODAyYTI4OWM5NiJ9fX0="
+ }
+ }
+ }
]
},
{
@@ -221,6 +234,19 @@
"meta": 0
}
}
+ ],
+ "mobs" : [
+ {
+ "id": "entity:SPIDER_SLAYER",
+ "displayItem": {
+ "item": "minecraft:skull",
+ "meta": 3,
+ "skullData": {
+ "id": "9bedf23e-8a90-410d-bd1f-333d3929821e",
+ "texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTdjNzkxY2IwNzk3ZGRkMTAzOTUyYjU0OGQzZDU2MGE3NzJiNGU5NDZjYzA5NjQzODU3Y2ViZGFhOWQxYmNjNCJ9fX0="
+ }
+ }
+ }
]
},
{
@@ -233,7 +259,8 @@
"id": "REVENANT_FLESH",
"displayItem": {
"item": "minecraft:rotten_flesh",
- "meta": 0
+ "meta": 0,
+ "enchanted": true
}
},
{
@@ -285,14 +312,6 @@
}
},
{
- "id": "REVENANT_VISCERA",
- "displayItem": {
- "item": "minecraft:cooked_porkchop",
- "meta": 0,
- "enchanted": true
- }
- },
- {
"id": "SHARD_OF_THE_SHREDDED",
"displayItem": {
"item": "minecraft:skull",
@@ -321,6 +340,27 @@
"texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDQ1ZjRkMTM5YzllODkyNjJlYzA2YjI3YWFhZDczZmE0ODhhYjQ5MjkwZDJjY2Q2ODVhMjU1NDcyNTM3M2M5YiJ9fX0="
}
}
+ },
+ {
+ "id": "SCYTHE_BLADE",
+ "displayItem": {
+ "item": "minecraft:diamond",
+ "meta": 0,
+ "enchanted": true
+ }
+ }
+ ],
+ "mobs" : [
+ {
+ "id": "entity:ZOMBIE_SLAYER",
+ "displayItem": {
+ "item": "minecraft:skull",
+ "meta": 3,
+ "skullData": {
+ "id": "a593ac46-8eb5-46f0-ab18-5a5c496a94fc",
+ "texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjY3YjI3ZmI3ZTI5ZWM5OGUxY2Q0YThmODQ2Njg1NmQ5ZWYzZjJlOWZiZDlhZWQ2MzExZjhhYmU1NGI2YWIyIn19fQ=="
+ }
+ }
}
]
},
diff --git a/src/main/resources/assets/skyblockhud/stats.png b/src/main/resources/assets/skyblockhud/stats.png
index 66dcbc6..e1f1a2b 100644
--- a/src/main/resources/assets/skyblockhud/stats.png
+++ b/src/main/resources/assets/skyblockhud/stats.png
Binary files differ
diff --git a/src/main/resources/mixins.skyblockhud.json b/src/main/resources/mixins.skyblockhud.json
index d928e55..a729fef 100644
--- a/src/main/resources/mixins.skyblockhud.json
+++ b/src/main/resources/mixins.skyblockhud.json
@@ -3,6 +3,7 @@
"refmap": "mixins.skyblockhud.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [
+ "MixinEntityArrow",
"MixinGuiIngameForge",
"MixinNetHandlerPlayClient"
]