diff options
Diffstat (limited to 'src/main/java/io')
4 files changed, 26 insertions, 240 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 5c3083a3..a001850e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -37,7 +37,6 @@ import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; import io.github.moulberry.notenoughupdates.recipes.RecipeHistory; import io.github.moulberry.notenoughupdates.util.ApiUtil; import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.HotmInformation; import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -144,7 +143,6 @@ public class NEUManager { public File configLocation; public File repoLocation; public File configFile; - public HotmInformation hotm; public KatSitterOverlay katSitterOverlay; @@ -154,7 +152,6 @@ public class NEUManager { this.neu = neu; this.configLocation = configLocation; this.auctionManager = new APIManager(this); - this.hotm = new HotmInformation(neu); this.craftingOverlay = new CraftingOverlay(this); this.katSitterOverlay = new KatSitterOverlay(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 6d6963e3..552cb5b1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -75,7 +75,6 @@ import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.client.ClientCommandHandler; @@ -603,6 +602,9 @@ public class NEUConfig extends Config { @Expose public boolean abiphoneShowOnlyFavourites = false; + + @Expose + public Map<String, Integer> hotmTree = new HashMap<>(); } public HiddenLocationSpecific getLocationSpecific() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java index 47eb0d11..73b4f32d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java @@ -25,7 +25,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.HotmInformation; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -35,7 +37,6 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -88,10 +89,6 @@ public class ForgeRecipe implements NeuRecipe { return output; } - public int getHotmLevel() { - return hotmLevel; - } - public int getTimeInSeconds() { return timeInSeconds; } @@ -166,30 +163,28 @@ public class ForgeRecipe implements NeuRecipe { @Override public void drawHoverInformation(GuiItemRecipe gui, int mouseX, int mouseY) { - manager.hotm.getInformationOnCurrentProfile().ifPresent(hotmTree -> { - if (timeInSeconds > 0 && gui.isWithinRect( - mouseX, mouseY, - gui.guiLeft + EXTRA_INFO_X - EXTRA_INFO_MAX_WIDTH / 2, - gui.guiTop + EXTRA_INFO_Y - 8, - EXTRA_INFO_MAX_WIDTH, 16 - )) { - int qf = hotmTree.getLevel("forge_time"); - int reducedTime = getReducedTime(qf); - if (qf > 0) { + NEUConfig.HiddenProfileSpecific profileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (profileSpecific == null) return; + + if (timeInSeconds <= 0 || !gui.isWithinRect( + mouseX, mouseY, + gui.guiLeft + EXTRA_INFO_X - EXTRA_INFO_MAX_WIDTH / 2, + gui.guiTop + EXTRA_INFO_Y - 8, + EXTRA_INFO_MAX_WIDTH, 16 + )) return; - Utils.drawHoveringText( - Arrays.asList( - EnumChatFormatting.YELLOW + formatDuration(reducedTime) + " with Quick Forge (Level " + qf + ")"), - mouseX, - mouseY, - gui.width, - gui.height, - 500, - Minecraft.getMinecraft().fontRendererObj - ); - } - } - }); + int level = profileSpecific.hotmTree.getOrDefault("Quick Forge", 0); + if (level == 0) return; + int reducedTime = getReducedTime(level); + + Utils.drawHoveringText( + Collections.singletonList( + EnumChatFormatting.YELLOW + formatDuration(reducedTime) + " with Quick Forge (Level " + level + ")"), + mouseX, mouseY, + gui.width, gui.height, + 500, + Minecraft.getMinecraft().fontRendererObj + ); } public int getReducedTime(int quickForgeUpgradeLevel) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java deleted file mode 100644 index 57c4ae3b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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.util; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.inventory.ContainerChest; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiOpenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; - -public class HotmInformation { - private final NotEnoughUpdates neu; - public static final int[] EXPERIENCE_FOR_HOTM_LEVEL = { - // Taken from the wiki: https://hypixel-skyblock.fandom.com/wiki/Heart_of_the_Mountain#Experience_for_Each_Tier - 0, - 3000, - 12000, - 37000, - 97000, - 197000, - 347000 - }; - public static final int[] QUICK_FORGE_MULTIPLIERS = { - 985, - 970, - 955, - 940, - 925, - 910, - 895, - 880, - 865, - 850, - 845, - 840, - 835, - 830, - 825, - 820, - 815, - 810, - 805, - 700 - }; - private final Map<String, Tree> profiles = new ConcurrentHashMap<>(); - - public static class Tree { - private final Map<String, Integer> levels = new HashMap<>(); - private int totalMithrilPowder; - private int totalGemstonePowder; - private int hotmExp; - - public int getHotmExp() { - return hotmExp; - } - - public int getTotalGemstonePowder() { - return totalGemstonePowder; - } - - public int getTotalMithrilPowder() { - return totalMithrilPowder; - } - - public Set<String> getAllUnlockedNodes() { - return levels.keySet(); - } - - public int getHotmLevel() { - for (int i = EXPERIENCE_FOR_HOTM_LEVEL.length - 1; i >= 0; i--) { - if (EXPERIENCE_FOR_HOTM_LEVEL[i] >= this.hotmExp) - return i; - } - return 0; - } - - public int getLevel(String node) { - return levels.getOrDefault(node, 0); - } - - } - - private CompletableFuture<Void> updateTask = CompletableFuture.completedFuture(null); - - private boolean shouldReloadSoon = false; - - public HotmInformation(NotEnoughUpdates neu) { - this.neu = neu; - MinecraftForge.EVENT_BUS.register(this); - } - - public Optional<Tree> getInformationOn(String profile) { - if (profile == null) { - return Optional.empty(); - } - return Optional.ofNullable(this.profiles.get(profile)); - } - - public Optional<Tree> getInformationOnCurrentProfile() { - return getInformationOn(neu.manager.getCurrentProfile()); - } - - @SubscribeEvent - public synchronized void onLobbyJoin(WorldEvent.Load event) { - if (shouldReloadSoon) { - shouldReloadSoon = false; - neu.manager.apiUtils.updateProfileData(); - } - } - - @SubscribeEvent - public synchronized void onGuiOpen(GuiOpenEvent event) { - if (event.gui instanceof GuiChest) { - String containerName = ((ContainerChest) ((GuiChest) event.gui).inventorySlots) - .getLowerChestInventory() - .getDisplayName() - .getUnformattedText(); - if (containerName.equals("Heart of the Mountain")) - shouldReloadSoon = true; - } - } - - @SubscribeEvent - public synchronized void onChat(ClientChatReceivedEvent event) { - if (event.message.getUnformattedText().equals("Welcome to Hypixel SkyBlock!")) - neu.manager.apiUtils.updateProfileData(); - } - - /* - * 1000 = 100% of the time left - * 700 = 70% of the time left - * */ - public static int getQuickForgeMultiplier(int level) { - if (level <= 0) return 1000; - if (level > 20) return -1; - return QUICK_FORGE_MULTIPLIERS[level - 1]; - } - @SubscribeEvent - public void onApiDataLoaded(ProfileDataLoadedEvent event) { - JsonObject data = event.getData(); - if (data == null) return; - - if (!data.has("success") || !data.get("success").getAsBoolean()) return; - JsonArray profiles = data.getAsJsonArray("profiles"); - for (JsonElement element : profiles) { - JsonObject profile = element.getAsJsonObject(); - String profileName = profile.get("cute_name").getAsString(); - JsonObject player = profile.getAsJsonObject("members").getAsJsonObject(Minecraft.getMinecraft().thePlayer - .getUniqueID() - .toString() - .replace("-", "")); - if (!player.has("mining_core")) - continue; - JsonObject miningCore = player.getAsJsonObject("mining_core"); - Tree tree = new Tree(); - JsonObject nodes = miningCore.getAsJsonObject("nodes"); - for (Map.Entry<String, JsonElement> node : nodes.entrySet()) { - String key = node.getKey(); - if (!key.startsWith("toggle_")) { - tree.levels.put(key, node.getValue().getAsInt()); - } - } - if (miningCore.has("powder_mithril_total")) { - tree.totalMithrilPowder = miningCore.get("powder_mithril_total").getAsInt(); - } - if (miningCore.has("powder_gemstone_total")) { - tree.totalGemstonePowder = miningCore.get("powder_gemstone_total").getAsInt(); - } - if (miningCore.has("experience")) { - tree.hotmExp = miningCore.get("experience").getAsInt(); - } - this.profiles.put(profileName, tree); - } - } - -} |