diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2022-09-23 04:53:29 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 20:53:29 +0200 |
commit | 2d9bf47ca3a61fee56d3a52f56ee0daca626a9c8 (patch) | |
tree | 3335a6524c1c294e95f33628ab76ee4fba9bf366 | |
parent | e5f1c29a9266fde6f1a558639bedc6437dffe7cb (diff) | |
download | NotEnoughUpdates-2d9bf47ca3a61fee56d3a52f56ee0daca626a9c8.tar.gz NotEnoughUpdates-2d9bf47ca3a61fee56d3a52f56ee0daca626a9c8.tar.bz2 NotEnoughUpdates-2d9bf47ca3a61fee56d3a52f56ee0daca626a9c8.zip |
Added price display to books in hex (#292)
3 files changed, 113 insertions, 15 deletions
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/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 = "" |