diff options
Diffstat (limited to 'src/main')
5 files changed, 181 insertions, 150 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index a0a78938..9ef9e474 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -66,6 +66,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; +import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.DECIMAL_FORMAT; import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt; public class BasicPage extends GuiProfileViewerPage { @@ -74,6 +75,13 @@ public class BasicPage extends GuiProfileViewerPage { private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1); public EntityOtherPlayerMP entityPlayer = null; private ResourceLocation playerLocationSkin = null; + private final GuiProfileViewer guiProfileViewer; + + private final String[] medalNames = { + "§cBronze", + "§fSilver", + "§6Gold" + }; private ResourceLocation playerLocationCape = null; private String skinType = null; private boolean loadingProfile = false; @@ -82,6 +90,7 @@ public class BasicPage extends GuiProfileViewerPage { public BasicPage(GuiProfileViewer instance) { super(instance); + this.guiProfileViewer = instance; } @Override @@ -154,6 +163,8 @@ public class BasicPage extends GuiProfileViewerPage { Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic); Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST); + JsonObject profileInfo = profile.getProfileInformation(profileId); + if (profileInfo == null) return; if (entityPlayer != null && profile.getHypixelProfile() != null) { String playerName = null; @@ -201,8 +212,11 @@ public class BasicPage extends GuiProfileViewerPage { playerName = EnumChatFormatting.GRAY + name; if (rankName != null) { + String icon = getIcon(getGameModeType(profileInfo)); playerName = - "\u00A7" + rankColor + "[" + rankName + rankPlusColor + rankPlus + "\u00A7" + rankColor + "] " + name; + "\u00A7" + rankColor + "[" + rankName + rankPlusColor + rankPlus + "\u00A7" + rankColor + "] " + name + + (icon.equals("") ? "" : " " + icon); + ; } } } @@ -404,9 +418,6 @@ public class BasicPage extends GuiProfileViewerPage { entityPlayer.getDataWatcher().updateObject(10, b); } - JsonObject profileInfo = profile.getProfileInformation(profileId); - if (profileInfo == null) return; - Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profileId); JsonObject inventoryInfo = profile.getInventoryInfo(profileId); @@ -636,42 +647,85 @@ public class BasicPage extends GuiProfileViewerPage { String skillName = entry.getValue().getDisplayName(); - float level = skyblockInfo.get(entry.getKey()).level; - int levelFloored = (int) Math.floor(level); + ProfileViewer.Level level = skyblockInfo.get(entry.getKey()); + int levelFloored = (int) Math.floor(level.level); int x = guiLeft + 237 + 86 * xPosition; int y = guiTop + 24 + 21 * yPosition; Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, 60); - if (skyblockInfo.get(entry.getKey()).maxed) { + if (level.maxed) { getInstance().renderGoldBar(x, y + 6, 80); } else { - getInstance().renderBar(x, y + 6, 80, level % 1); + getInstance().renderBar(x, y + 6, 80, level.level % 1); } if (mouseX > x && mouseX < x + 80) { if (mouseY > y - 4 && mouseY < y + 13) { getInstance().tooltipToDisplay = new ArrayList<>(); - getInstance().tooltipToDisplay.add(skillName); - if (skyblockInfo.get(entry.getKey()).maxed) { - getInstance().tooltipToDisplay.add( + List<String> tooltipToDisplay = getInstance().tooltipToDisplay; + tooltipToDisplay.add(skillName); + if (level.maxed) { + tooltipToDisplay.add( EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.GOLD + "MAXED!"); } else { - int maxXp = (int) skyblockInfo.get(entry.getKey()).maxXpForLevel; + int maxXp = (int) level.maxXpForLevel; getInstance() .tooltipToDisplay.add( EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE + - StringUtils.shortNumberFormat(Math.round((level % 1) * maxXp)) + + StringUtils.shortNumberFormat(Math.round((level.level % 1) * maxXp)) + "/" + - StringUtils.shortNumberFormat(maxXp) + StringUtils.shortNumberFormat(maxXp)); + } + String totalXpS = GuiProfileViewer.numberFormat.format((int) level.totalXp); + tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + totalXpS + + EnumChatFormatting.DARK_GRAY + " (" + + DECIMAL_FORMAT.format(guiProfileViewer.getPercentage(entry.getKey().toLowerCase(), level)) + + "% to " + level.maxLevel + ")"); + if (entry.getKey().equals("farming")) { + // double drops + pelts + int doubleDrops = Utils.getElementAsInt(Utils.getElement(profileInfo, "jacob2.perks.double_drops"), 0); + int peltCount = Utils.getElementAsInt(Utils.getElement(profileInfo, "trapper_quest.pelt_count"), 0); + + if (doubleDrops == 15) { + tooltipToDisplay.add("§7Double Drops: §6" + (doubleDrops * 2) + "%"); + } else tooltipToDisplay.add("§7Double Drops: §5" + (doubleDrops * 2) + "%"); + + tooltipToDisplay.add("§7Pelts: §e" + peltCount); + + // medals + JsonObject medals_inv = Utils.getElement(profileInfo, "jacob2.medals_inv").getAsJsonObject(); + tooltipToDisplay.add(" "); + for (String medalName : medalNames) { + String textWithoutFormattingCodes = + EnumChatFormatting.getTextWithoutFormattingCodes(medalName.toLowerCase()); + if (medals_inv.has(textWithoutFormattingCodes)) { + int medalAmount = medals_inv.get(textWithoutFormattingCodes).getAsInt(); + tooltipToDisplay.add(EnumChatFormatting.GRAY + WordUtils.capitalize(medalName) + ": " + + EnumChatFormatting.WHITE + medalAmount); + } else { + tooltipToDisplay.add(EnumChatFormatting.GRAY + WordUtils.capitalize(medalName) + ": " + + EnumChatFormatting.WHITE + "0"); + } + } + } + + String slayerNameLower = entry.getKey().toLowerCase(); + if (ExtraPage.slayers.containsKey(slayerNameLower)) { + int maxLevel = ExtraPage.slayers.get(slayerNameLower); + for (int i = 0; i < 5; i++) { + if (i >= maxLevel) break; + float tier = Utils.getElementAsFloat( + Utils.getElement(profileInfo, "slayer_bosses." + slayerNameLower + ".boss_kills_tier_" + i), + 0 ); + tooltipToDisplay.add(EnumChatFormatting.GRAY + "T" + (i + 1) + " Kills: " + + EnumChatFormatting.RED + (int) tier); + } } - String totalXpS = GuiProfileViewer.numberFormat.format((int) skyblockInfo.get(entry.getKey()).totalXp); - getInstance() - .tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + totalXpS); } } @@ -697,6 +751,19 @@ public class BasicPage extends GuiProfileViewerPage { renderWeight(mouseX, mouseY, skyblockInfo, profileInfo); } + private String getIcon(String gameModeType) { + switch (gameModeType) { + case "island": + return "§a☀"; + case "bingo": + return "§7Ⓑ"; + case "ironman": + return "§7♲"; + default: + return ""; + } + } + @Override public void resetCache() { entityPlayer = null; @@ -887,4 +954,11 @@ public class BasicPage extends GuiProfileViewerPage { GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } + + public String getGameModeType(JsonObject profileInfo) { + if (profileInfo != null && profileInfo.has("game_mode")) { + return profileInfo.get("game_mode").getAsString(); + } + return ""; + } } 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 3b30b9b7..f8da4144 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java @@ -19,9 +19,11 @@ package io.github.moulberry.notenoughupdates.profileviewer; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; @@ -36,6 +38,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -53,6 +56,58 @@ public class ExtraPage extends GuiProfileViewerPage { super(instance); } + // pls update in the future tyvm !!! + final static HashMap<String, Integer> slayers = new HashMap<String, Integer>() { + { + put("zombie", 5); + put("spider", 4); + put("wolf", 4); + put("enderman", 4); + put("blaze", 4); + } + }; + + public void drawEssence( + JsonObject profileInfo, + float xStart, + float yStartTop, + float xOffset, + float yOffset) { + int guiLeft = GuiProfileViewer.getGuiLeft(); + int guiTop = GuiProfileViewer.getGuiTop(); + yStartTop = yStartTop + 78; + if (Constants.PARENTS == null || !Constants.PARENTS.has("ESSENCE_WITHER")) { + Utils.showOutdatedRepoNotification(); + return; + } + JsonObject parents = Constants.PARENTS; + JsonArray essenceArray = parents.get("ESSENCE_WITHER").getAsJsonArray(); + + for (int i = 0; i < essenceArray.size(); i++) { + + JsonElement jsonElement = essenceArray.get(i); + String essenceName = jsonElement.getAsString(); + + TreeMap<String, JsonObject> itemInformation = NotEnoughUpdates.INSTANCE.manager.getItemInformation(); + if (!itemInformation.containsKey(essenceName)) { + Utils.showOutdatedRepoNotification(); + return; + } + String displayName = itemInformation.get(essenceName).getAsJsonObject().get("displayname").getAsString(); + if (profileInfo.has(essenceName.toLowerCase())) { + int essenceNumber = profileInfo.get(essenceName.toLowerCase()).getAsInt(); + + Utils.renderAlignedString( + EnumChatFormatting.GOLD + displayName, + EnumChatFormatting.WHITE + StringUtils.shortNumberFormat(essenceNumber, 0), + guiLeft + xStart + xOffset, + guiTop + yStartTop + yOffset * i, + 76 + ); + } + } + } + @Override public void drawPage(int mouseX, int mouseY, float partialTicks) { int guiLeft = GuiProfileViewer.getGuiLeft(); @@ -159,14 +214,13 @@ public class ExtraPage extends GuiProfileViewerPage { "alchemy", "carpentry" ); - List<String> slayers = Arrays.asList("zombie", "spider", "wolf", "enderman", "blaze"); for (Map.Entry<String, ProfileViewer.Level> entry : skyblockInfo.entrySet()) { if (skills.contains(entry.getKey())) { totalSkillLVL += entry.getValue().level; totalTrueSkillLVL += Math.floor(entry.getValue().level); totalSkillCount++; - } else if (slayers.contains(entry.getKey())) { + } else if (slayers.containsKey(entry.getKey())) { totalSlayerLVL += entry.getValue().level; totalSlayerCount++; totalSlayerXP += entry.getValue().totalXp; @@ -266,131 +320,6 @@ public class ExtraPage extends GuiProfileViewerPage { 76 ); - //Slayer values - float zombie_boss_kills_tier_2 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_2"), - 0 - ); - float zombie_boss_kills_tier_3 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_3"), - 0 - ); - float zombie_boss_kills_tier_4 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_4"), - 0 - ); - float wolf_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "slayer_bosses.wolf.boss_kills_tier_2" - ), 0); - float wolf_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "slayer_bosses.wolf.boss_kills_tier_3" - ), 0); - float spider_boss_kills_tier_2 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_2"), - 0 - ); - float spider_boss_kills_tier_3 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_3"), - 0 - ); - float enderman_boss_kills_tier_2 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_2"), - 0 - ); - float enderman_boss_kills_tier_3 = Utils.getElementAsFloat( - Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_3"), - 0 - ); - float blaze_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "slayer_bosses.blaze.boss_kills_tier_2" - ), 0); - float blaze_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "slayer_bosses.blaze.boss_kills_tier_3" - ), 0); - - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Revenant T3", - EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_2, - guiLeft + xStart + xOffset, - guiTop + yStartBottom, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Revenant T4", - EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_3, - guiLeft + xStart + xOffset, - guiTop + yStartBottom + yOffset, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Revenant T5", - EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_4, - guiLeft + xStart + xOffset, - guiTop + yStartBottom + yOffset * 2, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Tarantula T3", - EnumChatFormatting.WHITE.toString() + (int) spider_boss_kills_tier_2, - guiLeft + xStart + xOffset, - guiTop + yStartBottom + yOffset * 3, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Tarantula T4", - EnumChatFormatting.WHITE.toString() + (int) spider_boss_kills_tier_3, - guiLeft + xStart + xOffset, - guiTop + yStartBottom + yOffset * 4, - 76 - ); - - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Sven T3", - EnumChatFormatting.WHITE.toString() + (int) wolf_boss_kills_tier_2, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 0, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Sven T4", - EnumChatFormatting.WHITE.toString() + (int) wolf_boss_kills_tier_3, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 1, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Voidgloom T3", - EnumChatFormatting.WHITE.toString() + (int) enderman_boss_kills_tier_2, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 2, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Voidgloom T4", - EnumChatFormatting.WHITE.toString() + (int) enderman_boss_kills_tier_3, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 3, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Inferno T3", - EnumChatFormatting.WHITE.toString() + (int) blaze_boss_kills_tier_2, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 4, - 76 - ); - Utils.renderAlignedString( - EnumChatFormatting.DARK_AQUA + "Inferno T4", - EnumChatFormatting.WHITE.toString() + (int) blaze_boss_kills_tier_3, - guiLeft + xStart + xOffset * 2, - guiTop + yStartBottom + yOffset * 5, - 76 - ); - float pet_milestone_ores_mined = Utils.getElementAsFloat(Utils.getElement( profileInfo, "stats.pet_milestone_ores_mined" @@ -447,6 +376,8 @@ public class ExtraPage extends GuiProfileViewerPage { 76 ); + drawEssence(profileInfo, xStart, yStartTop, xOffset, yOffset); + if (topKills == null) { topKills = new TreeMap<>(); JsonObject stats = profileInfo.get("stats").getAsJsonObject(); 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 501af179..c78a6167 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -29,6 +29,8 @@ import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage; import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage; +import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.DungeonsWeight; +import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight; import io.github.moulberry.notenoughupdates.util.AsyncDependencyLoader; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.PronounDB; @@ -58,6 +60,7 @@ import java.awt.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; @@ -76,6 +79,8 @@ public class GuiProfileViewer extends GuiScreen { public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.png"); public static final ResourceLocation pv_bingo = new ResourceLocation("notenoughupdates:pv_bingo.png"); + + public final static DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#"); public static final ResourceLocation pv_stranded = new ResourceLocation("notenoughupdates:pv_stranded.png"); public static final ResourceLocation pv_unknown = new ResourceLocation("notenoughupdates:pv_unknown.png"); public static final ResourceLocation resource_packs = @@ -1024,9 +1029,11 @@ public class GuiProfileViewer extends GuiScreen { if (mouseY > y - 4 && mouseY < y + 13) { String levelStr; String totalXpStr = null; - if (skillName.contains("Catacombs")) totalXpStr = - EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + - numberFormat.format(levelObj.totalXp); + if (skillName.contains("Catacombs")) { + totalXpStr = EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + + numberFormat.format(levelObj.totalXp) + EnumChatFormatting.DARK_GRAY + " (" + + DECIMAL_FORMAT.format(getPercentage(skillName.toLowerCase(), levelObj)) + "% to 50)"; + } if (levelObj.maxed) { levelStr = EnumChatFormatting.GOLD + "MAXED!"; } else { @@ -1238,6 +1245,25 @@ public class GuiProfileViewer extends GuiScreen { } } + public float getPercentage(String skillName, ProfileViewer.Level level) { + if (level.maxed) { + return 100; + } + if (skillName.contains("catacombs")) { + return (level.totalXp / DungeonsWeight.CATACOMBS_LEVEL_50_XP) * 100; + } else if (ExtraPage.slayers.containsKey(skillName)) { + return (level.totalXp / 1000000) * 100; + } else if (skillName.equalsIgnoreCase("social")) { + return (level.totalXp / 272800) * 100; + } else { + if (level.maxLevel == 60) { + return (level.totalXp / SkillsWeight.SKILLS_LEVEL_60) * 100; + } else { + return (level.totalXp / SkillsWeight.SKILLS_LEVEL_50) * 100; + } + } + } + /** * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/DungeonsWeight.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/DungeonsWeight.java index 39e743aa..9c233554 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/DungeonsWeight.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/DungeonsWeight.java @@ -24,7 +24,7 @@ import java.util.Map; public abstract class DungeonsWeight { - protected static final long CATACOMBS_LEVEL_50_XP = 569809640; + public static final long CATACOMBS_LEVEL_50_XP = 569809640; protected final Map<String, ProfileViewer.Level> player; protected final WeightStruct weightStruct; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/SkillsWeight.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/SkillsWeight.java index 55669f7b..5c372591 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/SkillsWeight.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/SkillsWeight.java @@ -24,8 +24,8 @@ import java.util.Map; public abstract class SkillsWeight { - protected static final long SKILLS_LEVEL_50 = 55172425; - protected static final long SKILLS_LEVEL_60 = 111672425; + public static final long SKILLS_LEVEL_50 = 55172425; + public static final long SKILLS_LEVEL_60 = 111672425; protected final Map<String, ProfileViewer.Level> player; protected final WeightStruct weightStruct; |