aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorefefury <69400149+efefury@users.noreply.github.com>2022-11-20 11:53:21 +0000
committerGitHub <noreply@github.com>2022-11-20 12:53:21 +0100
commitc7989c3a139ebf058c816f1312c29b7b4ef293b3 (patch)
tree1953b46e609cde2a5cf02893e3ea1d0aff8e398e /src/main/java/io
parent69b2de53866b665a5b63c08afd3d92c0d068e812 (diff)
downloadNotEnoughUpdates-c7989c3a139ebf058c816f1312c29b7b4ef293b3.tar.gz
NotEnoughUpdates-c7989c3a139ebf058c816f1312c29b7b4ef293b3.tar.bz2
NotEnoughUpdates-c7989c3a139ebf058c816f1312c29b7b4ef293b3.zip
Fixed bugs & added sb xp to minion helper (#443)
* fixed minion helper bugs and croesus thing * fixed another npe * no more NPEs with missing/broken repo * properly handle repo error and show error message when exp gain is not in repo Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java25
5 files changed, 59 insertions, 14 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java
index 7caa4d6b..34a40c2f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java
@@ -204,8 +204,8 @@ public class DungeonNpcProfitOverlay {
Utils.renderAlignedString(
chestProfit.name,
(chestProfit.profit > 0
- ? EnumChatFormatting.GREEN.toString()
- : EnumChatFormatting.RED) + Utils.shortNumberFormat(chestProfit.profit, 0),
+ ? EnumChatFormatting.GREEN + Utils.shortNumberFormat(chestProfit.profit, 0)
+ : EnumChatFormatting.RED + "-" + Utils.shortNumberFormat(-chestProfit.profit, 0)),
x,
y,
160
@@ -273,8 +273,12 @@ public class DungeonNpcProfitOverlay {
lore.add(
EnumChatFormatting.AQUA + "Cost to open: " + EnumChatFormatting.RED + Utils.shortNumberFormat(costToOpen, 0));
lore.add(
- EnumChatFormatting.AQUA + "Total profit: " + (profit > 0 ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) +
- Utils.shortNumberFormat(profit, 0));
+ EnumChatFormatting.AQUA + "Total profit: " +
+ (profit > 0 ? EnumChatFormatting.GREEN + Utils.shortNumberFormat(profit, 0)
+ : EnumChatFormatting.RED + "-" + Utils.shortNumberFormat(
+ -profit,
+ 0
+ )));
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java
index ba38b01d..346fbfe2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java
@@ -38,11 +38,15 @@ public class Minion extends OverviewLine {
private final List<MinionRequirement> requirements = new ArrayList<>();
private boolean crafted = false;
+
+ private final int xpGain;
+
private boolean meetRequirements = false;
- public Minion(String internalName, int tier) {
+ public Minion(String internalName, int tier, int xpGain) {
this.internalName = internalName;
this.tier = tier;
+ this.xpGain = xpGain;
}
public MinionSource getMinionSource() {
@@ -97,6 +101,10 @@ public class Minion extends OverviewLine {
this.meetRequirements = meetRequirements;
}
+ public int getXpGain() {
+ return xpGain;
+ }
+
@Override
public void onClick() {
NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(internalName);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index f3c8a86a..512ebb8f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -116,8 +116,8 @@ public class MinionHelperManager {
return null;
}
- public void createMinion(String internalName, int tier) {
- minions.put(internalName, new Minion(internalName, tier));
+ public void createMinion(String internalName, int tier, int xpGain) {
+ minions.put(internalName, new Minion(internalName, tier, xpGain));
}
public String formatInternalName(String minionName) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
index 49dac537..4c3af84e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
@@ -80,7 +80,10 @@ public class MinionHelperRepoLoader {
void load() {
errorWhileLoading = false;
- createMinions();
+ if (!createMinions()) {
+ errorWhileLoading = true;
+ return;
+ }
loadNpcData();
minionLoader.loadMinionData();
@@ -167,15 +170,26 @@ public class MinionHelperRepoLoader {
}
}
- private void createMinions() {
- for (Map.Entry<String, JsonElement> entry : Constants.MISC.get("minions").getAsJsonObject().entrySet()) {
+ private boolean createMinions() {
+ JsonObject misc = Constants.MISC;
+ if (misc == null || !misc.has("minions")) {
+ return false;
+ }
+ for (Map.Entry<String, JsonElement> entry : misc.get("minions").getAsJsonObject().entrySet()) {
String internalName = entry.getKey();
int maxTier = entry.getValue().getAsInt();
for (int i = 0; i < maxTier; i++) {
int tier = i + 1;
- manager.createMinion(internalName + "_" + tier, tier);
+ int minionXp;
+ if (misc.has("minionXp")) {
+ minionXp = misc.get("minionXp").getAsJsonObject().get(tier + "").getAsInt();
+ } else {
+ minionXp = 0;
+ }
+ manager.createMinion(internalName + "_" + tier, tier, minionXp);
}
}
+ return true;
}
private void testForMissingData() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
index 6219cf2c..33753d6c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
@@ -41,6 +41,7 @@ import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
@@ -48,9 +49,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
public class MinionHelperOverlay {
@@ -306,16 +309,32 @@ public class MinionHelperOverlay {
}
double priceNeeded = 0;
+ int xpGain = 0;
int index = 0;
- for (Double price : TrophyRewardOverlay.sortByValue(prices).values()) {
+ for (Minion minion : TrophyRewardOverlay.sortByValue(prices).keySet()) {
+ Double price = prices.get(minion);
priceNeeded += price;
+ xpGain += minion.getXpGain();
index++;
if (index == neededForNextSlot) break;
}
String format = manager.getPriceCalculation().formatCoins(priceNeeded);
format = format.replace(" coins", "");
- String text = color + "Next slot: §3" + neededForNextSlot + " minions §8- " + format;
- renderMap.put(text, new OverviewText(Collections.emptyList(), () -> {}));
+ String text =
+ color + "Next slot: §3" + neededForNextSlot + " minions §8- " + format;
+ List<String> lore;
+ if (xpGain == 0) {
+ if (index == 0) {
+ lore = Arrays.asList("§aAll minions bought!", "§cNo more SkyBlock XP to gain!");
+ } else {
+ lore = Collections.singletonList("§cCould not load SkyBlock XP for next slot!");
+ }
+ } else {
+ lore = Arrays.asList(EnumChatFormatting.DARK_AQUA.toString() + xpGain + " Skyblock XP §efor next slot",
+ "§8DISCLAIMER: This only works if", "§8you follow the helper."
+ );
+ }
+ renderMap.put(text, new OverviewText(lore, () -> {}));
}
private void addTitle(Map<Minion, Double> prices, LinkedHashMap<String, OverviewLine> renderMap) {