From cdb2563b6ab656fefb6b19f38d7e742ab4278d85 Mon Sep 17 00:00:00 2001 From: DoKM Date: Mon, 5 Jul 2021 17:11:16 +0200 Subject: fixed todo list added colour coding to todolist added time based display options godpot works array out of bounds exception due to me removing config options that are still used but not needed --- .../notenoughupdates/options/NEUConfig.java | 185 +++++++++++++++++- .../notenoughupdates/overlays/TimersOverlay.java | 208 +++++++++++++++------ 2 files changed, 333 insertions(+), 60 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index a80cc94a..c6203059 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -1146,13 +1146,6 @@ public class NEUConfig extends Config { ) @ConfigEditorDraggableList( exampleText = { - "\u00a73Cakes: \u00a7eInactive!", - "\u00a73Cookie Buff: \u00a7eInactive!", - "\u00a73Godpot: \u00a7eInactive!", - "\u00a73Puzzler: \u00a7eReady!", - "\u00a73Fetchur: \u00a7eReady!", - "\u00a73Commissions: \u00a7eReady!", - "\u00a73Experiments: \u00a7eReady!", "\u00a73Cakes: \u00a7e1d21h", "\u00a73Cookie Buff: \u00a7e2d23h", "\u00a73Godpot: \u00a7e19h", @@ -1164,6 +1157,182 @@ public class NEUConfig extends Config { @ConfigAccordionId(id = 0) public List todoText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6)); + @ConfigOption( + name = "Show Only If Soon", + desc = "" + ) + @ConfigAccordionId(id = 0) + @ConfigEditorAccordion(id = 1) + public boolean TodoAccordion = false; + + @Expose + @ConfigOption( + name = "Experimentation Display", + desc = "Change the way the experimentation timer displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int experimentationDisplay = 0; + + + @Expose + @ConfigOption( + name = "Puzzler Reset Display", + desc = "Change the way the puzzler reset timer displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int puzzlerDisplay = 0; + + @Expose + @ConfigOption( + name = "Fetchur Reset Display", + desc = "Change the way the fetchur reset timer displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int fetchurDisplay = 0; + + @Expose + @ConfigOption( + name = "Commission timer Display", + desc = "Change the way the Commission timer displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int commissionDisplay = 0; + + @Expose + @ConfigOption( + name = "Cake Buff Display", + desc = "Change the way the cake buff timer displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int cakesDisplay = 0; + + @Expose + @ConfigOption( + name = "Cookie Buff Display", + desc = "Change the way the cookie buff displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int cookieBuffDisplay = 0; + + @Expose + @ConfigOption( + name = "God Pot Display", + desc = "Change the way the god pot displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id =1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int godpotDisplay = 0; + + @ConfigOption( + name = "Colours", + desc = "" + ) + + @ConfigEditorAccordion(id = 2) + @ConfigAccordionId(id = 0) + public boolean TodoColourAccordion = false; + + @Expose + @ConfigOption( + name = "Ready colour", + desc = "Change the colour of when the timer is ready" + + ) + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int readyColour = 0; + + @Expose + @ConfigOption( + name = "Gone colour", + desc = "Change the colour of when the timer is gone" + + ) + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int goneColour = 0; + + @Expose + @ConfigOption( + name = "Very soon colour", + desc = "Change the colour of when the timer is almost ready/gone" + + ) + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int verySoonColour = 0; + + @Expose + @ConfigOption( + name = "Soon Colour", + desc = "Change the colour of when the timer is soon ready/gone" + + ) + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int soonColour = 0; + + @Expose + @ConfigOption( + name = "Kinda Soon Colour", + desc = "Change the colour of when the timer is kinda soon ready/gone" + + ) + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int kindaSoonColour = 0; + + + @Expose + @ConfigOption( + name = "Default Colour", + desc = "Change the default colour of the timers" + + ) + + @ConfigEditorDropdown( + values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} + ) + @ConfigEditorAccordion(id = 2) + public int defaultColour = 0; + @Expose @ConfigOption( name = "Todo Position", @@ -2138,7 +2307,7 @@ public class NEUConfig extends Config { } public static class HiddenProfileSpecific { - @Expose public long godPotionDrunk = 0L; + @Expose public long godPotionDuration = 0L; @Expose public long puzzlerCompleted = 0L; @Expose public long firstCakeAte = 0L; @Expose public long fetchurCompleted = 0L; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index 0b6d1740..a1fca448 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -17,6 +17,7 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.WorldSettings; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -25,6 +26,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.util.vector.Vector2f; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.*; import java.util.function.Supplier; import java.util.regex.Matcher; @@ -34,7 +37,7 @@ import static net.minecraft.util.EnumChatFormatting.*; public class TimersOverlay extends TextOverlay { - private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile("\u00a77You have \u00a7r\u00a7e(\\d+) \u00a7r\u00a77active effects."); + private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile("\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([0-9]*?:?[0-9]*?:?[0-9]*)\u00a7r"); public TimersOverlay(Position position, Supplier> dummyStrings, Supplier styleSupplier) { super(position, dummyStrings, styleSupplier); @@ -44,8 +47,7 @@ public class TimersOverlay extends TextOverlay { private static final Pattern PUZZLER_PATTERN = Pattern.compile("\u00a7r\u00a7dPuzzler\u00a7r\u00a76 gave you .+ \u00a7r\u00a76for solving the puzzle!\u00a7r"); private static final Pattern FETCHUR_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rthanks thats probably what i needed\u00a7r"); private static final Pattern FETCHUR2_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rcome back another time, maybe tmrw\u00a7r"); - private static final Pattern GODPOT_PATTERN = Pattern.compile("\u00a7r\u00a7a\u00a7lGULP! \u00a7r\u00a7eThe \u00a7r\u00a7cGod Potion \u00a7r\u00a7egrants you" + - " powers for \u00a7r\u00a7924 hours\u00a7r\u00a7e!\u00a7r"); + private boolean hideGodpot = false; @@ -81,11 +83,7 @@ public class TimersOverlay extends TextOverlay { return; } - Matcher godpotMatcher = GODPOT_PATTERN.matcher(event.message.getFormattedText()); - if(godpotMatcher.matches()) { - hidden.godPotionDrunk = currentTime; - return; - } + } } @@ -136,7 +134,9 @@ public class TimersOverlay extends TextOverlay { } long currentTime = System.currentTimeMillis(); - long fetchurIndex = (currentTime-18000000)/86400000 % 13 - 4; + ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan")); + + long fetchurIndex = currentTimeEST.getDayOfMonth()-1 % 13; if(fetchurIndex < 0) fetchurIndex += 13; icon = FETCHUR_ICONS[(int)fetchurIndex]; @@ -162,10 +162,7 @@ public class TimersOverlay extends TextOverlay { @Override public void update() { - if(true) { - overlayStrings = null; - return; - } + long currentTime = System.currentTimeMillis(); @@ -213,12 +210,30 @@ public class TimersOverlay extends TextOverlay { String formatted = SBInfo.getInstance().footer.getFormattedText(); for(String line : formatted.split("\n")) { Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line); - if(activeEffectsMatcher.find()) { - String numEffectsS = activeEffectsMatcher.group(1); + if(activeEffectsMatcher.matches()) { + String[] godpotRemaingTimeUnformatted= activeEffectsMatcher.group(1).split(":"); + long godPotDuration = 0; try { - int numEffects = Integer.parseInt(numEffectsS); - hideGodpot = numEffects > 25; - } catch(NumberFormatException ignored) {} + int i = 0; + if (godpotRemaingTimeUnformatted.length == 4) { + godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 24 * 60 * 60 * 1000; + i++; + } + if (godpotRemaingTimeUnformatted.length >= 3) { + godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 60 * 1000; + i++; + } + if (godpotRemaingTimeUnformatted.length >= 2) { + godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 1000; + i++; + } + if (godpotRemaingTimeUnformatted.length >= 1) { + godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000; + + } + } catch(Exception ignored){} + hidden.godPotionDuration = godPotDuration; + } else if(line.contains("\u00a7d\u00a7lCookie Buff")) { foundCookieBuffText = true; } else if(foundCookieBuffText) { @@ -272,59 +287,124 @@ public class TimersOverlay extends TextOverlay { HashMap map = new HashMap<>(); long cakeEnd = hidden.firstCakeAte + 1000*60*60*48 - currentTime; - if(cakeEnd < 0) { - map.put(0, DARK_AQUA+"Cakes: "+YELLOW+"Inactive!"); - map.put(0+7, DARK_AQUA+"Cakes: "+YELLOW+"Inactive!"); - } else { - map.put(0+7, DARK_AQUA+"Cakes: "+YELLOW+Utils.prettyTime(cakeEnd)); + + //Cake Display + if(cakeEnd <= 0) { + map.put(0, DARK_AQUA+"Cakes: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour]+"Inactive!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + cakeEnd < TimeEnums.HOUR.time){ + map.put(0, DARK_AQUA+"Cakes: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(cakeEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.SOON.ordinal() && + cakeEnd < TimeEnums.HALFDAY.time){ + map.put(0, DARK_AQUA+"Cakes: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(cakeEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + cakeEnd < TimeEnums.DAY.time) { + map.put(0, DARK_AQUA+"Cakes: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(cakeEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(0, DARK_AQUA+"Cakes: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(cakeEnd)); } + //CookieBuff Display if(hidden.cookieBuffRemaining <= 0) { - map.put(1, DARK_AQUA+"Cookie Buff: "+YELLOW+"Inactive!"); - map.put(1+7, DARK_AQUA+"Cookie Buff: "+YELLOW+"Inactive!"); - } else { - map.put(1+7, DARK_AQUA+"Cookie Buff: "+YELLOW+Utils.prettyTime(hidden.cookieBuffRemaining)); + map.put(1, DARK_AQUA+"Cookie Buff: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour]+"Inactive!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + hidden.cookieBuffRemaining < TimeEnums.HOUR.time){ + map.put(1, DARK_AQUA+"Cookie Buff: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(hidden.cookieBuffRemaining)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.SOON.ordinal() && + hidden.cookieBuffRemaining < TimeEnums.HALFDAY.time){ + map.put(1, DARK_AQUA+"Cookie Buff: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(hidden.cookieBuffRemaining)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + hidden.cookieBuffRemaining < TimeEnums.DAY.time) { + map.put(1, DARK_AQUA+"Cookie Buff: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(hidden.cookieBuffRemaining)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(1, DARK_AQUA+"Cookie Buff: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(hidden.cookieBuffRemaining)); } - long godpotEnd = hidden.godPotionDrunk + 1000*60*60*24 - currentTime; - if(godpotEnd < 0) { - if(!hideGodpot) { - map.put(2, DARK_AQUA+"Godpot: "+YELLOW+"Inactive!"); - map.put(2+7, DARK_AQUA+"Godpot: "+YELLOW+"Inactive!"); - } - } else { - map.put(2+7, DARK_AQUA+"Godpot: "+YELLOW+Utils.prettyTime(godpotEnd)); + long godpotEnd = hidden.godPotionDuration; + //Godpot Display + if(hidden.godPotionDuration <= 0) { + map.put(2, DARK_AQUA+"Godpot: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour]+"Inactive!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + hidden.godPotionDuration < TimeEnums.HOUR.time){ + map.put(2, DARK_AQUA+"Godpot: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(hidden.godPotionDuration)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.SOON.ordinal() && + hidden.godPotionDuration < TimeEnums.HALFDAY.time){ + map.put(2, DARK_AQUA+"Godpot: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(hidden.godPotionDuration)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + hidden.godPotionDuration < TimeEnums.DAY.time) { + map.put(2, DARK_AQUA+"Godpot: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(hidden.godPotionDuration)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(2, DARK_AQUA+"Godpotf: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(hidden.godPotionDuration)); } long puzzlerEnd = hidden.puzzlerCompleted + 1000*60*60*24 - currentTime; - if(puzzlerEnd < 0) { - map.put(3, DARK_AQUA+"Puzzler: "+YELLOW+"Ready!"); - map.put(3+7, DARK_AQUA+"Puzzler: "+YELLOW+"Ready!"); - } else { - map.put(3+7, DARK_AQUA+"Puzzler: "+YELLOW+Utils.prettyTime(puzzlerEnd)); + //Puzzler Display + if((hidden.puzzlerCompleted + TimeEnums.DAY.time) < currentTime) { + map.put(3, DARK_AQUA+"Puzzler: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HALFANHOUR.time)) < currentTime){ + map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(puzzlerEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.SOON.ordinal() && + (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HOUR.time)) < currentTime){ + map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(puzzlerEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (hidden.puzzlerCompleted + (TimeEnums.DAY.time - (TimeEnums.HOUR.time)*3)) < currentTime) { + map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(puzzlerEnd)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(puzzlerEnd)); } long midnightReset = (currentTime-18000000)/86400000*86400000+18000000; long fetchurComplete = hidden.fetchurCompleted; + + long timeDiffMidnightNow = midnightReset + 86400000 - currentTime; + + //Fetchur Display if(fetchurComplete < midnightReset) { - map.put(4, DARK_AQUA+"Fetchur: "+YELLOW+"Ready!"); - map.put(4+7, DARK_AQUA+"Fetchur: "+YELLOW+"Ready!"); - } else { - map.put(4+7, DARK_AQUA+"Fetchur: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + map.put(4, DARK_AQUA+"Fetchur: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (fetchurComplete < (midnightReset-TimeEnums.HALFANHOUR.time))){ + map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.SOON.ordinal() && + (fetchurComplete < (midnightReset-TimeEnums.HOUR.time))){ + map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (fetchurComplete < (midnightReset-(TimeEnums.HOUR.time*3)))) { + map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow)); } + //Commissions Display if(hidden.commissionsCompleted < midnightReset) { - map.put(5, DARK_AQUA+"Commissions: "+YELLOW+"Ready!"); - map.put(5+7, DARK_AQUA+"Commissions: "+YELLOW+"Ready!"); - } else { - map.put(5+7, DARK_AQUA+"Commissions: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + map.put(5, DARK_AQUA+"Commissions: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (hidden.commissionsCompleted < (midnightReset-TimeEnums.HALFANHOUR.time))){ + map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.SOON.ordinal() && + (hidden.commissionsCompleted < (midnightReset-TimeEnums.HOUR.time))){ + map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (hidden.commissionsCompleted < (midnightReset-(TimeEnums.HOUR.time*3)))) { + map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow)); } + //Experiment Display if(hidden.experimentsCompleted < midnightReset) { - map.put(6, DARK_AQUA+"Experiments: "+YELLOW+"Ready!"); - map.put(6+7, DARK_AQUA+"Experiments: "+YELLOW+"Ready!"); - } else { - map.put(6+7, DARK_AQUA+"Experiments: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + map.put(6, DARK_AQUA+"Experiments: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (hidden.experimentsCompleted < (midnightReset-TimeEnums.HALFANHOUR.time))){ + map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.SOON.ordinal() && + (hidden.experimentsCompleted < (midnightReset-TimeEnums.HOUR.time))){ + map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (hidden.experimentsCompleted < (midnightReset-(TimeEnums.HOUR.time*3)))) { + map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow)); + } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){ + map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow)); } overlayStrings = new ArrayList<>(); @@ -336,4 +416,28 @@ public class TimersOverlay extends TextOverlay { if(overlayStrings.isEmpty()) overlayStrings = null; } + + private enum TimeEnums { + DAY (86400000), + HALFDAY(43200000), + HOUR(3600000), + HALFANHOUR(1800000); + + TimeEnums(long time) { + this.time = time; + } + + public final long time; + } + + private enum DISPLAYTYPE { + NOW, + VERYSOON, + SOON, + KINDASOON, + ALWAYS, + + } + } + -- cgit From e30345fcbcc48482ec46e321aa7d0cd3aec198ec Mon Sep 17 00:00:00 2001 From: DoKM Date: Tue, 6 Jul 2021 10:03:59 +0200 Subject: remove left over "debug" line --- .../io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index a1fca448..2a67d384 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -393,7 +393,7 @@ public class TimersOverlay extends TextOverlay { //Experiment Display if(hidden.experimentsCompleted < midnightReset) { - map.put(6, DARK_AQUA+"Experiments: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"+Utils.prettyTime(timeDiffMidnightNow)); + map.put(6, DARK_AQUA+"Experiments: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!"); } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && (hidden.experimentsCompleted < (midnightReset-TimeEnums.HALFANHOUR.time))){ map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow)); -- cgit From bc6a76d6b5348b450ffc2e398030da6128a31cae Mon Sep 17 00:00:00 2001 From: DoKM Date: Tue, 6 Jul 2021 15:16:51 +0200 Subject: add voidgloom stats to profile viewer add voidgloom level to main profile viewer tab reorganize slayer tabs add voidgloom 3 and 4 and revenant 5 stats to slayer stats --- .../profileviewer/GuiProfileViewer.java | 5864 ++++++++++---------- .../profileviewer/ProfileViewer.java | 2243 ++++---- 2 files changed, 4064 insertions(+), 4043 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 3fe7d9d3..661bd5a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1,2926 +1,2938 @@ -package io.github.moulberry.notenoughupdates.profileviewer; - -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; -import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; -import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.SkinManager; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.client.shader.Shader; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; -import net.minecraft.util.*; -import org.apache.commons.lang3.text.WordUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; -import org.lwjgl.opengl.GL20; - -import java.awt.*; -import java.io.IOException; -import java.text.NumberFormat; -import java.util.*; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class GuiProfileViewer extends GuiScreen { - - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png"); - public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png"); - public static final ResourceLocation pv_dung = new ResourceLocation("notenoughupdates:pv_dung.png"); - public static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png"); - public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png"); - public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png"); - public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png"); - public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png"); - public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png"); - public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); - public static final ResourceLocation resource_packs = new ResourceLocation("minecraft:textures/gui/resource_packs.png"); - public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); - - private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); - - private final ProfileViewer.Profile profile; - public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC; - private int sizeX; - private int sizeY; - private int guiLeft; - private int guiTop; - - private float backgroundRotation = 0; - - private long currentTime = 0; - private long lastTime = 0; - private long startTime = 0; - - private List tooltipToDisplay = null; - - private String profileId = null; - private boolean profileDropdownSelected = false; - - public enum ProfileViewerPage { - LOADING(null), - INVALID_NAME(null), - NO_SKYBLOCK(null), - BASIC(new ItemStack(Items.paper)), - DUNG(new ItemStack(Item.getItemFromBlock(Blocks.deadbush))), - EXTRA(new ItemStack(Items.book)), - INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))), - COLS(new ItemStack(Items.painting)), - PETS(new ItemStack(Items.bone)); - - public final ItemStack stack; - - ProfileViewerPage(ItemStack stack) { - this.stack = stack; - } - } - - public GuiProfileViewer(ProfileViewer.Profile profile) { - this.profile = profile; - String name = ""; - if(profile != null && profile.getHypixelProfile() != null) { - name = profile.getHypixelProfile().get("displayname").getAsString(); - } - playerNameTextField = new GuiElementTextField(name, - GuiElementTextField.SCALE_TEXT); - playerNameTextField.setSize(100, 20); - - if(currentPage == ProfileViewerPage.LOADING) { - currentPage = ProfileViewerPage.BASIC; - } - } - - private GuiElementTextField playerNameTextField; - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - currentTime = System.currentTimeMillis(); - if(startTime == 0) startTime = currentTime; - - ProfileViewerPage page = currentPage; - if(profile == null) { - page = ProfileViewerPage.INVALID_NAME; - } else if(profile.getPlayerInformation(null) == null) { - page = ProfileViewerPage.LOADING; - } else if(profile.getLatestProfile() == null) { - page = ProfileViewerPage.NO_SKYBLOCK; - } - - if(profileId == null && profile != null && profile.getLatestProfile() != null) { - profileId = profile.getLatestProfile(); - } - - this.sizeX = 431; - this.sizeY = 202; - this.guiLeft = (this.width-this.sizeX)/2; - this.guiTop = (this.height-this.sizeY)/2; - - super.drawScreen(mouseX, mouseY, partialTicks); - drawDefaultBackground(); - - blurBackground(); - renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4); - - GlStateManager.enableDepth(); - GlStateManager.translate(0, 0, 5); - renderTabs(true); - GlStateManager.translate(0, 0, -3); - - GlStateManager.disableDepth(); - GlStateManager.translate(0, 0, -2); - renderTabs(false); - GlStateManager.translate(0, 0, 2); - - GlStateManager.disableLighting(); - GlStateManager.enableDepth(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1F); - - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg); - Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - - if(!(page == ProfileViewerPage.LOADING)) { - playerNameTextField.render(guiLeft+sizeX-100, guiTop+sizeY+5); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - - if(profile != null) { - renderBlurredBackground(width, height, guiLeft+2, guiTop+sizeY+3+2, 100-4, 20-4); - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); - Utils.drawTexturedRect(guiLeft, guiTop+sizeY+3, 100, 20, - 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST); - Utils.drawStringCenteredScaledMaxWidth(profileId, Minecraft.getMinecraft().fontRendererObj, guiLeft+50, - guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB()); - - if(profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) { - int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20; - - int numProfiles = profile.getProfileIds().size(); - int sizeYDropdown = numProfiles*dropdownOptionSize; - renderBlurredBackground(width, height, guiLeft+2, guiTop+sizeY+23, 100-4, sizeYDropdown-2); - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); - Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23-3, 100, 3, - 100/200f, 1, 0, 3/185f, GL11.GL_NEAREST); - Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23+sizeYDropdown-4, 100, 4, - 100/200f, 1, 181/185f, 1, GL11.GL_NEAREST); - Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23, 100, sizeYDropdown-4, - 100/200f, 1, (181-sizeYDropdown)/185f, 181/185f, GL11.GL_NEAREST); - - for(int yIndex = 0; yIndex 333) { - if(currentTimeMod < 666) { - str += "."; - } else { - str += ".."; - } - } - - Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, - guiLeft+sizeX/2f, guiTop+101, true, 0); - break; - case INVALID_NAME: - Utils.drawStringCentered(EnumChatFormatting.RED+"Invalid name or API is down!", Minecraft.getMinecraft().fontRendererObj, - guiLeft+sizeX/2f, guiTop+101, true, 0); - break; - case NO_SKYBLOCK: - Utils.drawStringCentered(EnumChatFormatting.RED+"No skyblock data found!", Minecraft.getMinecraft().fontRendererObj, - guiLeft+sizeX/2f, guiTop+101, true, 0); - break; - } - - lastTime = currentTime; - - if(tooltipToDisplay != null) { - List grayTooltip = new ArrayList<>(tooltipToDisplay.size()); - for(String line : tooltipToDisplay) { - grayTooltip.add(EnumChatFormatting.GRAY + line); - } - Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); - tooltipToDisplay = null; - } - } - - private void renderTabs(boolean renderPressed) { - int ignoredTabs = 0; - for(int i=0; i x && mouseX < x+28) { - if(mouseY > y && mouseY < y+32) { - if(currentPage != page) Utils.playPressSound(); - currentPage = page; - inventoryTextField.otherComponentClick(); - playerNameTextField.otherComponentClick(); - return; - } - } - } - } - switch (currentPage) { - case DUNG: - mouseClickedDung(mouseX, mouseY, mouseButton); - break; - case INVS: - inventoryTextField.setSize(88, 20); - if(mouseX > guiLeft+19 && mouseX < guiLeft+19+88) { - if(mouseY > guiTop+sizeY-26-20 && mouseY < guiTop+sizeY-26) { - inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton); - playerNameTextField.otherComponentClick(); - return; - } - } - break; - case PETS: - if(sortedPets == null) break; - for(int i=petsPage*20; i guiLeft+x && mouseX < guiLeft+x+20) { - if(mouseY > guiTop+y && mouseY < guiTop+y+20) { - selectedPet = i; - return; - } - } - } - break; - } - if(mouseX > guiLeft+sizeX-100 && mouseX < guiLeft+sizeX) { - if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) { - playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton); - inventoryTextField.otherComponentClick(); - return; - } - } - if(mouseX > guiLeft && mouseX < guiLeft+100 && profile != null && !profile.getProfileIds().isEmpty()) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - if(mouseY > guiTop+sizeY+3 && mouseY < guiTop+sizeY+23) { - if(scaledResolution.getScaleFactor() == 4) { - profileDropdownSelected = false; - int profileNum = 0; - for(int index = 0; index= profile.getProfileIds().size()) profileNum = 0; - if(profileNum < 0) profileNum = profile.getProfileIds().size()-1; - - String newProfileId = profile.getProfileIds().get(profileNum); - if(profileId != null && !profileId.equals(newProfileId)) { - resetCache(); - } - profileId = newProfileId; - } else { - profileDropdownSelected = !profileDropdownSelected; - } - } else if(scaledResolution.getScaleFactor() != 4 && profileDropdownSelected) { - int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20; - int extraY = mouseY - (guiTop+sizeY+23); - int index = extraY/dropdownOptionSize; - if(index >= 0 && index < profile.getProfileIds().size()) { - String newProfileId = profile.getProfileIds().get(index); - if(profileId != null && !profileId.equals(newProfileId)) { - resetCache(); - } - profileId = newProfileId; - } - } - playerNameTextField.otherComponentClick(); - inventoryTextField.otherComponentClick(); - return; - } - profileDropdownSelected = false; - playerNameTextField.otherComponentClick(); - inventoryTextField.otherComponentClick(); - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - super.keyTyped(typedChar, keyCode); - switch (currentPage) { - case INVS: - keyTypedInvs(typedChar, keyCode); - inventoryTextField.keyTyped(typedChar, keyCode); - break; - case COLS: - keyTypedCols(typedChar, keyCode); - break; - case DUNG: - keyTypedDung(typedChar, keyCode); - break; - } - if(playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) { - if(keyCode == Keyboard.KEY_RETURN) { - currentPage = ProfileViewerPage.LOADING; - NotEnoughUpdates.profileViewer.getProfileByName(playerNameTextField.getText(), profile -> { //todo: invalid name - if(profile != null) profile.resetCache(); - Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile)); - }); - } - playerNameTextField.keyTyped(typedChar, keyCode); - } - } - - @Override - protected void mouseReleased(int mouseX, int mouseY, int mouseButton) { - super.mouseReleased(mouseX, mouseY, mouseButton); - - switch (currentPage) { - case INVS: - mouseReleasedInvs(mouseX, mouseY, mouseButton); - break; - case COLS: - mouseReleasedCols(mouseX, mouseY, mouseButton); - break; - case PETS: - mouseReleasedPets(mouseX, mouseY, mouseButton); - } - } - - protected void mouseClickedDung(int mouseX, int mouseY, int mouseButton) { - if(mouseX >= guiLeft+50 && mouseX <= guiLeft+70 && - mouseY >= guiTop+54 && mouseY <= guiTop+64) { - dungeonLevelTextField.mouseClicked(mouseX, mouseY, mouseButton); - } else { - dungeonLevelTextField.otherComponentClick(); - } - - int cW = fontRendererObj.getStringWidth("Calculate"); - if(mouseX >= guiLeft+23+110-17-cW && mouseX <= guiLeft+23+110-17 && - mouseY >= guiTop+55 && mouseY <= guiTop+65) { - calculateFloorLevelXP(); - } - - int y = guiTop+142; - - if(mouseY >= y-2 && mouseY <= y+9) { - for(int i=1; i<=7; i++) { - int w = fontRendererObj.getStringWidth(""+i); - - int x = guiLeft+23+110*i/8-w/2; - - if(mouseX >= x-2 && mouseX <= x+7) { - floorTime = i; - return; - } - } - } - } - - protected void keyTypedDung(char typedChar, int keyCode) { - dungeonLevelTextField.keyTyped(typedChar, keyCode); - } - - protected void keyTypedInvs(char typedChar, int keyCode) throws IOException { - switch(keyCode) { - case Keyboard.KEY_1: - case Keyboard.KEY_NUMPAD1: - selectedInventory = "inv_contents"; break; - case Keyboard.KEY_2: - case Keyboard.KEY_NUMPAD2: - selectedInventory = "ender_chest_contents"; break; - case Keyboard.KEY_3: - case Keyboard.KEY_NUMPAD3: - selectedInventory = "talisman_bag"; break; - case Keyboard.KEY_4: - case Keyboard.KEY_NUMPAD4: - selectedInventory = "wardrobe_contents"; break; - case Keyboard.KEY_5: - case Keyboard.KEY_NUMPAD5: - selectedInventory = "fishing_bag"; break; - case Keyboard.KEY_6: - case Keyboard.KEY_NUMPAD6: - selectedInventory = "potion_bag"; break; - } - Utils.playPressSound(); - } - - protected void keyTypedCols(char typedChar, int keyCode) throws IOException { - ItemStack stack = null; - Iterator items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator(); - switch(keyCode) { - case Keyboard.KEY_5: - case Keyboard.KEY_NUMPAD5: - stack = items.next(); - case Keyboard.KEY_4: - case Keyboard.KEY_NUMPAD4: - stack = items.next(); - case Keyboard.KEY_3: - case Keyboard.KEY_NUMPAD3: - stack = items.next(); - case Keyboard.KEY_2: - case Keyboard.KEY_NUMPAD2: - stack = items.next(); - case Keyboard.KEY_1: - case Keyboard.KEY_NUMPAD1: - stack = items.next(); - } - if(stack != null) { - selectedCollectionCategory = stack; - } - Utils.playPressSound(); - } - - private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) { - if(mouseY > guiTop+6 && mouseY < guiTop+22) { - if(mouseX > guiLeft+100-15-12 && mouseX < guiLeft+100-20) { - if(petsPage > 0) { - petsPage--; - } - return; - } else if(mouseX > guiLeft+100+15 && mouseX < guiLeft+100+20+12) { - if(sortedPets != null && petsPage < Math.ceil(sortedPets.size()/20f)-1) { - petsPage++; - } - return; - } - } - } - - private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) { - if(mouseButton == 0) { - int i=0; - for(Map.Entry entry : invNameToDisplayMap.entrySet()) { - int xIndex = i%3; - int yIndex = i/3; - - int x = guiLeft+19+34*xIndex; - int y = guiTop+26+34*yIndex; - - if(mouseX >= x && mouseX <= x+16) { - if(mouseY >= y && mouseY <= y+16) { - if(selectedInventory != entry.getKey()) Utils.playPressSound(); - selectedInventory = entry.getKey(); - return; - } - } - - i++; - } - - JsonObject inventoryInfo = profile.getInventoryInfo(profileId); - if(inventoryInfo == null) return; - - ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory); - if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1; - if(currentInventoryIndex < 0) currentInventoryIndex = 0; - - ItemStack[][] inventory = inventories[currentInventoryIndex]; - if(inventory == null) return; - - int inventoryRows = inventory.length; - int invSizeY = inventoryRows*18+17+7; - - int y = guiTop+101-invSizeY/2; - - if(mouseY > y+invSizeY && mouseY < y+invSizeY+16) { - if(mouseX > guiLeft+320-12 && mouseX < guiLeft+320+12) { - if(mouseX < guiLeft+320) { - currentInventoryIndex--; - } else { - currentInventoryIndex++; - } - } - } - } - } - - private ItemStack selectedCollectionCategory = null; - - private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) { - int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size(); - int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f)); - int yIndex = 0; - for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) { - if(mouseX > guiLeft+7 && mouseX < guiLeft+7+20) { - if(mouseY > guiTop+10+collectionCatYSize*yIndex && mouseY < guiTop+10+collectionCatYSize*yIndex+20) { - selectedCollectionCategory = stack; - Utils.playPressSound(); - return; - } - } - yIndex++; - } - } - - private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush)); - private static final ItemStack[] BOSS_HEADS = new ItemStack[7]; - - private HashMap levelObjCatas = new HashMap<>(); - private HashMap> levelObjClasseses = new HashMap<>(); - - private GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); - - private static final String[] dungSkillsName = {"Healer", "Mage", "Berserk", "Archer", "Tank"}; - private static final ItemStack[] dungSkillsStack = { new ItemStack(Items.potionitem, 1, 16389), - new ItemStack(Items.blaze_rod), new ItemStack(Items.iron_sword), new ItemStack(Items.bow), new ItemStack(Items.leather_chestplate)}; - private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"}; - private static final String[] bossFloorHeads = { - "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c", - "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d", - "9971cee8b833a62fc2a612f3503437fdf93cad692d216b8cf90bbb0538c47dd8", - "8b6a72138d69fbbd2fea3fa251cabd87152e4f1c97e5f986bf685571db3cc0", - "c1007c5b7114abec734206d4fc613da4f3a0e99f71ff949cedadc99079135a0b", - "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc", - "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a" - }; - private static int floorTime = 7; - private int floorLevelTo = -1; - private int floorLevelToXP = -1; - - private void calculateFloorLevelXP() { - JsonObject leveling = Constants.LEVELING; - if(leveling == null) return; - ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId); - if(levelObjCata == null) return; - - try { - dungeonLevelTextField.setCustomBorderColour(0xffffffff); - floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText()); - - JsonArray levelingArray = Utils.getElement(leveling, "catacombs").getAsJsonArray(); - - float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel); - - for(int level=0; level= 0) { - dungeonLevelTextField.setText(""+(levelFloored+1)); - calculateFloorLevelXP(); - } - - int x = guiLeft+23; - int y = guiTop+25; - - renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelObjCata, mouseX, mouseY); - - Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Until Cata "+floorLevelTo+": ", - EnumChatFormatting.WHITE.toString()+shortNumberFormat(floorLevelToXP, 0), x, y+16, sectionWidth); - - if(mouseX > x && mouseX < x + sectionWidth && - mouseY > y+16 && mouseY < y+24) { - float xpF5 = 2000; - float xpF6 = 4000; - float xpF7 = 20000; - if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - xpF5 *= 1.1; - xpF6 *= 1.1; - xpF7 *= 1.1; - } - - long runsF5 = (int)Math.ceil(floorLevelToXP/xpF5); - long runsF6 = (int)Math.ceil(floorLevelToXP/xpF6); - long runsF7 = (int)Math.ceil(f