diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-22 21:56:36 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-22 21:56:36 +0200 |
commit | 4020c4deff77a4c3f93914bf41aeebd54be1d753 (patch) | |
tree | 6c20f714ebd9cc705875efef821c1dd5116550bd | |
parent | 189904e79e80ccdcc3c44c520560cb409f5c7d1f (diff) | |
parent | 005f9ef89baa3bde63fcfc188359034606506550 (diff) | |
download | NotEnoughUpdates-4020c4deff77a4c3f93914bf41aeebd54be1d753.tar.gz NotEnoughUpdates-4020c4deff77a4c3f93914bf41aeebd54be1d753.tar.bz2 NotEnoughUpdates-4020c4deff77a4c3f93914bf41aeebd54be1d753.zip |
Merge branch 'master' into minion_helper_2
# Conflicts:
# src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
# src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
23 files changed, 359 insertions, 54 deletions
diff --git a/Update Notes/2.1.md b/Update Notes/2.1.md index e6b2b472..99b2eef0 100644 --- a/Update Notes/2.1.md +++ b/Update Notes/2.1.md @@ -155,6 +155,8 @@ - Fixed storage gui when having locked backpack slots - nopo - Fixed hyphens in /peek being the wrong color - whalker - Fixed skill average calculation to include carpentry in /peek - whalker +- Fixed middle clicking on pets not registering pet swap - nopo +- Fixed middle clicking on an item with no id searching for it - nopo ### **Other:** diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 135fcc20..d0ff431a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -29,6 +29,7 @@ import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.miscgui.KatSitterOverlay; +import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay; import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe; import io.github.moulberry.notenoughupdates.recipes.Ingredient; @@ -392,31 +393,94 @@ public class NEUManager { return getUsagesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()); } + private static class DebugMatch { + int index; + String match; + + DebugMatch(int index, String match) { + this.index = index; + this.match = match; + } + } + + + private String searchDebug(String[] searchArray, ArrayList<DebugMatch> debugMatches) { + //splitToSearch, debugMatches and query + final String ANSI_RED = "\u001B[31m"; + final String ANSI_RESET = "\u001B[0m"; + final String ANSI_YELLOW = "\u001B[33m"; + + //create debug message + StringBuilder debugBuilder = new StringBuilder(); + for (int i = 0; i < searchArray.length; i++) { + final int fi = i; + Object[] matches = debugMatches.stream().filter((d) -> d.index == fi).toArray(); + + if (matches.length > 0) { + debugBuilder.append(ANSI_YELLOW + "[").append(((DebugMatch) matches[0]).match).append("]"); + debugBuilder.append(ANSI_RED + "[").append(searchArray[i]).append("]").append(ANSI_RESET).append(" "); + } else { + debugBuilder.append(searchArray[i]).append(" "); + } + } + + //yellow = query match and red = string match + return debugBuilder.toString(); + } + /** * Searches a string for a query. This method is used to mimic the behaviour of the more complex map-based search * function. This method is used for the chest-item-search feature. */ public boolean searchString(String toSearch, String query) { - int lastQueryMatched = -1; + final String ANSI_RESET = "\u001B[0m"; + final String ANSI_YELLOW = "\u001B[33m"; + + int lastStringMatch = -1; + ArrayList<DebugMatch> debugMatches = new ArrayList<>(); toSearch = clean(toSearch).toLowerCase(); query = clean(query).toLowerCase(); String[] splitToSearch = toSearch.split(" "); String[] queryArray = query.split(" "); - out: - for (int j = 0; j < queryArray.length; j++) { - for (int i = 0; i < splitToSearch.length; i++) { - if ((queryArray.length - (lastQueryMatched != -1 ? lastQueryMatched : 0)) > (splitToSearch.length - i)) continue; - if (splitToSearch[i].startsWith(queryArray[j])) { - lastQueryMatched = j; - continue out; + { + String currentSearch = queryArray[0]; + int queryIndex = 0; + boolean matchedLastQueryItem = false; + + for (int k = 0; k < splitToSearch.length; k++) { + if (queryIndex - 1 != -1 && (queryArray.length - queryIndex) > (splitToSearch.length - k)) continue; + if (splitToSearch[k].startsWith(currentSearch)) { + if (((lastStringMatch != -1 ? lastStringMatch : k-1) == k-1)) { + debugMatches.add(new DebugMatch(k, currentSearch)); + lastStringMatch = k; + if (queryIndex+1 != queryArray.length) { + queryIndex++; + currentSearch = queryArray[queryIndex]; + } else { + matchedLastQueryItem = true; + } + } + } else if (queryIndex != 0) { + queryIndex = 0; + currentSearch = queryArray[queryIndex]; + lastStringMatch = -1; } } - return false; - } - return true; + if (matchedLastQueryItem) { + if (NEUDebugFlag.SEARCH.isSet()) { + NotEnoughUpdates.LOGGER.info("Found match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + searchDebug(splitToSearch, debugMatches)); + } + } else { + if (NEUDebugFlag.SEARCH.isSet() && lastStringMatch != -1) { + NotEnoughUpdates.LOGGER.info("Found partial match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + searchDebug(splitToSearch, debugMatches)); + } + } + + return matchedLastQueryItem; + } } /** diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 308bd63e..dbff2be2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -753,7 +753,9 @@ public class NEUOverlay extends Gui { if (slot != null) { ItemStack hover = slot.getStack(); if (hover != null) { - textField.setText("id:" + manager.getInternalNameForItem(hover)); + if (manager.getInternalNameForItem(hover) != null) { + textField.setText("id:" + manager.getInternalNameForItem(hover)); + } itemPaneOpen = true; updateSearch(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 3fb3c8d7..f67c1f43 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -100,6 +100,8 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.awt.*; import java.io.BufferedReader; @@ -120,6 +122,8 @@ public class NotEnoughUpdates { public static final int VERSION_ID = 20100; public static final int PRE_VERSION_ID = 0; public static final int HOTFIX_VERSION_ID = 0; + + public static final Logger LOGGER = LogManager.getLogger("NotEnoughUpdates"); /** * Registers the biomes for the crystal hollows here so optifine knows they exists */ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java index 2fb6b624..6036e796 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -60,10 +60,11 @@ public class DevTestCommand extends ClientCommandBase { "lrg89", "dediamondpro", "lulonaut", + "hannibal2", "craftyoldminer", "eisengolem", - "hannibal2", - "whalker" + "whalker", + "ascynx" ); private static final String[] DEV_FAIL_STRINGS = { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java index 326c00b4..fb546efb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java @@ -41,7 +41,8 @@ public class DiagCommand extends ClientCommandBase { " center=<off | on> Disable / enable using center\n" + "/neudiag wishing Wishing Compass Solver diagnostics\n" + "/neudiag debug\n" + - " <no sub-command> Show current flags\n" + + " <no sub-command> Show all enabled flags\n" + + " <list> Show all flags\n"+ " <enable | disable> <flag> Enable/disable flag\n"; private void showUsage(ICommandSender sender) { @@ -86,6 +87,10 @@ public class DiagCommand extends ClientCommandBase { boolean enablingFlag = true; String action = args[1]; switch (action) { + case "list": + sender.addChatMessage(new ChatComponentText( + EnumChatFormatting.YELLOW + "Here are all flags:\n" + NEUDebugFlag.getFlagList())); + return; case "disable": enablingFlag = false; // falls through @@ -93,7 +98,7 @@ public class DiagCommand extends ClientCommandBase { if (args.length != 3) { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must specify a flag:\n" + - NEUDebugFlag.FLAG_LIST)); + NEUDebugFlag.getFlagList())); return; } @@ -108,7 +113,7 @@ public class DiagCommand extends ClientCommandBase { } catch (IllegalArgumentException e) { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + flagName + " is invalid. Valid flags are:\n" + - NEUDebugFlag.FLAG_LIST)); + NEUDebugFlag.getFlagList())); return; } break; @@ -118,8 +123,8 @@ public class DiagCommand extends ClientCommandBase { } } - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: " + - NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.toString())); + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: \n" + + NEUDebugFlag.getEnabledFlags())); break; default: showUsage(sender); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java index 3c815016..98ac76a3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java @@ -79,6 +79,7 @@ public class DevInfoPane extends TextInfoPane { for (String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) { if (internalname.matches("^.*-[0-9]{1,3}$")) continue; if (!manager.getItemInformation().containsKey(internalname)) { + if (internalname.equals("RUNE") || internalname.contains("PARTY_HAT_CRAB")) continue; text += internalname + "\n"; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index 79b134a7..3b1382f2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -237,7 +237,7 @@ public class ChatListener { } missingRecipe.set(true); } - if (unformatted.startsWith("Sending to server") && neu.isOnSkyblock() && + if (unformatted.startsWith("Sending to server") && NotEnoughUpdates.INSTANCE.config.misc.streamerMode && e.message instanceof ChatComponentText) { String m = e.message.getFormattedText(); String m2 = StreamerMode.filterChat(e.message.getFormattedText()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index 0afa2ce2..e465f3d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -61,6 +61,7 @@ import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.RancherBootOverlay; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.RequestFocusListener; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -407,7 +408,7 @@ public class RenderListener { GL11.glTranslatef(0, 0, 10); } if (hoverInv) { - renderDungeonChestOverlay(event.gui); + renderDungKuudraChestOverlay(event.gui); if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { AccessoryBagOverlay.renderOverlay(); } @@ -630,7 +631,7 @@ public class RenderListener { } if (NotificationHandler.shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) { - renderDungeonChestOverlay(event.gui); + renderDungKuudraChestOverlay(event.gui); if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { AccessoryBagOverlay.renderOverlay(); } @@ -745,7 +746,7 @@ public class RenderListener { } } - private void renderDungeonChestOverlay(GuiScreen gui) { + private void renderDungKuudraChestOverlay(GuiScreen gui) { if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return; if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) { try { @@ -782,7 +783,9 @@ public class RenderListener { HashMap<String, Double> itemValues = new HashMap<>(); for (int i = 0; i < 5; i++) { ItemStack item = lower.getStackInSlot(11 + i); - String internal = neu.manager.getInternalNameForItem(item); + if (ItemUtils.isSoulbound(item)) continue; + + String internal = neu.manager.createItemResolutionQuery().withItemStack(item).resolveInternalName(); String displayName = item.getDisplayName(); Matcher matcher = ESSENCE_PATTERN.matcher(displayName); if (neu.config.dungeons.useEssenceCostFromBazaar && matcher.matches()) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java new file mode 100644 index 00000000..25aaaa0a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.init.Items; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +public class AntiCoopAdd { + + public static boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) { + if (!NotEnoughUpdates.INSTANCE.config.misc.coopWarning) return false; + if (slotId == -999) return false; + if (!Utils.getOpenChestName().contains("Profile")) return false; + + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + + ItemStack stack = chest.inventorySlots.getSlot(slotId).getStack(); + if (stack == null) return false; + if (stack.getItem() == Items.diamond && stack.getDisplayName() != null && stack.getDisplayName().contains("Co-op Request")) { + String ign = Utils.getOpenChestName().split("'s Profile")[0]; + ChatComponentText storageMessage = new ChatComponentText( + EnumChatFormatting.YELLOW + "[NEU] " + EnumChatFormatting.YELLOW + + "You just clicked on the Co-op add button. If you want to coop add this person, click this chat message"); + storageMessage.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/coopadd " + ign)); + storageMessage.setChatStyle(storageMessage.getChatStyle().setChatHoverEvent( + new HoverEvent(HoverEvent.Action.SHOW_TEXT, + new ChatComponentText(EnumChatFormatting.YELLOW + "Click to add " + ign + " to your coop")))); + ChatComponentText storageChatMessage = new ChatComponentText(""); + storageChatMessage.appendSibling(storageMessage); + Minecraft.getMinecraft().thePlayer.addChatMessage(storageChatMessage); + return true; + } + + return false; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index 93a80866..23115c36 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -170,7 +170,7 @@ public class CrystalMetalDetectorSolver { // falls through case FOUND: Utils.addChatMessage(EnumChatFormatting.YELLOW + "[NEU] Found solution."); - if (NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.contains(NEUDebugFlag.METAL) && + if (NEUDebugFlag.METAL.isSet() && (previousState == SolutionState.INVALID || previousState == SolutionState.FAILED)) { NEUDebugLogger.log( NEUDebugFlag.METAL, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java index 9715e34b..cf1647b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java @@ -919,7 +919,7 @@ public class CrystalWishingCompassSolver { return; } - boolean wishingDebugFlagSet = NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.contains(NEUDebugFlag.WISHING); + boolean wishingDebugFlagSet = NEUDebugFlag.WISHING.isSet(); if (outputAlways || wishingDebugFlagSet) { NEUDebugLogger.logAlways(getDiagnosticMessage()); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 15682f72..6706fe5c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -858,8 +858,7 @@ public class PetInfoOverlay extends TextOverlay { ); public static void onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) { - if (mode != 0) return; - if (mouseButtonClicked != 0 && mouseButtonClicked != 1) return; + if (mouseButtonClicked != 0 && mouseButtonClicked != 1 && mouseButtonClicked != 2) return; int slotIdMod = (slotId - 10) % 9; if (slotId >= 10 && slotId <= 43 && slotIdMod >= 0 && slotIdMod <= 6 && diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java index 748694cb..6f190ada 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java @@ -377,10 +377,12 @@ public class GuiCustomEnchant extends Gui { if (ea != null) { NBTTagCompound enchantments = ea.getCompoundTag("enchantments"); if (enchantments != null) { - String enchId = Utils.cleanColour(book.getDisplayName()).toLowerCase().replace(" ", "_").replace( - "-", - "_" - ); + String enchId = Utils + .cleanColour(book.getDisplayName()) + .toLowerCase() + .replace(" ", "_") + .replace("-", "_") + .replaceAll("[^a-z_]", ""); String name = Utils.cleanColour(book.getDisplayName()); int enchLevel = -1; if (name.equalsIgnoreCase("Bane of Arthropods")) { @@ -455,7 +457,8 @@ public class GuiCustomEnchant extends Gui { .cleanColour(book.getDisplayName()) .toLowerCase() .replace(" ", "_") - .replace("-", "_"); + .replace("-", "_") + .replaceAll("[^a-z_]", ""); if (enchId.equalsIgnoreCase("_")) continue; enchId = ItemUtils.fixEnchantId(enchId, true); String name = Utils.cleanColour(book.getDisplayName()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java index c981f75c..5361ae89 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java @@ -148,12 +148,20 @@ public class GuiCustomHex extends Gui { if (level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) { JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost"); + JsonObject maxLevel = null; + if (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel && Constants.ENCHANTS.has( + "max_xp_table_levels")) { + maxLevel = Constants.ENCHANTS.getAsJsonObject("max_xp_table_levels"); + } + if (allCosts.has(this.enchId)) { JsonArray costs = allCosts.getAsJsonArray(this.enchId); if (costs.size() >= 1) { if (useMaxLevelForCost) { - this.xpCost = costs.get(costs.size() - 1).getAsInt(); + int cost = + (maxLevel != null && maxLevel.has(this.enchId) ? maxLevel.get(this.enchId).getAsInt() : costs.size()); + this.xpCost = costs.get(cost - 1).getAsInt(); } else if (level - 1 < costs.size()) { this.xpCost = costs.get(level - 1).getAsInt(); } else { @@ -442,7 +450,7 @@ public class GuiCustomHex extends Gui { ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex); ItemStack xpBottle = cc.getLowerChestInventory().getStackInSlot(50); if (!hasXpBottle && xpBottle != null && - xpBottle.getItem() == Items.experience_bottle) { //Make show when in dungeon screen + xpBottle.getItem() == Items.experience_bottle) { String name = "Buy Xp Bottles"; String id = "XP_BOTTLE"; Enchantment xpBottleEnch = new Enchantment(50, name, id, @@ -465,10 +473,12 @@ public class GuiCustomHex extends Gui { if (ea != null) { NBTTagCompound enchantments = ea.getCompoundTag("enchantments"); if (enchantments != null) { - String enchId = Utils.cleanColour(book.getDisplayName()).toLowerCase().replace(" ", "_").replace( - "-", - "_" - ); + String enchId = Utils + .cleanColour(book.getDisplayName()) + .toLowerCase() + .replace(" ", "_") + .replace("-", "_") + .replaceAll("[^a-z_]", ""); String name = Utils.cleanColour(book.getDisplayName()); int enchLevel = -1; if (name.equalsIgnoreCase("Bane of Arthropods")) { @@ -494,6 +504,13 @@ public class GuiCustomHex extends Gui { String price = numberFormat.format(enchantment.price); enchantment.displayLore.set(index, "\u00a76" + price + ".0 Coins"); } + if (lore.contains("Loading...")) { + if (enchantment.price > 0) { + enchantment.displayLore.set(index, "\u00a7eClick to buy on the Bazaar!"); + } else { + enchantment.displayLore.set(index, "\u00a7cNot enough supply on the Bazaar!"); + } + } index++; } enchantment.displayLore.remove(0); @@ -506,10 +523,23 @@ public class GuiCustomHex extends Gui { continue; } + boolean aboveMaxLevelFromEt = false; + if (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel && Constants.ENCHANTS != null) { + JsonObject maxLevel = null; + if (Constants.ENCHANTS.has("max_xp_table_levels")) { + maxLevel = Constants.ENCHANTS.getAsJsonObject("max_xp_table_levels"); + } + if (maxLevel != null && maxLevel.has(enchId)) { + if (enchantment.level > maxLevel.get(enchId).getAsInt()) { + aboveMaxLevelFromEt = true; + } + } + } + if (enchanterCurrentEnch == null) { enchanterCurrentEnch = enchantment; } else if (updateLevel) { - if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) { + if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level && !aboveMaxLevelFromEt) { enchanterCurrentEnch = enchantment; } else if (removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) { enchanterCurrentEnch = enchantment; @@ -545,7 +575,7 @@ public class GuiCustomHex extends Gui { ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex); ItemStack xpBottle = cc.getLowerChestInventory().getStackInSlot(50); if (!hasXpBottle && xpBottle != null && - xpBottle.getItem() == Items.experience_bottle) { //Make show when in dungeon screen + xpBottle.getItem() == Items.experience_bottle) { String name = "Buy Xp Bottles"; String id = "XP_BOTTLE"; Enchantment xpBottleEnch = new Enchantment(50, name, id, @@ -565,7 +595,8 @@ public class GuiCustomHex extends Gui { .cleanColour(book.getDisplayName()) .toLowerCase() .replace(" ", "_") - .replace("-", "_"); + .replace("-", "_") + .replaceAll("[^a-z_]", ""); if (enchId.equalsIgnoreCase("_")) continue; enchId = ItemUtils.fixEnchantId(enchId, true); String name = Utils.cleanColour(book.getDisplayName()); @@ -702,7 +733,7 @@ public class GuiCustomHex extends Gui { ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex); ItemStack randomReforge = cc.getLowerChestInventory().getStackInSlot(48); if (!hasRandomReforge && randomReforge != null && - randomReforge.getItem() == Item.getItemFromBlock(Blocks.anvil)) { //Make show when in dungeon screen + randomReforge.getItem() == Item.getItemFromBlock(Blocks.anvil)) { String name = Utils.cleanColour(randomReforge.getDisplayName()); String id = Utils.cleanColour(randomReforge.getDisplayName()); if (name.equals("Convert to Dungeon Item")) { @@ -1639,6 +1670,48 @@ public class GuiCustomHex extends Gui { ); Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); + String priceStr = "" + numberFormat.format(enchanterCurrentEnch.price) + " Coins"; + if (enchanterCurrentEnch.price < 0) priceStr = ""; + int priceWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(priceStr); + int priceTop = guiTop + 16; + int x = 180; + int color = 0x2d2102; + Minecraft.getMinecraft().fontRendererObj.drawString( + priceStr, + guiLeft + x - priceWidth / 2 - 1, + priceTop + 4, + color, + false + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + priceStr, + guiLeft + x - priceWidth / 2 + 1, + priceTop + 4, + color, + false + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + priceStr, + guiLeft + x - priceWidth / 2, + priceTop + 4 - 1, + color, + false + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + priceStr, + guiLeft + x - priceWidth / 2, + priceTop + 4 + 1, + color, + false + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + priceStr, + guiLeft + x - priceWidth / 2, + priceTop + 4, + 0xfcba03, + false + ); + //Enchant name String name = WordUtils.capitalizeFully(ItemUtils .fixEnchantId(enchanterCurrentEnch.enchId, false) @@ -3572,6 +3645,15 @@ public class GuiCustomHex extends Gui { Gui.drawRect(guiLeft + 295, guiTop + 147, guiLeft + 295 + 16, guiTop + 147 + 16, 0x80ffffff); tooltipToDisplay = createTooltip("Enable GUI", 0, "On", "Off"); break; + case 1: + Gui.drawRect(guiLeft + 295 + 18, guiTop + 147, guiLeft + 295 + 16 + 18, guiTop + 147 + 16, 0x80ffffff); + tooltipToDisplay = createTooltip("Max Level", + (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel ? 0 : 1), + "Enabled", "Disabled"); + tooltipToDisplay.add(1, EnumChatFormatting.GRAY + "Show max level of enchant"); + tooltipToDisplay.add(2, EnumChatFormatting.GRAY + "from either hex or enchantment table"); + tooltipToDisplay.add(3, EnumChatFormatting.GRAY + "max level"); + break; case 2: Gui.drawRect(guiLeft + 295, guiTop + 147 + 18, guiLeft + 295 + 16, guiTop + 147 + 16 + 18, 0x80ffffff); tooltipToDisplay = createTooltip("Sort enchants...", @@ -4342,6 +4424,10 @@ public class GuiCustomHex extends Gui { NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableHexGUI = false; break; } + case 1: { + NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel = !NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel; + break; + } case 2: { int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting; val += direction; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index 7d17aa3e..f708fb5f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -23,6 +23,7 @@ import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneWarning; +import io.github.moulberry.notenoughupdates.miscfeatures.AntiCoopAdd; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionSortModeWarning; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; @@ -30,8 +31,8 @@ import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; -import io.github.moulberry.notenoughupdates.miscgui.hex.GuiCustomHex; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; +import io.github.moulberry.notenoughupdates.miscgui.hex.GuiCustomHex; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -97,7 +98,7 @@ public abstract class MixinGuiContainer extends GuiScreen { if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) { String tagName = tag.getCompoundTag("SkullOwner").getString("Name"); String displayName = Utils.cleanColour(cc.inventorySlots.get(22).getStack().getDisplayName()); - if (displayName.length() - tagName.length() > 0 && tagName.equals(displayName.substring(displayName.length() - tagName.length()))) { + if (displayName.length() - tagName.length() >= 0 && tagName.equals(displayName.substring(displayName.length() - tagName.length()))) { ci.cancel(); this.zLevel = 100.0F; @@ -314,6 +315,11 @@ public abstract class MixinGuiContainer extends GuiScreen { return; } + if (AntiCoopAdd.onMouseClick(slotIn, slotId, clickedButton, clickType)) { + ci.cancel(); + return; + } + AtomicBoolean ret = new AtomicBoolean(false); SlotLocking.getInstance().onWindowClick(slotIn, slotId, clickedButton, clickType, (tuple) -> { ci.cancel(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java index 3856e2d5..381f5934 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java @@ -43,7 +43,7 @@ public class MixinGuiIngame { @Redirect(method = "renderScoreboard", at = @At(value = "INVOKE", target = TARGET)) public String renderScoreboard_formatPlayerName(Team team, String name) { - if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode) { + if (NotEnoughUpdates.INSTANCE.config.misc.streamerMode) { return StreamerMode.filterScoreboard(ScorePlayerTeam.formatPlayerName(team, name)); } return ScorePlayerTeam.formatPlayerName(team, name); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java index 8e0e4c11..50f459c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java @@ -19,13 +19,55 @@ package io.github.moulberry.notenoughupdates.options.customtypes; +import io.github.moulberry.notenoughupdates.util.NEUDebugLogger; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + public enum NEUDebugFlag { // NOTE: Removing enum values causes gson to remove all debugFlags on load if any removed value is present - METAL, - WISHING, + METAL("Metal Detector Solver"), + WISHING("Wishing Compass Solver"), + MAP("Dungeon Map Player Information"), + SEARCH("SearchString Matches"), ; - public static final String FLAG_LIST = - "METAL - Metal Detector Solver\n" + - "WISHING - Wishing Compass Solver"; + private final String description; + + NEUDebugFlag(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public boolean isSet() { + return NEUDebugLogger.isFlagEnabled(this); + } + + public static String getFlagList() { + return renderFlagInformation(Arrays.asList(values())); + } + + public static String getEnabledFlags() { + return renderFlagInformation(Arrays.stream(values()) + .filter(NEUDebugFlag::isSet) + .collect(Collectors.toList())); + } + + public static String renderFlagInformation(List<NEUDebugFlag> flags) { + int maxNameLength = flags.stream() + .mapToInt(it -> it.name().length()) + .max() + .orElse(0); + return flags.stream() + .map(it -> (CharSequence) String.format( + "%-" + maxNameLength + "s" + " - %s", + it.name(), + it.getDescription() + )) + .collect(Collectors.joining("\n")); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java index 306629f7..2990498f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java @@ -85,6 +85,15 @@ public class Enchanting { @ConfigAccordionId(id = 1) public int enchantOrdering = 0; + @Expose + @ConfigOption( + name = "Use highest level from /et in /hex", + desc = "Show max level from /et in hex instead of highest possible" + ) + @ConfigEditorBoolean() + @ConfigAccordionId(id = 1) + public boolean maxEnchLevel = false; + @ConfigOption( name = "Enchanting Solvers", desc = "" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index 84e2322e..c6f00182 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -229,4 +229,12 @@ public class Misc { @ConfigEditorBoolean public boolean abiphoneWarning = true; + @Expose + @ConfigOption( + name = "Enable Coop Warning", + desc = "Asks for confirmation when clicking the coop diamond in profile menu" + ) + @ConfigEditorBoolean + public boolean coopWarning = true; + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java index 4ad6767d..bf106eed 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java @@ -91,6 +91,7 @@ public class CombatSkillOverlay championXpLast = championXp; xpGainHourLast = xpGainHour; kill = -1; + championXp = -1; if (Minecraft.getMinecraft().thePlayer == null) return; @@ -216,7 +217,7 @@ public class CombatSkillOverlay killQueue.removeLast(); } - if (kill != -1) { + if (kill != -1 || championXp != -1) { overlayStrings = new ArrayList<>(); } else { overlayStrings = null; @@ -228,7 +229,7 @@ public class CombatSkillOverlay public void updateFrequent() { super.updateFrequent(); - if ((kill < 0 || championXp < 0) && !NotEnoughUpdates.INSTANCE.config.skillOverlays.alwaysShowCombatOverlay) { + if ((kill < 0 && championXp < 0) && !NotEnoughUpdates.INSTANCE.config.skillOverlays.alwaysShowCombatOverlay) { overlayStrings = null; } else { HashMap<Integer, String> lineMap = new HashMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java index a80fcbc8..17a31cd7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java @@ -185,7 +185,10 @@ public class HotmInformation { Tree tree = new Tree(); JsonObject nodes = miningCore.getAsJsonObject("nodes"); for (Map.Entry<String, JsonElement> node : nodes.entrySet()) { - tree.levels.put(node.getKey(), node.getValue().getAsInt()); + String key = node.getKey(); + if (!key.startsWith("toggle_")) { + tree.levels.put(key, node.getValue().getAsInt()); + } } if (miningCore.has("powder_mithril_total")) { tree.totalMithrilPowder = miningCore.get("powder_mithril_total").getAsInt(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java index adf09161..c7c7d4b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java @@ -120,4 +120,8 @@ public class ItemUtils { return enchId; } + public static boolean isSoulbound(ItemStack item) { + return ItemUtils.getLore(item).stream() + .anyMatch(line -> line.equals("§8§l* §8Co-op Soulbound §8§l*") || line.equals("§8§l* Soulbound §8§l*")); + } } |