From 6d0e71699f4ec29c444aa867748ecb408756a01d Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Tue, 24 Aug 2021 10:40:18 +0200 Subject: semi finished crystal hollow overlay --- .../notenoughupdates/NEUEventListener.java | 8 +- .../notenoughupdates/options/NEUConfig.java | 46 +-- .../options/seperateSections/Mining.java | 204 ++++------- .../overlays/AutomatonOverlay.java | 166 --------- .../overlays/CrystalHollowOverlay.java | 403 +++++++++++++++++++++ .../overlays/DivanMinesOverlay.java | 142 -------- .../notenoughupdates/overlays/OverlayManager.java | 95 +++-- 7 files changed, 560 insertions(+), 504 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 4f565fa6..62a94ab8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -836,10 +836,10 @@ public class NEUEventListener { if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")){ CrystalMetalDetectorSolver.reset(); } - if(unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ")) - OverlayManager.automatonOverlay.message(unformatted); - else if(unformatted.startsWith("[NPC] Keeper of ")) - OverlayManager.divanMinesOverlay.message(unformatted); + if(unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ") || unformatted.startsWith("✦") || + unformatted.equals(" You've earned a Crystal Loot Bundle!")) + OverlayManager.crystalHollowOverlay.message(unformatted); + System.out.println(unformatted); } public static boolean drawingGuiScreen = false; 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..9327636a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -16,6 +16,7 @@ import io.github.moulberry.notenoughupdates.overlays.*; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; +import org.luaj.vm2.ast.Str; import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; @@ -86,10 +87,7 @@ public class NEUConfig extends Config { editOverlay(activeConfigCategory, OverlayManager.bonemerangOverlay, itemOverlays.bonemerangPosition); return; case 10: - editOverlay(activeConfigCategory, OverlayManager.automatonOverlay, mining.automatonOverlayPosition); - return; - case 11: - editOverlay(activeConfigCategory, OverlayManager.divanMinesOverlay, mining.divanMinesOverlayPosition); + editOverlay(activeConfigCategory, OverlayManager.crystalHollowOverlay, mining.crystalHollowOverlayPosition); } } @@ -338,23 +336,29 @@ public class NEUConfig extends Config { @Expose public int commissionMilestone = 0; - @Expose public HashMap automatonParts = new HashMap<>(); - - @Expose public HashMap divanMinesParts = new HashMap<>(); - - public HiddenProfileSpecific(){ - automatonParts.putIfAbsent("Electron Transmitter", false); - automatonParts.putIfAbsent("FTX 3070", false); - automatonParts.putIfAbsent("Robotron Reflector", false); - automatonParts.putIfAbsent("Superlite Motor", false); - automatonParts.putIfAbsent("Control Switch", false); - automatonParts.putIfAbsent("Synthetic Heart", false); - - divanMinesParts.putIfAbsent("Scavenged Lapis Sword", false); - divanMinesParts.putIfAbsent("Scavenged Golden Hammer", false); - divanMinesParts.putIfAbsent("Scavenged Diamond Axe", false); - divanMinesParts.putIfAbsent("Scavenged Emerald Hammer", false); - } + @Expose public HashMap automatonParts = new HashMap(){{ + put("Electron Transmitter", false); + put("FTX 3070", false); + put("Robotron Reflector", false); + put("Superlite Motor", false); + put("Control Switch", false); + put("Synthetic Heart", false); + }}; + + @Expose public HashMap divanMinesParts = new HashMap(){{ + put("Scavenged Lapis Sword", false); + put("Scavenged Golden Hammer", false); + put("Scavenged Diamond Axe", false); + put("Scavenged Emerald Hammer", false); + }}; + + @Expose public HashMap crystals = new HashMap(){{ + put("Jade", 0); + put("Amber", 0); + put("Amethyst", 0); + put("Sapphire", 0); + put("Topaz", 0); + }}; } public static List createDefaultInventoryButtons() { 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..4a4d5e23 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 @@ -166,169 +166,109 @@ public class Mining { public boolean metalDetectorShowPossible = false; @ConfigOption( - name = "Automaton Parts Overlay", + name = "Crystal Hollows Overlay", desc = "" ) - @ConfigEditorAccordion(id = 4) - public boolean automatonOverlayAccordion = false; + @ConfigEditorAccordion(id = 6) + public boolean crystalHollowOverlayAccordion = false; @Expose @ConfigOption( name = "Enabled", - desc = "Enables the Automaton parts overlay." + desc = "Enables the Crystal Hollows Overlay." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 4) - public boolean automatonOverlay = false; + @ConfigAccordionId(id = 6) + public boolean crystalHollowOverlay = false; @Expose @ConfigOption( name = "Position", - desc = "Change the position of the Automaton parts overlay." + desc = "Change the position of the Crystal Hollows Overlay overlay." ) @ConfigEditorButton( runnableId = 10, buttonText = "Edit" ) - @ConfigAccordionId(id = 4) - public Position automatonOverlayPosition = new Position(200, 0); - - @Expose - @ConfigOption( - name = "Style", - desc = "Change the style of the Automaton parts overlay." - ) - @ConfigEditorDropdown( - values = {"Background", "No Shadow", "Shadow", "Full Shadow"} - ) - @ConfigAccordionId(id = 4) - public int automatonOverlayStyle = 0; - - @Expose - @ConfigOption( - name = "Show Icons", - desc = "Show icons in the overlay that represent the part." - ) - @ConfigEditorBoolean - @ConfigAccordionId(id = 4) - public boolean automatonIcons = true; - - - @Expose - @ConfigOption( - name = "Hide Done", - desc = "Don't show parts you've given to Professor Robot." - ) - @ConfigEditorBoolean - @ConfigAccordionId(id = 4) - public boolean automatonHideDone = false; - - @ConfigOption( - name = "Colours", - desc = "" - ) - @ConfigEditorAccordion(id = 5) - @ConfigAccordionId(id = 4) - public boolean AutomatonColourAccordion = false; - - @Expose - @ConfigOption( - name = "Part colour", - desc = "Change the colour of the part text." - - ) - @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"} - ) - @ConfigAccordionId(id = 5) - public int automatonPartColor = 3; - - @Expose - @ConfigOption( - name = "Ready colour", - desc = "Change the colour when the part is given to Professor Robot." - - ) - @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"} - ) - @ConfigAccordionId(id = 5) - public int automatonDoneColor = 10; - - @Expose - @ConfigOption( - name = "In Inventory Color", - desc = "Change the colour when the part is in the inventory." - - ) - @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"} - ) - @ConfigAccordionId(id = 5) - public int automatonInventoryColor = 14; + @ConfigAccordionId(id = 6) + public Position crystalHollowOverlayPosition = new Position(200, 0); @Expose @ConfigOption( - name = "In Storage Color", - desc = "Change the colour when the part is in the storage." - + name = "Text", + desc = "\u00a7eDrag text to change the appearance of the overlay" ) - @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"} + @ConfigEditorDraggableList( + exampleText = { + "\u00a73Amber Crystal: \u00a7aPlaced\n" + + "\u00a73Sapphire Crystal: \u00a7eCollected\n" + + "\u00a73Jade Crystal: \u00a7eMissing\n" + + "\u00a73Amethyst Crystal: \u00a7cMissing\n" + + "\u00a73Topaz Crystal: \u00a7cMissing\n", + "\u00a73Crystals: \u00a7a4/5", + "\u00a73Crystals: \u00a7a80%", + "\u00a73Electron Transmitter: \u00a7aDone\n" + + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + + "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Control Switch: \u00a7cMissing\n" + + "\u00a73FTX 3070: \u00a7cMissing", + "\u00a73Electron Transmitter: \u00a7a3\n" + + "\u00a73Robotron Reflector: \u00a7e2\n" + + "\u00a73Superlite Motor: \u00a7e1\n" + + "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Control Switch: \u00a7c0\n" + + "\u00a73FTX 3070: \u00a7c0", + "\u00a73Automaton parts: \u00a7a5/6", + "\u00a73Automaton parts: \u00a7a83%", + "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" + + "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" + + "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" + + "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n", + "\u00a73Scavenged Lapis Sword: \u00a7a3\n" + + "\u00a73Scavenged Golden Hammer: \u00a7e2\n" + + "\u00a73Scavenged Diamond Axe: \u00a7e1\n" + + "\u00a73Scavenged Emerald Hammer: \u00a7c0\n", + "\u00a73Mines of Divan parts: \u00a7a3/4", + "\u00a73Mines of Divan parts: \u00a7a75%" + } ) - @ConfigAccordionId(id = 5) - public int automatonStorageColor = 14; + @ConfigAccordionId(id = 6) + public List crystalHollowText = new ArrayList<>(Arrays.asList(0, 3, 7)); @Expose @ConfigOption( - name = "Missing Color", - desc = "Change the colour when the part is missing." - + name = "Style", + desc = "Change the style of the Crystal Hollows Overlay overlay." ) @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"} - ) - @ConfigAccordionId(id = 5) - public int automatonMissingColor = 12; - - @ConfigOption( - name = "Mines of Divan overlay", - desc = "" - ) - @ConfigEditorAccordion(id = 6) - public boolean divanMinesOverlayAccordion = false; - - @Expose - @ConfigOption( - name = "Enabled", - desc = "Enables the Mines of Divan overlay." + values = {"Background", "No Shadow", "Shadow", "Full Shadow"} ) - @ConfigEditorBoolean @ConfigAccordionId(id = 6) - public boolean divanMinesOverlay = false; + public int crystalHollowOverlayStyle = 0; @Expose @ConfigOption( - name = "Position", - desc = "Change the position of the AMines of Divan overlay." + name = "Show Automaton", + desc = "Change where to show Automaton parts." ) - @ConfigEditorButton( - runnableId = 11, - buttonText = "Edit" + @ConfigEditorDropdown( + values = {"Crystal Hollows", "Precursor Remnants", "Lost Precursor City"} ) @ConfigAccordionId(id = 6) - public Position divanMinesOverlayPosition = new Position(200, 0); + public int crystalHollowAutomatonLocation = 2; @Expose @ConfigOption( - name = "Style", - desc = "Change the style of the Mines of Divan overlay." + name = "Show Automaton", + desc = "Change where to show Automaton parts." ) @ConfigEditorDropdown( - values = {"Background", "No Shadow", "Shadow", "Full Shadow"} + values = {"Crystal Hollows", "Mithril Deposits", "Mines of Divan"} ) @ConfigAccordionId(id = 6) - public int divanMinesOverlayStyle = 0; + public int crystalHollowDivanLocation = 2; + @Expose @ConfigOption( @@ -337,17 +277,17 @@ public class Mining { ) @ConfigEditorBoolean @ConfigAccordionId(id = 6) - public boolean divanMinesIcons = true; + public boolean crystalHollowIcons = true; @Expose @ConfigOption( name = "Hide Done", - desc = "Don't show parts you've given to the Keepers." + desc = "Don't show parts you've given to the NPC." ) @ConfigEditorBoolean @ConfigAccordionId(id = 6) - public boolean divanMinesHideDone = false; + public boolean crystalHollowHideDone = false; @ConfigOption( name = "Colours", @@ -355,7 +295,7 @@ public class Mining { ) @ConfigEditorAccordion(id = 7) @ConfigAccordionId(id = 6) - public boolean divanMinesColourAccordion = false; + public boolean crystalHollowColourAccordion = false; @Expose @ConfigOption( @@ -367,19 +307,19 @@ public class Mining { values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} ) @ConfigAccordionId(id = 7) - public int divanMinesPartColor = 3; + public int crystalHollowPartColor = 3; @Expose @ConfigOption( - name = "Ready colour", - desc = "Change the colour when the part is given to the Keepers." + name = "Done colour", + desc = "Change the colour when the part is given to the NPC." ) @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"} ) @ConfigAccordionId(id = 7) - public int divanMinesDoneColor = 10; + public int crystalHollowDoneColor = 10; @Expose @ConfigOption( @@ -391,7 +331,7 @@ public class Mining { values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} ) @ConfigAccordionId(id = 7) - public int divanMinesInventoryColor = 14; + public int crystalHollowInventoryColor = 14; @Expose @ConfigOption( @@ -403,7 +343,7 @@ public class Mining { values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} ) @ConfigAccordionId(id = 7) - public int divanMinesStorageColor = 14; + public int crystalHollowStorageColor = 14; @Expose @ConfigOption( @@ -415,7 +355,7 @@ public class Mining { values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"} ) @ConfigAccordionId(id = 7) - public int divanMinesMissingColor = 12; + public int crystalHollowMissingColor = 12; @Expose @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java deleted file mode 100644 index a0ef88b8..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java +++ /dev/null @@ -1,166 +0,0 @@ -package io.github.moulberry.notenoughupdates.overlays; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; -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; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import org.lwjgl.util.vector.Vector2f; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class AutomatonOverlay extends TextOverlay { - private static final Minecraft mc = Minecraft.getMinecraft(); - private final StorageManager storageManager = StorageManager.getInstance(); - private final Pattern givePattern = Pattern.compile("\\[NPC] Professor Robot: Thanks for bringing me the (?[a-zA-Z0-9 ]+)! Bring me (\\d+|one) more components? to fix the giant!"); - private final Pattern notFinalPattern = Pattern.compile("\\[NPC] Professor Robot: That's not the final component! Bring me a (?[a-zA-Z0-9 ]+) to gain access to Automaton Prime's storage container!"); - - public AutomatonOverlay(Position position, Supplier> dummyStrings, Supplier styleSupplier) { - super(position, dummyStrings, styleSupplier); - } - - @Override - public void update() { - overlayStrings = null; - if (!NotEnoughUpdates.INSTANCE.config.mining.automatonOverlay || SBInfo.getInstance().getLocation() == null || - !SBInfo.getInstance().getLocation().equals("crystal_hollows") || !SBInfo.getInstance().location.equals("Lost Precursor City")) - return; - - NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); - if (hidden == null) return; - overlayStrings = new ArrayList<>(); - HashMap states = new HashMap<>(); - for (String key : hidden.automatonParts.keySet()) { - Boolean has = hidden.automatonParts.get(key); - if (has) - states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.automatonDoneColor] + "Done"); - } - for (ItemStack item : mc.thePlayer.inventory.mainInventory) { - if (item != null) { - String name = Utils.cleanColour(item.getDisplayName()); - if (!states.containsKey(name)) { - states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.automatonInventoryColor] + "In Inventory"); - } - } - } - for (Map.Entry entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) { - int storageId = entry.getValue(); - StorageManager.StoragePage page = storageManager.getPage(storageId, false); - if (page != null && page.rows > 0) { - for (ItemStack item : page.items) { - if (item != null) { - String name = Utils.cleanColour(item.getDisplayName()); - if (!states.containsKey(name)) { - states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.automatonStorageColor] + "In Storage"); - } - } - } - } - } - for (String key : hidden.automatonParts.keySet()) { - if (!NotEnoughUpdates.INSTANCE.config.mining.automatonHideDone || !hidden.automatonParts.get(key)) { - if (!states.containsKey(key)) - states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.automatonMissingColor] + "Missing"); - overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.automatonPartColor] + key + ": " + states.get(key)); - } - } - } - - public void message(String message) { - NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); - if (hidden == null) return; - if (message.startsWith(" ")) { - String item = message.replace(" ", ""); - if (hidden.automatonParts.containsKey(item)) { - hidden.automatonParts.put(item, false); - } - } else if (message.startsWith("[NPC] Professor Robot: ")) { - switch (message) { - case "[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:": - hidden.automatonParts.replaceAll((k, v) -> true); - break; - case "[NPC] Professor Robot: You've brought me all of the components!": - case "[NPC] Professor Robot: You haven't placed the Sapphire Crystal yet!": - case "[NPC] Professor Robot: You have already placed the Sapphire Crystal!": - hidden.automatonParts.replaceAll((k, v) -> false); - break; - default: - Matcher giveMatcher = givePattern.matcher(message); - Matcher notFinalMatcher = notFinalPattern.matcher(message); - if (giveMatcher.matches()) { - String item = giveMatcher.group("part"); - if (hidden.automatonParts.containsKey(item)) { - hidden.automatonParts.put(item, true); - } - } else if (notFinalMatcher.matches()) { - String item = notFinalMatcher.group("part"); - if (hidden.automatonParts.containsKey(item)) { - hidden.automatonParts.replaceAll((k, v) -> true); - hidden.automatonParts.put(item, false); - } - } - break; - } - } - } - - @Override - protected void renderLine(String line, Vector2f position, boolean dummy) { - if (!NotEnoughUpdates.INSTANCE.config.mining.automatonIcons) return; - GlStateManager.enableDepth(); - - ItemStack icon = null; - String cleaned = Utils.cleanColour(line); - String beforeColon = cleaned.split(":")[0]; - switch (beforeColon) { - case "Electron Transmitter": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ELECTRON_TRANSMITTER")); - break; - case "FTX 3070": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("FTX_3070")); - break; - case "Robotron Reflector": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROBOTRON_REFLECTOR")); - break; - case "Superlite Motor": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SUPERLITE_MOTOR")); - break; - case "Control Switch": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CONTROL_SWITCH")); - break; - case "Synthetic Heart": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SYNTHETIC_HEART")); - break; - } - - if (icon != null) { - GlStateManager.pushMatrix(); - GlStateManager.translate(position.x - 2, position.y - 2, 0); - GlStateManager.scale(0.7f, 0.7f, 1f); - Utils.drawItemStack(icon, 0, 0); - GlStateManager.popMatrix(); - - position.x += 12; - } - - super.renderLine(line, position, dummy); - } - - @Override - protected Vector2f getSize(List strings) { - if (NotEnoughUpdates.INSTANCE.config.mining.automatonIcons) - return super.getSize(strings).translate(12, 0); - return super.getSize(strings); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java new file mode 100644 index 00000000..3dadca29 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java @@ -0,0 +1,403 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +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; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.util.vector.Vector2f; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CrystalHollowOverlay extends TextOverlay { + private static final Minecraft mc = Minecraft.getMinecraft(); + private final StorageManager storageManager = StorageManager.getInstance(); + private final Pattern notFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Talk to me when you have found a (?[a-z-A-Z ]+)!"); + private final Pattern foundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Excellent! You have returned the (?[a-z-A-Z ]+) to its rightful place!"); + private final Pattern resetPattern = Pattern.compile("\\[NPC] Keeper of \\w+: (You found all of the items! Behold\\.\\.\\. the Jade Crystal!)"); + private final Pattern alreadyFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: You have already restored this Dwarf's (?[a-z-A-Z ]+)!"); + private final Pattern givePattern = Pattern.compile("\\[NPC] Professor Robot: Thanks for bringing me the (?[a-zA-Z0-9 ]+)! Bring me (\\d+|one) more components? to fix the giant!"); + private final Pattern notFinalPattern = Pattern.compile("\\[NPC] Professor Robot: That's not the final component! Bring me a (?[a-zA-Z0-9 ]+) to gain access to Automaton Prime's storage container!"); + private final Pattern obtainCrystalPattern = Pattern.compile(" +(?[a-zA-Z]+) Crystal"); + private final Pattern crystalNotPlacedPattern = Pattern.compile(".*: You haven't placed the (?[a-zA-Z]+) Crystal yet!"); + private final Pattern crystalPlacedPattern = Pattern.compile(".*: You have already placed the (?[a-zA-Z]+) Crystal!"); + private final Pattern crystalPlacePattern = Pattern.compile("✦ You placed the (?[a-zA-Z]+) Crystal!"); + private final Pattern crystalReclaimPattern = Pattern.compile("✦ You reclaimed the (?[a-zA-Z]+) Crystal!"); + + public CrystalHollowOverlay(Position position, Supplier> dummyStrings, Supplier styleSupplier) { + super(position, dummyStrings, styleSupplier); + } + + @Override + public void update() { + overlayStrings = null; + if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlay || SBInfo.getInstance().getLocation() == null || + !SBInfo.getInstance().getLocation().equals("crystal_hollows")) + return; + + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (hidden == null) return; + overlayStrings = new ArrayList<>(); + HashMap inventoryData = new HashMap<>(); + for (String key : hidden.automatonParts.keySet()) + inventoryData.put(key, 0); + for (String key : hidden.divanMinesParts.keySet()) + inventoryData.put(key, 0); + HashMap storageData = new HashMap<>(inventoryData); + for (ItemStack item : mc.thePlayer.inventory.mainInventory) + if (item != null) { + String name = Utils.cleanColour(item.getDisplayName()); + if (inventoryData.containsKey(name)) + inventoryData.put(name, inventoryData.get(name) + item.stackSize); + } + for (Map.Entry entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) { + int storageId = entry.getValue(); + StorageManager.StoragePage page = storageManager.getPage(storageId, false); + if (page != null && page.rows > 0) + for (ItemStack item : page.items) + if (item != null) { + String name = Utils.cleanColour(item.getDisplayName()); + if (storageData.containsKey(name)) + storageData.put(name, storageData.get(name) + item.stackSize); + } + } + + for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) { + switch (i) { + case 0: + if (crystalCheck()) { + for (String part : hidden.crystals.keySet()) { + switch (hidden.crystals.get(part)) { + case 2: + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + "Placed"); + break; + case 1: + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] + "Collected"); + break; + case 0: + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + "Missing"); + break; + } + } + } + break; + case 1: + if (crystalCheck()) { + int count = getCountCrystal(hidden.crystals); + float percent = (float) count / hidden.crystals.size() * 100; + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + "Crystals: " + getColor(percent) + count + + "/" + hidden.crystals.size()); + } + break; + case 2: + if (crystalCheck()) { + int count = getCountCrystal(hidden.crystals); + float percent = (float) count / hidden.crystals.size() * 100; + DecimalFormat df = new DecimalFormat("#.#"); + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + "Crystals: " + getColor(percent) + + df.format(percent) + "%"); + } + break; + case 3: + if (automatonCheck()) + renderParts(hidden.automatonParts, inventoryData, storageData); + break; + case 4: + if (automatonCheck()) + renderPartsNumbers(hidden.automatonParts, inventoryData, storageData); + break; + case 5: + if (automatonCheck()) + renderCount("Automaton parts", hidden.automatonParts, inventoryData, storageData); + break; + case 6: + if (automatonCheck()) + renderPercent("Automaton parts", hidden.automatonParts, inventoryData, storageData); + break; + case 7: + if (divanCheck()) + renderParts(hidden.divanMinesParts, inventoryData, storageData); + break; + case 8: + if (divanCheck()) + renderPartsNumbers(hidden.divanMinesParts, inventoryData, storageData); + break; + case 9: + if (divanCheck()) + renderCount("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData); + break; + case 10: + if (divanCheck()) + renderPercent("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData); + break; + } + } + } + + private void renderParts(HashMap parts, HashMap inventoryData, HashMap storageData) { + for (String part : parts.keySet()) { + if (parts.get(part)) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + "Done"); + else if (inventoryData.get(part) >= 1) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] + "In Inventory"); + else if (storageData.get(part) >= 1) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] + "In Storage"); + else + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + "Missing"); + } + } + + private void renderPartsNumbers(HashMap parts, HashMap inventoryData, HashMap storageData) { + for (String part : parts.keySet()) { + if (parts.get(part)) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + (inventoryData.get(part) + storageData.get(part))); + else if (inventoryData.get(part) >= 1) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] + (inventoryData.get(part) + storageData.get(part))); + else if (storageData.get(part) >= 1) + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] + (inventoryData.get(part) + storageData.get(part))); + else + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + (inventoryData.get(part) + storageData.get(part))); + } + } + + private void renderCount(String text, HashMap parts, HashMap inventoryData, HashMap storageData) { + int count = getCount(parts, inventoryData, storageData); + float percent = (float) count / parts.size() * 100; + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " + getColor(percent) + count + + "/" + parts.size()); + } + + private void renderPercent(String text, HashMap parts, HashMap inventoryData, HashMap storageData) { + int count = getCount(parts, inventoryData, storageData); + float percent = (float) count / parts.size() * 100; + DecimalFormat df = new DecimalFormat("#.#"); + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " + getColor(percent) + + df.format(percent) + "%"); + } + + private EnumChatFormatting getColor(float percent) { + if (percent >= 66) + return EnumChatFormatting.GREEN; + else if (percent >= 33) + return EnumChatFormatting.YELLOW; + else + return EnumChatFormatting.RED; + } + + private int getCount(HashMap parts, HashMap inventoryData, HashMap storageData) { + int count = 0; + for (String part : parts.keySet()) + if (parts.get(part) || inventoryData.get(part) > 0 || storageData.get(part) > 0) + count++; + return count; + } + + private int getCountCrystal(HashMap parts) { + int count = 0; + for (String part : parts.keySet()) + if (parts.get(part) > 0) + count++; + return count; + } + + private boolean automatonCheck() { + return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 0 || + NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 1 && + SBInfo.getInstance().location.equals("Precursor Remnants") || + NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation >= 1 && + SBInfo.getInstance().location.equals("Lost Precursor City"); + } + + private boolean divanCheck() { + return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 0 || + NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 1 && + SBInfo.getInstance().location.equals("Mithril Deposits") || + NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation >= 1 && + SBInfo.getInstance().location.equals("Mines of Divan"); + } + + private boolean crystalCheck() { + return true; + } + + public void message(String message) { + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (hidden == null) return; + + Matcher crystalNotPlacedMatcher = crystalNotPlacedPattern.matcher(message); + Matcher crystalPlacedMatcher = crystalPlacedPattern.matcher(message); + Matcher crystalPlaceMatcher = crystalPlacePattern.matcher(message); + Matcher crystalReclaimMatcher = crystalReclaimPattern.matcher(message); + if(message.equals(" You've earned a Crystal Loot Bundle!")) + hidden.crystals.replaceAll((k,v) -> 0); + if (crystalNotPlacedMatcher.matches() && hidden.crystals.containsKey(crystalNotPlacedMatcher.group("crystal"))) { + hidden.crystals.put(crystalNotPlacedMatcher.group("crystal"), 1); + resetCrystal(hidden, crystalNotPlacedMatcher.group("crystal")); + } else if (crystalPlacedMatcher.matches() && hidden.crystals.containsKey(crystalPlacedMatcher.group("crystal"))) { + hidden.crystals.put(crystalPlacedMatcher.group("crystal"), 2); + resetCrystal(hidden, crystalPlacedMatcher.group("crystal")); + } else if (crystalPlaceMatcher.matches() && hidden.crystals.containsKey(crystalPlaceMatcher.group("crystal"))) + hidden.crystals.put(crystalPlaceMatcher.group("crystal"), 2); + else if (crystalReclaimMatcher.matches() && hidden.crystals.containsKey(crystalReclaimMatcher.group("crystal"))) + hidden.crystals.put(crystalReclaimMatcher.group("crystal"), 1); + else if (message.startsWith("[NPC] Keeper of ")) { + Matcher foundMatcher = foundPattern.matcher(message); + Matcher alreadyFoundMatcher = alreadyFoundPattern.matcher(message); + Matcher notFoundMatcher = notFoundPattern.matcher(message); + Matcher resetMatcher = resetPattern.matcher(message); + if (foundMatcher.matches() && hidden.divanMinesParts.containsKey(foundMatcher.group("item"))) + hidden.divanMinesParts.put(foundMatcher.group("item"), true); + else if (notFoundMatcher.matches() && hidden.divanMinesParts.containsKey(notFoundMatcher.group("item"))) + hidden.divanMinesParts.put(notFoundMatcher.group("item"), false); + else if (resetMatcher.matches()) + hidden.divanMinesParts.replaceAll((k, v) -> false); + else if (alreadyFoundMatcher.matches() && hidden.divanMinesParts.containsKey(alreadyFoundMatcher.group("item"))) + hidden.divanMinesParts.put(alreadyFoundMatcher.group("item"), true); + } else if (message.startsWith(" ")) { + Matcher crystalMatcher = obtainCrystalPattern.matcher(message); + if (crystalMatcher.matches()) + if (hidden.crystals.containsKey(crystalMatcher.group("crystal"))) + hidden.crystals.put(crystalMatcher.group("crystal"), 1); + else { + String item = message.replace(" ", ""); + if (hidden.divanMinesParts.containsKey(item)) + hidden.divanMinesParts.put(item, false); + } + } else if (message.startsWith("[NPC] Professor Robot: ")) { + switch (message) { + case "[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:": + hidden.automatonParts.replaceAll((k, v) -> true); + break; + case "[NPC] Professor Robot: You've brought me all of the components!": + hidden.automatonParts.replaceAll((k, v) -> false); + break; + default: + Matcher giveMatcher = givePattern.matcher(message); + Matcher notFinalMatcher = notFinalPattern.matcher(message); + if (giveMatcher.matches()) { + String item = giveMatcher.group("part"); + if (hidden.automatonParts.containsKey(item)) { + hidden.automatonParts.put(item, true); + } + } else if (notFinalMatcher.matches()) { + String item = notFinalMatcher.group("part"); + if (hidden.automatonParts.containsKey(item)) { + hidden.automatonParts.replaceAll((k, v) -> true); + hidden.automatonParts.put(item, false); + } + } + break; + } + } + } + + private void resetCrystal(NEUConfig.HiddenProfileSpecific hidden, String crystal) { + switch (crystal) { + case "Sapphire": + hidden.automatonParts.replaceAll((k, v) -> false); + break; + case "Jade": + hidden.divanMinesParts.replaceAll((k, v) -> false); + break; + } + } + + @Override + protected void renderLine(String line, Vector2f position, boolean dummy) { + if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons) return; + GlStateManager.enableDepth(); + + ItemStack icon = null; + String cleaned = Utils.cleanColour(line); + String beforeColon = cleaned.split(":")[0]; + switch (beforeColon) { + case "Scavenged Lapis Sword": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_LAPIS_SWORD")); + break; + case "Scavenged Golden Hammer": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_GOLD_HAMMER")); + break; + case "Scavenged Diamond Axe": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_DIAMOND_AXE")); + break; + case "Scavenged Emerald Hammer": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_EMERALD_HAMMER")); + break; + case "Electron Transmitter": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ELECTRON_TRANSMITTER")); + break; + case "FTX 3070": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("FTX_3070")); + break; + case "Robotron Reflector": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROBOTRON_REFLECTOR")); + break; + case "Superlite Motor": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SUPERLITE_MOTOR")); + break; + case "Control Switch": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CONTROL_SWITCH")); + break; + case "Synthetic Heart": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SYNTHETIC_HEART")); + break; + case "Amber": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_AMBER_GEM")); + break; + case "Sapphire": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_SAPPHIRE_GEM")); + break; + case "Jade": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_JADE_GEM")); + break; + case "Amethyst": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_AMETHYST_GEM")); + break; + case "Topaz": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_TOPAZ_GEM")); + break; + } + + if (icon != null) { + GlStateManager.pushMatrix(); + GlStateManager.translate(position.x, position.y, 0); + GlStateManager.scale(0.5f, 0.5f, 1f); + Utils.drawItemStack(icon, 0, 0); + GlStateManager.popMatrix(); + + position.x += 12; + } + + super.renderLine(line, position, dummy); + } + + @Override + protected Vector2f getSize(List strings) { + if (NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons) + return super.getSize(strings).translate(12, 0); + return super.getSize(strings); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java deleted file mode 100644 index 85ac2f82..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java +++ /dev/null @@ -1,142 +0,0 @@ -package io.github.moulberry.notenoughupdates.overlays; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; -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; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import org.lwjgl.util.vector.Vector2f; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class DivanMinesOverlay extends TextOverlay { - private static final Minecraft mc = Minecraft.getMinecraft(); - private final StorageManager storageManager = StorageManager.getInstance(); - private final Pattern notFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Talk to me when you have found a (?[a-z-A-Z ]+)!"); - private final Pattern foundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Excellent! You have returned the (?[a-z-A-Z ]+) to its rightful place!"); - private final Pattern resetPattern = Pattern.compile("\\[NPC] Keeper of \\w+: (You haven't placed the Jade Crystal yet!|You found all of the items! Behold\\.\\.\\. the Jade Crystal!|You have already placed the Jade Crystal!)"); - private final Pattern alreadyFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: You have already restored this Dwarf's (?[a-z-A-Z ]+)!"); - - public DivanMinesOverlay(Position position, Supplier> dummyStrings, Supplier styleSupplier) { - super(position, dummyStrings, styleSupplier); - } - - @Override - public void update() { - overlayStrings = null; - if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlay || SBInfo.getInstance().getLocation() == null || - !SBInfo.getInstance().getLocation().equals("crystal_hollows") || !SBInfo.getInstance().location.equals("Mines of Divan")) - return; - - NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); - if (hidden == null) return; - overlayStrings = new ArrayList<>(); - HashMap states = new HashMap<>(); - for (String key : hidden.divanMinesParts.keySet()) { - Boolean has = hidden.divanMinesParts.get(key); - if (has) - states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesDoneColor] + "Done"); - } - for (ItemStack item : mc.thePlayer.inventory.mainInventory) { - if (item != null) { - String name = Utils.cleanColour(item.getDisplayName()); - if (!states.containsKey(name)) { - states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesInventoryColor] + "In Inventory"); - } - } - } - for (Map.Entry entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) { - int storageId = entry.getValue(); - StorageManager.StoragePage page = storageManager.getPage(storageId, false); - if (page != null && page.rows > 0) { - for (ItemStack item : page.items) { - if (item != null) { - String name = Utils.cleanColour(item.getDisplayName()); - if (!states.containsKey(name)) { - states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesStorageColor] + "In Storage"); - } - } - } - } - } - for (String key : hidden.divanMinesParts.keySet()) { - if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesHideDone || !hidden.divanMinesParts.get(key)) { - if (!states.containsKey(key)) - states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesMissingColor] + "Missing"); - overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesPartColor] + key + ": " + states.get(key)); - } - } - } - - public void message(String message) { - NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); - if (hidden == null) return; - Matcher foundMatcher = foundPattern.matcher(message); - Matcher alreadyFoundMatcher = alreadyFoundPattern.matcher(message); - Matcher notFoundMatcher = notFoundPattern.matcher(message); - Matcher resetMatcher = resetPattern.matcher(message); - System.out.println(message); - if (foundMatcher.matches() && hidden.divanMinesParts.containsKey(foundMatcher.group("item"))) - hidden.divanMinesParts.put(foundMatcher.group("item"), true); - else if (notFoundMatcher.matches() && hidden.divanMinesParts.containsKey(notFoundMatcher.group("item"))) - hidden.divanMinesParts.put(notFoundMatcher.group("item"), false); - else if (resetMatcher.matches()) - hidden.divanMinesParts.replaceAll((k, v) -> false); - else if (alreadyFoundMatcher.matches() && hidden.divanMinesParts.containsKey(alreadyFoundMatcher.group("item"))) - hidden.divanMinesParts.put(alreadyFoundMatcher.group("item"), true); - } - - @Override - protected void renderLine(String line, Vector2f position, boolean dummy) { - if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesIcons) return; - GlStateManager.enableDepth(); - - ItemStack icon = null; - String cleaned = Utils.cleanColour(line); - String beforeColon = cleaned.split(":")[0]; - switch (beforeColon) { - case "Scavenged Lapis Sword": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_LAPIS_SWORD")); - break; - case "Scavenged Golden Hammer": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_GOLD_HAMMER")); - break; - case "Scavenged Diamond Axe": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_DIAMOND_AXE")); - break; - case "Scavenged Emerald Hammer": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_EMERALD_HAMMER")); - break; - } - - if (icon != null) { - GlStateManager.pushMatrix(); - GlStateManager.translate(position.x, position.y, 0); - GlStateManager.scale(0.5f, 0.5f, 1f); - Utils.drawItemStack(icon, 0, 0); - GlStateManager.popMatrix(); - - position.x += 12; - } - - super.renderLine(line, position, dummy); - } - - @Override - protected Vector2f getSize(List strings) { - if (NotEnoughUpdates.INSTANCE.config.mining.divanMinesIcons) - return super.getSize(strings).translate(12, 0); - return super.getSize(strings); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index 0aa0d273..8ff0bff2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -16,8 +16,7 @@ public class OverlayManager { public static PetInfoOverlay petInfoOverlay; public static TimersOverlay timersOverlay; public static BonemerangOverlay bonemerangOverlay; - public static AutomatonOverlay automatonOverlay; - public static DivanMinesOverlay divanMinesOverlay; + public static CrystalHollowOverlay crystalHollowOverlay; public static final List textOverlays = new ArrayList<>(); static { @@ -38,13 +37,13 @@ public class OverlayManager { "\u00a73Experiments: \u00a7e3h38m"); textOverlays.add(timersOverlay = new TimersOverlay(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoPosition, () -> { List strings = new ArrayList<>(); - for(int i : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) { - if(i >= 0 && i < todoDummy.size()) strings.add(todoDummy.get(i)); + for (int i : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) { + if (i >= 0 && i < todoDummy.size()) strings.add(todoDummy.get(i)); } return strings; }, () -> { int style = NotEnoughUpdates.INSTANCE.config.miscOverlays.todoStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; @@ -56,13 +55,13 @@ public class OverlayManager { "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"); miningOverlay = new MiningOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> { List strings = new ArrayList<>(); - for(int i : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { - if(i >= 0 && i < miningDummy.size()) strings.add(miningDummy.get(i)); + for (int i : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { + if (i >= 0 && i < miningDummy.size()) strings.add(miningDummy.get(i)); } return strings; }, () -> { int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; @@ -77,13 +76,13 @@ public class OverlayManager { "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"); farmingOverlay = new FarmingOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingPosition, () -> { List strings = new ArrayList<>(); - for(int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) { - if(i >= 0 && i < farmingDummy.size()) strings.add(farmingDummy.get(i)); + for (int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) { + if (i >= 0 && i < farmingDummy.size()) strings.add(farmingDummy.get(i)); } return strings; }, () -> { int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; @@ -99,13 +98,13 @@ public class OverlayManager { "\u00a7bUntil L100: \u00a7e2d13h"); petInfoOverlay = new PetInfoOverlay(NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoPosition, () -> { List strings = new ArrayList<>(); - for(int i : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) { - if(i >= 0 && i < petInfoDummy.size()) strings.add(petInfoDummy.get(i)); + for (int i : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) { + if (i >= 0 && i < petInfoDummy.size()) strings.add(petInfoDummy.get(i)); } return strings; }, () -> { int style = NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoOverlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; @@ -117,34 +116,53 @@ public class OverlayManager { ); bonemerangOverlay = new BonemerangOverlay(NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangPosition, () -> bonemerangDummy, () -> { int style = NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; }); - List automatonOverlayDummy = Lists.newArrayList( - "\u00a73Electron Transmitter: \u00a7aDone", - "\u00a73Robotron Reflector: \u00a7eIn Storage", - "\u00a73Superlite Motor: \u00a7eIn Inventory", - "\u00a73Synthetic Hearth: \u00a7cMissing", - "\u00a73Control Switch: \u00a7cMissing", - "\u00a73FTX 3070: \u00a7cMissing"); - automatonOverlay = new AutomatonOverlay(NotEnoughUpdates.INSTANCE.config.mining.automatonOverlayPosition, () -> automatonOverlayDummy, () -> { - int style = NotEnoughUpdates.INSTANCE.config.mining.automatonOverlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { - return TextOverlayStyle.values()[style]; - } - return TextOverlayStyle.BACKGROUND; - }); - List divanMinesOverlayDummy = Lists.newArrayList( - "\u00a73Scavenged Lapis Sword: \u00a7aDone", - "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage", - "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory", - "\u00a73Scavenged Emerald Hammer: \u00a7cMissing" + List crystalHollowOverlayDummy = Lists.newArrayList( + "\u00a73Amber Crystal: \u00a7aPlaced\n" + + "\u00a73Sapphire Crystal: \u00a7eCollected\n" + + "\u00a73Jade Crystal: \u00a7eMissing\n" + + "\u00a73Amethyst Crystal: \u00a7cMissing\n" + + "\u00a73Topaz Crystal: \u00a7cMissing\n", + "\u00a73Crystals: \u00a7a4/5", + "\u00a73Crystals: \u00a7a80%", + "\u00a73Electron Transmitter: \u00a7aDone\n" + + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + + "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Control Switch: \u00a7cMissing\n" + + "\u00a73FTX 3070: \u00a7cMissing", + "\u00a73Electron Transmitter: \u00a7a3\n" + + "\u00a73Robotron Reflector: \u00a7e2\n" + + "\u00a73Superlite Motor: \u00a7e1\n" + + "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Control Switch: \u00a7c0\n" + + "\u00a73FTX 3070: \u00a7c0", + "\u00a73Automaton parts: \u00a7a5/6", + "\u00a73Automaton parts: \u00a7a83%", + "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" + + "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" + + "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" + + "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n", + "\u00a73Scavenged Lapis Sword: \u00a7a3\n" + + "\u00a73Scavenged Golden Hammer: \u00a7e2\n" + + "\u00a73Scavenged Diamond Axe: \u00a7e1\n" + + "\u00a73Scavenged Emerald Hammer: \u00a7c0\n", + "\u00a73Mines of Divan parts: \u00a7a3/4", + "\u00a73Mines of Divan parts: \u00a7a75%" ); - divanMinesOverlay = new DivanMinesOverlay(NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlayPosition, () -> divanMinesOverlayDummy, () -> { - int style = NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { + crystalHollowOverlay = new CrystalHollowOverlay(NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayPosition, () -> { + List strings = new ArrayList<>(); + for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) { + if (i >= 0 && i < crystalHollowOverlayDummy.size()) strings.add(crystalHollowOverlayDummy.get(i)); + } + return strings; + }, () -> { + int style = NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayStyle; + if (style >= 0 && style < TextOverlayStyle.values().length) { return TextOverlayStyle.values()[style]; } return TextOverlayStyle.BACKGROUND; @@ -154,8 +172,7 @@ public class OverlayManager { textOverlays.add(farmingOverlay); textOverlays.add(petInfoOverlay); textOverlays.add(bonemerangOverlay); - textOverlays.add(automatonOverlay); - textOverlays.add(divanMinesOverlay); + textOverlays.add(crystalHollowOverlay); } } -- cgit