From c9cc530adfb39085fe4b0f9a60e0ca6e4bbb8eb9 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 13 Jan 2021 10:17:56 +0800 Subject: 2.0 PRE6 --- .../notenoughupdates/NEUEventListener.java | 9 + .../moulberry/notenoughupdates/NEUOverlay.java | 106 +---- .../notenoughupdates/NotEnoughUpdates.java | 34 +- .../notenoughupdates/core/BackgroundBlur.java | 6 +- .../core/util/GuiElementSlider.java | 1 - .../notenoughupdates/cosmetics/CapeManager.java | 30 +- .../notenoughupdates/dungeons/DungeonMap.java | 93 +---- .../dungeons/GuiDungeonMapEditor.java | 39 +- .../notenoughupdates/infopanes/InfoPane.java | 3 +- .../miscfeatures/EnchantingSolvers.java | 6 +- .../miscgui/AccessoryBagOverlay.java | 5 + .../profileviewer/GuiProfileViewer.java | 442 +++++++++++++++++++-- .../profileviewer/PlayerStats.java | 3 +- .../profileviewer/ProfileViewer.java | 160 +++++--- .../moulberry/notenoughupdates/util/Utils.java | 56 ++- 15 files changed, 665 insertions(+), 328 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 7b08ddf4..1111a580 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -146,6 +146,8 @@ public class NEUEventListener { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if(event.phase != TickEvent.Phase.START) return; + if(Minecraft.getMinecraft().theWorld == null) return; + if(Minecraft.getMinecraft().thePlayer == null) return; boolean longUpdate = false; long currentTime = System.currentTimeMillis(); @@ -159,6 +161,13 @@ public class NEUEventListener { DungeonWin.tick(); if(longUpdate) { NotEnoughUpdates.INSTANCE.overlay.redrawItems(); + CapeManager.onTickSlow(); + + for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + NotEnoughUpdates.profileViewer.putNameUuid(player.getName(), player.getUniqueID().toString().replace("-", "")); + } + NotEnoughUpdates.profileViewer.putNameUuid(Minecraft.getMinecraft().thePlayer.getName(), + Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")); if(neu.config.dungeonBlock.slowDungeonBlocks) { DungeonBlocks.tick(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 69cda23a..edaa8335 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -4,6 +4,7 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.infopanes.*; @@ -440,6 +441,7 @@ public class NEUOverlay extends Gui { } } + GlStateManager.enableDepth(); float itemScale = bigItemSize/(float)ITEM_SIZE*extraScale; GlStateManager.pushMatrix(); GlStateManager.scale(itemScale, itemScale, 1); @@ -1575,93 +1577,6 @@ public class NEUOverlay extends Gui { return projMatrix; } - /** - * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal - * and vertical blur separately in order to significantly save computation time. - * This is only possible if framebuffers are supported by the system, so this method will exit prematurely - * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support). - */ - private double lastBgBlurFactor = 5; - private void blurBackground() { - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - - if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor <= 0 || !OpenGlHelper.isFramebufferEnabled()) return; - - if(blurOutputHorz == null) { - blurOutputHorz = new Framebuffer(width, height, false); - blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); - } - if(blurOutputVert == null) { - blurOutputVert = new Framebuffer(width, height, false); - blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST); - } - if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { - blurOutputHorz.createBindFramebuffer(width, height); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) { - blurOutputVert.createBindFramebuffer(width, height); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - - if(blurShaderHorz == null) { - try { - blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), - "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); - blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch(Exception e) { } - } - if(blurShaderVert == null) { - try { - blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), - "blur", blurOutputHorz, blurOutputVert); - blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch(Exception e) { } - } - if(blurShaderHorz != null && blurShaderVert != null) { - if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor != lastBgBlurFactor) { - if(blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) { - return; - } - lastBgBlurFactor = Math.max(0, Math.min(50, NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor)); - blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)lastBgBlurFactor); - blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)lastBgBlurFactor); - } - GL11.glPushMatrix(); - blurShaderHorz.loadShader(0); - blurShaderVert.loadShader(0); - GlStateManager.enableDepth(); - GL11.glPopMatrix(); - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - } - - /** - * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. - * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] - */ - public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) { - if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor <= 0 || !OpenGlHelper.isFramebufferEnabled()) return; - - float uMin = x/(float)width; - float uMax = (x+blurWidth)/(float)width; - float vMin = y/(float)height; - float vMax = (y+blurHeight)/(float)height; - - blurOutputVert.bindFramebufferTexture(); - GlStateManager.color(1f, 1f, 1f, 1f); - //Utils.setScreen(width*f, height*f, f); - Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMax, vMin); - //Utils.setScreen(width, height, f); - blurOutputVert.unbindFramebufferTexture(); - } - public void updateGuiGroupSize() { Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale); int width = Utils.peekGuiScale().getScaledWidth(); @@ -1728,8 +1643,6 @@ public class NEUOverlay extends Gui { redrawItems = true; } - blurBackground(); - yaw++; yaw %= 360; @@ -1799,9 +1712,12 @@ public class NEUOverlay extends Gui { //Atomic reference used so that below lambda doesn't complain about non-effectively-final variable AtomicReference tooltipToDisplay = new AtomicReference<>(null); if(itemPaneOffsetFactor.getValue() < 1) { - renderBlurredBackground(width, height, + BackgroundBlur.renderBlurredBackground(width, height, leftSide+getBoxPadding()-5, getBoxPadding()-5, paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10); + Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, + leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10, + getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010); drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, leftSide+paneWidth-getBoxPadding()+5, height-getBoxPadding()+5, bg.getRGB()); @@ -1951,16 +1867,16 @@ public class NEUOverlay extends Gui { int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size()); + GlStateManager.enableDepth(); GlStateManager.depthFunc(GL11.GL_LESS); - - drawRect(selectedX-1+2, selectedItemGroupY+17+2, - selectedX-1+18*selectedItemGroup.size()+2, selectedItemGroupY+35+2, 0xa0000000); drawRect(selectedX, selectedItemGroupY+18, selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, fgCustomOpacity.getRGB()); - drawRect(selectedX, selectedItemGroupY+18, - selectedX-1+18*selectedItemGroup.size(), selectedItemGroupY+35, new Color(30, 30, 30).getRGB()); drawRect(selectedX-1, selectedItemGroupY+17, selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, new Color(180, 180, 180).getRGB()); + drawRect(selectedX, selectedItemGroupY+18, + selectedX-1+18*selectedItemGroup.size(), selectedItemGroupY+35, new Color(30, 30, 30).getRGB()); + drawRect(selectedX-1+2, selectedItemGroupY+17+2, + selectedX-1+18*selectedItemGroup.size()+2, selectedItemGroupY+35+2, 0xa0000000); GlStateManager.depthFunc(GL11.GL_LEQUAL); GL11.glTranslatef(0, 0, 10); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 897db723..d5e6b927 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -595,6 +595,28 @@ public class NotEnoughUpdates { } }; + + SimpleCommand joinDungeonCommand = new SimpleCommand("join", new SimpleCommand.ProcessCommandRunnable() { + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (!hasSkyblockScoreboard()) { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/join " + StringUtils.join(args, " ")); + } else { + if(args.length != 1) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED+"Example Usage: /join f7 or /join 7")); + } else { + String cmd = "/joindungeon catacombs " + args[0].charAt(args[0].length()-1); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.YELLOW+"Running command: "+cmd)); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.YELLOW+"The dungeon should start soon. If it doesn't, make sure you have a party of 5 people")); + Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd); + } + } + } + }); + SimpleCommand viewProfileCommand = new SimpleCommand("neuprofile", viewProfileRunnable, new SimpleCommand.TabCompleteRunnable() { @Override public List tabComplete(ICommandSender sender, String[] args, BlockPos pos) { @@ -638,14 +660,11 @@ public class NotEnoughUpdates { } }); - SimpleCommand viewProfileShort2Command = new SimpleCommand("vp", new SimpleCommand.ProcessCommandRunnable() { + SimpleCommand viewCataCommand = new SimpleCommand("cata", new SimpleCommand.ProcessCommandRunnable() { @Override public void processCommand(ICommandSender sender, String[] args) { - if(!isOnSkyblock()) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/vp " + StringUtils.join(args, " ")); - } else { - viewProfileRunnable.processCommand(sender, args); - } + GuiProfileViewer.currentPage = GuiProfileViewer.ProfileViewerPage.DUNG; + viewProfileRunnable.processCommand(sender, args); } }, new SimpleCommand.TabCompleteRunnable() { @Override @@ -889,9 +908,10 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(resetRepoCommand); ClientCommandHandler.instance.registerCommand(reloadRepoCommand); ClientCommandHandler.instance.registerCommand(itemRenameCommand); + ClientCommandHandler.instance.registerCommand(joinDungeonCommand); ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(viewProfileShortCommand); - ClientCommandHandler.instance.registerCommand(viewProfileShort2Command); + ClientCommandHandler.instance.registerCommand(viewCataCommand); ClientCommandHandler.instance.registerCommand(peekCommand); ClientCommandHandler.instance.registerCommand(tutorialCommand); ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java index 30d056b4..85b442a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java @@ -14,6 +14,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL30; @@ -23,6 +24,7 @@ public class BackgroundBlur { private static boolean registered = false; public static void registerListener() { if(!registered) { + registered = true; MinecraftForge.EVENT_BUS.register(new BackgroundBlur()); } } @@ -79,7 +81,7 @@ public class BackgroundBlur { private static double lastBgBlurFactor = -1; private static void blurBackground() { - if(!OpenGlHelper.isFramebufferEnabled()) return; + if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; int width = Minecraft.getMinecraft().displayWidth; int height = Minecraft.getMinecraft().displayHeight; @@ -161,7 +163,7 @@ public class BackgroundBlur { */ public static void renderBlurredBackground(int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight) { - if(!OpenGlHelper.isFramebufferEnabled()) return; + if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; if(blurOutputVert == null) return; float uMin = x/(float)screenWidth; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java index 4cffb479..cedf368b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java @@ -112,7 +112,6 @@ public class GuiElementSlider extends GuiElement { return true; } - return false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 6f2ab3f1..712ac09a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -44,8 +44,8 @@ public class CapeManager { private HashSet availableCapes = new HashSet<>(); private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", - "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false }; + "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, true }; public static CapeManager getInstance() { return INSTANCE; @@ -215,16 +215,9 @@ public class CapeManager { } } - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (event.phase != TickEvent.Phase.END) return; + public static void onTickSlow() { if(Minecraft.getMinecraft().theWorld == null) return; - String clientUuid = null; - if(Minecraft.getMinecraft().thePlayer != null) { - clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); - } - if(playerMap == null) { playerMap = HashBiMap.create(Minecraft.getMinecraft().theWorld.playerEntities.size()); } @@ -232,11 +225,26 @@ public class CapeManager { for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { String uuid = player.getUniqueID().toString().replace("-", ""); contains.add(uuid); - if(!playerMap.containsValue(player)) { + if(!playerMap.containsValue(player) && !playerMap.containsKey(uuid)) { playerMap.put(uuid, player); } } playerMap.keySet().retainAll(contains); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.END) return; + if(Minecraft.getMinecraft().theWorld == null) return; + + if(playerMap == null) { + return; + } + + String clientUuid = null; + if(Minecraft.getMinecraft().thePlayer != null) { + clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); + } boolean hasLocalCape = localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index bbb5fd31..ce59b7c6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.dungeons; import com.google.common.collect.Iterables; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.util.NEUResourceManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SpecialColour; @@ -494,7 +495,7 @@ public class DungeonMap { if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1) { GlStateManager.translate(-centerX+mapSizeX/2, -centerY+mapSizeY/2, 0); - renderBlurredBackground(scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), + BackgroundBlur.renderBlurredBackground(scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), centerX-mapSizeX/2, centerY-mapSizeY/2, mapSizeX, mapSizeY); GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 0); } @@ -1347,17 +1348,6 @@ public class DungeonMap { this.colourMap = colourMap; } - @SubscribeEvent(priority=EventPriority.HIGH) - public void onRenderOverlayPre(RenderGameOverlayEvent.Pre event) { - if(event.type == RenderGameOverlayEvent.ElementType.ALL && - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable && - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1) { - blurBackground(); - GlStateManager.enableBlend(); - GlStateManager.enableTexture2D(); - } - } - @SubscribeEvent public void onWorldChange(WorldEvent.Load event) { colourMap = null; @@ -1534,83 +1524,4 @@ public class DungeonMap { return projMatrix; } - private double lastBgBlurFactor = -1; - private void blurBackground() { - if(!OpenGlHelper.isFramebufferEnabled()) return; - - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - - if(blurOutputHorz == null) { - blurOutputHorz = new Framebuffer(width, height, false); - blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); - } - if(blurOutputVert == null) { - blurOutputVert = new Framebuffer(width, height, false); - blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST); - } - if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { - blurOutputHorz.createBindFramebuffer(width, height); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) { - blurOutputVert.createBindFramebuffer(width, height); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - - if(blurShaderHorz == null) { - try { - blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); - blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch(Exception e) { } - } - if(blurShaderVert == null) { - try { - blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - blurOutputHorz, blurOutputVert); - blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch(Exception e) { } - } - if(blurShaderHorz != null && blurShaderVert != null) { - float blur = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur; - blur = Math.max(0, Math.min(50, blur)); - if(blur != lastBgBlurFactor) { - blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blur); - blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blur); - lastBgBlurFactor = blur; - } - GL11.glPushMatrix(); - blurShaderHorz.loadShader(0); - blurShaderVert.loadShader(0); - GlStateManager.enableDepth(); - GL11.glPopMatrix(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - } - - /** - * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. - * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] - */ - public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) { - if(!OpenGlHelper.isFramebufferEnabled()) return; - - if(blurOutputVert == null) return; - - float uMin = x/(float)width; - float uMax = (x+blurWidth)/(float)width; - float vMin = (height-y)/(float)height; - float vMax = (height-y-blurHeight)/(float)height; - - blurOutputVert.bindFramebufferTexture(); - GlStateManager.color(1f, 1f, 1f, 1f); - Utils.drawTexturedRectNoBlend(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax, GL11.GL_LINEAR); - blurOutputVert.unbindFramebufferTexture(); - } - } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index e962f793..5677bf9e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -177,9 +177,42 @@ public class GuiDungeonMapEditor extends GuiScreen { //buttons.add(new Button(29, 52, 86+19, "XLarge", options.dmRoomSize)); //buttons.add(new Button(30, 52, 56, "XLarge", options.dmBorderSize)); - xField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterX)); - yField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterY)); - blurField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur)); + { + double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterX; + String strVal; + if(val % 1 == 0) { + strVal = Integer.toString((int)val); + } else { + strVal = Double.toString(val); + strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); + strVal = strVal.replaceAll("0+$", ""); + } + xField.setText(strVal); + } + { + double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterY; + String strVal; + if(val % 1 == 0) { + strVal = Integer.toString((int)val); + } else { + strVal = Double.toString(val); + strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); + strVal = strVal.replaceAll("0+$", ""); + } + yField.setText(strVal); + } + { + double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur; + String strVal; + if(val % 1 == 0) { + strVal = Integer.toString((int)val); + } else { + strVal = Double.toString(val); + strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); + strVal = strVal.replaceAll("0+$", ""); + } + blurField.setText(strVal); + } } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java index 76b500f5..a0657ecc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.infopanes; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NEUOverlay; +import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; @@ -37,7 +38,7 @@ public abstract class InfoPane extends Gui { int boxLeft = leftSide + overlay.getBoxPadding() - 5; int boxRight = rightSide - overlay.getBoxPadding() + 5; - overlay.renderBlurredBackground(width, height, + BackgroundBlur.renderBlurredBackground(width, height, boxLeft, overlay.getBoxPadding()-5, boxRight-boxLeft, height-overlay.getBoxPadding()*2+10); drawRect(boxLeft, overlay.getBoxPadding() - 5, boxRight, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java index 79dc2bba..eed1ec60 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java @@ -467,7 +467,7 @@ public class EnchantingSolvers { for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) { ItemStack stack2 = lower.getStackInSlot(index2); if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) && - stack.getItem() == stack2.getItem()) { + stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) { numMatches++; } } @@ -480,7 +480,7 @@ public class EnchantingSolvers { ItemStack stack2 = lower.getStackInSlot(index2); if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) && - stack.getItem() == stack2.getItem()) { + stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) { successfulMatches.add(index); successfulMatches.add(index2); } @@ -496,7 +496,7 @@ public class EnchantingSolvers { if(superpairStacks.containsKey(index2) && superpairStacks.get(index2) != null) { ItemStack stack2 = superpairStacks.get(index2); if(stack1.getDisplayName().equals(stack2.getDisplayName()) && - stack1.getItem() == stack2.getItem()) { + stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) { possibleMatches.add(index); possibleMatches.add(index2); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index 612dd8d7..233e8819 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -518,6 +518,7 @@ public class AccessoryBagOverlay { String second = containerName.trim().split("/")[1].split("\\)")[0]; //System.out.println(second + ":" + pagesVisited.size()); if(Integer.parseInt(second) > pagesVisited.size()) { + GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST); @@ -542,8 +543,11 @@ public class AccessoryBagOverlay { if(hasStack) pagesVisited.add(1); } + GlStateManager.disableLighting(); + for(int i=0; i<=TAB_MISSING; i++) { if(i != currentTab) { + GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); Utils.drawTexturedRect(guiLeft+xSize+80, guiTop+20*i, 25, 22, 80/256f, 105/256f, 0, 22/256f, GL11.GL_NEAREST); @@ -551,6 +555,7 @@ public class AccessoryBagOverlay { } } + GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST); 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 bc2361f2..601cd362 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -45,6 +45,8 @@ import java.io.IOException; import java.text.NumberFormat; import java.util.*; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -52,6 +54,7 @@ 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"); @@ -65,7 +68,7 @@ public class GuiProfileViewer extends GuiScreen { private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); private final ProfileViewer.Profile profile; - private ProfileViewerPage currentPage = ProfileViewerPage.BASIC; + public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC; private int sizeX; private int sizeY; private int guiLeft; @@ -86,6 +89,7 @@ public class GuiProfileViewer extends GuiScreen { LOADING(null), INVALID_NAME(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)), @@ -93,7 +97,6 @@ public class GuiProfileViewer extends GuiScreen { public final ItemStack stack; - ProfileViewerPage(ItemStack stack) { this.stack = stack; } @@ -102,7 +105,7 @@ public class GuiProfileViewer extends GuiScreen { public GuiProfileViewer(ProfileViewer.Profile profile) { this.profile = profile; String name = ""; - if(profile != null) { + if(profile != null && profile.getHypixelProfile() != null) { name = profile.getHypixelProfile().get("displayname").getAsString(); } playerNameTextField = new GuiElementTextField(name, @@ -196,6 +199,9 @@ public class GuiProfileViewer extends GuiScreen { case BASIC: drawBasicPage(mouseX, mouseY, partialTicks); break; + case DUNG: + drawDungPage(mouseX, mouseY, partialTicks); + break; case EXTRA: drawExtraPage(mouseX, mouseY, partialTicks); break; @@ -312,6 +318,9 @@ public class GuiProfileViewer extends GuiScreen { } } switch (currentPage) { + case DUNG: + mouseClickedDung(mouseX, mouseY, mouseButton); + break; case INVS: inventoryTextField.setSize(88, 20); if(mouseX > guiLeft+19 && mouseX < guiLeft+19+88) { @@ -408,6 +417,9 @@ public class GuiProfileViewer extends GuiScreen { case COLS: keyTypedCols(typedChar, keyCode); break; + case DUNG: + keyTypedDung(typedChar, keyCode); + break; } if(playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) { if(keyCode == Keyboard.KEY_RETURN) { @@ -437,6 +449,40 @@ public class GuiProfileViewer extends GuiScreen { } } + 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; + } + } + } + } + + 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: @@ -569,13 +615,316 @@ public class GuiProfileViewer extends GuiScreen { } } - public static class Level { + private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush)); + private static final ItemStack[] BOSS_HEADS = new ItemStack[7]; + + private ProfileViewer.Level levelObjCata = null; + private HashMap levelObjClasses = 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; + 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= 0) { + dungeonLevelTextField.setText(""+(levelFloored+1)); + calculateFloorLevelXP(); + } + + int x = guiLeft+23; + int y = guiTop+25; + + renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelFloored, level, mouseX, mouseY); + + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Until Cata "+floorLevelTo+": ", + EnumChatFormatting.WHITE.toString()+shortNumberFormat(floorLevelToXP, 0), x, y+16, sectionWidth); + + dungeonLevelTextField.setSize(20, 10); + dungeonLevelTextField.render(x+22, y+29); + //fontRendererObj.drawString("Calculate", + // x+sectionWidth-17-fontRendererObj.getStringWidth("Calculate"), y+30, 0xffffffff); + int calcLen = fontRendererObj.getStringWidth("Calculate"); + Utils.renderShadowedString(EnumChatFormatting.WHITE+"Calculate", x+sectionWidth-17-calcLen/2f, + y+30, 100); + + //Random stats + + float secrets = Utils.getElementAsFloat(Utils.getElement(hypixelInfo, + "achievements.skyblock_treasure_hunter"), 0); + + float totalRuns = 0; + float totalRunsF5 = 0; + for(int i=1; i<=7; i++) { + float runs = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.tier_completions."+i), 0); + totalRuns += runs; + if(i >= 5) { + totalRunsF5 += runs; + } + } + + float mobKills = 0; + float mobKillsF5 = 0; + for(int i=1; i<=7; i++) { + float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.mobs_killed."+i), 0); + mobKills += kills; + if(i >= 5) { + mobKillsF5 += kills; + } + } + + int miscTopY = y+55; + + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Total Runs ", + EnumChatFormatting.WHITE.toString()+((int)(totalRuns)), x, miscTopY, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Total Runs (F5-7) ", + EnumChatFormatting.WHITE.toString()+((int)(totalRunsF5)), x, miscTopY+10, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (Total) ", + EnumChatFormatting.WHITE.toString()+shortNumberFormat(secrets, 0), x, miscTopY+20, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (/Run) ", + EnumChatFormatting.WHITE.toString()+(Math.round(secrets/totalRunsF5*100)/100f), x, miscTopY+30, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Mob Kills (Total) ", + EnumChatFormatting.WHITE.toString()+shortNumberFormat(mobKills, 0), x, miscTopY+40, sectionWidth); + + int y3 = y+117; + + for(int i=1; i<=7; i++) { + int w = fontRendererObj.getStringWidth(""+i); + + int bx = x+sectionWidth*i/8-w/2; + + boolean invert = i == floorTime; + float uMin = 20/256f; + float uMax = 29/256f; + float vMin = 0/256f; + float vMax = 11/256f; + + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(bx-2, y3-2, 9, 11, + invert ? uMax : uMin, invert ? uMin : uMax, + invert ? vMax : vMin, invert ? vMin : vMax, GL11.GL_NEAREST); + + Utils.renderShadowedString(EnumChatFormatting.WHITE.toString()+i, bx+w/2, y3, 10); + } + + float timeNorm = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time."+floorTime), 0); + float timeS = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time_s."+floorTime), 0); + float timeSPLUS = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time_s_plus."+floorTime), 0); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" ", + EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeNorm), x, y3+10, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S", + EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeS), x, y3+20, sectionWidth); + Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S+", + EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeSPLUS), x, y3+30, sectionWidth); + } + + //Completions + { + int x = guiLeft+161; + int y = guiTop+27; + + Utils.renderShadowedString(EnumChatFormatting.RED+"Boss Collections", + x+sectionWidth/2, y, sectionWidth); + for(int i=1; i<=7; i++) { + float compl = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.tier_completions."+i), 0); + + if(BOSS_HEADS[i-1] == null) { + String textureLink = bossFloorHeads[i-1]; + + String b64Decoded = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + textureLink + "\"}}}"; + String b64Encoded = new String(Base64.getEncoder().encode(b64Decoded.getBytes())); + + ItemStack stack = new ItemStack(Items.skull, 1, 3); + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound skullOwner = new NBTTagCompound(); + NBTTagCompound properties = new NBTTagCompound(); + NBTTagList textures = new NBTTagList(); + NBTTagCompound textures_0 = new NBTTagCompound(); + + String uuid = UUID.nameUUIDFromBytes(b64Encoded.getBytes()).toString(); + skullOwner.setString("Id", uuid); + skullOwner.setString("Name", uuid); + + textures_0.setString("Value", b64Encoded); + textures.appendTag(textures_0); + + properties.setTag("textures", textures); + skullOwner.setTag("Properties", properties); + nbt.setTag("SkullOwner", skullOwner); + stack.setTagCompound(nbt); + + BOSS_HEADS[i-1] = stack; + } + + GlStateManager.pushMatrix(); + GlStateManager.translate(x-4, y+10+20*(i-1), 0); + GlStateManager.scale(1.3f, 1.3f, 1); + Utils.drawItemStack(BOSS_HEADS[i-1], 0, 0); + GlStateManager.popMatrix(); + + Utils.renderAlignedString(String.format(EnumChatFormatting.YELLOW+"%s (F%d) ", bossFloorArr[i-1], i), + EnumChatFormatting.WHITE.toString()+(int)compl, + x+16, y+18+20*(i-1), sectionWidth-15); + + } + } + + //Skills + { + int x = guiLeft+298; + int y = guiTop+27; + + //Gui.drawRect(x, y, x+120, y+147, 0xffffffff); + + Utils.renderShadowedString(EnumChatFormatting.DARK_PURPLE+"Class Levels", + x+sectionWidth/2, y, sectionWidth); + + JsonElement activeClassElement = Utils.getElement(profileInfo, "dungeons.selected_dungeon_class"); + String activeClass = null; + if(activeClassElement instanceof JsonPrimitive && ((JsonPrimitive) activeClassElement).isString()) { + activeClass = activeClassElement.getAsString(); + } + + for(int i=0; i x && mouseX < x+120) { + if(mouseY > y-4 && mouseY < y+13) { + String levelStr; + if(levelObjCata.maxed) { + levelStr = EnumChatFormatting.GOLD+"MAXED!"; + } else { + int maxXp = (int)levelObjCata.maxXpForLevel; + levelStr = EnumChatFormatting.DARK_PURPLE.toString() + shortNumberFormat(Math.round((level%1)*maxXp), + 0) + "/" + shortNumberFormat(maxXp, 0); + } + + tooltipToDisplay = Utils.createList(levelStr); + } + } + + 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); + } + + public static class PetLevel { float level; float currentLevelRequirement; float maxXP; } - public static Level getLevel(JsonArray levels, int offset, float exp) { + public static PetLevel getPetLevel(JsonArray levels, int offset, float exp) { float xpTotal = 0; float level = 1; float currentLevelRequirement = 0; @@ -605,7 +954,7 @@ public class GuiProfileViewer extends GuiScreen { } else if(level > 100) { level = 100; } - Level levelObj = new Level(); + PetLevel levelObj = new PetLevel(); levelObj.level = level; levelObj.currentLevelRequirement = currentLevelRequirement; levelObj.maxXP = xpTotal; @@ -717,7 +1066,7 @@ public class GuiProfileViewer extends GuiScreen { int petRarityOffset = petsJson.get("pet_rarity_offset").getAsJsonObject().get(tier).getAsInt(); JsonArray levelsArr = petsJson.get("pet_levels").getAsJsonArray(); - Level levelObj = getLevel(levelsArr, petRarityOffset, exp); + PetLevel levelObj = getPetLevel(levelsArr, petRarityOffset, exp); float level = levelObj.level; float currentLevelRequirement = levelObj.currentLevelRequirement; float maxXP = levelObj.maxXP; @@ -1841,6 +2190,14 @@ public class GuiProfileViewer extends GuiScreen { private static char[] c = new char[]{'k', 'm', 'b', 't'}; public static String shortNumberFormat(double n, int iteration) { + if(n < 1000) { + if(n % 1 == 0) { + return Integer.toString((int)n); + } else { + return Double.toString(n); + } + } + double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) %10 == 0; return (d < 1000? @@ -1850,6 +2207,9 @@ public class GuiProfileViewer extends GuiScreen { : shortNumberFormat(d, iteration+1)); } + private boolean loadingProfile = false; + private static final ExecutorService profileLoader = Executors.newSingleThreadExecutor(); + private void drawBasicPage(int mouseX, int mouseY, float partialTicks) { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; @@ -2014,23 +2374,29 @@ public class GuiProfileViewer extends GuiScreen { } if(entityPlayer == null) { - UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid())); - GameProfile fakeProfile = Minecraft.getMinecraft().getSessionService().fillProfileProperties(new GameProfile(playerUUID, "CoolGuy123"), false); - entityPlayer = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, fakeProfile) { - public ResourceLocation getLocationSkin() { - return playerLocationSkin == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : playerLocationSkin; - } + if(!loadingProfile) { + loadingProfile = true; + UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid())); + + profileLoader.submit(() -> { + GameProfile fakeProfile = Minecraft.getMinecraft().getSessionService().fillProfileProperties(new GameProfile(playerUUID, "CoolGuy123"), false); + entityPlayer = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, fakeProfile) { + public ResourceLocation getLocationSkin() { + return playerLocationSkin == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : playerLocationSkin; + } - public ResourceLocation getLocationCape() { - return playerLocationCape; - } + public ResourceLocation getLocationCape() { + return playerLocationCape; + } - public String getSkinType() { - return skinType == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : skinType; - } - }; - entityPlayer.setAlwaysRenderNameTag(false); - entityPlayer.setCustomNameTag(""); + public String getSkinType() { + return skinType == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : skinType; + } + }; + entityPlayer.setAlwaysRenderNameTag(false); + entityPlayer.setCustomNameTag(""); + }); + } } else { entityPlayer.refreshDisplayName(); byte b = 0; @@ -2046,25 +2412,27 @@ public class GuiProfileViewer extends GuiScreen { JsonObject skillInfo = profile.getSkillInfo(profileId); JsonObject inventoryInfo = profile.getInventoryInfo(profileId); - if(backgroundClickedX != -1 && Mouse.isButtonDown(1)) { - for(int i=0; i xp) { + if(cumulative) { + float previous = 0; + if(level > 0) previous = levelingArray.get(level-1).getAsFloat(); + levelObj.maxXpForLevel = (levelXp-previous); + levelObj.level = 1 + level + (xp-levelXp)/levelObj.maxXpForLevel; + } else { + levelObj.maxXpForLevel = levelXp; + levelObj.level = level + xp/levelXp; + } + if(levelObj.level > levelCap) { + levelObj.level = levelCap; + levelObj.maxed = true; + } + return levelObj; + } else { + if(!cumulative) xp -= levelXp; + } + } + levelObj.level = levelingArray.size(); + if(levelObj.level > levelCap) { + levelObj.level = levelCap; + } + levelObj.maxed = true; + return levelObj; + } + public class Profile { private final String uuid; private String latestProfile = null; @@ -325,10 +363,10 @@ public class ProfileViewer { if(manager.auctionManager.isVanillaItem(internalname)) continue; - JsonObject info = manager.auctionManager.getItemAuctionInfo(internalname); - if(info == null || !info.has("price") || !info.has("count")) continue; - - int auctionPrice = (int)(info.get("price").getAsFloat() / info.get("count").getAsFloat()); + int auctionPrice = (int)manager.auctionManager.getItemAvgBin(internalname); + if(auctionPrice <= 0) { + auctionPrice = (int)manager.auctionManager.getLowestBin(internalname); + } try { if(item.has("item_contents")) { @@ -346,9 +384,10 @@ public class ProfileViewer { if(internalname2 != null) { if(manager.auctionManager.isVanillaItem(internalname2)) continue; - JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2); - if(info2 == null || !info2.has("price") || !info2.has("count")) continue; - int auctionPrice2 = (int)(info2.get("price").getAsFloat() / info2.get("count").getAsFloat()); + int auctionPrice2 = (int)manager.auctionManager.getItemAvgBin(internalname2); + if(auctionPrice2 <= 0) { + auctionPrice2 = (int)manager.auctionManager.getLowestBin(internalname2); + } int count2 = items.getCompoundTagAt(j).getByte("Count"); networth += auctionPrice2 * count2; @@ -370,6 +409,8 @@ public class ProfileViewer { } if(networth == 0) return -1; + networth = (int)(networth*1.3f); + JsonObject petsInfo = getPetsInfo(profileId); if(petsInfo != null && petsInfo.has("pets")) { if(petsInfo.get("pets").isJsonArray()) { @@ -547,43 +588,6 @@ public class ProfileViewer { networth = -1; } - private class Level { - private float level = 0; - private float maxXpForLevel = 0; - private boolean maxed = false; - } - - public Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) { - Level levelObj = new Level(); - for(int level=0; level xp) { - if(cumulative) { - float previous = 0; - if(level > 0) previous = levelingArray.get(level-1).getAsFloat(); - levelObj.maxXpForLevel = (levelXp-previous); - levelObj.level = 1 + level + (xp-levelXp)/levelObj.maxXpForLevel; - } else { - levelObj.maxXpForLevel = levelXp; - levelObj.level = level + xp/levelXp; - } - if(levelObj.level > levelCap) { - levelObj.level = levelCap; - levelObj.maxed = true; - } - return levelObj; - } else { - if(!cumulative) xp -= levelXp; - } - } - levelObj.level = levelingArray.size(); - if(levelObj.level > levelCap) { - levelObj.level = levelCap; - } - levelObj.maxed = true; - return levelObj; - } - public int getCap(JsonObject leveling, String skillName) { JsonElement capsElement = Utils.getElement(leveling, "leveling_caps"); if(capsElement == null || !capsElement.isJsonObject()) { @@ -956,7 +960,7 @@ public class ProfileViewer { return uuid; } - public JsonObject getHypixelProfile() { + public @Nullable JsonObject getHypixelProfile() { if(uuidToHypixelProfile.containsKey(uuid)) return uuidToHypixelProfile.get(uuid); return null; } @@ -967,39 +971,69 @@ public class ProfileViewer { private HashMap uuidToProfileMap = new HashMap<>(); public void getHypixelProfile(String name, Consumer callback) { + String nameF = name.toLowerCase(); HashMap args = new HashMap<>(); - args.put("name", ""+name); + args.put("name", ""+nameF); manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "player", args, jsonObject -> { if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean() && jsonObject.get("player").isJsonObject()) { - nameToHypixelProfile.put(name, jsonObject.get("player").getAsJsonObject()); + nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString()); uuidToHypixelProfile.put(jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(), jsonObject.get("player").getAsJsonObject()); if(callback != null) callback.accept(jsonObject); } else { if(callback != null) callback.accept(null); - return; } } ); } - public Profile getProfileByName(String name, Consumer callback) { - if(nameToHypixelProfile.containsKey(name)) { - Profile profile = getProfileReset(nameToHypixelProfile.get(name).get("uuid").getAsString(), ignored -> {}); - callback.accept(profile); - return profile; - } else { - getHypixelProfile(name, jsonObject -> { - if(jsonObject == null) { - callback.accept(null); - } else { - callback.accept(getProfileReset(jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(), ignored -> {})); - } + private final HashMap nameToUuid = new HashMap<>(); + + public void putNameUuid(String name, String uuid) { + nameToUuid.put(name, uuid); + } - }); + public void getPlayerUUID(String name, Consumer uuidCallback) { + String nameF = name.toLowerCase(); + if(nameToUuid.containsKey(nameF)) { + uuidCallback.accept(nameToUuid.get(nameF)); + return; } - return null; + + manager.hypixelApi.getApiAsync("https://api.mojang.com/users/profiles/minecraft/"+nameF, + (jsonObject) -> { + if(jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() && + ((JsonPrimitive)jsonObject.get("id")).isString()) { + String uuid = jsonObject.get("id").getAsString(); + nameToUuid.put(nameF, uuid); + uuidCallback.accept(uuid); + return; + } + uuidCallback.accept(null); + }, () -> uuidCallback.accept(null) + ); + } + + public void getProfileByName(String name, Consumer callback) { + String nameF = name.toLowerCase(); + + getPlayerUUID(nameF, (uuid) -> { + if(uuid == null) { + getHypixelProfile(nameF, jsonObject -> { + if(jsonObject != null) { + callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {})); + } + }); + } else { + if(!uuidToHypixelProfile.containsKey(uuid)) { + getHypixelProfile(nameF, jsonObject -> {}); + } + callback.accept(getProfileReset(uuid, ignored -> {})); + } + }); + + return; } public Profile getProfile(String uuid, Consumer callback) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 37f4db0c..3f4e96bc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -517,22 +517,26 @@ public class Utils { } } - public static void renderAlignedString(String first, String second, float x, float y, int length) { - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; - if(fontRendererObj.getStringWidth(first + " " + second) >= length) { - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(first + " " + second), Minecraft.getMinecraft().fontRendererObj, - x+length/2f+xOff/2f, y+4+yOff/2f, false, length, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); - } + public static void renderShadowedString(String str, float x, float y, int maxLength) { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str), Minecraft.getMinecraft().fontRendererObj, + x+xOff/2f, y+4+yOff/2f, false, maxLength, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); } } + } - GlStateManager.color(1, 1, 1, 1); - Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj, - x+length/2f, y+4, false, length, 4210752); + GlStateManager.color(1, 1, 1, 1); + Utils.drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, + x, y+4, false, maxLength, 4210752); + } + + public static void renderAlignedString(String first, String second, float x, float y, int length) { + FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; + if(fontRendererObj.getStringWidth(first + " " + second) >= length) { + renderShadowedString(first + " " + second, x+length/2f, y, length); } else { for(int xOff=-2; xOff<=2; xOff++) { for(int yOff=-2; yOff<=2; yOff++) { @@ -1080,4 +1084,30 @@ public class Utils { GlStateManager.enableTexture2D(); } + public static String prettyTime(long millis) { + long seconds = millis / 1000 % 60; + long minutes = (millis / 1000 / 60) % 60; + long hours = (millis / 1000 / 60 / 60) % 24; + long days = (millis / 1000 / 60 / 60 / 24); + + String endsIn = ""; + if(millis < 0) { + endsIn += "Ended!"; + } else if(minutes == 0 && hours == 0 && days == 0) { + endsIn += seconds + "s"; + } else if(hours==0 && days==0) { + endsIn += minutes + "m" + seconds + "s"; + } else if(days==0) { + if(hours <= 6) { + endsIn += hours + "h" + minutes + "m" + seconds + "s"; + } else { + endsIn += hours + "h"; + } + } else { + endsIn += days + "d" + hours + "h"; + } + + return endsIn; + } + } -- cgit