aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
diff options
context:
space:
mode:
authorMoulberry <jjenour@student.unimelb.edu.au>2022-03-03 11:03:58 +0800
committerGitHub <noreply@github.com>2022-03-03 11:03:58 +0800
commit7c6d37b2eb758a13b342b906f0aef88b940bc52a (patch)
tree9602a014425b859e3aba98f31f93d6de04521356 /src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
parentdb59eba3fd9121c7c0a88363994876c5b582c08c (diff)
downloadnotenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.tar.gz
notenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.tar.bz2
notenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.zip
Merge pull request #248 from NotEnoughUpdates/master
NEU 2.1 🙂
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java8310
1 files changed, 5027 insertions, 3283 deletions
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 bf305b51..44ea686d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -7,7 +7,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
@@ -24,7 +23,6 @@ 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.resources.SkinManager;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.client.shader.Shader;
import net.minecraft.entity.EntityLivingBase;
@@ -58,3151 +56,4892 @@ import java.util.*;
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;
public class GuiProfileViewer extends GuiScreen {
-
- private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
- 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_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
- public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.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");
- public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.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");
-
- private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
-
- private final ProfileViewer.Profile profile;
- public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
- private int sizeX;
- private int sizeY;
- private int guiLeft;
- private int guiTop;
-
- private float backgroundRotation = 0;
-
- private long currentTime = 0;
- private long lastTime = 0;
- private long startTime = 0;
-
- private List<String> tooltipToDisplay = null;
-
- private String profileId = null;
- private boolean profileDropdownSelected = false;
-
- public enum ProfileViewerPage {
- LOADING(null),
- INVALID_NAME(null),
- NO_SKYBLOCK(null),
- BASIC(new ItemStack(Items.paper)),
- DUNG(new ItemStack(Item.getItemFromBlock(Blocks.deadbush))),
- EXTRA(new ItemStack(Items.book)),
- INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))),
- COLS(new ItemStack(Items.painting)),
- PETS(new ItemStack(Items.bone));
-
- public final ItemStack stack;
-
- ProfileViewerPage(ItemStack stack) {
- this.stack = stack;
- }
- }
-
- public GuiProfileViewer(ProfileViewer.Profile profile) {
- this.profile = profile;
- String name = "";
- if(profile != null && profile.getHypixelProfile() != null) {
- name = profile.getHypixelProfile().get("displayname").getAsString();
- }
- playerNameTextField = new GuiElementTextField(name,
- GuiElementTextField.SCALE_TEXT);
- playerNameTextField.setSize(100, 20);
-
- if(currentPage == ProfileViewerPage.LOADING) {
- currentPage = ProfileViewerPage.BASIC;
- }
- }
-
- private GuiElementTextField playerNameTextField;
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- currentTime = System.currentTimeMillis();
- if(startTime == 0) startTime = currentTime;
-
- ProfileViewerPage page = currentPage;
- if(profile == null) {
- page = ProfileViewerPage.INVALID_NAME;
- } else if(profile.getPlayerInformation(null) == null) {
- page = ProfileViewerPage.LOADING;
- } else if(profile.getLatestProfile() == null) {
- page = ProfileViewerPage.NO_SKYBLOCK;
- }
-
- if(profileId == null && profile != null && profile.getLatestProfile() != null) {
- profileId = profile.getLatestProfile();
- }
- {
- //this is just to cache the guild info
- if(profile != null) {
- JsonObject guildinfo = profile.getGuildInfo(null);
- }
- }
-
- this.sizeX = 431;
- this.sizeY = 202;
- this.guiLeft = (this.width-this.sizeX)/2;
- this.guiTop = (this.height-this.sizeY)/2;
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- drawDefaultBackground();
-
- blurBackground();
- renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4);
-
- GlStateManager.enableDepth();
- GlStateManager.translate(0, 0, 5);
- renderTabs(true);
- GlStateManager.translate(0, 0, -3);
-
- GlStateManager.disableDepth();
- GlStateManager.translate(0, 0, -2);
- renderTabs(false);
- GlStateManager.translate(0, 0, 2);
-
- GlStateManager.disableLighting();
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- if(!(page == ProfileViewerPage.LOADING)) {
- playerNameTextField.render(guiLeft+sizeX-100, guiTop+sizeY+5);
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- if(profile != null) {
- JsonObject currProfileInfo = profile.getProfileInformation(profileId);
- //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());
- 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);
- }
- //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.drawStringCenteredScaledMaxWidth("Open in Skycrypt", Minecraft.getMinecraft().fontRendererObj, guiLeft+50+100+6,
- guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB());
-
-
-
-
- if(profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) {
- int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20;
-
- int numProfiles = profile.getProfileIds().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+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);
-
- for(int yIndex = 0; yIndex<profile.getProfileIds().size(); yIndex++) {
- String otherProfileId = profile.getProfileIds().get(yIndex);
- Utils.drawStringCenteredScaledMaxWidth(otherProfileId, Minecraft.getMinecraft().fontRendererObj, guiLeft+50,
- guiTop+sizeY+23+dropdownOptionSize/2f+dropdownOptionSize*yIndex, true, 90, 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")) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
- Utils.drawTexturedRect(guiLeft-16-5, guiTop+sizeY+2+23+dropdownOptionSize*yIndex, 16, 16, GL11.GL_NEAREST);
- }
- }
-
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- switch (page) {
- case BASIC:
- drawBasicPage(mouseX, mouseY, partialTicks);
- break;
- case DUNG:
- drawDungPage(mouseX, mouseY, partialTicks);
- break;
- case EXTRA:
- drawExtraPage(mouseX, mouseY, partialTicks);
- break;
- case INVS:
- drawInvsPage(mouseX, mouseY, partialTicks);
- break;
- case COLS:
- drawColsPage(mouseX, mouseY, partialTicks);
- break;
- case PETS:
- drawPetsPage(mouseX, mouseY, partialTicks);
- break;
- 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);
-
- //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){
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Might be hypixel's fault.", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+131, true, 0);
- if(timeDiff > 180000){
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Wow you're still here?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+141, 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);
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+""+EnumChatFormatting.BOLD+"What are you doing with your life?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+161, true, 0);
- if(timeDiff > 600000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"Maniac", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+171, true, 0);
- if(timeDiff > 1200000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You're a menace to society", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+181, true, 0);
- if(timeDiff > 1800000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You dont know whats gonna happen to you", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+191, true, 0);
- if(timeDiff > 3000000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You really want this?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+91, true, 0);
- 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");
- }
- };
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- 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;
-
- if(tooltipToDisplay != null) {
- List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size());
- for(String line : tooltipToDisplay) {
- grayTooltip.add(EnumChatFormatting.GRAY + line);
- }
- Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- tooltipToDisplay = null;
- }
- }
-
- private void renderTabs(boolean renderPressed) {
- int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
- ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
- ignoredTabs++;
- continue;
- }
- boolean pressed = page == currentPage;
- if(pressed == renderPressed) {
- renderTab(page.stack, i-ignoredTabs, pressed);
- }
- }
- }
-
- private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- int x = guiLeft+xIndex*28;
- int y = guiTop-28;
-
- float uMin = 0;
- float uMax = 28/256f;
- float vMin = 20/256f;
- float vMax = 51/256f;
- if(pressed) {
- vMin = 52/256f;
- vMax = 84/256f;
-
- if(xIndex != 0) {
- uMin = 28/256f;
- uMax = 56/256f;
- }
-
- renderBlurredBackground(width, height, x+2, y+2, 28-4, 28-4);
- } else {
- renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4);
- }
-
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(x, y, 28, pressed?32:31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
-
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, x+6, y+9);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if(currentPage != ProfileViewerPage.LOADING && currentPage != ProfileViewerPage.INVALID_NAME) {
- int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
- ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
- ignoredTabs++;
- continue;
- }
- int i2 = i - ignoredTabs;
- int x = guiLeft+i2*28;
- int y = guiTop-28;
-
- if(mouseX > x && mouseX < x+28) {
- if(mouseY > y && mouseY < y+32) {
- if(currentPage != page) Utils.playPressSound();
- currentPage = page;
- inventoryTextField.otherComponentClick();
- playerNameTextField.otherComponentClick();
- return;
- }
- }
- }
- }
- switch (currentPage) {
- case DUNG:
- mouseClickedDung(mouseX, mouseY, mouseButton);
- break;
- case INVS:
- 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(mouseX > guiLeft+sizeX-100 && mouseX < guiLeft+sizeX) {
- if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) {
- playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton);
- inventoryTextField.otherComponentClick();
- return;
- }
- }
- if(mouseX > guiLeft+106 && mouseX < guiLeft+106+100 && profile != null && !profile.getProfileIds().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));
- Utils.playPressSound();
- return;
- } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
- //no idea how this sounds, but ya know just in case
- Utils.playSound(new ResourceLocation("game.player.hurt"), true);
- return;
- }
- }
- }
-
- if(mouseX > guiLeft && mouseX < guiLeft+100 && profile != null && !profile.getProfileIds().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)) {
- profileNum = index;
- break;
- }
- }
- if(mouseButton == 0) {
- profileNum++;
- } else {
- profileNum--;
- }
- if(profileNum >= profile.getProfileIds().size()) profileNum = 0;
- if(profileNum < 0) profileNum = profile.getProfileIds().size()-1;
-
- String newProfileId = profile.getProfileIds().get(profileNum);
- if(profileId != null && !profileId.equals(newProfileId)) {
- resetCache();
- }
- profileId = newProfileId;
- } else {
- profileDropdownSelected = !profileDropdownSelected;
- }
- } else if(scaledResolution.getScaleFactor() != 4 && profileDropdownSelected) {
- 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(profileId != null && !profileId.equals(newProfileId)) {
- resetCache();
- }
- profileId = newProfileId;
- }
- }
- playerNameTextField.otherComponentClick();
- inventoryTextField.otherComponentClick();
- return;
- }
- profileDropdownSelected = false;
- playerNameTextField.otherComponentClick();
- inventoryTextField.otherComponentClick();
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- switch (currentPage) {
- case INVS:
- keyTypedInvs(typedChar, keyCode);
- inventoryTextField.keyTyped(typedChar, keyCode);
- break;
- case COLS:
- keyTypedCols(typedChar, keyCode);
- break;
- case DUNG:
- keyTypedDung(typedChar, keyCode);
- break;
- }
- if(playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) {
- 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));
- });
- }
- playerNameTextField.keyTyped(typedChar, keyCode);
- }
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
- super.mouseReleased(mouseX, mouseY, mouseButton);
-
- switch (currentPage) {
- case INVS:
- mouseReleasedInvs(mouseX, mouseY, mouseButton);
- break;
- case COLS:
- mouseReleasedCols(mouseX, mouseY, mouseButton);
- break;
- case PETS:
- mouseReleasedPets(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);
-
- int x = guiLeft+23+110*i/8-w/2;
-
- if(mouseX >= x-2 && mouseX <= x+7) {
- floorTime = i;
- return;
- }
- }
- }
- if(mouseX >= guiLeft-29 && mouseX <= guiLeft){
- if(mouseY >= guiTop && mouseY<= guiTop+28){
- onMasterMode = false;
- return;
- } else if(mouseY+28 >= guiTop && mouseY<= guiTop+28*2){
- onMasterMode = true;
- return;
- }
- }
- }
-
- protected void keyTypedDung(char typedChar, int keyCode) {
- dungeonLevelTextField.keyTyped(typedChar, keyCode);
- }
-
- 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;
-
- }
- Utils.playPressSound();
- }
-
- protected void keyTypedCols(char typedChar, int keyCode) throws IOException {
- ItemStack stack = null;
- Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator();
- switch(keyCode) {
- case Keyboard.KEY_5:
- case Keyboard.KEY_NUMPAD5:
- stack = items.next();
- case Keyboard.KEY_4:
- case Keyboard.KEY_NUMPAD4:
- stack = items.next();
- case Keyboard.KEY_3:
- case Keyboard.KEY_NUMPAD3:
- stack = items.next();
- case Keyboard.KEY_2:
- case Keyboard.KEY_NUMPAD2:
- stack = items.next();
- case Keyboard.KEY_1:
- case Keyboard.KEY_NUMPAD1:
- stack = items.next();
- }
- if(stack != null) {
- selectedCollectionCategory = stack;
- }
- Utils.playPressSound();
- }
-
- 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;
- }
- }
- }
-
- private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 0) {
- int i=0;
- for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
- int xIndex = i%3;
- int yIndex = i/3;
-
- int x = guiLeft+19+34*xIndex;
- int y = guiTop+26+34*yIndex;
-
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
- if(selectedInventory != entry.getKey()) Utils.playPressSound();
- selectedInventory = entry.getKey();
- return;
- }
- }
-
- 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 ItemStack selectedCollectionCategory = null;
-
- private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) {
- int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
- int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
- int yIndex = 0;
- for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
- if(mouseX > guiLeft+7 && mouseX < guiLeft+7+20) {
- if(mouseY > guiTop+10+collectionCatYSize*yIndex && mouseY < guiTop+10+collectionCatYSize*yIndex+20) {
- selectedCollectionCategory = stack;
- Utils.playPressSound();
- return;
- }
- }
- yIndex++;
- }
- }
-
- private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush));
- private static final ItemStack[] BOSS_HEADS = new ItemStack[7];
-
- private HashMap<String, ProfileViewer.Level> levelObjCatas = new HashMap<>();
- private HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>();
-
- private GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
-
- 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)};
- private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"};
- private static final String[] bossFloorHeads = {
- "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c",
- "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d",
- "9971cee8b833a62fc2a612f3503437fdf93cad692d216b8cf90bbb0538c47dd8",
- "8b6a72138d69fbbd2fea3fa251cabd87152e4f1c97e5f986bf685571db3cc0",
- "c1007c5b7114abec734206d4fc613da4f3a0e99f71ff949cedadc99079135a0b",
- "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc",
- "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a"
- };
- private static int floorTime = 7;
- private int floorLevelTo = -1;
- private int floorLevelToXP = -1;
-
- 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.getElement(leveling, "catacombs").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;
- }
- remain