aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2022-09-13 02:31:56 +1000
committerGitHub <noreply@github.com>2022-09-12 18:31:56 +0200
commit94054563ff1d595253a4e50cf48b22fc77a05515 (patch)
tree16d2466aa4e889b49cc68bdaf447dd8d9d39cf1b /src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java
parentd404b5c694e9873c1f2bcb48966785ad5c9640d0 (diff)
downloadnotenoughupdates-94054563ff1d595253a4e50cf48b22fc77a05515.tar.gz
notenoughupdates-94054563ff1d595253a4e50cf48b22fc77a05515.tar.bz2
notenoughupdates-94054563ff1d595253a4e50cf48b22fc77a05515.zip
Fix enchantment table overlay (#238)
Co-authored-by: nea <romangraef@gmail.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java264
1 files changed, 264 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java
new file mode 100644
index 00000000..5b3b30ea
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/HexItem.java
@@ -0,0 +1,264 @@
+/*
+ * 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.miscgui.hex;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.util.StringUtils;
+
+import java.util.List;
+
+public class HexItem {
+ public int slotIndex;
+ public String itemName;
+ public String itemId;
+ public List<String> displayLore;
+ public int level;
+ public int price = -1;
+ public boolean overMaxLevel = false;
+ public boolean conflicts = false;
+ public ItemType itemType;
+ public int gemstoneLevel = -1;
+
+ public HexItem(
+ int slotIndex, String itemName, String itemId, List<String> displayLore,
+ boolean useMaxLevelForCost, boolean checkConflicts
+ ) {
+ this.slotIndex = slotIndex;
+ this.itemName = itemName;
+ this.itemId = itemId.replace("'S", "");
+ this.displayLore = displayLore;
+ switch (itemId) {
+ default:
+ this.itemType = ItemType.UNKNOWN;
+ break;
+ case "HOT_POTATO_BOOK":
+ this.itemType = ItemType.HOT_POTATO;
+ break;
+ case "FUMING_POTATO_BOOK":
+ this.itemType = ItemType.FUMING_POTATO;
+ break;
+ case "BOOK_OF_STATS":
+ this.itemType = ItemType.BOOK_OF_STATS;
+ break;
+ case "THE_ART_OF_WAR":
+ this.itemType = ItemType.ART_OF_WAR;
+ break;
+ case "FARMING_FOR_DUMMIES":
+ this.itemType = ItemType.FARMING_DUMMY;
+ break;
+ case "THE_ART_OF_PEACE":
+ this.itemType = ItemType.ART_OF_PEACE;
+ break;
+ case "RECOMBOBULATOR_3000":
+ this.itemType = ItemType.RECOMB;
+ break;
+ case "SILEX":
+ this.itemId = "SIL_EX";
+ this.itemType = ItemType.SILEX;
+ break;
+ case "RUBY_POWER_SCROLL":
+ this.itemType = ItemType.RUBY_SCROLL;
+ break;
+ case "SAPPHIRE_POWER_SCROLL":
+ this.itemType = ItemType.SAPPHIRE_SCROLL;
+ break;
+ case "JASPER_POWER_SCROLL":
+ this.itemType = ItemType.JASPER_SCROLL;
+ break;
+ case "AMETHYST_POWER_SCROLL":
+ this.itemType = ItemType.AMETHYST_SCROLL;
+ break;
+ case "AMBER_POWER_SCROLL":
+ this.itemType = ItemType.AMBER_SCROLL;
+ break;
+ case "OPAL_POWER_SCROLL":
+ this.itemType = ItemType.OPAL_SCROLL;
+ break;
+ case "FIRST_MASTER_STAR":
+ this.itemType = ItemType.FIRST_MASTER_STAR;
+ break;
+ case "SECOND_MASTER_STAR":
+ this.itemType = ItemType.SECOND_MASTER_STAR;
+ break;
+ case "THIRD_MASTER_STAR":
+ this.itemType = ItemType.THIRD_MASTER_STAR;
+ break;
+ case "FOURTH_MASTER_STAR":
+ this.itemType = ItemType.FOURTH_MASTER_STAR;
+ break;
+ case "FIFTH_MASTER_STAR":
+ this.itemType = ItemType.FIFTH_MASTER_STAR;
+ break;
+ case "WOOD_SINGULARITY":
+ this.itemType = ItemType.WOOD_SINGULARITY;
+ break;
+ case "IMPLOSION":
+ this.itemType = ItemType.IMPLOSION_SCROLL;
+ break;
+ case "WITHER_SHIELD":
+ this.itemType = ItemType.WITHER_SHIELD_SCROLL;
+ break;
+ case "SHADOW_WARP":
+ this.itemType = ItemType.SHADOW_WARP_SCROLL;
+ break;
+ case "TRANSMISSION_TUNER":
+ this.itemType = ItemType.TUNER;
+ break;
+ case "RANDOM_REFORGE":
+ this.itemType = ItemType.RANDOM_REFORGE;
+ break;
+ case "MANA_DISINTEGRATOR":
+ this.itemType = ItemType.MANA_DISINTEGRATOR;
+ break;
+ case "TOTAL_UPGRADES":
+ this.itemType = ItemType.TOTAL_UPGRADES;
+ break;
+ case "CONVERT_TO_DUNGEON":
+ this.itemType = ItemType.CONVERT_TO_DUNGEON;
+ break;
+ case "EXPERIENCE_BOTTLE":
+ this.itemType = ItemType.EXPERIENCE_BOTTLE;
+ break;
+ case "GRAND_EXPERIENCE_BOTTLE":
+ this.itemType = ItemType.GRAND_EXPERIENCE_BOTTLE;
+ break;
+ case "TITANIC_EXPERIENCE_BOTTLE":
+ this.itemType = ItemType.TITANIC_EXPERIENCE_BOTTLE;
+ break;
+ case "COLOSSAL_EXPERIENCE_BOTTLE":
+ this.itemType = ItemType.COLOSSAL_EXPERIENCE_BOTTLE;
+ break;
+ }
+ if (this.itemType == ItemType.UNKNOWN) {
+ for (String string : displayLore) {
+ if ((string.contains("Applies the") && string.contains("reforge")) ||
+ string.contains("reforge when combined")) {
+ this.itemType = ItemType.REFORGE;
+ break;
+ }
+ }
+ }
+ if (!this.isMasterStar() && itemId.contains("✪")) {
+ if (itemId.contains("✪✪✪✪✪")) this.itemType = ItemType.FIFTH_STAR;
+ else if (itemId.contains("✪✪✪✪")) this.itemType = ItemType.FOURTH_STAR;
+ else if (itemId.contains("✪✪✪")) this.itemType = ItemType.THIRD_STAR;
+ else if (itemId.contains("✪✪")) this.itemType = ItemType.SECOND_STAR;
+ else if (itemId.contains("✪")) this.itemType = ItemType.FIRST_STAR;
+ }
+ if (this.itemId.contains("EXPERIENCE_BOTTLE")) {
+ this.itemId = this.itemId.replace("EXPERIENCE_BOTTLE", "EXP_BOTTLE");
+ }
+ if (this.itemId.contains("END_STONE_GEODE")) {
+ this.itemId = this.itemId.replace("END_STONE_GEODE", "ENDSTONE_GEODE");
+ }
+ if (itemId.contains("HEX_ITEM")) this.itemType = ItemType.HEX_ITEM;
+ JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(this.itemId);
+ if (bazaarInfo != null && bazaarInfo.get("curr_buy") != null) {
+ this.price = bazaarInfo.get("curr_buy").getAsInt();
+ }
+ if ("SIL_EX".equals(this.itemId)) this.itemId = "SILEX";
+ if (itemName.contains("Amethyst Gemstone")) this.itemType = ItemType.AMETHYST_GEMSTONE;
+ if (itemName.contains("Ruby Gemstone")) this.itemType = ItemType.RUBY_GEMSTONE;
+ if (itemName.contains("Sapphire Gemstone")) this.itemType = ItemType.SAPPHIRE_GEMSTONE;
+ if (itemName.contains("Jasper Gemstone")) this.itemType = ItemType.JASPER_GEMSTONE;
+ if (itemName.contains("Jade Gemstone")) this.itemType = ItemType.JADE_GEMSTONE;
+ if (itemName.contains("Amber Gemstone")) this.itemType = ItemType.AMBER_GEMSTONE;
+ if (itemName.contains("Opal Gemstone")) this.itemType = ItemType.OPAL_GEMSTONE;
+ if (itemName.contains("Topaz Gemstone")) this.itemType = ItemType.TOPAZ_GEMSTONE;
+ if (itemName.contains("Gemstone Slot")) this.itemType = ItemType.GEMSTONE_SLOT;
+ if (this.itemName.contains(" Gemstone")) {
+ this.itemName = this.itemName.replace(" Gemstone", "").substring(2);
+ } else if (this.itemName.contains(" Experience Bottle")) {
+ this.itemName = this.itemName.replace("Experience Bottle", "");
+ } else if (this.itemName.equals("Experience Bottle")) {
+ this.itemName = "Exp Bottle";
+ }
+ if (isGemstone()) {
+ if (this.itemName.contains("Rough")) this.gemstoneLevel = 0;
+ if (this.itemName.contains("Flawed")) this.gemstoneLevel = 1;
+ if (this.itemName.contains("Fine")) this.gemstoneLevel = 2;
+ if (this.itemName.contains("Flawless")) this.gemstoneLevel = 3;
+ if (this.itemName.contains("Perfect")) this.gemstoneLevel = 4;
+ }
+ }
+
+ public boolean isPowerScroll() {
+ return itemType == ItemType.RUBY_SCROLL || itemType == ItemType.SAPPHIRE_SCROLL ||
+ itemType == ItemType.JASPER_SCROLL || itemType == ItemType.AMETHYST_SCROLL ||
+ itemType == ItemType.AMBER_SCROLL || itemType == ItemType.OPAL_SCROLL;
+ }
+
+ public boolean isDungeonStar() {
+ return itemType == ItemType.FIRST_STAR || itemType == ItemType.SECOND_STAR ||
+ itemType == ItemType.THIRD_STAR || itemType == ItemType.FOURTH_STAR ||
+ itemType == ItemType.FIFTH_STAR;
+ }
+
+ public boolean isMasterStar() {
+ return itemType == ItemType.FIRST_MASTER_STAR || itemType == ItemType.SECOND_MASTER_STAR ||
+ itemType == ItemType.THIRD_MASTER_STAR || itemType == ItemType.FOURTH_MASTER_STAR ||
+ itemType == ItemType.FIFTH_MASTER_STAR;
+ }
+
+ public String getReforge() {
+ JsonObject reforgeStones = Constants.REFORGESTONES;
+ if (reforgeStones != null && reforgeStones.has(this.itemId.toUpperCase())) {
+ JsonObject reforgeInfo = reforgeStones.get(this.itemId.toUpperCase()).getAsJsonObject();
+ if (reforgeInfo != null) {
+ return Utils.getElementAsString(reforgeInfo.get("reforgeName"), "");
+ }
+
+ }
+ return "";
+ }
+
+ public int getPrice() {
+ if (this.itemType == ItemType.RANDOM_REFORGE) {
+ for (String string : displayLore) {
+ if (string.contains("Coins")) {
+ try {
+ price = Integer.parseInt(StringUtils
+ .stripControlCodes(string)
+ .replace(" Coins", "")
+ .replace(",", "")
+ .trim());
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+ }
+ return price;
+ }
+
+ public boolean isHypeScroll() {
+ return itemType == ItemType.IMPLOSION_SCROLL || itemType == ItemType.WITHER_SHIELD_SCROLL ||
+ itemType == ItemType.SHADOW_WARP_SCROLL;
+ }
+
+ public boolean isGemstone() {
+ return itemType == ItemType.RUBY_GEMSTONE || itemType == ItemType.AMETHYST_GEMSTONE ||
+ itemType == ItemType.SAPPHIRE_GEMSTONE || itemType == ItemType.JASPER_GEMSTONE ||
+ itemType == ItemType.JADE_GEMSTONE || itemType == ItemType.AMBER_GEMSTONE ||
+ itemType == ItemType.OPAL_GEMSTONE || itemType == ItemType.TOPAZ_GEMSTONE;
+ }
+}