diff options
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) { |