From ce968641b42be85e0b308ecb95a435d7b2b97b3d Mon Sep 17 00:00:00 2001 From: DoKM Date: Sat, 21 Aug 2021 18:16:11 +0200 Subject: Fix experimentation table timer detection not working if you finished all experimentations for the day --- .../notenoughupdates/overlays/TimersOverlay.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/main') 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 39bc0b60..baa407c9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates.overlays; +import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.options.NEUConfig; @@ -13,6 +14,8 @@ import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -190,11 +193,22 @@ public class TimersOverlay extends TextOverlay { if (stack.getItem() == Items.blaze_powder) { if (hidden.experimentsCompleted == 0) { hidden.experimentsCompleted = currentTime; + return; } - } else { - hidden.experimentsCompleted = 0; } } + ItemStack stackSuperPairs = lower.getStackInSlot(22); + if(stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull && stackSuperPairs.getTagCompound() != null){ + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stackSuperPairs.getTagCompound()); + String text = lore[lore.length-1]; + String cleanText = Utils.cleanColour(text); + if(cleanText.equals("Experiments on cooldown!")){ + hidden.experimentsCompleted = currentTime; + return; + } + } + hidden.experimentsCompleted = 0; + return; } } -- cgit From 6d886c664d34a30e67e450e9af6c88f9466376e8 Mon Sep 17 00:00:00 2001 From: DoKM Date: Sun, 22 Aug 2021 10:17:12 +0200 Subject: "fix" fetchur item predictor showing the wrong item until hypixel changes it again --- .../io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main') 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 f8ae54f8..c3e33a83 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -135,6 +135,9 @@ public class TimersOverlay extends TextOverlay { ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan")); long fetchurIndex = (currentTimeEST.getDayOfMonth() % 13)-1; + //Added because disabled fetchur and enabled it again but it was showing the wrong item + //Lets see if this stays correct + fetchurIndex+=2; if(fetchurIndex < 0) fetchurIndex += 13; icon = FETCHUR_ICONS[(int)fetchurIndex]; -- cgit From e176ed76f756be322d1f866375e054f0cd438885 Mon Sep 17 00:00:00 2001 From: DoKM Date: Sun, 22 Aug 2021 12:13:12 +0200 Subject: fix storage overlay nullpointer crash --- .../io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index 91ac5e6f..6b459ecb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -594,14 +594,14 @@ public class StorageOverlay extends GuiElement { if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue; StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false); - + if(editingNameId == storageId) { int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay())+10; renameStorageField.setSize(len, 12); renameStorageField.render(storageX, storageY-13); } else { String pageTitle; - if(page.customTitle != null && !page.customTitle.isEmpty()) { + if(page != null && page.customTitle != null && !page.customTitle.isEmpty()) { pageTitle = Utils.chromaStringByColourCode(page.customTitle); } else if(entry.getValue() < 9) { pageTitle = "Ender Chest Page " + (entry.getValue() + 1); -- cgit From 6e5730be493996fd5a6bebd0c7b9bb87e6b6b31c Mon Sep 17 00:00:00 2001 From: DoKM Date: Sun, 22 Aug 2021 12:38:54 +0200 Subject: Fix not being able to dye via neucustomize undyed leather armour --- .../io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java index 07f1340d..fb0deaaf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java @@ -68,7 +68,7 @@ public class GuiItemCustomize extends GuiScreen { this.enchantGlint = stackHasEffect; } - supportCustomLeatherColour = stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).hasColor(stack); + supportCustomLeatherColour = stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0); this.enchantGlintButton = new GuiElementBoolean(0, 0, enchantGlint, (bool) -> { -- cgit From 97b19369c6cc26705c71e0c7697a1133f5246681 Mon Sep 17 00:00:00 2001 From: DoKM Date: Sun, 22 Aug 2021 22:42:53 +0200 Subject: Fix some text mistakes --- .../options/seperateSections/Mining.java | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index b35704d0..0609f970 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -93,7 +93,7 @@ public class Mining { @Expose @ConfigOption( name = "Dwarven Overlay", - desc = "Show an overlay with useful information on the screen while in Dwarven Mines" + desc = "Show an Overlay with useful information on the screen while in Dwarven Mines" ) @ConfigEditorBoolean @ConfigAccordionId(id = 2) @@ -102,8 +102,8 @@ public class Mining { @Expose @ConfigOption( name = "Dwarven Text", - desc = "\u00a7eDrag text to change the appearance of the overlay\n" + - "\u00a7rGo to the Dwarven Mines to show this overlay with useful information" + desc = "\u00a7eDrag text to change the appearance of the Overlay\n" + + "\u00a7rGo to the Dwarven Mines to show this Overlay with useful information" ) @ConfigEditorDraggableList( exampleText = {"\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", @@ -119,7 +119,7 @@ public class Mining { @Expose @ConfigOption( name = "Overlay Position", - desc = "Change the position of the Dwarven Mines information overlay (commisions, powder & forge statuses)" + desc = "Change the position of the Dwarven Mines information Overlay (commisions, powder & forge statuses)" ) @ConfigEditorButton( runnableId = 1, @@ -131,7 +131,7 @@ public class Mining { @Expose @ConfigOption( name = "Overlay Style", - desc = "Change the style of the Dwarven Mines information overlay" + desc = "Change the style of the Dwarven Mines information Overlay" ) @ConfigEditorDropdown( values = {"Background", "No Shadow", "Shadow", "Full Shadow"} @@ -148,7 +148,7 @@ public class Mining { @Expose @ConfigOption( - name = "Enabled", + name = "Enable Waypoints", desc = "Enabled the metal detector solver for Mines of Divan, to use this stand still to calculate possible blocks and then if required stand" + " still on another block." ) @@ -174,8 +174,8 @@ public class Mining { @Expose @ConfigOption( - name = "Enabled", - desc = "Enables the Automaton parts overlay." + name = "Enable Overlay", + desc = "Enables the Automaton parts Overlay." ) @ConfigEditorBoolean @ConfigAccordionId(id = 4) @@ -183,8 +183,8 @@ public class Mining { @Expose @ConfigOption( - name = "Position", - desc = "Change the position of the Automaton parts overlay." + name = "Overlay Position", + desc = "Change the position of the Automaton parts Overlay." ) @ConfigEditorButton( runnableId = 10, @@ -196,7 +196,7 @@ public class Mining { @Expose @ConfigOption( name = "Style", - desc = "Change the style of the Automaton parts overlay." + desc = "Change the style of the Automaton parts Overlay." ) @ConfigEditorDropdown( values = {"Background", "No Shadow", "Shadow", "Full Shadow"} @@ -207,7 +207,7 @@ public class Mining { @Expose @ConfigOption( name = "Show Icons", - desc = "Show icons in the overlay that represent the part." + desc = "Show icons in the Overlay that represent the part." ) @ConfigEditorBoolean @ConfigAccordionId(id = 4) @@ -292,7 +292,7 @@ public class Mining { public int automatonMissingColor = 12; @ConfigOption( - name = "Mines of Divan overlay", + name = "Mines of Divan Overlay", desc = "" ) @ConfigEditorAccordion(id = 6) @@ -300,8 +300,8 @@ public class Mining { @Expose @ConfigOption( - name = "Enabled", - desc = "Enables the Mines of Divan overlay." + name = "Enable Overlay", + desc = "Enables the Mines of Divan Overlay." ) @ConfigEditorBoolean @ConfigAccordionId(id = 6) @@ -309,8 +309,8 @@ public class Mining { @Expose @ConfigOption( - name = "Position", - desc = "Change the position of the AMines of Divan overlay." + name = "Overlay Position", + desc = "Change the position of the Mines of Divan Overlay." ) @ConfigEditorButton( runnableId = 11, @@ -322,7 +322,7 @@ public class Mining { @Expose @ConfigOption( name = "Style", - desc = "Change the style of the Mines of Divan overlay." + desc = "Change the style of the Mines of Divan Overlay." ) @ConfigEditorDropdown( values = {"Background", "No Shadow", "Shadow", "Full Shadow"} @@ -333,7 +333,7 @@ public class Mining { @Expose @ConfigOption( name = "Show Icons", - desc = "Show icons in the overlay that represent the part." + desc = "Show icons in the Overlay that represent the part." ) @ConfigEditorBoolean @ConfigAccordionId(id = 6) -- cgit From f85740988b8fe5ae8255a97eca2333e63937f96c Mon Sep 17 00:00:00 2001 From: DoKM Date: Mon, 23 Aug 2021 14:13:19 +0200 Subject: First working version --- .../notenoughupdates/NEUEventListener.java | 89 +++++++++++++++++++++- .../moulberry/notenoughupdates/NEUOverlay.java | 1 + .../options/seperateSections/TooltipTweaks.java | 10 +++ .../moulberry/notenoughupdates/util/Utils.java | 81 ++++++++++++++++---- 4 files changed, 163 insertions(+), 18 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 4f565fa6..08fee4b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -1,10 +1,7 @@ package io.github.moulberry.notenoughupdates; 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.google.gson.*; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; @@ -37,6 +34,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -61,6 +59,7 @@ import java.awt.*; import java.awt.datatransfer.StringSelection; import java.io.File; import java.io.IOException; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; import java.util.*; @@ -1723,6 +1722,7 @@ public class NEUEventListener { String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); if(internalname == null) { + onItemToolTipInternalNameNull(event); return; } @@ -1780,6 +1780,8 @@ public class NEUEventListener { boolean dungeonProfit = false; int index = 0; List newTooltip = new ArrayList<>(); + + for(String line : event.toolTip) { if(line.endsWith(EnumChatFormatting.DARK_GRAY+"Reforge Stone") && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) { JsonObject reforgeStones = Constants.REFORGESTONES; @@ -2118,6 +2120,7 @@ public class NEUEventListener { newTooltip.add(line); + if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) { if(line.contains(EnumChatFormatting.GRAY+"Buy it now: ") || line.contains(EnumChatFormatting.GRAY+"Bidder: ") || @@ -2302,8 +2305,86 @@ public class NEUEventListener { if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) { ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); } + + //petToolTipXPExtend(event, false); + + + + } + + private Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))"); + + private void onItemToolTipInternalNameNull(ItemTooltipEvent event){ + petToolTipXPExtend(event, true); + } + private void petToolTipXPExtend(ItemTooltipEvent event, boolean xpBarExists) { + + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { + + + //7 is just a random number i chose, prob no pets with less lines than 7 + if (event.toolTip.size() > 7) { + + if (Utils.cleanColour(event.toolTip.get(1)).matches("((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)).*")) { + + GuiProfileViewer.PetLevel petlevel = null; + + //This is in the pets menu + if (xpBarExists) { + PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())); + if(pet == null){ + return; + } + Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(event.toolTip.size() - 3)); + if(matcher.matches()) { + event.toolTip.set(event.toolTip.size() - 3, matcher.group(1)); + } + petlevel = pet.petLevel; + } else { + //this is the item itself + NBTTagCompound tag = event.itemStack.getTagCompound(); + if (tag.hasKey("ExtraAttributes")) { + if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) { + JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson( + tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class); + if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { + JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); + int rarityOffset = Constants.PETS.get("pet_rarity_offset").getAsJsonObject().get( + Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); + petlevel = GuiProfileViewer.getPetLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarityOffset, exp.getAsLong()); + } + } + } + } + + if (petlevel == null) { + return; + } + if(petlevel.totalXp > petlevel.maxXP && !xpBarExists) { + event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD +"MAX LEVEL"); + } else { + if(!xpBarExists){ + int percentage = (int)Math.round(petlevel.levelPercentage*20); + + String bar = EnumChatFormatting.DARK_GREEN +String.join("", Collections.nCopies(percentage, "-"))+EnumChatFormatting.WHITE+String.join("", Collections.nCopies(20-percentage, "-")); + event.toolTip.add(event.toolTip.size() - 2, bar); + } + if(!xpBarExists || (xpBarExists && !Utils.cleanColour(event.toolTip.get(event.toolTip.size() - 3)).matches("MAX LEVEL"))) { + event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); + } + } + } + } + } + } + + DecimalFormat myFormatter = new DecimalFormat("###,###.###"); + + + + /** * This makes it so that holding LCONTROL while hovering over an item with NBT will show the NBT of the item. * @param event diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index d196f75a..e2e582fa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -2008,6 +2008,7 @@ public class NEUOverlay extends Gui { if(hasClick) text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"LMB/R : View recipe!"); if(hasInfo) text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"RMB : View additional information!"); + textToDisplay = text; } if(textToDisplay != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index 71508144..1bdbc84a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -95,6 +95,16 @@ public class TooltipTweaks { @ConfigEditorBoolean public boolean missingEnchantList = true; + @Expose + @ConfigOption( + name = "Expand Pet Exp Requirement", + desc = "Show which the full amount of pet xp required" + ) + @ConfigEditorBoolean + public boolean petExtendExp = true; + + + @Expose @ConfigOption( name = "Tooltip Border Colours", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 5ca9b316..8f373460 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -472,23 +472,74 @@ public class Utils { private static String[] rarityArr = new String[] { "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", }; + + public static String getRarityFromInt(int rarity){ + if(rarity < 0|| rarity >= rarityArr.length){ return rarityArr[0]; } + return rarityArr[rarity]; + } + + public static int checkItemTypePet(List lore){ + for(int i=lore.size()-1; i>=0; i--){ + String line = Utils.cleanColour(lore.get(i)); + for (int i1 = 0; i1 < rarityArr.length; i1++) { + if(line.equals(rarityArr[i1])){ + return i1; + } + } + } + return -1; + } + public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) { for(int i=lore.size()-1; i>=0; i--) { String line = lore.get(i).getAsString(); - for(String rarity : rarityArr) { - for(int j=0; j=0; i--) { + String line = lore[i]; + + int returnType = checkItemType(line, contains, typeMatches); + if(returnType != -1){ + return returnType; + } + } + return -1; + } + + public static int checkItemType(List lore, boolean contains, String... typeMatches) { + for(int i=lore.size()-1; i>=0; i--) { + String line = lore.get(i); + + int returnType = checkItemType(line, contains, typeMatches); + if(returnType != -1){ + return returnType; + } + } + return -1; + } + + private static int checkItemType(String line, boolean contains, String... typeMatches) { + for (String rarity : rarityArr) { + for (int j = 0; j < typeMatches.length; j++) { + if (contains) { + if (line.trim().contains(rarity + " " + typeMatches[j])) { + return j; + } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) { + return j; + } + } else { + if (line.trim().endsWith(rarity + " " + typeMatches[j])) { + return j; + } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) { + return j; } } } @@ -496,6 +547,8 @@ public class Utils { return -1; } + + public static void playPressSound() { playSound(new ResourceLocation("gui.button.press"), true); } -- cgit From 752e77d7407bfa7a0355677cd15d205fccf8d8f1 Mon Sep 17 00:00:00 2001 From: DoKM Date: Mon, 23 Aug 2021 15:15:15 +0200 Subject: Fix some pet xp tooltip bugs --- .../notenoughupdates/NEUEventListener.java | 120 ++++++++++++++------- .../moulberry/notenoughupdates/util/Utils.java | 7 +- 2 files changed, 85 insertions(+), 42 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 08fee4b2..29013ea5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2286,6 +2286,19 @@ public class NEUEventListener { index++; } + for (int i = newTooltip.size()-1; i >=0; i--) { + String line = Utils.cleanColour(newTooltip.get(i)); + for (int i1 = 0; i1 < Utils.rarityArr.length; i1++) { + if(line.equals(Utils.rarityArr[i1])){ + if(i-2 <0){ + break; + } + newTooltip.addAll(i-1, petToolTipXPExtend(event)); + break; + } + } + } + pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT); @@ -2306,7 +2319,7 @@ public class NEUEventListener { ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); } - //petToolTipXPExtend(event, false); + @@ -2315,15 +2328,13 @@ public class NEUEventListener { private Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))"); private void onItemToolTipInternalNameNull(ItemTooltipEvent event){ - petToolTipXPExtend(event, true); + petToolTipXPExtendPetMenu(event); } - private void petToolTipXPExtend(ItemTooltipEvent event, boolean xpBarExists) { - + private List petToolTipXPExtend(ItemTooltipEvent event) { + List tooltipText = new ArrayList(); if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { - - //7 is just a random number i chose, prob no pets with less lines than 7 if (event.toolTip.size() > 7) { @@ -2331,49 +2342,76 @@ public class NEUEventListener { GuiProfileViewer.PetLevel petlevel = null; - //This is in the pets menu - if (xpBarExists) { - PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())); - if(pet == null){ - return; + //this is the item itself + NBTTagCompound tag = event.itemStack.getTagCompound(); + if (tag.hasKey("ExtraAttributes")) { + if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) { + JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson( + tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class); + if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { + JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); + int rarityOffset = Constants.PETS.get("pet_rarity_offset").getAsJsonObject().get( + Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); + petlevel = GuiProfileViewer.getPetLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarityOffset, exp.getAsLong()); + } } - Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(event.toolTip.size() - 3)); - if(matcher.matches()) { - event.toolTip.set(event.toolTip.size() - 3, matcher.group(1)); + } + + + + if (petlevel != null) { + tooltipText.add(""); + if(petlevel.totalXp > petlevel.maxXP) { + tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD +"MAX LEVEL"); + } else { + tooltipText.add(EnumChatFormatting.GRAY+"Progress to Level "+(int)Math.floor(petlevel.level+1)+": "+EnumChatFormatting.YELLOW+Utils.round(petlevel.levelPercentage*100, 1)+"%"); + int levelpercentage = Math.round(petlevel.levelPercentage*20); + tooltipText.add(EnumChatFormatting.DARK_GREEN+String.join("", Collections.nCopies(levelpercentage, "-"))+EnumChatFormatting.WHITE+String.join("", Collections.nCopies(20-levelpercentage, "-"))); + tooltipText.add(EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); } - petlevel = pet.petLevel; - } else { - //this is the item itself - NBTTagCompound tag = event.itemStack.getTagCompound(); - if (tag.hasKey("ExtraAttributes")) { - if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) { - JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson( - tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class); - if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { - JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); - int rarityOffset = Constants.PETS.get("pet_rarity_offset").getAsJsonObject().get( - Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); - petlevel = GuiProfileViewer.getPetLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarityOffset, exp.getAsLong()); - } - } + } + } + } + } + return tooltipText; + } + + + private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) { + + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { + //7 is just a random number i chose, prob no pets with less lines than 7 + if (event.toolTip.size() > 7) { + if (Utils.cleanColour(event.toolTip.get(1)).matches("((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)).*")) { + GuiProfileViewer.PetLevel petlevel = null; + + PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())); + if (pet == null) { + return; + } + petlevel = pet.petLevel; + + boolean maxLevel = false; + int xpLine = -1; + for (int i = event.toolTip.size() - 1; i >= 0; i--) { + Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i)); + if (matcher.matches()) { + xpLine = i; + event.toolTip.set(xpLine, matcher.group(1)); + break; + } else if (event.toolTip.get(i).matches("MAX LEVEL")) { + xpLine = i; + maxLevel = true; } } - if (petlevel == null) { + if (petlevel == null||xpLine==-1) { return; } - if(petlevel.totalXp > petlevel.maxXP && !xpBarExists) { - event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD +"MAX LEVEL"); - } else { - if(!xpBarExists){ - int percentage = (int)Math.round(petlevel.levelPercentage*20); - String bar = EnumChatFormatting.DARK_GREEN +String.join("", Collections.nCopies(percentage, "-"))+EnumChatFormatting.WHITE+String.join("", Collections.nCopies(20-percentage, "-")); - event.toolTip.add(event.toolTip.size() - 2, bar); - } - if(!xpBarExists || (xpBarExists && !Utils.cleanColour(event.toolTip.get(event.toolTip.size() - 3)).matches("MAX LEVEL"))) { - event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); - } + + if (!maxLevel) { + event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 8f373460..3e84261c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -469,7 +469,7 @@ public class Utils { return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); } - private static String[] rarityArr = new String[] { + public static String[] rarityArr = new String[] { "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", }; @@ -547,6 +547,11 @@ public class Utils { return -1; } + public static float round (float value, int precision) { + int scale = (int) Math.pow(10, precision); + return (float) Math.round(value * scale) / scale; + } + public static void playPressSound() { -- cgit From c8a7dfb175a667ba2a3aef5bfa1cafeb5df9ae8d Mon Sep 17 00:00:00 2001 From: DoKM Date: Mon, 23 Aug 2021 15:49:18 +0200 Subject: Stop pet exp display showing on itemlist pet --- .../io/github/moulberry/notenoughupdates/NEUEventListener.java | 5 +++++ src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 29013ea5..c499ce0f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2335,6 +2335,11 @@ public class NEUEventListener { private List petToolTipXPExtend(ItemTooltipEvent event) { List tooltipText = new ArrayList(); if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { + if(event.itemStack.getTagCompound().hasKey("ItemList")){ + if(event.itemStack.getTagCompound().getBoolean("ItemList")){ + return tooltipText; + } + } //7 is just a random number i chose, prob no pets with less lines than 7 if (event.toolTip.size() > 7) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index e2e582fa..2208b53c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1987,7 +1987,14 @@ public class NEUOverlay extends Gui { //Render tooltip JsonObject json = tooltipToDisplay.get(); if(json != null) { + ItemStack stack = manager.jsonToStack(json); + { + NBTTagCompound tag = stack.getTagCompound(); + tag.setBoolean("ItemList", true); + stack.setTagCompound(tag); + } + List text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); String internalname = json.get("internalname").getAsString(); -- cgit From 3ff239d48b8b45e86efae37b8e9b1963927a6d8c Mon Sep 17 00:00:00 2001 From: DoKM Date: Mon, 23 Aug 2021 17:58:53 +0200 Subject: fix a small bug and some code clean up in pet exp extender --- .../moulberry/notenoughupdates/NEUEventListener.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index c499ce0f..fbf51fca 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2390,13 +2390,6 @@ public class NEUEventListener { if (Utils.cleanColour(event.toolTip.get(1)).matches("((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)).*")) { GuiProfileViewer.PetLevel petlevel = null; - PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())); - if (pet == null) { - return; - } - petlevel = pet.petLevel; - - boolean maxLevel = false; int xpLine = -1; for (int i = event.toolTip.size() - 1; i >= 0; i--) { Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i)); @@ -2405,19 +2398,22 @@ public class NEUEventListener { event.toolTip.set(xpLine, matcher.group(1)); break; } else if (event.toolTip.get(i).matches("MAX LEVEL")) { - xpLine = i; - maxLevel = true; + return; } } + PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())); + if (pet == null) { + return; + } + petlevel = pet.petLevel; + if (petlevel == null||xpLine==-1) { return; } + event.toolTip.add(xpLine+1, EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); - if (!maxLevel) { - event.toolTip.add(event.toolTip.size() - 2, EnumChatFormatting.YELLOW + "" + myFormatter.format(petlevel.levelXp) + "/" + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); - } } } } -- cgit From a48012a509a3733d908fc0a23ce07335ccb4493e Mon Sep 17 00:00:00 2001 From: DoKM Date: Tue, 24 Aug 2021 14:23:13 +0200 Subject: Very cool forge display test --- .../notenoughupdates/options/NEUConfig.java | 1 + .../options/seperateSections/Mining.java | 24 ++ .../notenoughupdates/overlays/MiningOverlay.java | 246 ++++++++++++++++++++- .../notenoughupdates/overlays/TimersOverlay.java | 1 - 4 files changed, 262 insertions(+), 10 deletions(-) (limited to 'src/main') 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 ee24472f..cbf92fb2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -335,6 +335,7 @@ public class NEUConfig extends Config { @Expose public long commissionsCompleted = 0L; @Expose public long experimentsCompleted = 0L; @Expose public long cookieBuffRemaining = 0L; + @Expose public List forgeItems = new ArrayList(); @Expose public int commissionMilestone = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 0609f970..57db90c6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -139,6 +139,30 @@ public class Mining { @ConfigAccordionId(id = 2) public int overlayStyle = 0; + + @Expose + @ConfigOption( + name = "Forge Display", + desc = "Change what gets shown in the Forge Display" + ) + @ConfigEditorDropdown( + values = {"Only Done", "Only Working", "Everything Except Locked", "Everything"} + ) + @ConfigAccordionId(id = 2) + public int forgeDisplay = 1; + + @Expose + @ConfigOption( + name = "Forge Location", + desc = "Change when the forge display gets shown" + ) + @ConfigEditorDropdown( + values = {"Dwarven mines", "DM+Crystal Hollows", "Everywhere except dungeons", "Everywhere"} + ) + @ConfigAccordionId(id = 2) + public int forgeDisplayLocation = 0; + + @ConfigOption( name = "Metal Detector Solver", desc = "" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index e6bc90ad..bc435ad9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -3,12 +3,14 @@ package io.github.moulberry.notenoughupdates.overlays; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Ordering; import com.google.gson.JsonObject; +import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -22,6 +24,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.WorldSettings; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.Sys; import java.util.*; import java.util.function.Supplier; @@ -85,9 +88,12 @@ public class MiningOverlay extends TextOverlay { } } + private static final Pattern timeRemainingForge = Pattern.compile("\\xA77Time Remaining: \\xA7a((?Completed!)|(((?[0-9]+)d)? ?((?[0-9]+)h)? ?((?[0-9]+)m)? ?((?[0-9]+)s)?))"); + private static final Pattern timeRemainingTab = Pattern.compile(".*[1-5]\\) (?.*): ((?Ready!)|(((?[0-9]+)d)? ?((?[0-9]+)h)? ?((?[0-9]+)m)? ?((?[0-9]+)s)?))"); @Override public void update() { overlayStrings = null; + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); /*if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; @@ -155,20 +161,86 @@ public class MiningOverlay extends TextOverlay { } }*/ + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) chest.inventorySlots; + IInventory lower = container.getLowerChestInventory(); + String containerName = lower.getDisplayName().getUnformattedText(); + if(containerName.equals("Forge") && lower.getSizeInventory() >= 36 && hidden != null){ + + itemLoop: + for (int i = 0; i < 5; i++) { + ItemStack stack = lower.getStackInSlot(i+11); + if(stack != null) { + + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + + + for (int i1 = 0; i1 < lore.length; i1++) { + String line = lore[i1]; + Matcher matcher = timeRemainingForge.matcher(line); + if (stack.getDisplayName().matches("\\xA7cSlot #([1-5])")){ + ForgeItem newForgeItem = new ForgeItem("Locked", 0,1, i, false); + replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true); + //empty Slot + } else if(stack.getDisplayName().matches("\\xA7aSlot #([1-5])")){ + ForgeItem newForgeItem = new ForgeItem("Empty", 0,0, i, false); + replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true); + } else if(matcher.matches()){ + String timeremainingString = matcher.group(1); + + long duration = 0; + + if(matcher.group("Completed")!= null && !matcher.group("Completed").equals("")){ + ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), 0, 2, i, false); + replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true); + } else { + + try { + if (matcher.group("days") != null && !matcher.group("days").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000; + } + if (matcher.group("hours") != null && !matcher.group("hours").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000; + } + if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000; + } + if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000; + } + } catch (Exception ignored) { + } + if (duration > 0) { + ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), System.currentTimeMillis() + duration, 2, i, false); + replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true); + } + } + + continue itemLoop; + } + } + //Locked Slot + + } + } + } + } + if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay && NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return; if(SBInfo.getInstance().getLocation() == null) return; if(!SBInfo.getInstance().getLocation().equals("mining_3") && !SBInfo.getInstance().getLocation().equals("crystal_hollows")) return; overlayStrings = new ArrayList<>(); commissionProgress.clear(); - List forgeStrings = new ArrayList<>(); - List forgeStringsEmpty = new ArrayList<>(); + String mithrilPowder = null; String gemstonePowder = null; - + int forgeInt = 0; boolean commissions = false; boolean forges = false; List players = playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + for(NetworkPlayerInfo info : players) { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); if(name.contains("Mithril Powder:")) { @@ -188,16 +260,57 @@ public class MiningOverlay extends TextOverlay { } String clean = StringUtils.cleanColour(name); if(forges && clean.startsWith(" ")) { + char firstChar = clean.trim().charAt(0); if(firstChar < '0' || firstChar > '9') { forges = false; } else { - if(name.contains("LOCKED")) continue; - if(name.contains("EMPTY")) { - forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + + if(name.contains("LOCKED")) { + ForgeItem item = new ForgeItem("Locked", 0,1, forgeInt, true); + replaceForgeOrAdd(item, hidden.forgeItems, true); + } else if(name.contains("EMPTY")) { + ForgeItem item = new ForgeItem("Empty", 0,0, forgeInt, true); + replaceForgeOrAdd(item, hidden.forgeItems, true); + //forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); } else { - forgeStrings.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + String cleanName = Utils.cleanColour(name); + + Matcher matcher = timeRemainingTab.matcher(cleanName); + + if(matcher.matches()){ + + String itemName = matcher.group(1); + + if(matcher.group("Ready") != null && !matcher.group("Ready").equals("")){ + ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), 0, 2, forgeInt, true); + replaceForgeOrAdd(item, hidden.forgeItems, true); + } else { + long duration = 0; + try { + if (matcher.group("days") != null && !matcher.group("days").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000; + } + if (matcher.group("hours") != null && !matcher.group("hours").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000; + } + if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000; + } + if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) { + duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000; + } + } catch (Exception ignored) { + } + if (duration > 0) { + duration = duration + 4000; + ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), System.currentTimeMillis() + duration, 2, forgeInt, true); + replaceForgeOrAdd(item, hidden.forgeItems, false); + } + } + } } + forgeInt++; } } else if(commissions && clean.startsWith(" ")) { String[] split = clean.trim().split(": "); @@ -269,6 +382,8 @@ public class MiningOverlay extends TextOverlay { pickaxeCooldown = DARK_AQUA+"Pickaxe CD: \u00a7a" + (ItemCooldowns.pickaxeUseCooldownMillisRemaining/1000) + "s"; } + + for(int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { switch(index) { case 0: @@ -278,9 +393,9 @@ public class MiningOverlay extends TextOverlay { case 2: overlayStrings.add(gemstonePowder); break; case 3: - overlayStrings.addAll(forgeStrings); break; + overlayStrings.addAll(getForgeStrings(hidden.forgeItems)); break; case 4: - overlayStrings.addAll(forgeStringsEmpty); break; + //overlayStrings.addAll(forgeStringsEmpty); break; case 5: overlayStrings.add(pickaxeCooldown); break; } @@ -289,6 +404,119 @@ public class MiningOverlay extends TextOverlay { if(overlayStrings.isEmpty()) overlayStrings = null; } + private static List getForgeStrings(List forgeItems){ + List forgeString = new ArrayList<>(); + long currentTimeMillis = System.currentTimeMillis(); + forgeIDLabel: + for (int i = 0; i < 5; i++) { + for (int y = 0; y < forgeItems.size(); y++) { + if (forgeItems.get(y).forgeID == i) { + ForgeItem item = forgeItems.get(y); + if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 0) { + if (item.status == 2 && item.finishTime < currentTimeMillis) { + + forgeString.add(item.getFormattedString(currentTimeMillis)); + continue forgeIDLabel; + } + } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 1) { + if (item.status == 2) { + + forgeString.add(item.getFormattedString(currentTimeMillis)); + continue forgeIDLabel; + } + } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 2) { + if (item.status == 2 || item.status ==0) { + + forgeString.add(item.getFormattedString(currentTimeMillis)); + continue forgeIDLabel; + } + } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 3) { + + forgeString.add(item.getFormattedString(currentTimeMillis)); + continue forgeIDLabel; + } + } + } + } + return forgeString; + } + + private static void replaceForgeOrAdd(ForgeItem item, List forgeItems, boolean overwrite){ + for (int i = 0; i < forgeItems.size(); i++) { + if (forgeItems.get(i).forgeID == item.forgeID) { + if (overwrite) { + forgeItems.set(i, item); + return; + } else { + ForgeItem currentItem = forgeItems.get(i); + if (!(currentItem.status == 2 && item.status ==2)) { + forgeItems.set(i, item); + return; + } else if(currentItem.fromScoreBoard){ + forgeItems.set(i, item); + return; + } + } + return; + } + } + forgeItems.add(item); + return; + } + + public static class ForgeItem{ + public ForgeItem(String itemName, long finishTime, int status, int forgeID, boolean fromScoreBoard){ + this.itemName = itemName; + this.finishTime = finishTime; + this.status = status; + this.forgeID = forgeID; + this.fromScoreBoard = fromScoreBoard; + } + + + @Expose public final String itemName; + @Expose public final long finishTime; + @Expose public final int status; + @Expose public final int forgeID; + @Expose public final boolean fromScoreBoard; + + + + public String getFormattedString(long currentTimeMillis){ + String returnText = EnumChatFormatting.AQUA+"Forge "+(this.forgeID+1)+": "; + if(status == 0){ + return returnText +EnumChatFormatting.GRAY +"Empty"; + } else if(status == 1){ + return returnText+ EnumChatFormatting.DARK_RED+"Locked"; + } + + long timeDuration = finishTime - currentTimeMillis; + returnText = returnText+ EnumChatFormatting.DARK_PURPLE +this.itemName+" : "; + + int days = (int) (timeDuration / (1000*60*60*24)); + timeDuration = timeDuration-(days*(1000*60*60*24)); + int hours = (int) ((timeDuration / (1000*60*60)) % 24); + + if(days > 0){ + return returnText+EnumChatFormatting.AQUA+days+"d "+hours+"h"; + } + timeDuration = timeDuration-(hours*(1000*60*60)); + int minutes = (int) ((timeDuration / (1000*60)) % 60); + if(hours > 0){ + return returnText+EnumChatFormatting.AQUA+hours+"h "+minutes+"m"; + } + timeDuration = timeDuration-(minutes*(1000*60)); + int seconds = (int) (timeDuration / 1000) % 60 ; + if(minutes > 0){ + return returnText+EnumChatFormatting.AQUA+minutes+"m "+seconds+"s"; + } else if(seconds > 0){ + return returnText+EnumChatFormatting.AQUA+seconds+"s"; + } else { + return returnText+ EnumChatFormatting.DARK_GREEN+"Done"; + } + } + } + private static final Ordering playerOrdering = Ordering.from(new PlayerComparator()); @SideOnly(Side.CLIENT) 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 c3e33a83..728703ad 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -243,7 +243,6 @@ public class TimersOverlay extends TextOverlay { } if (godpotRemaingTimeUnformatted.length >= 1) { godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000; - } } catch (Exception ignored) { } -- cgit