aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2022-09-16 02:28:13 +1000
committerGitHub <noreply@github.com>2022-09-15 18:28:13 +0200
commitd4350c2943dab39326ed268e859731649ba53f1b (patch)
tree6c8fc87225f9b4c503ddaaf85765d8d054e33ea6
parentf270bf2074d3c10e6bfabc17b22df203aff12c2c (diff)
downloadNotEnoughUpdates-d4350c2943dab39326ed268e859731649ba53f1b.tar.gz
NotEnoughUpdates-d4350c2943dab39326ed268e859731649ba53f1b.tar.bz2
NotEnoughUpdates-d4350c2943dab39326ed268e859731649ba53f1b.zip
Fix a few bugs with et/hex overlay (#285)
* Fix a few bugs with et/hex overlay * Moved fixEnchantId into ItemUtils Co-authored-by: Lorenz <lo.scherf@gmail.com>
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java33
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java17
3 files changed, 49 insertions, 26 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 cbf98290..748694cb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -32,6 +32,7 @@ import io.github.moulberry.notenoughupdates.miscgui.util.OrbDisplay;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.ItemUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
@@ -106,10 +107,7 @@ public class GuiCustomEnchant extends Gui {
this.enchId = enchId;
this.displayLore = displayLore;
this.level = level;
- if (this.enchId.equals("prosecute")) {
- this.enchId = "PROSECUTE";
- }
-
+ this.enchId = ItemUtils.fixEnchantId(enchId, true);
if (Constants.ENCHANTS != null) {
if (checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
@@ -143,12 +141,12 @@ public class GuiCustomEnchant extends Gui {
maxLevel = Constants.ENCHANTS.getAsJsonObject("max_xp_table_levels");
}
- if (allCosts.has(enchId)) {
- JsonArray costs = allCosts.getAsJsonArray(enchId);
+ if (allCosts.has(this.enchId)) {
+ JsonArray costs = allCosts.getAsJsonArray(this.enchId);
if (costs.size() >= 1) {
if (useMaxLevelForCost) {
- int cost = (maxLevel != null && maxLevel.has(enchId) ? maxLevel.get(enchId).getAsInt() : costs.size());
+ 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();
@@ -242,7 +240,10 @@ public class GuiCustomEnchant extends Gui {
GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
ItemStack hexStack = cc.getLowerChestInventory().getStackInSlot(50);
- if (hexStack != null && hexStack.getItem() == Items.experience_bottle) return false;
+ if (hexStack != null && hexStack.getItem() == Items.experience_bottle) {
+ shouldOverrideFast = false;
+ return false;
+ }
return shouldOverrideFast;
}
@@ -456,9 +457,7 @@ public class GuiCustomEnchant extends Gui {
.replace(" ", "_")
.replace("-", "_");
if (enchId.equalsIgnoreCase("_")) continue;
- if (enchId.equals("prosecute")) {
- enchId = "PROSECUTE";
- }
+ enchId = ItemUtils.fixEnchantId(enchId, true);
String name = Utils.cleanColour(book.getDisplayName());
if (searchField.getText().trim().isEmpty() ||
@@ -1071,7 +1070,9 @@ public class GuiCustomEnchant extends Gui {
Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false);
//Enchant name
- String name = WordUtils.capitalizeFully(enchanterCurrentEnch.enchId.replace("_", " "));
+ String name = WordUtils.capitalizeFully(ItemUtils
+ .fixEnchantId(enchanterCurrentEnch.enchId, false)
+ .replace("_", " "));
if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
} else if (name.equalsIgnoreCase("Projectile Protection")) {
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 c59a7003..c981f75c 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
@@ -33,6 +33,7 @@ import io.github.moulberry.notenoughupdates.miscgui.util.OrbDisplay;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.ItemUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
@@ -118,9 +119,7 @@ public class GuiCustomHex extends Gui {
if (bazaarInfo != null && bazaarInfo.get("curr_buy") != null) {
this.price = bazaarInfo.get("curr_buy").getAsInt();
}
- if (this.enchId.equals("prosecute")) {
- this.enchId = "PROSECUTE";
- }
+ this.enchId = ItemUtils.fixEnchantId(this.enchId, true);
if (Constants.ENCHANTS != null) {
if (checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
@@ -134,7 +133,7 @@ public class GuiCustomHex extends Gui {
for (int j = 0; j < pool.size(); j++) {
String enchIdPoolElement = pool.get(j).getAsString();
- if (enchId.equalsIgnoreCase(enchIdPoolElement)) {
+ if (this.enchId.equalsIgnoreCase(enchIdPoolElement)) {
hasThis = true;
} else if (playerEnchantIds.containsKey(enchIdPoolElement)) {
hasApplied = true;
@@ -149,8 +148,8 @@ public class GuiCustomHex extends Gui {
if (level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
- if (allCosts.has(enchId)) {
- JsonArray costs = allCosts.getAsJsonArray(enchId);
+ if (allCosts.has(this.enchId)) {
+ JsonArray costs = allCosts.getAsJsonArray(this.enchId);
if (costs.size() >= 1) {
if (useMaxLevelForCost) {
@@ -279,12 +278,16 @@ public class GuiCustomHex extends Gui {
}
shouldOverrideXp = config &&
- (containerName.length() >= 21 && Objects.equals("Bottles of Enchanting", containerName.substring(0, "Bottles of Enchanting".length()))) &&
+ (containerName.length() >= 21 && Objects.equals(
+ "Bottles of Enchanting",
+ containerName.substring(0, "Bottles of Enchanting".length())
+ )) &&
NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard();
GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
ItemStack hexStack = cc.getLowerChestInventory().getStackInSlot(50);
- CalendarOverlay.ableToClickCalendar = !(shouldOverrideET || shouldOverrideFast || shouldOverrideGemstones || shouldOverrideXp);
+ CalendarOverlay.ableToClickCalendar =
+ !(shouldOverrideET || shouldOverrideFast || shouldOverrideGemstones || shouldOverrideXp);
if (hexStack != null && hexStack.getItem() == Items.experience_bottle)
return (shouldOverrideET || shouldOverrideFast);
if (!shouldOverrideFast && !shouldOverrideET && !shouldOverrideGemstones && !shouldOverrideXp) {
@@ -564,9 +567,7 @@ public class GuiCustomHex extends Gui {
.replace(" ", "_")
.replace("-", "_");
if (enchId.equalsIgnoreCase("_")) continue;
- if (enchId.equals("prosecute")) {
- enchId = "PROSECUTE";
- }
+ enchId = ItemUtils.fixEnchantId(enchId, true);
String name = Utils.cleanColour(book.getDisplayName());
if (searchField.getText().trim().isEmpty() ||
@@ -1233,7 +1234,8 @@ public class GuiCustomHex extends Gui {
renderHex(partialTicks);
} else if (containerName.contains("Enchant Item")) {
renderEnchantment(partialTicks);
- } else if (containerName.contains("Books") || containerName.contains("Modifiers") || containerName.contains("Bottles of Enchanting")) {
+ } else if (containerName.contains("Books") || containerName.contains("Modifiers") || containerName.contains(
+ "Bottles of Enchanting")) {
renderBooks(partialTicks);
} else if (containerName.contains("Gemstones")) {
renderGemstones(partialTicks);
@@ -1638,7 +1640,9 @@ public class GuiCustomHex extends Gui {
Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false);
//Enchant name
- String name = WordUtils.capitalizeFully(enchanterCurrentEnch.enchId.replace("_", " "));
+ String name = WordUtils.capitalizeFully(ItemUtils
+ .fixEnchantId(enchanterCurrentEnch.enchId, false)
+ .replace("_", " "));
if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
} else if (name.equalsIgnoreCase("Projectile Protection")) {
@@ -3770,7 +3774,8 @@ public class GuiCustomHex extends Gui {
}
public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if ((shouldOverrideFast || shouldOverrideGemstones || shouldOverrideXp) && currentState != EnchantState.ADDING_ENCHANT) {
+ if ((shouldOverrideFast || shouldOverrideGemstones || shouldOverrideXp) &&
+ currentState != EnchantState.ADDING_ENCHANT) {
boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
int slotId = slot.getSlotIndex();
if (playerInv && slotId < 36) {
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 ad8a6c98..adf09161 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.util;
+import com.google.gson.JsonArray;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -103,4 +104,20 @@ public class ItemUtils {
return string;
}
+ public static String fixEnchantId(String enchId, boolean useId) {
+ if (Constants.ENCHANTS != null && Constants.ENCHANTS.has("enchant_mapping_id") &&
+ Constants.ENCHANTS.has("enchant_mapping_item")) {
+ JsonArray mappingFrom = Constants.ENCHANTS.getAsJsonArray("enchant_mapping_" + (useId ? "id" : "item"));
+ JsonArray mappingTo = Constants.ENCHANTS.getAsJsonArray("enchant_mapping_" + (useId ? "item" : "id"));
+
+ for (int i = 0; i < mappingFrom.size(); i++) {
+ if (mappingFrom.get(i).getAsString().equals(enchId)) {
+ return mappingTo.get(i).getAsString();
+ }
+ }
+
+ }
+ return enchId;
+ }
+
}