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 748694cbd4..6f190adafe 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 void tick() { 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 void tick() { .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 c981f75c86..5361ae8918 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 Enchantment( 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 @@ private void tickEnchants() { 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 @@ private void tickEnchants() { 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 @@ private void tickEnchants() { 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 @@ private void tickEnchants() { 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 @@ private void tickEnchants() { 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 @@ private void tickEnchants() { .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 @@ private void tickBooks() { 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 @@ private void renderEnchantment(float partialTicks) { ); 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 @@ private List renderSettings(int mouseX, int mouseY, List tooltip 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 boolean mouseInput(int mouseX, int mouseY) { 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/options/seperateSections/Enchanting.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java index 306629f7e0..2990498f31 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 = ""