From fde462b796ed7fbb22fdf7cf04c032389f3e8629 Mon Sep 17 00:00:00 2001 From: kr45732 <52721908+kr45732@users.noreply.github.com> Date: Thu, 11 Aug 2022 07:03:39 -0400 Subject: PV Refactoring (#212) --- .../profileviewer/GuiProfileViewer.java | 4894 ++------------------ 1 file changed, 449 insertions(+), 4445 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java') 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 a21145d1..0ab67595 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -19,99 +19,50 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import com.mojang.authlib.GameProfile; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage; -import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishingPage; -import io.github.moulberry.notenoughupdates.profileviewer.weight.lily.LilyWeight; -import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight; +import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage; import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; +import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTException; -import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Matrix4f; import net.minecraft.util.ResourceLocation; -import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; -import java.awt.*; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.NumberFormat; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.TimeZone; -import java.util.TreeMap; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt; - public class GuiProfileViewer extends GuiScreen { - public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png"); - public static final ResourceLocation pv_dung = new ResourceLocation("notenoughupdates:pv_dung.png"); - public static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png"); - public static final ResourceLocation pv_mining = new ResourceLocation("notenoughupdates:pv_mining.png"); - public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png"); - public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png"); public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png"); public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png"); public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); @@ -119,168 +70,100 @@ public class GuiProfileViewer extends GuiScreen { public static final ResourceLocation pv_bingo = new ResourceLocation("notenoughupdates:pv_bingo.png"); 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 = - new ResourceLocation("minecraft:textures/gui/resource_packs.png"); + public static final ResourceLocation resource_packs = new ResourceLocation("minecraft:textures/gui/resource_packs.png"); public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); - public static final HashMap> PET_STAT_BOOSTS = - new HashMap>() {{ - put("PET_ITEM_BIG_TEETH_COMMON", new HashMap() {{ - put("CRIT_CHANCE", 5f); - }}); - put("PET_ITEM_HARDENED_SCALES_UNCOMMON", new HashMap() {{ - put("DEFENCE", 25f); - }}); - put("PET_ITEM_LUCKY_CLOVER", new HashMap() {{ - put("MAGIC_FIND", 7f); - }}); - put("PET_ITEM_SHARPENED_CLAWS_UNCOMMON", new HashMap() {{ - put("CRIT_DAMAGE", 15f); - }}); - }}; - public static final HashMap> PET_STAT_BOOSTS_MULT = - new HashMap>() {{ - put("PET_ITEM_IRON_CLAWS_COMMON", new HashMap() {{ - put("CRIT_DAMAGE", 1.4f); - put("CRIT_CHANCE", 1.4f); - }}); - put("PET_ITEM_TEXTBOOK", new HashMap() {{ - put("INTELLIGENCE", 2f); - }}); - }}; - private static final ResourceLocation CHEST_GUI_TEXTURE = - new ResourceLocation("textures/gui/container/generic_54.png"); - private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); - private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush)); - private static final ItemStack iron_pick = new ItemStack(Items.iron_pickaxe); - private static final ItemStack[] BOSS_HEADS = new ItemStack[7]; - private static final String[] dungSkillsName = {"Healer", "Mage", "Berserk", "Archer", "Tank"}; - private static final ItemStack[] dungSkillsStack = { - new ItemStack(Items.potionitem, 1, 16389), - new ItemStack(Items.blaze_rod), - new ItemStack(Items.iron_sword), - new ItemStack(Items.bow), - new ItemStack(Items.leather_chestplate) + public static final HashMap> PET_STAT_BOOSTS = new HashMap>() { + { + put( + "PET_ITEM_BIG_TEETH_COMMON", + new HashMap() { + { + put("CRIT_CHANCE", 5f); + } + } + ); + put( + "PET_ITEM_HARDENED_SCALES_UNCOMMON", + new HashMap() { + { + put("DEFENCE", 25f); + } + } + ); + put( + "PET_ITEM_LUCKY_CLOVER", + new HashMap() { + { + put("MAGIC_FIND", 7f); + } + } + ); + put( + "PET_ITEM_SHARPENED_CLAWS_UNCOMMON", + new HashMap() { + { + put("CRIT_DAMAGE", 15f); + } + } + ); + } }; - private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"}; - private static final String[] bossFloorHeads = { - "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c", - "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d", - "9971cee8b833a62fc2a612f3503437fdf93cad692d216b8cf90bbb0538c47dd8", - "8b6a72138d69fbbd2fea3fa251cabd87152e4f1c97e5f986bf685571db3cc0", - "c1007c5b7114abec734206d4fc613da4f3a0e99f71ff949cedadc99079135a0b", - "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc", - "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a" + public static final HashMap> PET_STAT_BOOSTS_MULT = new HashMap>() { + { + put( + "PET_ITEM_IRON_CLAWS_COMMON", + new HashMap() { + { + put("CRIT_DAMAGE", 1.4f); + put("CRIT_CHANCE", 1.4f); + } + } + ); + put( + "PET_ITEM_TEXTBOOK", + new HashMap() { + { + put("INTELLIGENCE", 2f); + } + } + ); + } }; - private static final LinkedHashMap dungeonsModeIcons = new LinkedHashMap() {{ - put( - "catacombs", - Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DUNGEON_STONE")), EnumChatFormatting.GRAY + "Normal Mode", true) - ); - put( - "master_catacombs", - Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("MASTER_SKULL_TIER_7")), EnumChatFormatting.GRAY + "Master Mode", true) - ); - }}; - private static final LinkedHashMap invNameToDisplayMap = new LinkedHashMap() {{ - put( - "inv_contents", - Utils.createItemStack(Item.getItemFromBlock(Blocks.chest), EnumChatFormatting.GRAY + "Inventory") - ); - put( - "ender_chest_contents", - Utils.createItemStack(Item.getItemFromBlock(Blocks.ender_chest), EnumChatFormatting.GRAY + "Ender Chest") - ); - // put("backpack_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.dropper), EnumChatFormatting.GRAY+"Backpacks")); - put( - "backpack_contents", - Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("JUMBO_BACKPACK")), EnumChatFormatting.GRAY + "Backpacks", true) - ); - put( - "personal_vault_contents", - Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("IRON_CHEST")), EnumChatFormatting.GRAY + "Personal Vault", true) - ); - put("talisman_bag", Utils.createItemStack(Items.golden_apple, EnumChatFormatting.GRAY + "Accessory Bag")); - put("wardrobe_contents", Utils.createItemStack(Items.leather_chestplate, EnumChatFormatting.GRAY + "Wardrobe")); - put("fishing_bag", Utils.createItemStack(Items.fish, EnumChatFormatting.GRAY + "Fishing Bag")); - put("potion_bag", Utils.createItemStack(Items.potionitem, EnumChatFormatting.GRAY + "Potion Bag")); - }}; - private static final Pattern DAMAGE_PATTERN = Pattern.compile("^Damage: \\+([0-9]+)"); - private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: \\+([0-9]+)"); - private static final Pattern FISHSPEED_PATTERN = Pattern.compile("^Increases fishing speed by \\+([0-9]+)"); - private static final char[] c = new char[]{'k', 'm', 'b', 't'}; - private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1); + + public static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); + + private static final char[] c = new char[] { 'k', 'm', 'b', 't' }; public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC; - public static HashMap MINION_RARITY_TO_NUM = new HashMap() {{ - put("COMMON", "0"); - put("UNCOMMON", "1"); - put("RARE", "2"); - put("EPIC", "3"); - put("LEGENDARY", "4"); - put("MYTHIC", "5"); - }}; - private static int floorTime = 7; + public static HashMap MINION_RARITY_TO_NUM = new HashMap() { + { + put("COMMON", "0"); + put("UNCOMMON", "1"); + put("RARE", "2"); + put("EPIC", "3"); + put("LEGENDARY", "4"); + put("MYTHIC", "5"); + } + }; private static int guiLeft; private static int guiTop; private static ProfileViewer.Profile profile; - private final GuiElementTextField playerNameTextField; - private final HashMap levelObjCatas = new HashMap<>(); - private final HashMap levelObjhotms = new HashMap<>(); - private final HashMap> levelObjClasseses = new HashMap<>(); - private final GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); - - private final int COLLS_XCOUNT = 5; - private final int COLLS_YCOUNT = 4; - private final float COLLS_XPADDING = (190 - COLLS_XCOUNT * 20) / (float) (COLLS_XCOUNT + 1); - private final float COLLS_YPADDING = (202 - COLLS_YCOUNT * 20) / (float) (COLLS_YCOUNT + 1); - private final ItemStack fillerStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15); - private final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); - private final HashMap panoramasMap = new HashMap<>(); + private static String profileId = null; + public final GuiElementTextField playerNameTextField; + public final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); + private final Map pages = new HashMap<>(); + public int sizeX; + public int sizeY; + public float backgroundRotation = 0; + public long currentTime = 0; + public long lastTime = 0; + public long startTime = 0; + public List tooltipToDisplay = null; Shader blurShaderHorz = null; Framebuffer blurOutputHorz = null; Shader blurShaderVert = null; Framebuffer blurOutputVert = null; - private int sizeX; - private int sizeY; - private float backgroundRotation = 0; - private long currentTime = 0; - private long lastTime = 0; - private long startTime = 0; - private List tooltipToDisplay = null; - private static String profileId = null; private boolean profileDropdownSelected = false; - private int floorLevelTo = -1; - private long floorLevelToXP = -1; - private boolean onMasterMode = false; - private int selectedPet = -1; - private int petsPage = 0; - private List sortedPets = null; - private List sortedPetsStack = null; - private ItemStack[] bestWeapons = null; - private ItemStack[] bestRods = null; - private ItemStack[] armorItems = null; - private ItemStack[] equipmentItems = null; - private HashMap inventoryItems = new HashMap<>(); - private String selectedInventory = "inv_contents"; - private int currentInventoryIndex = 0; - private int arrowCount = -1; - private int greenCandyCount = -1; - private int purpleCandyCount = -1; - private EntityOtherPlayerMP entityPlayer = null; - private ResourceLocation playerLocationSkin = null; - private ResourceLocation playerLocationCape = null; - private String skinType = null; - private TreeMap> topKills = null; - private TreeMap> topDeaths = null; - private int backgroundClickedX = -1; - private boolean loadingProfile = false; + private double lastBgBlurFactor = -1; private boolean showBingoPage; @@ -291,15 +174,23 @@ public class GuiProfileViewer extends GuiScreen { if (profile.getHypixelProfile() != null) { name = profile.getHypixelProfile().get("displayname").getAsString(); } - playerNameTextField = new GuiElementTextField( - name, - GuiElementTextField.SCALE_TEXT - ); + playerNameTextField = new GuiElementTextField(name, GuiElementTextField.SCALE_TEXT); playerNameTextField.setSize(100, 20); if (currentPage == ProfileViewerPage.LOADING) { currentPage = ProfileViewerPage.BASIC; } + + pages.put(ProfileViewerPage.BASIC, new BasicPage(this)); + pages.put(ProfileViewerPage.DUNGEON, new DungeonPage(this)); + pages.put(ProfileViewerPage.EXTRA, new ExtraPage(this)); + pages.put(ProfileViewerPage.INVENTORIES, new InventoriesPage(this)); + pages.put(ProfileViewerPage.COLLECTIONS, new CollectionsPage(this)); + pages.put(ProfileViewerPage.PETS, new PetsPage(this)); + pages.put(ProfileViewerPage.MINING, new MiningPage(this)); + pages.put(ProfileViewerPage.BINGO, new BingoPage(this)); + pages.put(ProfileViewerPage.TROPHY_FISH, new TrophyFishPage(this)); + pages.put(ProfileViewerPage.BESTIARY, new BestiaryPage(this)); } private static JsonObject getPetInfo(String pet_name, String rarity) { @@ -310,8 +201,7 @@ public class GuiProfileViewer extends GuiScreen { return null; } - if (Constants.PETS.has("custom_pet_leveling") && - Constants.PETS.getAsJsonObject("custom_pet_leveling").has(pet_name)) { + if (Constants.PETS.has("custom_pet_leveling") && Constants.PETS.getAsJsonObject("custom_pet_leveling").has(pet_name)) { JsonObject pet = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(pet_name); if (pet.has("type") && pet.has("pet_levels")) { int type = pet.get("type").getAsInt(); @@ -342,7 +232,6 @@ public class GuiProfileViewer extends GuiScreen { } else { petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity)); } - } else { //System.out.println("Default Path"); petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity)); @@ -351,7 +240,6 @@ public class GuiProfileViewer extends GuiScreen { } return petInfo; - } public static PetLevel getPetLevel(String pet_name, String rarity, float exp) { @@ -381,9 +269,7 @@ public class GuiProfileViewer extends GuiScreen { level += 1; } } else { - xpTotal += levels.get(i).getAsFloat(); - } } @@ -414,56 +300,7 @@ public class GuiProfileViewer extends GuiScreen { double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) % 10 == 0; - return (d < 1000 ? - ((d > 99.9 || isRound || (!isRound && d > 9.99) ? - (int) d * 10 / 10 : d + "" - ) + "" + c[iteration]) - : shortNumberFormat(d, iteration + 1)); - } - - public static void drawEntityOnScreen( - int posX, - int posY, - int scale, - float mouseX, - float mouseY, - EntityLivingBase ent - ) { - GlStateManager.enableColorMaterial(); - GlStateManager.pushMatrix(); - GlStateManager.translate((float) posX, (float) posY, 50.0F); - GlStateManager.scale((float) (-scale), (float) scale, (float) scale); - GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); - float renderYawOffset = ent.renderYawOffset; - float f1 = ent.rotationYaw; - float f2 = ent.rotationPitch; - float f3 = ent.prevRotationYawHead; - float f4 = ent.rotationYawHead; - GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(25, 1.0F, 0.0F, 0.0F); - ent.renderYawOffset = (float) Math.atan(mouseX / 40.0F) * 20.0F; - ent.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F; - ent.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F; - ent.rotationYawHead = ent.rotationYaw; - ent.prevRotationYawHead = ent.rotationYaw; - RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); - rendermanager.setPlayerViewY(180.0F); - rendermanager.setRenderShadow(false); - rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - - ent.renderYawOffset = renderYawOffset; - ent.rotationYaw = f1; - ent.rotationPitch = f2; - ent.prevRotationYawHead = f3; - ent.rotationYawHead = f4; - GlStateManager.popMatrix(); - RenderHelper.disableStandardItemLighting(); - GlStateManager.disableRescaleNormal(); - GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GlStateManager.disableTexture2D(); - GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + c[iteration] : shortNumberFormat(d, iteration + 1); } public static int getGuiLeft() { @@ -490,7 +327,7 @@ public class GuiProfileViewer extends GuiScreen { ProfileViewerPage page = currentPage; if (profile == null) { page = ProfileViewerPage.INVALID_NAME; - } else if (profile.getPlayerInformation(null) == null) { + } else if (profile.getSkyblockProfiles(null) == null) { page = ProfileViewerPage.LOADING; } else if (profile.getLatestProfile() == null) { page = ProfileViewerPage.NO_SKYBLOCK; @@ -502,30 +339,26 @@ public class GuiProfileViewer extends GuiScreen { { //this is just to cache the guild info if (profile != null) { - profile.getGuildInfo(null); + profile.getGuildInformation(null); } } this.sizeX = 431; this.sizeY = 202; - this.guiLeft = (this.width - this.sizeX) / 2; - this.guiTop = (this.height - this.sizeY) / 2; + guiLeft = (this.width - this.sizeX) / 2; + guiTop = (this.height - this.sizeY) / 2; - boolean bingo = false; JsonObject currProfileInfo = profile != null ? profile.getProfileInformation(profileId) : null; if (NotEnoughUpdates.INSTANCE.config.profileViewer.alwaysShowBingoTab) { showBingoPage = true; } else { - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("bingo")) { - showBingoPage = true; - } else { - showBingoPage = false; - } + showBingoPage = + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("bingo"); } - if (!showBingoPage && currentPage == ProfileViewerPage.BINGO) - currentPage = ProfileViewerPage.BASIC; + if (!showBingoPage && currentPage == ProfileViewerPage.BINGO) currentPage = ProfileViewerPage.BASIC; super.drawScreen(mouseX, mouseY, partialTicks); drawDefaultBackground(); @@ -561,38 +394,54 @@ public class GuiProfileViewer extends GuiScreen { //Render Profile chooser button renderBlurredBackground(width, height, guiLeft + 2, guiTop + sizeY + 3 + 2, 100 - 4, 20 - 4); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); - Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 3, 100, 20, - 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST - ); - Utils.drawStringCenteredScaledMaxWidth(profileId, Minecraft.getMinecraft().fontRendererObj, guiLeft + 50, - guiTop + sizeY + 3 + 10, true, 90, new Color(63, 224, 208, 255).getRGB() + Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 3, 100, 20, 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST); + Utils.drawStringCenteredScaledMaxWidth( + profileId, + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 50, + guiTop + sizeY + 3 + 10, + true, + 90, + new Color(63, 224, 208, 255).getRGB() ); //ironman icon - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("ironman")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("ironman") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman); Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST); } //bingo! icon - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("bingo")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("bingo") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo); Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST); } //stranded icon - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("island")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("island") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded); Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST); } //icon if game mode is unknown - if (currProfileInfo != null && currProfileInfo.has("game_mode") && + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && !currProfileInfo.get("game_mode").getAsString().equals("island") && !currProfileInfo.get("game_mode").getAsString().equals("bingo") && - !currProfileInfo.get("game_mode").getAsString().equals("ironman")) { + !currProfileInfo.get("game_mode").getAsString().equals("ironman") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown); Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST); @@ -600,9 +449,7 @@ public class GuiProfileViewer extends GuiScreen { //Render Open In Skycrypt button renderBlurredBackground(width, height, guiLeft + 100 + 6 + 2, guiTop + sizeY + 3 + 2, 100 - 4, 20 - 4); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); - Utils.drawTexturedRect(guiLeft + 100 + 6, guiTop + sizeY + 3, 100, 20, - 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST - ); + Utils.drawTexturedRect(guiLeft + 100 + 6, guiTop + sizeY + 3, 100, 20, 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST); Utils.drawStringCenteredScaledMaxWidth( "Open in Skycrypt", Minecraft.getMinecraft().fontRendererObj, @@ -613,25 +460,39 @@ public class GuiProfileViewer extends GuiScreen { new Color(63, 224, 208, 255).getRGB() ); - if (profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) { + if (profileDropdownSelected && !profile.getProfileNames().isEmpty() && scaledResolution.getScaleFactor() != 4) { int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20; - int numProfiles = profile.getProfileIds().size(); + int numProfiles = profile.getProfileNames().size(); int sizeYDropdown = numProfiles * dropdownOptionSize; renderBlurredBackground(width, height, guiLeft + 2, guiTop + sizeY + 23, 100 - 4, sizeYDropdown - 2); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); - Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 - 3, 100, 3, - 100 / 200f, 1, 0, 3 / 185f, GL11.GL_NEAREST + Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 - 3, 100, 3, 100 / 200f, 1, 0, 3 / 185f, GL11.GL_NEAREST); + Utils.drawTexturedRect( + guiLeft, + guiTop + sizeY + 23 + sizeYDropdown - 4, + 100, + 4, + 100 / 200f, + 1, + 181 / 185f, + 1, + GL11.GL_NEAREST ); - Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 + sizeYDropdown - 4, 100, 4, - 100 / 200f, 1, 181 / 185f, 1, GL11.GL_NEAREST - ); - Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23, 100, sizeYDropdown - 4, - 100 / 200f, 1, (181 - sizeYDropdown) / 185f, 181 / 185f, GL11.GL_NEAREST + Utils.drawTexturedRect( + guiLeft, + guiTop + sizeY + 23, + 100, + sizeYDropdown - 4, + 100 / 200f, + 1, + (181 - sizeYDropdown) / 185f, + 181 / 185f, + GL11.GL_NEAREST ); - for (int yIndex = 0; yIndex < profile.getProfileIds().size(); yIndex++) { - String otherProfileId = profile.getProfileIds().get(yIndex); + for (int yIndex = 0; yIndex < profile.getProfileNames().size(); yIndex++) { + String otherProfileId = profile.getProfileNames().get(yIndex); Utils.drawStringCenteredScaledMaxWidth( otherProfileId, Minecraft.getMinecraft().fontRendererObj, @@ -642,8 +503,11 @@ public class GuiProfileViewer extends GuiScreen { new Color(33, 112, 104, 255).getRGB() ); currProfileInfo = profile.getProfileInformation(otherProfileId); - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("ironman")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("ironman") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman); Utils.drawTexturedRect( @@ -654,8 +518,11 @@ public class GuiProfileViewer extends GuiScreen { GL11.GL_NEAREST ); } - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("bingo")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("bingo") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo); Utils.drawTexturedRect( @@ -666,8 +533,11 @@ public class GuiProfileViewer extends GuiScreen { GL11.GL_NEAREST ); } - if (currProfileInfo != null && currProfileInfo.has("game_mode") && - currProfileInfo.get("game_mode").getAsString().equals("island")) { + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && + currProfileInfo.get("game_mode").getAsString().equals("island") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded); Utils.drawTexturedRect( @@ -678,10 +548,13 @@ public class GuiProfileViewer extends GuiScreen { GL11.GL_NEAREST ); } - if (currProfileInfo != null && currProfileInfo.has("game_mode") && + if ( + currProfileInfo != null && + currProfileInfo.has("game_mode") && !currProfileInfo.get("game_mode").getAsString().equals("island") && !currProfileInfo.get("game_mode").getAsString().equals("bingo") && - !currProfileInfo.get("game_mode").getAsString().equals("ironman")) { + !currProfileInfo.get("game_mode").getAsString().equals("ironman") + ) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown); Utils.drawTexturedRect( @@ -693,172 +566,149 @@ public class GuiProfileViewer extends GuiScreen { ); } } - } } } GlStateManager.color(1, 1, 1, 1); - switch (page) { - case BASIC: - drawBasicPage(mouseX, mouseY, partialTicks); - break; - case DUNGEON: - drawDungPage(mouseX, mouseY, partialTicks); - break; - case EXTRA: - drawExtraPage(mouseX, mouseY, partialTicks); - break; - case INVENTORIES: - drawInvsPage(mouseX, mouseY); - break; - case COLLECTIONS: - CollectionPage.drawColsPage(mouseX, mouseY, width, height); - break; - case PETS: - drawPetsPage(mouseX, mouseY, partialTicks); - break; - case MINING: - drawMiningPage(mouseX, mouseY, partialTicks); - break; - case BINGO: - BingoPage.renderPage(mouseX, mouseY); - break; - case TROPHY_FISH: - TrophyFishingPage.renderPage(mouseX, mouseY); - break; - case BESTIARY: - BestiaryPage.renderPage(mouseX, mouseY); - break; - case LOADING: - String str = EnumChatFormatting.YELLOW + "Loading player profiles."; - long currentTimeMod = System.currentTimeMillis() % 1000; - if (currentTimeMod > 333) { - if (currentTimeMod < 666) { - str += "."; - } else { - str += ".."; + + if (pages.containsKey(page)) { + pages.get(page).drawPage(mouseX, mouseY, partialTicks); + } else { + switch (page) { + case LOADING: + String str = EnumChatFormatting.YELLOW + "Loading player profiles."; + long currentTimeMod = System.currentTimeMillis() % 1000; + if (currentTimeMod > 333) { + if (currentTimeMod < 666) { + str += "."; + } else { + str += ".."; + } } - } - Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, guiTop + 101, true, 0 - ); + Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, guiTop + 101, true, 0); - //This is just here to inform the player what to do - //like typing /api new or telling them to go find a psychotherapist - long timeDiff = System.currentTimeMillis() - startTime; + //This is just here to inform the player what to do + //like typing /api new or telling them to go find a psychotherapist + long timeDiff = System.currentTimeMillis() - startTime; - if (timeDiff > 20000) { - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Its taking a while...", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 111, - true, - 0 - ); - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Try \"/api new\".", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 121, - true, - 0 - ); - if (timeDiff > 60000) { + if (timeDiff > 20000) { + Utils.drawStringCentered( + EnumChatFormatting.YELLOW + "Its taking a while...", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + sizeX / 2f, + guiTop + 111, + true, + 0 + ); Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Might be hypixel's fault.", + EnumChatFormatting.YELLOW + "Try \"/api new\".", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 131, + guiTop + 121, true, 0 ); - if (timeDiff > 180000) { + if (timeDiff > 60000) { Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Wow you're still here?", + EnumChatFormatting.YELLOW + "Might be hypixel's fault.", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 141, + guiTop + 131, true, 0 ); - if (timeDiff > 360000) { - long second = (timeDiff / 1000) % 60; - long minute = (timeDiff / (1000 * 60)) % 60; - long hour = (timeDiff / (1000 * 60 * 60)) % 24; - - String time = String.format("%02d:%02d:%02d", hour, minute, second); - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "You've wasted your time here for: " + time, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 151, - true, - 0 - ); + if (timeDiff > 180000) { Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "What are you doing with your life?", + EnumChatFormatting.YELLOW + "Wow you're still here?", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 161, + guiTop + 141, true, 0 ); - if (timeDiff > 600000) { + if (timeDiff > 360000) { + long second = (timeDiff / 1000) % 60; + long minute = (timeDiff / (1000 * 60)) % 60; + long hour = (timeDiff / (1000 * 60 * 60)) % 24; + + String time = String.format("%02d:%02d:%02d", hour, minute, second); + Utils.drawStringCentered( + EnumChatFormatting.YELLOW + "You've wasted your time here for: " + time, + Minecraft.getMinecraft().fontRendererObj, + guiLeft + sizeX / 2f, + guiTop + 151, + true, + 0 + ); Utils.drawStringCentered( - EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "Maniac", + EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "What are you doing with your life?", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 171, + guiTop + 161, true, 0 ); - if (timeDiff > 1200000) { + if (timeDiff > 600000) { Utils.drawStringCentered( - EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You're a menace to society", + EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "Maniac", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 181, + guiTop + 171, true, 0 ); - if (timeDiff > 1800000) { + if (timeDiff > 1200000) { Utils.drawStringCentered( - EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + - "You don't know what's gonna happen to you", + EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You're a menace to society", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 191, + guiTop + 181, true, 0 ); - if (timeDiff > 3000000) { + if (timeDiff > 1800000) { Utils.drawStringCentered( - EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You really want this?", + EnumChatFormatting.RED + + "" + + EnumChatFormatting.BOLD + + "You don't know what's gonna happen to you", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 91, + guiTop + 191, true, 0 ); - if (timeDiff > 3300000) { + if (timeDiff > 3000000) { Utils.drawStringCentered( - EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.BOLD + "OW LORD FORGIVE ME FOR THIS", + EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You really want this?", Minecraft.getMinecraft().fontRendererObj, guiLeft + sizeX / 2f, - guiTop + 71, + guiTop + 91, true, 0 ); - if (timeDiff > 3600000) { - throw new Error("Go do something productive") { - @Override - public void printStackTrace() { - throw new Error("Go do something productive"); - } - }; + if (timeDiff > 3300000) { + Utils.drawStringCentered( + EnumChatFormatting.DARK_RED + + "" + + EnumChatFormatting.BOLD + + "OW LORD FORGIVE ME FOR THIS", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + sizeX / 2f, + guiTop + 71, + true, + 0 + ); + if (timeDiff > 3600000) { + throw new Error("Go do something productive") { + @Override + public void printStackTrace() { + throw new Error("Go do something productive"); + } + }; + } } } } @@ -868,29 +718,29 @@ public class GuiProfileViewer extends GuiScreen { } } } - } - break; - case INVALID_NAME: - Utils.drawStringCentered( - EnumChatFormatting.RED + "Invalid name or API is down!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 101, - true, - 0 - ); - break; - case NO_SKYBLOCK: - Utils.drawStringCentered( - EnumChatFormatting.RED + "No skyblock data found!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 101, - true, - 0 - ); - break; + break; + case INVALID_NAME: + Utils.drawStringCentered( + EnumChatFormatting.RED + "Invalid name or API is down!", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + sizeX / 2f, + guiTop + 101, + true, + 0 + ); + break; + case NO_SKYBLOCK: + Utils.drawStringCentered( + EnumChatFormatting.RED + "No skyblock data found!", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + sizeX / 2f, + guiTop + 101, + true, + 0 + ); + break; + } } lastTime = currentTime; @@ -990,38 +840,13 @@ public class GuiProfileViewer extends GuiScreen { } } } - switch (currentPage) { - case DUNGEON: - mouseClickedDung(mouseX, mouseY, mouseButton); - break; - case INVENTORIES: - inventoryTextField.setSize(88, 20); - if (mouseX > guiLeft + 19 && mouseX < guiLeft + 19 + 88) { - if (mouseY > guiTop + sizeY - 26 - 20 && mouseY < guiTop + sizeY - 26) { - inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton); - playerNameTextField.otherComponentClick(); - return; - } - } - break; - case PETS: - if (sortedPets == null) break; - for (int i = petsPage * 20; i < Math.min(petsPage * 20 + 20, sortedPets.size()); i++) { - int xIndex = (i % 20) % COLLS_XCOUNT; - int yIndex = (i % 20) / COLLS_XCOUNT; - float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex; - float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex; - - if (mouseX > guiLeft + x && mouseX < guiLeft + x + 20) { - if (mouseY > guiTop + y && mouseY < guiTop + y + 20) { - selectedPet = i; - return; - } - } - } - break; + if (pages.containsKey(currentPage)) { + if (pages.get(currentPage).mouseClicked(mouseX, mouseY, mouseButton)) { + return; + } } + if (mouseX > guiLeft + sizeX - 100 && mouseX < guiLeft + sizeX) { if (mouseY > guiTop + sizeY + 5 && mouseY < guiTop + sizeY + 25) { playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton); @@ -1029,14 +854,21 @@ public class GuiProfileViewer extends GuiScreen { return; } } - if (mouseX > guiLeft + 106 && mouseX < guiLeft + 106 + 100 && profile != null && - !profile.getProfileIds().isEmpty() && profileId != null) { + if ( + mouseX > guiLeft + 106 && + mouseX < guiLeft + 106 + 100 && + profile != null && + !profile.getProfileNames().isEmpty() && + profileId != null + ) { if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) { try { Desktop desk = Desktop.getDesktop(); - desk.browse(new URI( - "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" + - profileId)); + desk.browse( + new URI( + "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" + profileId + ) + ); Utils.playPressSound(); return; } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) { @@ -1047,14 +879,14 @@ public class GuiProfileViewer extends GuiScreen { } } - if (mouseX > guiLeft && mouseX < guiLeft + 100 && profile != null && !profile.getProfileIds().isEmpty()) { + if (mouseX > guiLeft && mouseX < guiLeft + 100 && profile != null && !profile.getProfileNames().isEmpty()) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) { if (scaledResolution.getScaleFactor() == 4) { profileDropdownSelected = false; int profileNum = 0; - for (int index = 0; index < profile.getProfileIds().size(); index++) { - if (profile.getProfileIds().get(index).equals(profileId)) { + for (int index = 0; index < profile.getProfileNames().size(); index++) { + if (profile.getProfileNames().get(index).equals(profileId)) { profileNum = index; break; } @@ -1064,10 +896,10 @@ public class GuiProfileViewer extends GuiScreen { } else { profileNum--; } - if (profileNum >= profile.getProfileIds().size()) profileNum = 0; - if (profileNum < 0) profileNum = profile.getProfileIds().size() - 1; + if (profileNum >= profile.getProfileNames().size()) profileNum = 0; + if (profileNum < 0) profileNum = profile.getProfileNames().size() - 1; - String newProfileId = profile.getProfileIds().get(profileNum); + String newProfileId = profile.getProfileNames().get(profileNum); if (profileId != null && !profileId.equals(newProfileId)) { resetCache(); } @@ -1079,8 +911,8 @@ public class GuiProfileViewer extends GuiScreen { int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20; int extraY = mouseY - (guiTop + sizeY + 23); int index = extraY / dropdownOptionSize; - if (index >= 0 && index < profile.getProfileIds().size()) { - String newProfileId = profile.getProfileIds().get(index); + if (index >= 0 && index < profile.getProfileNames().size()) { + String newProfileId = profile.getProfileNames().get(index); if (profileId != null && !profileId.equals(newProfileId)) { resetCache(); } @@ -1099,25 +931,21 @@ public class GuiProfileViewer extends GuiScreen { @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); - switch (currentPage) { - case INVENTORIES: - keyTypedInvs(typedChar, keyCode); - inventoryTextField.keyTyped(typedChar, keyCode); - break; - case COLLECTIONS: - CollectionPage.keyTypedCols(typedChar, keyCode); - break; - case DUNGEON: - keyTypedDung(typedChar, keyCode); - break; + + if (pages.containsKey(currentPage)) { + pages.get(currentPage).keyTyped(typedChar, keyCode); } + if (playerNameTextField.getFocus()) { if (keyCode == Keyboard.KEY_RETURN) { currentPage = ProfileViewerPage.LOADING; - NotEnoughUpdates.profileViewer.getProfileByName(playerNameTextField.getText(), profile -> { //todo: invalid name - if (profile != null) profile.resetCache(); - Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile)); - }); + NotEnoughUpdates.profileViewer.getProfileByName( + playerNameTextField.getText(), + profile -> { //todo: invalid name + if (profile != null) profile.resetCache(); + Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile)); + } + ); } playerNameTextField.keyTyped(typedChar, keyCode); } @@ -1127,3927 +955,113 @@ public class GuiProfileViewer extends GuiScreen { protected void mouseReleased(int mouseX, int mouseY, int mouseButton) { super.mouseReleased(mouseX, mouseY, mouseButton); - switch (currentPage) { - case INVENTORIES: - mouseReleasedInvs(mouseX, mouseY, mouseButton); - break; - case COLLECTIONS: - CollectionPage.mouseReleasedCols(mouseX, mouseY, mouseButton); - break; - case PETS: - mouseReleasedPets(mouseX, mouseY, mouseButton); - break; - case BESTIARY: - BestiaryPage.mouseReleased(mouseX, mouseY, mouseButton); + if (pages.containsKey(currentPage)) { + pages.get(currentPage).mouseReleased(mouseX, mouseY, mouseButton); } } - protected void mouseClickedDung(int mouseX, int mouseY, int mouseButton) { - if (mouseX >= guiLeft + 50 && mouseX <= guiLeft + 70 && - mouseY >= guiTop + 54 && mouseY <= guiTop + 64) { - dungeonLevelTextField.mouseClicked(mouseX, mouseY, mouseButton); - } else { - dungeonLevelTextField.otherComponentClick(); - } - - int cW = fontRendererObj.getStringWidth("Calculate"); - if (mouseX >= guiLeft + 23 + 110 - 17 - cW && mouseX <= guiLeft + 23 + 110 - 17 && - mouseY >= guiTop + 55 && mouseY <= guiTop + 65) { - calculateFloorLevelXP(); - } - - int y = guiTop + 142; - - if (mouseY >= y - 2 && mouseY <= y + 9) { - for (int i = 1; i <= 7; i++) { - int w = fontRendererObj.getStringWidth("" + i); + public void renderXpBar( + String skillName, + ItemStack stack, + int x, + int y, + int xSize, + ProfileViewer.Level levelObj, + int mouseX, + int mouseY + ) { + float level = levelObj.level; + int levelFloored = (int) Math.floor(level); - int x = guiLeft + 23 + 110 * i / 8 - w / 2; + Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, xSize - 20); - if (mouseX >= x - 2 && mouseX <= x + 7) { - floorTime = i; - return; - } + if (levelObj.maxed) { + renderGoldBar(x, y + 6, xSize); + } else { + if (skillName.contains("Catacombs") && levelObj.level >= 50) { + renderGoldBar(x, y + 6, xSize); + } else { + renderBar(x, y + 6, xSize, level % 1); } } - if (mouseX >= guiLeft - 29 && mouseX <= guiLeft) { - if (mouseY >= guiTop && mouseY <= guiTop + 28) { - onMasterMode = false; - } else if (mouseY + 28 >= guiTop && mouseY <= guiTop + 28 * 2) { - onMasterMode = true; + + if (mouseX > x && mouseX < x + 120) { + 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 (levelObj.maxed) { + levelStr = EnumChatFormatting.GOLD + "MAXED!"; + } else { + int maxXp = (int) levelObj.maxXpForLevel; + levelStr = + EnumChatFormatting.DARK_PURPLE + + shortNumberFormat(Math.round((level % 1) * maxXp), 0) + + "/" + + shortNumberFormat(maxXp, 0); + } + if (totalXpStr != null) { + tooltipToDisplay = Utils.createList(levelStr, totalXpStr); + } else { + tooltipToDisplay = Utils.createList(levelStr); + } } } - } - protected void keyTypedDung(char typedChar, int keyCode) { - dungeonLevelTextField.keyTyped(typedChar, keyCode); + NBTTagCompound nbt = new NBTTagCompound(); //Adding NBT Data for Custom Resource Packs + NBTTagCompound display = new NBTTagCompound(); + display.setString("Name", skillName); + nbt.setTag("display", display); + stack.setTagCompound(nbt); + + GL11.glTranslatef((x), (y - 6f), 0); + GL11.glScalef(0.7f, 0.7f, 1); + Utils.drawItemStackLinear(stack, 0, 0); + GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1); + GL11.glTranslatef(-(x), -(y - 6f), 0); } - protected void keyTypedInvs(char typedChar, int keyCode) throws IOException { - switch (keyCode) { - case Keyboard.KEY_1: - case Keyboard.KEY_NUMPAD1: - selectedInventory = "inv_contents"; - break; - case Keyboard.KEY_2: - case Keyboard.KEY_NUMPAD2: - selectedInventory = "ender_chest_contents"; - break; - case Keyboard.KEY_3: - case Keyboard.KEY_NUMPAD3: - selectedInventory = "backpack_contents"; - break; - case Keyboard.KEY_4: - case Keyboard.KEY_NUMPAD4: - selectedInventory = "personal_vault_contents"; - break; - case Keyboard.KEY_5: - case Keyboard.KEY_NUMPAD5: - selectedInventory = "talisman_bag"; - break; - case Keyboard.KEY_6: - case Keyboard.KEY_NUMPAD6: - selectedInventory = "wardrobe_contents"; - break; - case Keyboard.KEY_7: - case Keyboard.KEY_NUMPAD7: - selectedInventory = "fishing_bag"; - break; - case Keyboard.KEY_8: - case Keyboard.KEY_NUMPAD8: - selectedInventory = "potion_bag"; - break; - default: - return; + public EntityOtherPlayerMP getEntityPlayer() { + return ((BasicPage) pages.get(ProfileViewerPage.BASIC)).entityPlayer; + } + public void renderGoldBar(float x, float y, float xSize) { + if (!OpenGlHelper.areShadersSupported()) { + renderBar(x, y, xSize, 1); + return; } - Utils.playPressSound(); - } + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); + ShaderManager shaderManager = ShaderManager.getInstance(); + shaderManager.loadShader("make_gold"); + shaderManager.loadData("make_gold", "amount", (startTime - System.currentTimeMillis()) / 10000f); + Utils.drawTexturedRect(x, y, xSize / 2f, 5, 0 / 256f, (xSize / 2f) / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST); + Utils.drawTexturedRect( + x + xSize / 2f, + y, + xSize / 2f, + 5, + (182 - xSize / 2f) / 256f, + 182 / 256f, + 79 / 256f, + 84 / 256f, + GL11.GL_NEAREST + ); - private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) { - if (mouseY > guiTop + 6 && mouseY < guiTop + 22) { - if (mouseX > guiLeft + 100 - 15 - 12 && mouseX < guiLeft + 100 - 20) { - if (petsPage > 0) { - petsPage--; - } - return; - } else if (mouseX > guiLeft + 100 + 15 && mouseX < guiLeft + 100 + 20 + 12) { - if (sortedPets != null && petsPage < Math.ceil(sortedPets.size() / 20f) - 1) { - petsPage++; - } - return; - } - } + GL20.glUseProgram(0); } - private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0) { - int i = 0; - for (Map.Entry entry : invNameToDisplayMap.entrySet()) { - int xIndex = i % 3; - int yIndex = i / 3; - - int x = guiLeft + 19 + 34 * xIndex; - int y = guiTop + 26 + 34 * yIndex; + public void renderBar(float x, float y, float xSize, float completed) { + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); - if (mouseX >= x && mouseX <= x + 16) { - if (mouseY >= y && mouseY <= y + 16) { - if (selectedInventory != entry.getKey()) Utils.playPressSound(); - selectedInventory = entry.getKey(); - return; - } - } + completed = Math.round(completed / 0.05f) * 0.05f; + float notCompleted = 1 - completed; + GlStateManager.color(1, 1, 1, 1); + float width; - i++; - } - - JsonObject inventoryInfo = profile.getInventoryInfo(profileId); - if (inventoryInfo == null) return; - - ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory); - if (currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length - 1; - if (currentInventoryIndex < 0) currentInventoryIndex = 0; - - ItemStack[][] inventory = inventories[currentInventoryIndex]; - if (inventory == null) return; - - int inventoryRows = inventory.length; - int invSizeY = inventoryRows * 18 + 17 + 7; - - int y = guiTop + 101 - invSizeY / 2; - int staticSelectorHeight = guiTop + 177; - - if (mouseY > staticSelectorHeight && mouseY < staticSelectorHeight + 16) { - if (mouseX > guiLeft + 320 - 12 && mouseX < guiLeft + 320 + 12) { - if (mouseX < guiLeft + 320) { - currentInventoryIndex--; - } else { - currentInventoryIndex++; - } - } - } - } - } - - - private void calculateFloorLevelXP() { - JsonObject leveling = Constants.LEVELING; - if (leveling == null) return; - ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId); - if (levelObjCata == null) return; - - try { - dungeonLevelTextField.setCustomBorderColour(0xffffffff); - floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText()); - - JsonArray levelingArray = Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(); - - float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel); - - for (int level = 0; level < Math.min(floorLevelTo, levelingArray.size()); level++) { - if (level < Math.floor(levelObjCata.level)) { - continue; - } - remaining += levelingArray.get(level).getAsFloat(); - } - - if (remaining < 0) { - remaining = 0; - } - floorLevelToXP = (long) remaining; - } catch (Exception e) { - dungeonLevelTextField.setCustomBorderColour(0xffff0000); - } - } - - private void drawDungPage(int mouseX, int mouseY, float partialTicks) { - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dung); - Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - - JsonObject hypixelInfo = profile.getHypixelProfile(); - if (hypixelInfo == null) return; - JsonObject profileInfo = profile.getProfileInformation(profileId); - if (profileInfo == null) return; - - JsonObject leveling = Constants.LEVELING; - if (leveling == null) return; - - int sectionWidth = 110; - - String dungeonString = onMasterMode ? "master_catacombs" : "catacombs"; - - //Utils.drawStringCentered((onMasterMode?"Master Mode":"Catacombs"),fontRendererObj,(guiLeft+sizeX/2), guiTop+10, true, 0xffff0000); - Utils.renderShadowedString(EnumChatFormatting.RED + (onMasterMode ? "Master Mode" : "Catacombs"), - (guiLeft + sizeX / 2), guiTop + 5, sectionWidth - ); - - ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId); - //Catacombs level thingy - { - if (levelObjCata == null) { - float cataXp = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.experience" - ), 0); - levelObjCata = ProfileViewer.getLevel(Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(), - cataXp, 99, false - ); - levelObjCata.totalXp = cataXp; - levelObjCatas.put(profileId, levelObjCata); - } - - String skillName = EnumChatFormatting.RED + "Catacombs"; - float level = levelObjCata.level; - int levelFloored = (int) Math.floor(level); - - if (floorLevelTo == -1 && levelFloored >= 0) { - dungeonLevelTextField.setText("" + (levelFloored + 1)); - calculateFloorLevelXP(); - } - - int x = guiLeft + 23; - int y = guiTop + 25; - - renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelObjCata, mouseX, mouseY); - - Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Until Cata " + floorLevelTo + ": ", - EnumChatFormatting.WHITE + shortNumberFormat(floorLevelToXP, 0), x, y + 16, sectionWidth - ); - - if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && !onMasterMode) { - float F5 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.tier_completions." + 5 - ), 0)); //this can prob be done better - float F6 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.tier_completions." + 6 - ), 0)); - float F7 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.tier_completions." + 7 - ), 0)); - if (F5 > 150) { - F5 = 150; - } - if (F6 > 100) { - F6 = 100; - } - if (F7 > 50) { - F7 = 50; - } - float xpF5 = 2000 * (F5 / 100 + 1); - float xpF6 = 4000 * (F6 / 100 + 1); - float xpF7 = 20000 * (F7 / 100 + 1); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - xpF5 *= 1.1; - xpF6 *= 1.1; - xpF7 *= 1.1; - } - - long runsF5 = (int) Math.ceil(floorLevelToXP / xpF5); - long runsF6 = (int) Math.ceil(floorLevelToXP / xpF6); - long runsF7 = (int) Math.ceil(floorLevelToXP / xpF7); - - float timeF5 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.fastest_time_s_plus.5" - ), 0); - float timeF6 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.fastest_time_s_plus.6" - ), 0); - float timeF7 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.catacombs.fastest_time_s_plus.7" - ), 0); - - tooltipToDisplay = Lists.newArrayList( - String.format("# F5 Runs (%s xp) : %d", shortNumberFormat(xpF5, 0), runsF5), - String.format("# F6 Runs (%s xp) : %d", shortNumberFormat(xpF6, 0), runsF6), - String.format("# F7 Runs (%s xp) : %d", shortNumberFormat(xpF7, 0), runsF7), - "" - ); - boolean hasTime = false; - if (timeF5 > 1000) { - tooltipToDisplay.add(String.format( - "Expected Time (F5) : %s", - Utils.prettyTime(runsF5 * (long) (timeF5 * 1.2)) - )); - hasTime = true; - } - if (timeF6 > 1000) { - tooltipToDisplay.add(String.format( - "Expected Time (F6) : %s", - Utils.prettyTime(runsF6 * (long) (timeF6 * 1.2)) - )); - hasTime = true; - } - if (timeF7 > 1000) { - tooltipToDisplay.add(String.format( - "Expected Time (F7) : %s", - Utils.prettyTime(runsF7 * (long) (timeF7 * 1.2)) - )); - hasTime = true; - } - if (hasTime) { - tooltipToDisplay.add(""); - } - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - tooltipToDisplay.add( - "[Hold " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY + " to show without Expert Ring]"); - } - if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) tooltipToDisplay.add(""); - tooltipToDisplay.add("Number of runs is calculated as [Remaining XP]/[XP per Run]."); - tooltipToDisplay.add("The [XP per Run] is the average xp gained from an S+ run"); - tooltipToDisplay.add( - "The " + EnumChatFormatting.DARK_PURPLE + "Catacombs Expert Ring" + EnumChatFormatting.GRAY + - " is assumed to be used, unless " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY + - " is held."); - tooltipToDisplay.add("[Time per run] is calculated using Fastest S+ x 120%"); - } else { - tooltipToDisplay.add( - "[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]"); - } - } - - if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && onMasterMode) { - float M3 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.tier_completions." + 3 - ), 0)); - float M4 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.tier_completions." + 4 - ), 0)); - float M5 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.tier_completions." + 5 - ), 0)); //this can prob be done better - float M6 = (Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.tier_completions." + 6 - ), 0)); - if (M3 > 50) { - M3 = 50; - } - if (M4 > 50) { - M4 = 50; - } - if (M5 > 50) { - M5 = 50; - } - if (M6 > 50) { - M6 = 50; - } - float xpM3 = 36500 * (M3 / 100 + 1); - float xpM4 = 48500 * (M4 / 100 + 1); - float xpM5 = 70000 * (M5 / 100 + 1); - float xpM6 = 100000 * (M6 / 100 + 1); - //No clue if M3 or M4 xp values are right - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - xpM3 *= 1.1; - xpM4 *= 1.1; - xpM5 *= 1.1; - xpM6 *= 1.1; - } - - long runsM3 = (int) Math.ceil(floorLevelToXP / xpM3); - long runsM4 = (int) Math.ceil(floorLevelToXP / xpM4); - long runsM5 = (int) Math.ceil(floorLevelToXP / xpM5); - long runsM6 = (int) Math.ceil(floorLevelToXP / xpM6); - - float timeM3 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.3" - ), 0); - float timeM4 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.4" - ), 0); - float timeM5 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.5" - ), 0); - float timeM6 = Utils.getElementAsFloat(Utils.getElement( - profileInfo, - "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.6" - ), 0); - - tooltipToDisplay = Lists.newArrayList( - String.format("#