diff options
| author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-20 05:12:05 +1000 |
|---|---|---|
| committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-20 05:12:05 +1000 |
| commit | 8499a98beeb556c16987fc375dbd7d05d6c27ab4 (patch) | |
| tree | afd17c1abac0eb147258f8f12d33a9ee7bd21fd8 /src/main/java | |
| parent | f7d3491def0f7498d7bf0d547445f75f0c515912 (diff) | |
| download | NotEnoughUpdates-8499a98beeb556c16987fc375dbd7d05d6c27ab4.tar.gz NotEnoughUpdates-8499a98beeb556c16987fc375dbd7d05d6c27ab4.tar.bz2 NotEnoughUpdates-8499a98beeb556c16987fc375dbd7d05d6c27ab4.zip | |
some profile viewer stuffs
Diffstat (limited to 'src/main/java')
10 files changed, 1455 insertions, 90 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 8d625c14..edf1d31c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -112,10 +112,12 @@ public class NEUManager { public void setCurrentProfile(String currentProfile) { this.currentProfile = currentProfile; + this.auctionManager.incPlayerInfoVersion(); } public void setCurrentProfileBackup(String currentProfile) { this.currentProfileBackup = currentProfile; + this.auctionManager.incPlayerInfoVersion(); } public String getCurrentProfile() { @@ -227,7 +229,7 @@ public class NEUManager { public void updatePrices() { if(System.currentTimeMillis() - auctionLastUpdate > 1000*60*120) { //2 hours craftCost.clear(); - System.out.println("UPDATING PRICE INFORMATION"); + System.out.println("[NEU] UPDATING PRICE INFORMATION"); auctionLastUpdate = System.currentTimeMillis(); try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) { auctionPricesJson = gson.fromJson(inReader, JsonObject.class); @@ -349,7 +351,7 @@ public class NEUManager { BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); JsonObject json = gson.fromJson(reader, JsonObject.class); return json; - } catch(Exception e) { return null; } + } catch(Exception e) { e.printStackTrace(); return null; } } /** @@ -389,7 +391,6 @@ public class NEUManager { if (Display.isActive()) dialog.toFront(); if (changedFiles != null && changedFiles.size() <= 20) { - String startMessage = "NotEnoughUpdates: Syncing with remote repository ("; int downloaded = 0; @@ -403,6 +404,7 @@ public class NEUManager { File item = new File(repoLocation, name); try { + item.getParentFile().mkdirs(); item.createNewFile(); } catch (IOException e) { } @@ -810,6 +812,7 @@ public class NEUManager { public JsonObject getJsonFromItemBytes(String item_bytes) { try { NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes))); + //System.out.println(tag.toString()); return getJsonFromNBT(tag); } catch(IOException e) { return null; @@ -873,7 +876,12 @@ public class NEUManager { } public JsonObject getJsonFromNBT(NBTTagCompound tag) { - tag = tag.getTagList("i", 10).getCompoundTagAt(0); + return getJsonFromNBTEntry(tag.getTagList("i", 10).getCompoundTagAt(0)); + } + + public JsonObject getJsonFromNBTEntry(NBTTagCompound tag) { + if(tag.getKeySet().size() == 0) return null; + int id = tag.getShort("id"); int damage = tag.getShort("Damage"); int count = tag.getShort("Count"); @@ -882,6 +890,7 @@ public class NEUManager { if(id == 141) id = 391; //for some reason hypixel thinks carrots have id 141 String internalname = getInternalnameFromNBT(tag); + if(internalname == null) return null; NBTTagCompound display = tag.getCompoundTag("display"); String[] lore = getLoreFromNBT(tag); @@ -896,15 +905,25 @@ public class NEUManager { String clickcommand = ""; - //public JsonObject createItemJson(String internalname, String itemid, String displayname, String[] lore, - // String crafttext, String infoType, String[] info, - // String clickcommand, int damage, NBTTagCompound nbttag) { JsonObject item = new JsonObject(); item.addProperty("internalname", internalname); item.addProperty("itemid", itemid); item.addProperty("displayname", displayname); + if(tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + + if (ea.hasKey("new_year_cake_bag_data", 7)) { + byte[] bytes = ea.getByteArray("new_year_cake_bag_data"); + JsonArray bytesArr = new JsonArray(); + for(byte b : bytes) { + bytesArr.add(new JsonPrimitive(b)); + } + item.add("item_contents", bytesArr); + } + } + if(lore != null && lore.length > 0) { JsonArray jsonLore = new JsonArray(); for (String line : lore) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 23def271..a33c13b3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1097,6 +1097,9 @@ public class NEUOverlay extends Gui { case "ducttapedigger": searchedItems.add(CustomItems.DUCTTAPE); break; + case "thirtyvirus": + searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT")); + break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index a589fe2b..a7a30233 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -11,6 +11,8 @@ import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; import io.github.moulberry.notenoughupdates.infopanes.CosmeticsInfoPane; +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.questing.GuiQuestLine; import io.github.moulberry.notenoughupdates.questing.NEUQuesting; import io.github.moulberry.notenoughupdates.util.Utils; @@ -29,6 +31,7 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.scoreboard.ScoreObjective; @@ -129,6 +132,37 @@ public class NotEnoughUpdates { } }); + private static ProfileViewer profileViewer; + + SimpleCommand viewProfileCommand = new SimpleCommand("neuprofile", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if(args.length != 1) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + + "idiot.")); + } + profileViewer.getProfileByName(args[0], profile -> { + openGui = new GuiProfileViewer(profile); + }); + } + }); + + SimpleCommand linksCommand = new SimpleCommand("neulinks", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + File repo = manager.repoLocation; + if(repo.exists()) { + File updateJson = new File(repo, "update.json"); + try { + JsonObject update = manager.getJsonFromFile(updateJson); + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + displayLinks(update); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + } catch (Exception ignored) { + } + } + } + }); + SimpleCommand overlayPlacementsCommand = new SimpleCommand("neuoverlay", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { openGui = new NEUOverlayPlacements(); @@ -175,6 +209,8 @@ public class NotEnoughUpdates { f.mkdirs(); ClientCommandHandler.instance.registerCommand(collectionLogCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); + ClientCommandHandler.instance.registerCommand(linksCommand); + ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand); //ClientCommandHandler.instance.registerCommand(questingCommand); ClientCommandHandler.instance.registerCommand(neuAhCommand); @@ -183,6 +219,7 @@ public class NotEnoughUpdates { manager = new NEUManager(this, neuio, f); manager.loadItemInformation(); overlay = new NEUOverlay(manager); + profileViewer = new ProfileViewer(manager); for(KeyBinding kb : manager.keybinds) { ClientRegistry.registerKeyBinding(kb); @@ -203,7 +240,7 @@ public class NotEnoughUpdates { })); //TODO: login code. Ignore this, used for testing. - /*try { + try { Field field = Minecraft.class.getDeclaredField("session"); YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()) @@ -232,7 +269,7 @@ public class NotEnoughUpdates { field.setAccessible(true); field.set(Minecraft.getMinecraft(), session); } catch (NoSuchFieldException | AuthenticationException | IllegalAccessException e) { - }*/ + } } /** @@ -250,6 +287,98 @@ public class NotEnoughUpdates { } } + private void displayLinks(JsonObject update) { + String discord_link = update.get("discord_link").getAsString(); + String youtube_link = update.get("youtube_link").getAsString(); + String update_link = update.get("update_link").getAsString(); + String github_link = update.get("github_link").getAsString(); + String other_text = update.get("other_text").getAsString(); + String other_link = update.get("other_link").getAsString(); + + ChatComponentText other = null; + if(other_text.length() > 0) { + other = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+other_text+EnumChatFormatting.GRAY+"]"); + other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link)); + } + ChatComponentText links = new ChatComponentText(""); + ChatComponentText separator = new ChatComponentText( + EnumChatFormatting.GRAY+EnumChatFormatting.BOLD.toString()+EnumChatFormatting.STRIKETHROUGH+(other==null?"---":"--")); + ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+"Discord"+EnumChatFormatting.GRAY+"]"); + discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link)); + ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.RED+"YouTube"+EnumChatFormatting.GRAY+"]"); + youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link)); + ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.GREEN+"Release"+EnumChatFormatting.GRAY+"]"); + release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link)); + ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"GitHub"+EnumChatFormatting.GRAY+"]"); + github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); + + + links.appendSibling(separator); + links.appendSibling(discord); + links.appendSibling(separator); + links.appendSibling(youtube); + links.appendSibling(separator); + links.appendSibling(release); + links.appendSibling(separator); + links.appendSibling(github); + links.appendSibling(separator); + if(other != null) { + links.appendSibling(other); + links.appendSibling(separator); + } + + Minecraft.getMinecraft().thePlayer.addChatMessage(links); + } + + private boolean displayUpdateMessageIfOutOfDate() { + File repo = manager.repoLocation; + if(repo.exists()) { + File updateJson = new File(repo, "update.json"); + try { + JsonObject o = manager.getJsonFromFile(updateJson); + + String version = o.get("version").getAsString(); + + if(!VERSION.equalsIgnoreCase(version)) { + String update_msg = o.get("update_msg").getAsString(); + String discord_link = o.get("discord_link").getAsString(); + String youtube_link = o.get("youtube_link").getAsString(); + String update_link = o.get("update_link").getAsString(); + String github_link = o.get("github_link").getAsString(); + String other_text = o.get("other_text").getAsString(); + String other_link = o.get("other_link").getAsString(); + + int first_len = -1; + for(String line : update_msg.split("\n")) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int len = fr.getStringWidth(line); + if(first_len == -1) { + first_len = len; + } + int missing_len = first_len-len; + if(missing_len > 0) { + StringBuilder sb = new StringBuilder(line); + for(int i=0; i<missing_len/8; i++) { + sb.insert(0, " "); + } + line = sb.toString(); + } + line = line.replaceAll("\\{version}", version); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); + } + + displayLinks(o); + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + + } + + return true; + } catch(Exception ignored) {} + } + return false; + } + /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. @@ -265,80 +394,8 @@ public class NotEnoughUpdates { if(hasSkyblockScoreboard()) { manager.auctionManager.tick(); if(!joinedSB && manager.config.showUpdateMsg.value) { - File repo = manager.repoLocation; - if(repo.exists()) { - File updateJson = new File(repo, "update.json"); - try { - JsonObject o = manager.getJsonFromFile(updateJson); - - String version = o.get("version").getAsString(); - - if(!VERSION.equalsIgnoreCase(version)) { - String update_msg = o.get("update_msg").getAsString(); - String discord_link = o.get("discord_link").getAsString(); - String youtube_link = o.get("youtube_link").getAsString(); - String update_link = o.get("update_link").getAsString(); - String github_link = o.get("github_link").getAsString(); - String other_text = o.get("other_text").getAsString(); - String other_link = o.get("other_link").getAsString(); - - int first_len = -1; - for(String line : update_msg.split("\n")) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int len = fr.getStringWidth(line); - if(first_len == -1) { - first_len = len; - } - int missing_len = first_len-len; - if(missing_len > 0) { - StringBuilder sb = new StringBuilder(line); - for(int i=0; i<missing_len/8; i++) { - sb.insert(0, " "); - } - line = sb.toString(); - } - line = line.replaceAll("\\{version}", version); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); - } - ChatComponentText other = null; - if(other_text.length() > 0) { - other = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+other_text+EnumChatFormatting.GRAY+"]"); - other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link)); - } - ChatComponentText links = new ChatComponentText(""); - ChatComponentText separator = new ChatComponentText( - EnumChatFormatting.GRAY+EnumChatFormatting.BOLD.toString()+EnumChatFormatting.STRIKETHROUGH+(other==null?"---":"--")); - ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+"Discord"+EnumChatFormatting.GRAY+"]"); - discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link)); - ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.RED+"YouTube"+EnumChatFormatting.GRAY+"]"); - youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link)); - ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.GREEN+"Release"+EnumChatFormatting.GRAY+"]"); - release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link)); - ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"GitHub"+EnumChatFormatting.GRAY+"]"); - github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); - - - links.appendSibling(separator); - links.appendSibling(discord); - links.appendSibling(separator); - links.appendSibling(youtube); - links.appendSibling(separator); - links.appendSibling(release); - links.appendSibling(separator); - links.appendSibling(github); - links.appendSibling(separator); - if(other != null) { - links.appendSibling(other); - links.appendSibling(separator); - } - - Minecraft.getMinecraft().thePlayer.addChatMessage(links); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - - } - - joinedSB = true; - } catch(Exception ignored) {} + if(displayUpdateMessageIfOutOfDate()) { + joinedSB = false; } } //NEUQuesting.getInstance().tick(); @@ -387,7 +444,6 @@ public class NotEnoughUpdates { } } } else { - for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { processUniqueStack(stack, newItem); } @@ -407,6 +463,7 @@ public class NotEnoughUpdates { if(newItemAddMap.containsKey(internalname)) { if(System.currentTimeMillis() - newItemAddMap.get(internalname) > 1000) { log.add(internalname); + try { manager.saveConfig(); } catch(IOException ignored) {} } } else { newItemAddMap.put(internalname, System.currentTimeMillis()); @@ -732,7 +789,10 @@ public class NotEnoughUpdates { ItemStack item = lower.getStackInSlot(11+i); String internal = manager.getInternalNameForItem(item); if(internal != null) { - int worth = manager.auctionManager.getLowestBin(internal); + float worth = manager.auctionManager.getLowestBin(internal); + + if(worth == -1) worth = manager.getCraftCost(internal).craftCost; + if(worth > 0) { totalValue += worth; } else { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 20ac86ba..65f6545e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -19,6 +19,7 @@ import net.minecraft.util.EnumChatFormatting; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; public class APIManager { @@ -60,6 +61,8 @@ public class APIManager { customAH = new CustomAH(manager); } + private AtomicInteger playerInfoVersion = new AtomicInteger(0); + public JsonObject getPlayerInformation() { if(playerInformation == null) return null; for(int i=0; i<playerInformation.size(); i++) { @@ -75,6 +78,14 @@ public class APIManager { return null; } + public int getPlayerInfoVersion() { + return playerInfoVersion.get(); + } + + public void incPlayerInfoVersion() { + playerInfoVersion.incrementAndGet(); + } + public TreeMap<String, Auction> getAuctionItems() { return auctionMap; } @@ -158,6 +169,7 @@ public class APIManager { manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/profiles", args, jsonObject -> { if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { + incPlayerInfoVersion(); playerInformation = jsonObject.get("profiles").getAsJsonArray(); if(playerInformation == null) return; String backup = null; @@ -332,6 +344,8 @@ public class APIManager { if(contains) { if(line.trim().contains(rarity + " " + typeMatches[j])) { return j; + } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) { + return j; } } else { if(line.trim().endsWith(rarity + " " + typeMatches[j])) { @@ -464,7 +478,7 @@ public class APIManager { //Categories String category = sbCategory; - int itemType = checkItemType(item_lore, false,"SWORD", "FISHING ROD", "PICKAXE", + int itemType = checkItemType(item_lore, true,"SWORD", "FISHING ROD", "PICKAXE", "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW"); if(itemType >= 0 && itemType < categoryItemType.length) { category = categoryItemType[itemType]; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java new file mode 100644 index 00000000..81ecc9b4 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -0,0 +1,315 @@ +package io.github.moulberry.notenoughupdates.profileviewer; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.properties.Property; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.TexLoc; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.network.NetworkPlayerInfo; +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.resources.SkinManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.Charsets; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; + +public class GuiProfileViewer extends GuiScreen { + + public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png"); + + private final ProfileViewer.Profile profile; + private ProfileViewerPage currentPage = ProfileViewerPage.BASIC; + private int sizeX; + private int sizeY; + private int guiLeft; + private int guiTop; + + public enum ProfileViewerPage { + BASIC + } + + public GuiProfileViewer(ProfileViewer.Profile profile) { + this.profile = profile; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + drawDefaultBackground(); + + switch (currentPage) { + case BASIC: + drawBasicPage(mouseX, mouseY, partialTicks); + break; + } + + } + + private String niceUuid(String uuidStr) { + if(uuidStr.length()!=32) return uuidStr; + + StringBuilder niceAucId = new StringBuilder(); + niceAucId.append(uuidStr, 0, 8); + niceAucId.append("-"); + niceAucId.append(uuidStr, 8, 12); + niceAucId.append("-"); + niceAucId.append(uuidStr, 12, 16); + niceAucId.append("-"); + niceAucId.append(uuidStr, 16, 20); + niceAucId.append("-"); + niceAucId.append(uuidStr, 20, 32); + return niceAucId.toString(); + } + + private EntityOtherPlayerMP entityPlayer = null; + private ResourceLocation playerLocationSkin = null; + private ResourceLocation playerLocationCape = null; + private String skinType = null; + + TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M); + TexLoc tl2 = new TexLoc(0, 0, Keyboard.KEY_B); + TexLoc tl3 = new TexLoc(0, 0, Keyboard.KEY_J); + private void drawBasicPage(int mouseX, int mouseY, float partialTicks) { + this.sizeX = 431; + this.sizeY = 202; + this.guiLeft = (this.width-this.sizeX)/2; + this.guiTop = (this.height-this.sizeY)/2; + + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic); + Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); + + tl.handleKeyboardInput(); + tl2.handleKeyboardInput(); + tl3.handleKeyboardInput(); + + if(entityPlayer == null) { + UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid())); + GameProfile fakeProfile = Minecraft.getMinecraft().getSessionService().fillProfileProperties(new GameProfile(playerUUID, "CoolGuy123"), false); + for(Property prop : fakeProfile.getProperties().get("textures")) { + System.out.println(new String(Base64.decodeBase64(prop.getValue()), Charsets.UTF_8)); + } + entityPlayer = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, fakeProfile) { + public ResourceLocation getLocationSkin() { + return playerLocationSkin == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : playerLocationSkin; + } + + public ResourceLocation getLocationCape() { + return playerLocationCape; + } + + public String getSkinType() { + return skinType == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : skinType; + } + }; + } + + JsonObject profileInfo = profile.getProfileInformation(null); + if(profileInfo == null) return; + + JsonObject skillInfo = profile.getSkillInfo(null); + JsonObject inventoryInfo = profile.getInventoryInfo(null); + JsonObject collectionInfo =profile. getCollectionInfo(null); + + if(inventoryInfo != null && inventoryInfo.has("inv_armor")) { + JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray(); + for(int i=0; i<entityPlayer.inventory.armorInventory.length; i++) { + JsonElement itemElement = items.get(i); + if(itemElement != null && itemElement.isJsonObject()) { + entityPlayer.inventory.armorInventory[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false); + } + } + } + if(playerLocationSkin == null) { + try { + Minecraft.getMinecraft().getSkinManager().loadProfileTextures(entityPlayer.getGameProfile(), new SkinManager.SkinAvailableCallback() { + public void skinAvailable(MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { + switch (type) { + case SKIN: + playerLocationSkin = location; + skinType = profileTexture.getMetadata("model"); + + if(skinType == null) { + skinType = "default"; + } + + break; + case CAPE: + playerLocationCape = location; + } + } + }, false); + } catch(Exception e){}< |
