diff options
author | Madeleaan <70163122+Madeleaan@users.noreply.github.com> | 2023-10-09 06:59:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-09 15:59:26 +1100 |
commit | 13e7fe8584a00e8d840e32cd0605d476463b8913 (patch) | |
tree | 36a028d3607c80b76ad2b2e5d3d4ce4b3030daf3 | |
parent | 40f42921de591a2ced74f4c5d2b2d5e412a2b31a (diff) | |
download | NotEnoughUpdates-13e7fe8584a00e8d840e32cd0605d476463b8913.tar.gz NotEnoughUpdates-13e7fe8584a00e8d840e32cd0605d476463b8913.tar.bz2 NotEnoughUpdates-13e7fe8584a00e8d840e32cd0605d476463b8913.zip |
Profile viewer fixes (#871)
8 files changed, 118 insertions, 47 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java index 1672fa83..dc04fdef 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java @@ -314,27 +314,27 @@ public class ExtraPage extends GuiProfileViewerPage { float avgSlayerLVL = totalSlayerLVL / totalSlayerCount; Utils.renderAlignedString( - EnumChatFormatting.RED + "AVG Skill Level", + EnumChatFormatting.RED + "AVG Skill LVL", selectedProfile.skillsApiEnabled() ? EnumChatFormatting.WHITE.toString() + Math.floor(avgSkillLVL * 10) / 10 : - EnumChatFormatting.RED + "Skills API not enabled!", + EnumChatFormatting.RED + "API OFF!", guiLeft + xStart, guiTop + yStartBottom + yOffset, 76 ); Utils.renderAlignedString( - EnumChatFormatting.RED + "True AVG Skill Level", + EnumChatFormatting.RED + "True AVG Skill LVL", selectedProfile.skillsApiEnabled() ? EnumChatFormatting.WHITE.toString() + Math.floor(avgTrueSkillLVL * 10) / 10 : - EnumChatFormatting.RED + "Skills API not enabled!", + EnumChatFormatting.RED + "API OFF!", guiLeft + xStart, guiTop + yStartBottom + yOffset * 2, 76 ); Utils.renderAlignedString( - EnumChatFormatting.RED + "AVG Slayer Level", + EnumChatFormatting.RED + "AVG Slayer LVL", EnumChatFormatting.WHITE.toString() + Math.floor(avgSlayerLVL * 10) / 10, guiLeft + xStart, guiTop + yStartBottom + yOffset * 3, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 198abb54..824e1995 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -166,6 +166,7 @@ public class GuiProfileViewer extends GuiScreen { ); public final GuiElementTextField playerNameTextField; public final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); + public final GuiElementTextField museumTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); public final GuiElementTextField killDeathSearchTextField = new GuiElementTextField( "", GuiElementTextField.SCALE_TEXT @@ -735,6 +736,7 @@ public class GuiProfileViewer extends GuiScreen { inventoryTextField.otherComponentClick(); playerNameTextField.otherComponentClick(); killDeathSearchTextField.otherComponentClick(); + museumTextField.otherComponentClick(); return; } } @@ -784,6 +786,7 @@ public class GuiProfileViewer extends GuiScreen { playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton); inventoryTextField.otherComponentClick(); killDeathSearchTextField.otherComponentClick(); + museumTextField.otherComponentClick(); return; } } @@ -847,12 +850,14 @@ public class GuiProfileViewer extends GuiScreen { playerNameTextField.otherComponentClick(); inventoryTextField.otherComponentClick(); killDeathSearchTextField.otherComponentClick(); + museumTextField.otherComponentClick(); return; } profileDropdownSelected = false; playerNameTextField.otherComponentClick(); inventoryTextField.otherComponentClick(); killDeathSearchTextField.otherComponentClick(); + museumTextField.otherComponentClick(); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java index cca27962..641040e9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java @@ -123,11 +123,13 @@ public class MiningPage extends GuiProfileViewerPage { int orbit = Utils.getElementAsInt(Utils.getElement(nodes, "experience_orbs"), 0); float orbitStat = (float) (orbit * .01 + 0.2); int crystallized = Utils.getElementAsInt(Utils.getElement(nodes, "fallen_star_bonus"), 0); - int crystallizedStat = crystallized * 6 + 14; + int crystallizedStat = (crystallized - 1) * 6 + 20; + int crystallizedStat2 = (crystallized - 1) * 5 + 20; int professional = Utils.getElementAsInt(Utils.getElement(nodes, "professional"), 0); int professionalStat = professional * 5 + 50; int greatExplorer = Utils.getElementAsInt(Utils.getElement(nodes, "great_explorer"), 0); int greatExplorerStat = greatExplorer * 4 + 16; + int greatExplorerStat2 = greatExplorer / 5 + 1; int fortunate = Utils.getElementAsInt(Utils.getElement(nodes, "fortunate"), 0); int fortunateStat = fortunate * 4 + 20; int lonesomeMiner = ((Utils.getElementAsInt(Utils.getElement(nodes, "lonesome_miner"), 0))); @@ -999,9 +1001,12 @@ public class MiningPage extends GuiProfileViewerPage { "Great Explorer", "§7Level " + greatExplorer + EnumChatFormatting.DARK_GRAY + "/20", "", - "§7Grants " + EnumChatFormatting.GREEN + "+" + greatExplorerStat + "% " + EnumChatFormatting.GRAY + - "chance to", - "§7find treasure.", + "§7Boosts the chance to find", + "§7treasure chests while mining in", + "§7the §5Crystal Hollows §7by", + EnumChatFormatting.GREEN + "+" + greatExplorerStat + "%" + " §7and reduces the", + "§7amount of locks on the chests by", + EnumChatFormatting.GREEN.toString() + greatExplorerStat2 + "§7.", "", EnumChatFormatting.GRAY + "Cost", EnumChatFormatting.LIGHT_PURPLE + @@ -1012,9 +1017,12 @@ public class MiningPage extends GuiProfileViewerPage { "Great Explorer", "§7Level " + greatExplorer + EnumChatFormatting.DARK_GRAY + "/20", "", - "§7Grants " + EnumChatFormatting.GREEN + "+" + greatExplorerStat + "% " + EnumChatFormatting.GRAY + - "chance to", - "§7find treasure." + "§7Boosts the chance to find", + "§7treasure chests while mining in", + "§7the §5Crystal Hollows §7by", + EnumChatFormatting.GREEN + "+" + greatExplorerStat + "%" + " §7and reduces the", + "§7amount of locks on the chests by", + EnumChatFormatting.GREEN.toString() + greatExplorerStat2 + "§7." ), 20 ); @@ -1142,10 +1150,9 @@ public class MiningPage extends GuiProfileViewerPage { "Crystallized", "§7Level " + crystallized + EnumChatFormatting.DARK_GRAY + "/30", "", - "§7Grants §a+§a" + crystallizedStat + "§7 §6⸕ Mining", - "§6Speed §7and a §a" + crystallizedStat + "%§7 §7chance", - "§7to deal §a+1 §7extra damage near", - "§7§5Fallen Stars§7.", + "§7Grants §a+§a" + crystallizedStat + "§7 §6⸕ Mining Speed", + "§7and §a+" + crystallizedStat + "§7 §6☘ Mining Fortune", + "§7near §5Fallen Stars§7.", "", EnumChatFormatting.GRAY + "Cost", EnumChatFormatting.DARK_GREEN + @@ -1156,10 +1163,9 @@ public class MiningPage extends GuiProfileViewerPage { "Crystallized", "§7Level " + crystallized + EnumChatFormatting.DARK_GRAY + "/30", "", - "§7Grants §a+§a" + crystallizedStat + "§7 §6⸕ Mining", - "§6Speed §7and a §a" + crystallizedStat + "%§7 §7chance", - "§7to deal §a+1 §7extra damage near", - "§7§5Fallen Stars§7." + "§7Grants §a+§a" + crystallizedStat + "§7 §6⸕ Mining Speed", + "§7and §a+" + crystallizedStat + "§7 §6☘ Mining Fortune", + "§7near §5Fallen Stars§7." ), 30 ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MuseumPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MuseumPage.java index 69f9e85a..6bcf4405 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MuseumPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MuseumPage.java @@ -27,6 +27,7 @@ import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -38,6 +39,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import java.awt.*; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; @@ -69,11 +71,14 @@ public class MuseumPage extends GuiProfileViewerPage { new ResourceLocation("textures/gui/container/generic_54.png"); private static String selectedMuseumCategory = "weapons"; JsonObject museum = Constants.MUSEUM; - int pageArrowsHeight = 164; + int pageArrowsHeight = 34; int pages = 0; int onPage = 1; String currentItemSelected = null; JsonArray selectedItem = null; + int overlay = new Color(0, 0, 0, 100).getRGB(); + private static final int searchBarSizeX = 120; + private static final int searchBarSizeY = 20; public MuseumPage(GuiProfileViewer instance) {super(instance);} @@ -82,6 +87,8 @@ public class MuseumPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); + getInstance().museumTextField.setSize(searchBarSizeX, searchBarSizeY); + SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile(); if (selectedProfile == null) { return; @@ -109,6 +116,8 @@ public class MuseumPage extends GuiProfileViewerPage { return; } + getInstance().museumTextField.render(guiLeft + 251-searchBarSizeX/2, guiTop + getInstance().sizeY - 26 - 20); + int xIndex = 0; for (Map.Entry<String, ItemStack> entry : museumCategories.entrySet()) { Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); @@ -317,6 +326,7 @@ public class MuseumPage extends GuiProfileViewerPage { } } Utils.drawItemStack(stack, x, y); + highlightMatchingItem(stack, x, y); } break; default: @@ -368,6 +378,7 @@ public class MuseumPage extends GuiProfileViewerPage { getInstance().tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); } Utils.drawItemStack(stack, x, y); + highlightMatchingItem(stack, x, y); } } @@ -523,9 +534,11 @@ public class MuseumPage extends GuiProfileViewerPage { setPage("special"); break; default: + getInstance().museumTextField.keyTyped(typedChar, keyCode); return; } Utils.playPressSound(); + getInstance().museumTextField.keyTyped(typedChar, keyCode); } private void setPage(String pageName) { @@ -543,4 +556,44 @@ public class MuseumPage extends GuiProfileViewerPage { } return 1; } + + @Override + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + int guiLeft = GuiProfileViewer.getGuiLeft(); + int guiTop = GuiProfileViewer.getGuiTop(); + + getInstance().museumTextField.setSize(searchBarSizeX, searchBarSizeY); + if (mouseX > guiLeft + 251 - searchBarSizeX/2 && mouseX < guiLeft + 251 + searchBarSizeX/2) { + if (mouseY > guiTop + getInstance().sizeY - 26 - 20 && mouseY < guiTop + getInstance().sizeY - 26) { + getInstance().museumTextField.mouseClicked(mouseX, mouseY, mouseButton); + getInstance().playerNameTextField.otherComponentClick(); + return true; + } + } + return false; + } + + private void highlightMatchingItem(ItemStack stack, int x, int y) { + if ( + getInstance().museumTextField.getText() != null && + !getInstance().museumTextField.getText().isEmpty() && + ( + stack == null || + !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch( + stack, + getInstance().museumTextField.getText() + ) + ) + ) { + GlStateManager.translate(0, 0, 50); + GuiScreen.drawRect( + x, + y, + x + 16, + y + 16, + overlay + ); + GlStateManager.translate(0, 0, -50); + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java index 4eda3d9f..d9bfb80d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java @@ -139,6 +139,7 @@ public class PetsPage extends GuiProfileViewerPage { pet.addProperty("level", parsedPet.petLevel.getCurrentLevel()); pet.addProperty("currentLevelRequirement", parsedPet.petLevel.getExpRequiredForNextLevel()); pet.addProperty("maxXP", parsedPet.petLevel.getExpRequiredForMaxLevel()); + pet.addProperty("percentageToNextLevel", parsedPet.petLevel.getPercentageToNextLevel()); } } @@ -280,6 +281,7 @@ public class PetsPage extends GuiProfileViewerPage { float level = pet.get("level").getAsFloat(); float currentLevelRequirement = pet.get("currentLevelRequirement").getAsFloat(); + float percentageToNextLevel = pet.get("percentageToNextLevel").getAsFloat(); float exp = pet.get("exp").getAsFloat(); float maxXP = pet.get("maxXP").getAsFloat(); @@ -300,12 +302,12 @@ public class PetsPage extends GuiProfileViewerPage { Utils.renderAlignedString( EnumChatFormatting.YELLOW + "To Next LVL", - EnumChatFormatting.WHITE.toString() + (int) (level % 1 * 100) + "%", + EnumChatFormatting.WHITE.toString() + (int) (percentageToNextLevel * 100) + "%", guiLeft + 319, guiTop + 46, 98 ); - getInstance().renderBar(guiLeft + 319, guiTop + 56, 98, level % 1); + getInstance().renderBar(guiLeft + 319, guiTop + 56, 98, percentageToNextLevel); Utils.renderAlignedString( EnumChatFormatting.YELLOW + "To Max LVL", @@ -325,7 +327,7 @@ public class PetsPage extends GuiProfileViewerPage { ); Utils.renderAlignedString( EnumChatFormatting.YELLOW + "Current LVL XP", - EnumChatFormatting.WHITE + StringUtils.shortNumberFormat((level % 1) * currentLevelRequirement), + EnumChatFormatting.WHITE + StringUtils.shortNumberFormat(percentageToNextLevel * currentLevelRequirement), guiLeft + 319, guiTop + 143, 98 diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java index 3184fba6..601556e5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java @@ -1197,7 +1197,9 @@ public class SkyblockProfiles { if (!getUuid().equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""))) return; if (!getLatestProfile().skillsApiEnabled()) return; - PetInfoOverlay.getConfig().tamingLevel = (int) getLevelingInfo().get("taming").level; + if (getLevelingInfo().get("taming") != null) { //idfk what else could cause an NPE here + PetInfoOverlay.getConfig().tamingLevel = (int) getLevelingInfo().get("taming").level; + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt index 2691f23c..62847ea6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt @@ -120,7 +120,7 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) mouseX < guiLeft + 30 + bestiaryXSize * categoryXIndex + 20 && mouseY > guiTop + 10 && mouseY < guiTop + 10 + 20 ) { - tooltipToDisplay = category.icon.getTooltip(Minecraft.getMinecraft().thePlayer, false) + tooltipToDisplay.add(EnumChatFormatting.GRAY.toString() + category.name) if (Mouse.getEventButtonState() && selectedCategory != category.id) { selectedCategory = category.id Utils.playPressSound() diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java index f7bee433..e12c91fb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java @@ -183,13 +183,12 @@ public class RiftPage extends GuiProfileViewerPage { // 346, 16 if (timecharm != null) { - Utils.drawStringScaled( - EnumChatFormatting.RED + "Timecharms: §f" + timecharm.size() + "/7", + Utils.renderAlignedString( + EnumChatFormatting.RED + "Timecharms:", + EnumChatFormatting.WHITE.toString() + timecharm.size() + "/7", guiLeft + 336, guiTop + 39, - true, - 0, - 1f + 83 ); if ((mouseX > guiLeft + 336 && mouseX < guiLeft + 336 + 80) && @@ -198,9 +197,15 @@ public class RiftPage extends GuiProfileViewerPage { List<String> displayNames = new ArrayList<>(); for (JsonElement jsonElement : timecharm) { String timecharmType = jsonElement.getAsJsonObject().get("type").getAsString(); - String displayName = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withKnownInternalName( - "RIFT_TROPHY_" + timecharmType.toUpperCase()).resolveToItemStack().getDisplayName(); - displayNames.add(displayName + "§7: §a✔"); + ItemStack timecharmItem = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withKnownInternalName( + "RIFT_TROPHY_" + timecharmType.toUpperCase()).resolveToItemStack(); + if(timecharmItem != null) { + displayNames.add(timecharmItem.getDisplayName() + "§7: §a✔"); + } else { + displayNames.add(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "ERROR LOADING TIMECHARM!"); + displayNames.add(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "PLEASE REPORT THIS AT " + EnumChatFormatting.GOLD + "discord.gg/moulberry"); + displayNames.add(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "WITH THE FOLLOWING TEXT: " + EnumChatFormatting.AQUA + timecharmType.toUpperCase()); + } } getInstance().tooltipToDisplay = displayNames; } @@ -215,13 +220,12 @@ public class RiftPage extends GuiProfileViewerPage { grubberStacks = castleData.get("grubber_stacks").getAsInt(); } - Utils.drawStringScaled( - EnumChatFormatting.GOLD + "Burger: §f" + grubberStacks + "/5", + Utils.renderAlignedString( + EnumChatFormatting.GOLD + "Burger:", + EnumChatFormatting.WHITE.toString() + grubberStacks + "/5", guiLeft + 331, guiTop + 87, - true, - 0, - 1f + 83 ); renderItem("MCGRUBBER_BURGER", 314, +84, guiLeft, guiTop); @@ -236,9 +240,9 @@ public class RiftPage extends GuiProfileViewerPage { ); if (vampire.maxed) { - getInstance().renderGoldBar(guiLeft + 320, guiTop + 69, 90); + getInstance().renderGoldBar(guiLeft + 320, guiTop + 71, 90); } else { - getInstance().renderBar(guiLeft + 320, guiTop + 69, 90, vampire.level % 1); + getInstance().renderBar(guiLeft + 320, guiTop + 71, 90, vampire.level % 1); } if (mouseX > guiLeft + 300 && mouseX < guiLeft + 410) { @@ -269,13 +273,12 @@ public class RiftPage extends GuiProfileViewerPage { foundSouls = enigma.getAsJsonArray("found_souls").size(); } - Utils.drawStringScaled( - EnumChatFormatting.DARK_PURPLE + "Enigma Souls: §f" + foundSouls + "/42", + Utils.renderAlignedString( + EnumChatFormatting.DARK_PURPLE + "Enigma Souls:", + EnumChatFormatting.WHITE.toString() + foundSouls + "/42", guiLeft + 331, guiTop + 110, - true, - 0, - 0.9f + 83 ); renderItem("SKYBLOCK_ENIGMA_SOUL", 314, 106, guiLeft, guiTop); @@ -558,6 +561,6 @@ public class RiftPage extends GuiProfileViewerPage { public void drawErrorMessage() { String message = EnumChatFormatting.RED + "No Rift data available!"; - Utils.drawStringCentered(message, guiLeft + 431 / 2f, guiTop + 101, true, 0); + Utils.drawStringCentered(message, guiLeft + 431 / 2f, guiTop + 61, true, 0); } } |