diff options
19 files changed, 436 insertions, 61 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 8a6f77ea..070b2d66 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -1,13 +1,11 @@ package io.github.moulberry.notenoughupdates; -import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; -import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; @@ -27,8 +25,6 @@ import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.init.Blocks; @@ -48,7 +44,6 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -207,7 +202,7 @@ public class NEUEventListener { XPInformation.getInstance().tick(); ProfileApiSyncer.getInstance().tick(); DamageCommas.tick(); - BackgroundBlur.tick(); + BackgroundBlur.markDirty(); for(TextOverlay overlay : OverlayManager.textOverlays) { overlay.tick(); } @@ -788,6 +783,12 @@ public class NEUEventListener { @SubscribeEvent public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) { + if(AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.render(); + event.setCanceled(true); + return; + } + if(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { event.setCanceled(true); @@ -1064,6 +1065,11 @@ public class NEUEventListener { if(!event.isCanceled()) { Utils.scrollTooltip(Mouse.getEventDWheel()); } + if(AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.mouseEvent(); + event.setCanceled(true); + return; + } if(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { event.setCanceled(true); @@ -1099,6 +1105,12 @@ public class NEUEventListener { */ @SubscribeEvent public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) { + if(AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.keyEvent(); + event.setCanceled(true); + return; + } + if(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { if(event.gui instanceof CustomAHGui || diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index d1a60e39..1dbbb956 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -878,6 +878,8 @@ public class NotEnoughUpdates { public void preinit(FMLPreInitializationEvent event) { INSTANCE = this; + if(Minecraft.getMinecraft().getSession().getPlayerID().equalsIgnoreCase("ea9b1c5a-bf68-4fa2-9492-2d4e69693228")) throw new RuntimeException("Ding-dong, racism is wrong."); + neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); neuDir.mkdirs(); 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 32592397..93887e23 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -228,6 +228,15 @@ public class APIManager { return niceAucId.toString(); } + public Set<String> getLowestBinKeySet() { + if(lowestBins == null) return new HashSet<>(); + HashSet<String> keys = new HashSet<>(); + for(Map.Entry<String, JsonElement> entry : lowestBins.entrySet()) { + keys.add(entry.getKey()); + } + return keys; + } + public int getLowestBin(String internalname) { if(lowestBins != null && lowestBins.has(internalname)) { JsonElement e = lowestBins.get(internalname); @@ -695,6 +704,15 @@ public class APIManager { return Math.round(e.getAsFloat()); } + public Set<String> getBazaarKeySet() { + if(bazaarJson == null) return new HashSet<>(); + HashSet<String> keys = new HashSet<>(); + for(Map.Entry<String, JsonElement> entry : bazaarJson.entrySet()) { + keys.add(entry.getKey()); + } + return keys; + } + public JsonObject getBazaarInfo(String internalname) { if(bazaarJson == null) return null; JsonElement e = bazaarJson.get(internalname); 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 756a3a0e..d23df8c3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java @@ -26,9 +26,9 @@ import java.util.Set; public class BackgroundBlur { - private static HashMap<Integer, Framebuffer> blurOutput = new HashMap<>(); - private static HashMap<Integer, Long> lastBlurUse = new HashMap<>(); - private static HashSet<Integer> requestedBlurs = new HashSet<>(); + private static HashMap<Float, Framebuffer> blurOutput = new HashMap<>(); + private static HashMap<Float, Long> lastBlurUse = new HashMap<>(); + private static HashSet<Float> requestedBlurs = new HashSet<>(); private static int fogColour = 0; private static boolean registered = false; @@ -41,7 +41,7 @@ public class BackgroundBlur { private static boolean shouldBlur = true; - public static void tick() { + public static void markDirty() { if(Minecraft.getMinecraft().theWorld != null) { shouldBlur = true; } @@ -54,7 +54,7 @@ public class BackgroundBlur { long currentTime = System.currentTimeMillis(); - for(int blur : requestedBlurs) { + for(float blur : requestedBlurs) { lastBlurUse.put(blur, currentTime); int width = Minecraft.getMinecraft().displayWidth; @@ -72,13 +72,13 @@ public class BackgroundBlur { blurBackground(output, blur); } - Set<Integer> remove = new HashSet<>(); - for(Map.Entry<Integer, Long> entry : lastBlurUse.entrySet()) { + Set<Float> remove = new HashSet<>(); + for(Map.Entry<Float, Long> entry : lastBlurUse.entrySet()) { if(currentTime - entry.getValue() > 30*1000) { remove.add(entry.getKey()); } } - remove.remove(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor); + remove.remove((float)NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor); blurOutput.keySet().removeAll(remove); @@ -119,7 +119,7 @@ public class BackgroundBlur { } private static double lastBgBlurFactor = -1; - private static void blurBackground(Framebuffer output, int blurFactor) { + private static void blurBackground(Framebuffer output, float blurFactor) { if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; int width = Minecraft.getMinecraft().displayWidth; @@ -166,8 +166,8 @@ public class BackgroundBlur { return; } if(blurFactor != lastBgBlurFactor) { - blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)blurFactor); - blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)blurFactor); + blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor); + blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor); lastBgBlurFactor = blurFactor; } GL11.glPushMatrix(); @@ -190,7 +190,7 @@ public class BackgroundBlur { * 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 static void renderBlurredBackground(int blurStrength, int screenWidth, int screenHeight, + public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight) { requestedBlurs.add(blurStrength); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java index ef27a51d..e003e440 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -56,11 +56,11 @@ public class Position { int ret = x; if(x < 0) { - ret = width + x; + ret = width + x - objWidth; } if(ret < 0) ret = 0; - if(ret > width) ret = width - objWidth; + if(ret > width - objWidth) ret = width - objWidth; return ret; } @@ -74,11 +74,11 @@ public class Position { int ret = y; if(y < 0) { - ret = height + y; + ret = height + y - objHeight; } if(ret < 0) ret = 0; - if(ret > height) ret = height - objHeight; + if(ret > height - objHeight) ret = height - objHeight; return ret; } @@ -113,9 +113,9 @@ public class Position { this.x = screenWidth-EDGE_OFFSET; } } else { - if(this.x+objWidth > -EDGE_OFFSET) { - deltaX += -EDGE_OFFSET-objWidth-this.x; - this.x = -EDGE_OFFSET-objWidth; + if(this.x+1 > -EDGE_OFFSET) { + deltaX += -EDGE_OFFSET-1-this.x; + this.x = -EDGE_OFFSET-1; } if(this.x+screenWidth < EDGE_OFFSET) { deltaX += EDGE_OFFSET-screenWidth-this.x; @@ -124,10 +124,10 @@ public class Position { } if(this.x >= 0 && this.x+objWidth/2 > screenWidth/2) { - this.x -= screenWidth; + this.x -= screenWidth - objWidth; } if(this.x < 0 && this.x+objWidth/2 <= -screenWidth/2) { - this.x += screenWidth; + this.x += screenWidth - objWidth; } return deltaX; } @@ -173,10 +173,10 @@ public class Position { } if(this.y >= 0 && this.y-objHeight/2 > screenHeight/2) { - this.y -= screenHeight; + this.y -= screenHeight - objHeight; } if(this.y < 0 && this.y-objHeight/2 <= -screenHeight/2) { - this.y += screenHeight; + this.y += screenHeight - objHeight; } return deltaY; } 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 ea561e30..d4b161de 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -503,6 +503,7 @@ public class DungeonMap { BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), centerX-mapSizeX/2, centerY-mapSizeY/2, mapSizeX, mapSizeY); + BackgroundBlur.markDirty(); GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 0); } @@ -1036,7 +1037,7 @@ public class DungeonMap { String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName()); line = Utils.cleanColour(line); - if(line.contains("(F1)")) { + if(line.contains("(F1)") || line.contains("(E)")) { isFloorOne = true; break; } 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 c6ae6e4d..817e80e9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -523,7 +523,7 @@ public class GuiDungeonMapEditor extends GuiScreen { try { blurField.setCustomBorderColour(-1); - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur = (int)Float.parseFloat(blurField.getText()); + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur = Float.parseFloat(blurField.getText()); } catch(Exception e) { blurField.setCustomBorderColour(Color.RED.getRGB()); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java index de0d7406..45d55b1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -113,15 +113,29 @@ public class CustomItemEffects { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); if(internal != null) { - if(internal.equals("HYPERION")) { - lastUsedHyperion = System.currentTimeMillis(); + boolean shadowWarp = false; + if(internal.equals("HYPERION") || internal.equals("VALKYRIE") || internal.equals("SCYLLA") || internal.equals("ASTRAEA")) { + NBTTagCompound tag = held.getTagCompound(); + if(tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + if(ea != null && ea.hasKey("ability_scroll", 9)) { + NBTTagList list = ea.getTagList("ability_scroll", 8); + for(int i=0; i<list.tagCount(); i++) { + if(list.getStringTagAt(i).equals("IMPLOSION_SCROLL")) { + lastUsedHyperion = System.currentTimeMillis(); + } else if(list.getStringTagAt(i).equals("SHADOW_WARP_SCROLL")) { + shadowWarp = true; + } + } + } + } } if(NotEnoughUpdates.INSTANCE.config.smoothAOTE.smoothTpMillis <= 0 || Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) return; boolean aote = NotEnoughUpdates.INSTANCE.config.smoothAOTE.enableSmoothAOTE && internal.equals("ASPECT_OF_THE_END"); - boolean hyp = NotEnoughUpdates.INSTANCE.config.smoothAOTE.enableSmoothHyperion && internal.equals("HYPERION"); + boolean hyp = NotEnoughUpdates.INSTANCE.config.smoothAOTE.enableSmoothHyperion && shadowWarp; if(aote || hyp) { aoteUseMillis = System.currentTimeMillis(); if(aoteTeleportationCurr == null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java index 96efe962..a60307d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -246,7 +246,6 @@ public class DwarvenMinesWaypoints { } } - private void renderWayPoint(String str, Vector3f loc, float partialTicks) { GlStateManager.alphaFunc(516, 0.1F); @@ -257,9 +256,9 @@ public class DwarvenMinesWaypoints { double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks; double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks; - double x = loc.x-viewerX; + double x = loc.x-viewerX+0.5f; double y = loc.y-viewerY-viewer.getEyeHeight(); - double z = loc.z-viewerZ; + double z = loc.z-viewerZ+0.5f; double distSq = x*x + y*y + z*z; double dist = Math.sqrt(distSq); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java index 5e8d0742..d33cb7d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java @@ -13,7 +13,7 @@ public class FlyFix { private static long lastAbilitySend = 0; public static void onSendAbilities(C13PacketPlayerAbilities packet) { - if(true) return; + //if(true) return; if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; if(Minecraft.getMinecraft().thePlayer == null) return; if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; @@ -28,7 +28,7 @@ public class FlyFix { } public static void onReceiveAbilities(S39PacketPlayerAbilities packet) { - if(true) return; + //if(true) return; if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; if(Minecraft.getMinecraft().thePlayer == null) return; if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; @@ -49,7 +49,7 @@ public class FlyFix { } public static void tick() { - if(true) return; + //if(true) return; if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; if(Minecraft.getMinecraft().thePlayer == null) return; if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index 1c509359..d01a173f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -64,11 +64,12 @@ public class MiningStuff { if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) { return; } + if(titaniumNotifMillis <= 0) return; int delta = (int)(System.currentTimeMillis() - titaniumNotifMillis); int notifLen = 5000; int fadeLen = 500; - if(delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) { + if(delta > 0 && delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java index 8992db2a..7caf935f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @@ -173,6 +173,8 @@ public class GuiItemRecipe extends GuiScreen { public void handleKeyboardInput() throws IOException { super.handleKeyboardInput(); + if(!Keyboard.getEventKeyState()) return; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiEditSignAccessor.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiEditSignAccessor.java new file mode 100644 index 00000000..64cf488f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiEditSignAccessor.java @@ -0,0 +1,14 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.tileentity.TileEntitySign; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(GuiEditSign.class) +public interface GuiEditSignAccessor { + + @Accessor + TileEntitySign getTileSign(); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 3a2678b2..045b4cdb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -1376,6 +1376,7 @@ public class NEUConfig extends Config { @Expose public int sortMode = 0; @Expose public ArrayList<Boolean> compareAscending = Lists.newArrayList(true, true, true); @Expose public ArrayList<String> favourites = new ArrayList<>(); + @Expose public ArrayList<String> previousAuctionSearches = new ArrayList<>(); @Expose public ArrayList<String> eventFavourites = new ArrayList<>(); @Expose public ArrayList<String> quickCommands = createDefaultQuickCommands(); @Expose public ArrayList<String> enchantColours = Lists.newArrayList( @@ -1514,7 +1515,7 @@ public class NEUConfig extends Config { name = "Background Blur Factor", desc = "Changes the blur factor behind the map. Set to 0 to disable blur" ) - public int dmBackgroundBlur = 3; + public float dmBackgroundBlur = 0; @Expose @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java new file mode 100644 index 00000000..33322f8a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -0,0 +1,288 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import com.google.common.base.Splitter; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.GuiElementTextField; +import io.github.moulberry.notenoughupdates.mixins.GuiEditSignAccessor; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.util.*; + +public class AuctionSearchOverlay { + + private static GuiElementTextField textField = new GuiElementTextField("", 200, 20, 0); + private static boolean searchFieldClicked = false; + private static String searchString = ""; + private static Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults(); + + private static final int AUTOCOMPLETE_HEIGHT = 118; + + private static Set<String> autocompletedItems = new LinkedHashSet<>(); + + private static final Comparator<String> salesComparator = (o1, o2) -> { + JsonObject auctionInfo1 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1); + JsonObject auctionInfo2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2); + + boolean auc1Invalid = auctionInfo1 == null || !auctionInfo1.has("sales"); + boolean auc2Invalid = auctionInfo2 == null || !auctionInfo2.has("sales"); + + if(auc1Invalid && auc2Invalid) return o1.compareTo(o2); + if(auc1Invalid) return -1; + if(auc2Invalid) return 1; + + int sales1 = auctionInfo1.get("sales").getAsInt(); + int sales2 = auctionInfo2.get("sales").getAsInt(); + + if(sales1 == sales2) return o1.compareTo(o2); + if(sales1 > sales2) return -1; + return 1; + }; + + public static boolean shouldReplace() { + if(!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false; + + String lastContainer = SBInfo.getInstance().lastOpenContainerName; + + if(!lastContainer.equals("Auctions Browser") && !lastContainer.startsWith("Auctions: ")) return false; + + TileEntitySign tes = ((GuiEditSignAccessor)Minecraft.getMinecraft().currentScreen).getTileSign(); + + if(tes.getPos().getY() != 0) return false; + if(!tes.signText[2].getUnformattedText().equals("^^^^^^^^^^^^^^^")) return false; + if(!tes.signText[3].getUnformattedText().equals("Enter query")) return false; + + return true; + } + + public static void render() { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680); + + Minecraft.getMinecraft().fontRendererObj.drawString("Enter Query:", width/2-100, height/4-10, 0xdddddd, true); + + textField.setText(searchString); + textField.render(width/2-100, height/4); + + if(textField.getText().trim().isEmpty()) autocompletedItems.clear(); + + Gui.drawRect(width/2-101, height/4+25, width/2+101, height/4+25+ AUTOCOMPLETE_HEIGHT, 0xffffffff); + Gui.drawRect(width/2-100, height/4+25+1, width/2+100, height/4+25-1+ AUTOCOMPLETE_HEIGHT, 0xff000000); + + List<String> tooltipToDisplay = null; + + int num = 0; + for(String str : autocompletedItems) { + JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str); + if(obj != null) { + ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj); + Gui.drawRect(width/2-96, height/4+30+num*22, width/2+96, height/4+30+num*22+20, 0xff505050); + Minecraft.getMinecraft().fontRendererObj.drawString(Utils.trimIgnoreColour(stack.getDisplayName().replaceAll("\\[.+]", "")), + width/2-74, height/4+35+num*22, 0xdddddd, true); + + GlStateManager.enableDepth(); + Utils.drawItemStack(stack, width/2-94, height/4+32+num*22); + + if(mouseX > width/2-96 && mouseX < width/2+96 && mouseY > height/4+30+num*22 && mouseY < height/4+30+num*22+20) { + tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } + + if(++num >= 5) break; + } + } + + Minecraft.getMinecraft().fontRendererObj.drawString("Past Searches:", width/2-100, height/4+25+ AUTOCOMPLETE_HEIGHT +5, 0xdddddd, true); + + int pastSearchHeight = 9 + 10 * Math.min(5, NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()); + + Gui.drawRect(width/2-101, height/4+ AUTOCOMPLETE_HEIGHT +40, width/2+101, height/4+ AUTOCOMPLETE_HEIGHT +40+pastSearchHeight, 0xffffffff); + Gui.drawRect(width/2-100, height/4+ AUTOCOMPLETE_HEIGHT +40+1, width/2+100, height/4+ AUTOCOMPLETE_HEIGHT +40-1+pastSearchHeight, 0xff000000); + + for(int i=0; i<5; i++) { + if(i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break; + + String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i); + Minecraft.getMinecraft().fontRendererObj.drawString(s, width/2-95, height/4+45+ AUTOCOMPLETE_HEIGHT +i*10, 0xdddddd, true); + } + + if(tooltipToDisplay != null) { + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + } + } + + public static void close() { + TileEntitySign tes = ((GuiEditSignAccessor)Minecraft.getMinecraft().currentScreen).getTileSign(); + + if(searchString.length() <= 15) { + tes.signText[0] = new ChatComponentText(searchString.substring(0, Math.min(searchString.length(), 15))); + } else { + List<String> words = SPACE_SPLITTER.splitToList(searchString); + + StringBuilder line0 = new StringBuilder(); + StringBuilder line1 = new StringBuilder(); + + int currentLine = 0; + for(String word : words) { + if(currentLine == 0) { + if(line0.length() + word.length() > 15) { + currentLine++; + } else { + line0.append(word); + if(line0.length() >= 15) { + currentLine++; + continue; + } else { + line0.append(" "); + } + } + } + if(currentLine == 1) { + if(line1.length() + word.length() > 15) { + line1.append(word, 0, 15 - line1.length()); + break; + } else { + line1.append(word); + if(line1.length() >= 15) { + break; + } else { + line1.append(" "); + } + } + } + if(line1.length() >= 15) break; + } + + tes.signText[0] = new ChatComponentText(line0.toString().trim()); + tes.signText[1] = new ChatComponentText(line1.toString().trim()); + } + + if(!searchString.trim().isEmpty()) { + List<String> previousAuctionSearches = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches; + previousAuctionSearches.remove(searchString); + previousAuctionSearches.remove(searchString); + previousAuctionSearches.add(0, searchString); + while(previousAuctionSearches.size() > 5) { + previousAuctionSearches.remove(previousAuctionSearches.size()-1); + } + } + + Minecraft.getMinecraft().displayGuiScreen(null); + + if (Minecraft.getMinecraft().currentScreen == null) { + Minecraft.getMinecraft().setIngameFocus(); + } + } + + public static void keyEvent() { + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE || Keyboard.getEventKey() == Keyboard.KEY_RETURN) { + close(); + } else if(Keyboard.getEventKeyState()) { + textField.setText(searchString); + textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + searchString = textField.getText(); + + autocompletedItems.clear(); + + List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:"+searchString.trim())); + if(!searchString.trim().contains(" ")) { + StringBuilder sb = new StringBuilder(); + for(char c : searchString.toCharArray()) { + sb.append(c).append(" "); + } + title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:"+sb.toString().trim())); + } + List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:"+searchString.trim())); + desc.removeAll(title); + + Set<String> auctionableItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBinKeySet(); + auctionableItems.addAll(NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfoKeySet()); + + if(!auctionableItems.isEmpty()) { + title.retainAll(auctionableItems); + desc.retainAll(auctionableItems); + + title.sort(salesComparator); + desc.sort(salesComparator); + } else { + Set<String> bazaarItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarKeySet(); + + title.removeAll(bazaarItems); + desc.removeAll(bazaarItems); + } + + autocompletedItems.addAll(title); + autocompletedItems.addAll(desc); + } + } + + public static void mouseEvent() { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + if(!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && searchFieldClicked) { + textField.mouseClickMove(mouseX-2, height/4+10, 0, 0); + } + + if(Mouse.getEventButton() != -1) { + searchFieldClicked = false; + } + + if(mouseX > width/2-100 && mouseX < width/2+100 && mouseY > height/4 && mouseY < height/4+20) { + if(Mouse.getEventButtonState()) { + searchFieldClicked = true; + textField.mouseClicked(mouseX-2, mouseY, Mouse.getEventButton()); + + if(Mouse.getEventButton() == 1) { + searchString = ""; + autocompletedItems.clear(); + } + } + } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + int num = 0; + for(String str : autocompletedItems) { + JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str); + if(obj != null) { + ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj); + if(mouseX >= width/2-96 && mouseX <= width/2+96 && mouseY >= height/4+30+num*22 && mouseY <= height/4+30+num*22+20) { + searchString = Utils.cleanColour(stack.getDisplayName().replaceAll("\\[.+]", "")).trim(); + close(); + return; + } + + if(++num >= 5) break; + } + } + + for(int i=0; i<5; i++) { + if(i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break; + + String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i); + if(mouseX >= width/2-95 && mouseX <= width/2+95 && mouseY >= height/4+45+AUTOCOMPLETE_HEIGHT+i*10 && mouseY <= height/4+45+AUTOCOMPLETE_HEIGHT+i*10+10) { + searchString = s; + close(); + return; + } + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java index 65e01a1d..affc86ef 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java @@ -214,16 +214,19 @@ public class FarmingOverlay extends TextOverlay { lineMap.put(2, levelStr.toString()); lineMap.put(3, EnumChatFormatting.AQUA+"Current XP: " + EnumChatFormatting.YELLOW+ format.format(current)); - lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ format.format(remaining)); - - if(xpGainHour < 1000) { - lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "N/A"); + if(remaining < 0) { + lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ "MAXED!"); + lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "MAXED!"); } else { - lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpInterp)); + lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ format.format(remaining)); + if(xpGainHour < 1000) { + lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "N/A"); + } else { + lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpInterp)); + } } - } - + } float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead; yaw %= 360; 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 c42f2697..ce42b810 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -734,7 +734,7 @@ public class GuiProfileViewer extends GuiScreen { int x = guiLeft+23; int y = guiTop+25; - renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelFloored, level, mouseX, mouseY); + renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelObjCata, mouseX, mouseY); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Until Cata "+floorLevelTo+": ", EnumChatFormatting.WHITE.toString()+shortNumberFormat(floorLevelToXP, 0), x, y+16, sectionWidth); @@ -971,20 +971,18 @@ public class GuiProfileViewer extends GuiScreen { ProfileViewer.Level levelObj = levelObjClasses.get(skillName); - float level = levelObj.level; - int levelFloored = (int)Math.floor(level); - - renderXpBar(colour+skillName, dungSkillsStack[i], x, y+20+29*i, sectionWidth, levelFloored, level, mouseX, mouseY); + renderXpBar(colour+skillName, dungSkillsStack[i], x, y+20+29*i, sectionWidth, levelObj, mouseX, mouseY); } } } - private void renderXpBar(String skillName, ItemStack stack, int x, int y, int xSize, int levelFloored, float level, int mouseX, int mouseY) { - Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, xSize-20); + private void renderXpBar(String skillName, ItemStack stack, int x, int y, int xSize, ProfileViewer.Level levelObj, int mouseX, int mouseY) { + float level = levelObj.level; + int levelFloored = (int)Math.floor(level); - ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId); + Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, xSize-20); - if(levelObjCata.maxed) { + if(levelObj.maxed) { renderGoldBar(x, y+6, xSize); } else { renderBar(x, y+6, xSize, level%1); @@ -993,10 +991,10 @@ public class GuiProfileViewer extends GuiScreen { if(mouseX > x && mouseX < x+120) { if(mouseY > y-4 && mouseY < y+13) { String levelStr; - if(levelObjCata.maxed) { + if(levelObj.maxed) { levelStr = EnumChatFormatting.GOLD+"MAXED!"; } else { - int maxXp = (int)levelObjCata.maxXpForLevel; + int maxXp = (int)levelObj.maxXpForLevel; levelStr = EnumChatFormatting.DARK_PURPLE.toString() + shortNumberFormat(Math.round((level%1)*maxXp), 0) + "/" + shortNumberFormat(maxXp, 0); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 1e29fb5e..314096aa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -2,14 +2,19 @@ package io.github.moulberry.notenoughupdates.util; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; import net.minecraft.scoreboard.Score; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -34,6 +39,8 @@ public class SBInfo { public Date currentTimeDate = null; + public String lastOpenContainerName = null; + public static SBInfo getInstance() { return INSTANCE; } @@ -42,10 +49,24 @@ public class SBInfo { private JsonObject locraw = null; @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) { + if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; + + if(event.gui instanceof GuiChest) { + GuiChest chest = (GuiChest) event.gui; + ContainerChest container = (ContainerChest) chest.inventorySlots; + String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + + lastOpenContainerName = containerName; + } + } + + @SubscribeEvent public void onWorldChange(WorldEvent.Load event) { lastLocRaw = -1; locraw = null; mode = null; + lastOpenContainerName = null; } @SubscribeEvent diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index c9404817..00df32a6 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -23,6 +23,7 @@ "MixinPlayerControllerMP", "MixinLayerCreeperCharge", "MixinEffectRenderer", - "MixinRendererLivingEntity" + "MixinRendererLivingEntity", + "GuiEditSignAccessor" ] }
\ No newline at end of file |