diff options
author | BuildTools <james.jenour@protonmail.com> | 2021-02-20 23:37:59 +0800 |
---|---|---|
committer | BuildTools <james.jenour@protonmail.com> | 2021-02-20 23:37:59 +0800 |
commit | 06cb4d208801e276a0e4d96252c00ae01d9e522d (patch) | |
tree | edb9ea57e98398c004433be0b9a7fd7ce324b385 /src/main | |
parent | de834a97505c66b5655ee7ff91e78e84da3f81f3 (diff) | |
download | NotEnoughUpdates-06cb4d208801e276a0e4d96252c00ae01d9e522d.tar.gz NotEnoughUpdates-06cb4d208801e276a0e4d96252c00ae01d9e522d.tar.bz2 NotEnoughUpdates-06cb4d208801e276a0e4d96252c00ae01d9e522d.zip |
charzard just 4 u
Diffstat (limited to 'src/main')
51 files changed, 1782 insertions, 800 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 401898d2..58efa371 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -28,14 +28,7 @@ public class ItemPriceInformation { NumberFormat format = NumberFormat.getInstance(Locale.US); if(bazaarItem) { - int[] lines = { - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line1, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line2, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line3, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line4, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line5, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line6 - }; + List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz; boolean added = false; @@ -51,8 +44,6 @@ public class ItemPriceInformation { for(int lineId : lines) { switch (lineId) { case 0: - continue; - case 1: if(bazaarInfo.has("avg_buy")) { if(!added) { tooltip.add(""); @@ -64,7 +55,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); } break; - case 2: + case 1: if(bazaarInfo.has("avg_sell")) { if(!added) { tooltip.add(""); @@ -76,7 +67,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); } break; - case 3: + case 2: if(bazaarInfo.has("curr_buy")) { if(!added) { tooltip.add(""); @@ -88,7 +79,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); } break; - case 4: + case 3: if(bazaarInfo.has("curr_sell")) { if(!added) { tooltip.add(""); @@ -100,7 +91,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); } break; - case 5: + case 4: if(craftCost.fromRecipe) { if(!added) { tooltip.add(""); @@ -115,22 +106,13 @@ public class ItemPriceInformation { return added; } else if(auctionItem) { - int[] lines = { - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line1, - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line2, - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line3, - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line4, - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line5, - NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line6 - }; + List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc; boolean added = false; for(int lineId : lines) { switch (lineId) { case 0: - continue; - case 1: if(lowestBin > 0) { if(!added) { tooltip.add(""); @@ -140,7 +122,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); } break; - case 2: + case 1: if(auctionInfo != null) { if(!added) { tooltip.add(""); @@ -159,7 +141,7 @@ public class ItemPriceInformation { } break; - case 3: + case 2: if(auctionInfo != null) { if(!added) { tooltip.add(""); @@ -176,7 +158,7 @@ public class ItemPriceInformation { } } break; - case 4: + case 3: if(craftCost.fromRecipe) { if(!added) { tooltip.add(""); @@ -186,7 +168,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); } break; - case 5: + case 4: if(lowestBinAvg > 0) { if(!added) { tooltip.add(""); @@ -196,7 +178,7 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBinAvg)+" coins"); } break; - case 6: + case 5: if(Constants.ESSENCECOSTS == null) break; JsonObject essenceCosts = Constants.ESSENCECOSTS; if(!essenceCosts.has(internalname)) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 4ba2cba9..838f0b0a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -185,7 +185,7 @@ public class NEUEventListener { longUpdate = true; lastLongUpdate = currentTime; } - if(!neu.config.dungeonBlock.slowDungeonBlocks) { + if(!neu.config.dungeons.slowDungeonBlocks) { DungeonBlocks.tick(); } DungeonWin.tick(); @@ -254,7 +254,7 @@ public class NEUEventListener { NotEnoughUpdates.profileViewer.putNameUuid(Minecraft.getMinecraft().thePlayer.getName(), Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")); - if(neu.config.dungeonBlock.slowDungeonBlocks) { + if(neu.config.dungeons.slowDungeonBlocks) { DungeonBlocks.tick(); } @@ -287,7 +287,7 @@ public class NEUEventListener { displayUpdateMessageIfOutOfDate(); } - if(neu.config.hidden.doRamNotif) { + if(neu.config.notifications.doRamNotif) { long maxMemoryMB = Runtime.getRuntime().maxMemory()/1024L/1024L; if(maxMemoryMB > 4100) { notificationDisplayMillis = System.currentTimeMillis(); @@ -295,9 +295,9 @@ public class NEUEventListener { notificationLines.add(EnumChatFormatting.DARK_RED+"Too much memory allocated!"); notificationLines.add(String.format(EnumChatFormatting.DARK_GRAY+"NEU has detected %03dMB of memory allocated to Minecraft!", maxMemoryMB)); notificationLines.add(EnumChatFormatting.DARK_GRAY+"It is recommended to allocated between 2-4GB of memory"); - notificationLines.add(EnumChatFormatting.DARK_GRAY+"More than 4GB WILL cause FPS issues, EVEN if you have 16GB+ available"); + notificationLines.add(EnumChatFormatting.DARK_GRAY+"More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available"); notificationLines.add(""); - notificationLines.add(EnumChatFormatting.DARK_GRAY+"For more information, visit #ram-info in discord.gg/spr6ESn"); + notificationLines.add(EnumChatFormatting.DARK_GRAY+"For more information, visit #ram-info in discord.gg/moulberry"); } } @@ -884,9 +884,9 @@ public class NEUEventListener { } private void renderDungeonChestOverlay(GuiScreen gui) { - if(neu.config.dungeonProfit.profitDisplayLoc == 3) return; + if(neu.config.dungeons.profitDisplayLoc == 3) return; - if(gui instanceof GuiChest && neu.config.dungeonProfit.profitDisplayLoc != 2) { + if(gui instanceof GuiChest && neu.config.dungeons.profitDisplayLoc != 2) { try { int xSize = (int) Utils.getField(GuiContainer.class, gui, "xSize", "field_146999_f"); int ySize = (int) Utils.getField(GuiContainer.class, gui, "ySize", "field_147000_g"); @@ -933,7 +933,7 @@ public class NEUEventListener { if(bazaarPrice > 0) { worth = bazaarPrice; } else { - switch(neu.config.dungeonProfit.profitType) { + switch(neu.config.dungeons.profitType) { case 1: worth = neu.manager.auctionManager.getItemAvgBin(internal); break; @@ -1025,7 +1025,7 @@ public class NEUEventListener { plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; } - if(neu.config.dungeonProfit.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) { + if(neu.config.dungeons.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) { int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(plStringBIN); GlStateManager.disableLighting(); GlStateManager.translate(0, 0, 200); @@ -1729,7 +1729,7 @@ public class NEUEventListener { } } - if(neu.config.dungeonProfit.profitDisplayLoc == 2 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + if(neu.config.dungeons.profitDisplayLoc == 2 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { if(line.contains(EnumChatFormatting.GREEN+"Open Reward Chest")) { dungeonProfit = true; } else if(index == 7 && dungeonProfit) { @@ -1771,7 +1771,7 @@ public class NEUEventListener { if(bazaarPrice > 0) { worth = bazaarPrice; } else { - switch(neu.config.dungeonProfit.profitType) { + switch(neu.config.dungeons.profitType) { case 1: worth = neu.manager.auctionManager.getItemAvgBin(internal); break; @@ -1886,6 +1886,16 @@ public class NEUEventListener { event.toolTip.clear(); event.toolTip.addAll(newTooltip); + HashMap<String, List<String>> loreBuckets = new HashMap<>(); + + List<String> hypixelOrder = new ArrayList<>(); + + hypixelOrder.add("attributes"); + hypixelOrder.add("enchants"); + hypixelOrder.add("ability"); + hypixelOrder.add("reforge_bonus"); + hypixelOrder.add("rarity"); + if(neu.config.tooltipTweaks.showPriceInfoInvItem) { ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index bbaa08db..061d6774 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.HypixelApi; +import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; @@ -25,9 +26,6 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -105,16 +103,8 @@ public class NEUManager { this.currentProfile = currentProfile; } - public void setCurrentProfileBackup(String currentProfile) { - this.currentProfileBackup = currentProfile; - } - public String getCurrentProfile() { - if(currentProfile == null || currentProfile.length() == 0) { - return currentProfileBackup; - } else { - return currentProfile; - } + return SBInfo.getInstance().currentProfile; } public void saveItemRenameConfig() { @@ -606,11 +596,11 @@ public class NEUManager { */ public <T> Map<String, T> subMapWithKeysThatAreSuffixes(String prefix, NavigableMap<String, T> map) { if ("".equals(prefix)) return map; - String lastKey = createLexicographicallyNextStringOfTheSameLenght(prefix); + String lastKey = createLexicographicallyNextStringOfTheSameLength(prefix); return map.subMap(prefix, true, lastKey, false); } - String createLexicographicallyNextStringOfTheSameLenght(String input) { + public String createLexicographicallyNextStringOfTheSameLength(String input) { final int lastCharPosition = input.length()-1; String inputWithoutLastChar = input.substring(0, lastCharPosition); char lastChar = input.charAt(lastCharPosition) ; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index a87d266a..689a98f1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1732,7 +1732,7 @@ public class NEUOverlay extends Gui { BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor, width, height, leftSide+getBoxPadding()-5, getBoxPadding()-5, - paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10); + paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10, true); Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10, getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 447dc8d1..59c821b0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -690,6 +690,7 @@ public class NotEnoughUpdates { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++])); return; } + if(args.length == 1 && args[0].equalsIgnoreCase("dev")) NotEnoughUpdates.INSTANCE.config.hidden.dev = true; Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code")); /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0; Minecraft.getMinecraft().thePlayer.rotationPitch = 0; @@ -876,6 +877,23 @@ public class NotEnoughUpdates { SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { + if(Loader.isModLoaded("optifine") && + new File(Minecraft.getMinecraft().mcDataDir, "optionsof.txt").exists()) { + try(InputStream in = new FileInputStream(new File(Minecraft.getMinecraft().mcDataDir, "optionsof.txt"))) { + BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + + String line; + while((line = reader.readLine()) != null) { + if(line.contains("ofFastRender:true")) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + + "NEU cosmetics do not work with OF Fast Render. Go to Video > Performance to disable it.")); + return; + } + } + } catch(Exception e) { + } + } + openGui = new GuiCosmetics(); } }); @@ -972,6 +990,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new FuelBar()); MinecraftForge.EVENT_BUS.register(XPInformation.getInstance()); MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); + MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); 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 b0f0bff3..bc8ea93a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.core; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; @@ -28,6 +29,7 @@ public class BackgroundBlur { private static HashMap<Float, Framebuffer> blurOutput = new HashMap<>(); private static HashMap<Float, Long> lastBlurUse = new HashMap<>(); + private static long lastBlur = 0; private static HashSet<Float> requestedBlurs = new HashSet<>(); private static int fogColour = 0; @@ -47,14 +49,14 @@ public class BackgroundBlur { } } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onScreenRender(RenderGameOverlayEvent.Pre event) { - if(shouldBlur && event.type == RenderGameOverlayEvent.ElementType.ALL) { + public static void processBlurs() { + if(shouldBlur) { shouldBlur = false; long currentTime = System.currentTimeMillis(); for(float blur : requestedBlurs) { + lastBlur = currentTime; lastBlurUse.put(blur, currentTime); int width = Minecraft.getMinecraft().displayWidth; @@ -87,6 +89,13 @@ public class BackgroundBlur { } } + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onScreenRender(RenderGameOverlayEvent.Pre event) { + if(event.type == RenderGameOverlayEvent.ElementType.ALL) { + processBlurs(); + } + } + @SubscribeEvent public void onFogColour(EntityViewRenderEvent.FogColors event) { fogColour = 0xff000000; @@ -146,9 +155,6 @@ public class BackgroundBlur { Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); } - /*if(blurShaderHorz == null) { - - }*/ try { blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); @@ -172,9 +178,9 @@ public class BackgroundBlur { GL11.glPushMatrix(); /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); - GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, blurOutputVert.framebufferObject); + GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject); GL30.glBlitFramebuffer(0, 0, width, height, - 0, 0, width, height, + 0, 0, output.framebufferWidth, output.framebufferHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);*/ blurShaderHorz.loadShader(0); @@ -186,22 +192,31 @@ public class BackgroundBlur { } } + public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, + int x, int y, int blurWidth, int blurHeight) { + renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, 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 static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, - int x, int y, int blurWidth, int blurHeight) { + int x, int y, int blurWidth, int blurHeight, boolean forcedUpdate) { + if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; if(blurStrength < 0.5) return; requestedBlurs.add(blurStrength); - if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; + long currentTime = System.currentTimeMillis(); + if(currentTime - lastBlur > 300) { + shouldBlur = true; + if(currentTime - lastBlur > 400 && forcedUpdate) return; + } if(blurOutput.isEmpty()) return; Framebuffer fb = blurOutput.get(blurStrength); if(fb == null) { - System.out.println("Blur not found:"+blurStrength); fb = blurOutput.values().iterator().next(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java new file mode 100644 index 00000000..54d3e345 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java @@ -0,0 +1,14 @@ +package io.github.moulberry.notenoughupdates.core.config.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ConfigAccordionId { + + int id(); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java new file mode 100644 index 00000000..47948985 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java @@ -0,0 +1,14 @@ +package io.github.moulberry.notenoughupdates.core.config.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ConfigEditorAccordion { + + int id(); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java new file mode 100644 index 00000000..79667ff8 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java @@ -0,0 +1,86 @@ +package io.github.moulberry.notenoughupdates.core.config.gui; + +import io.github.moulberry.notenoughupdates.core.config.Config; +import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex; + +public class GuiOptionEditorAccordion extends GuiOptionEditor { + + private int accordionId; + private boolean accordionToggled; + + public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) { + super(option); + this.accordionToggled = (boolean) option.get(); + this.accordionId = accordionId; + } + + @Override + public int getHeight() { + return 20; + } + + public int getAccordionId() { + return accordionId; + } + + public boolean getToggled() { + return accordionToggled; + } + + @Override + public void render(int x, int y, int width) { + int height = getHeight(); + RenderUtils.drawFloatingRectDark(x, y, width, height, true); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(1, 1, 1, 1); + worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); + if(accordionToggled) { + worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex(); + worldrenderer.pos((double)x+9.75f, (double)y+13.5f, 0.0D).endVertex(); + worldrenderer.pos((double)x+13.5f, (double)y+6, 0.0D).endVertex(); + } else { + worldrenderer.pos((double)x+6, (double)y+13.5f, 0.0D).endVertex(); + worldrenderer.pos((double)x+13.5f, (double)y+9.75f, 0.0D).endVertex(); + worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + + TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj, + x+18, y+6, false, width-10, 0xc0c0c0); + } + + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + if(Mouse.getEventButtonState() && mouseX > x && mouseX < x+ width && + mouseY > y && mouseY < y+getHeight()) { + accordionToggled = !accordionToggled; + return true; + } + + return false; + } + + @Override + public boolean keyboardInput() { + return false; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java index 103a8c92..03c5bc6c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java index 2f2e1fdb..794d4837 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java @@ -29,6 +29,8 @@ public class ConfigProcessor { public final int subcategoryId; public GuiOptionEditor editor; + public int accordionId = -1; + private final Field field; private final Object container; @@ -87,10 +89,9 @@ public class ConfigProcessor { processedConfig.put(categoryField.getName(), cat); for(Field optionField : categoryObj.getClass().getDeclaredFields()) { - boolean optionExposePresent = optionField.isAnnotationPresent(Expose.class); boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class); - if(optionExposePresent && optionPresent) { + if(optionPresent) { ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class); ProcessedOption option = new ProcessedOption( optionAnnotation.name(), @@ -99,6 +100,10 @@ public class ConfigProcessor { optionField, categoryObj ); + if(optionField.isAnnotationPresent(ConfigAccordionId.class)) { + ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class); + option.accordionId = annotation.id(); + } GuiOptionEditor editor = null; Class<?> optionType = optionField.getType(); @@ -110,6 +115,11 @@ public class ConfigProcessor { optionField.isAnnotationPresent(ConfigEditorBoolean.class)) { editor = new GuiOptionEditorBoolean(option); } + if(optionType.isAssignableFrom(boolean.class) && + optionField.isAnnotationPresent(ConfigEditorAccordion.class)) { + ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class); + editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id()); + } if(optionType.isAssignableFrom(int.class)) { if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); @@ -154,8 +164,6 @@ public class ConfigProcessor { } option.editor = editor; cat.options.put(optionField.getName(), option); - } else if(optionExposePresent || optionPresent) { - //System.err.printf("Failed to load config option %s. Both @Expose and @ConfigOption must be present.\n", optionField.getName()); } } } else if(exposePresent || categoryPresent) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java index 516169c9..b3dd9d6f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java @@ -54,6 +54,10 @@ public class LerpingInteger { this.lastMillis = System.currentTimeMillis(); } + public void setTimeToReachTarget(int timeToReachTarget) { + this.timeToReachTarget = timeToReachTarget; + } + public void setTarget(int targetValue) { this.targetValue = targetValue; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index b3aa8c97..a43eb0e6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java @@ -24,7 +24,7 @@ public class RenderUtils { if(OpenGlHelper.isFramebufferEnabled()) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); BackgroundBlur.renderBlurredBackground(15, scaledResolution.getScaledWidth(), - scaledResolution.getScaledHeight(), x, y, width, height); + scaledResolution.getScaledHeight(), x, y, width, height, true); } else { alpha = 0xff000000; } 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 6bd8418d..5a453247 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.RenderWorldEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.apache.commons.lang3.ArrayUtils; @@ -46,8 +47,8 @@ public class CapeManager { public JsonObject lastJsonSync = null; private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", - "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false, true }; + "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf", "soldier" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false, true, true }; public static CapeManager getInstance() { return INSTANCE; @@ -196,6 +197,11 @@ public class CapeManager { } @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + if(playerMap != null) playerMap.clear(); + } + + @SubscribeEvent public void onRenderPlayer(RenderPlayerEvent.Post e) { if(e.partialRenderTick == 1.0F) return; //rendering in inventory diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index 3f84f8fc..07162a77 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -16,6 +16,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import java.awt.*; +import java.math.BigInteger; import java.util.List; import java.util.*; @@ -271,17 +272,37 @@ public class GuiCosmetics extends GuiScreen { null, true); lastCapeEquip = System.currentTimeMillis(); - if(wantToEquipCape == null) { - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType=null&accessToken="+ - Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> { System.out.println(jsonObject); }, () -> { - System.out.println("change cape error"); - }); - } else { - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType="+wantToEquipCape+"&accessToken="+ - Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> { System.out.println(jsonObject); }, () -> { - System.out.println("change cape error"); - }); + + try { + String userName = Minecraft.getMinecraft().thePlayer.getName(); + String accessToken = Minecraft.getMinecraft().getSession().getToken(); + Random r1 = new Random(); + Random r2 = new Random(System.identityHashCode(new Object())); + BigInteger random1Bi = new BigInteger(128, r1); + BigInteger random2Bi = new BigInteger(128, r2); + BigInteger serverBi = random1Bi.xor(random2Bi); + String serverId = serverBi.toString(16); + Minecraft.getMinecraft().getSessionService().joinServer(Minecraft.getMinecraft().getSession().getProfile(), accessToken, serverId); + + //System.out.println("Joined with serverId="+serverId); + + if(wantToEquipCape == null) { + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType=null&serverId="+ + serverId+"&username="+userName, (jsonObject) -> { System.out.println(jsonObject); }, () -> { + System.out.println("Change cape error"); + }); + } else { + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType="+wantToEquipCape+"&serverId="+ + serverId+"&username="+userName, (jsonObject) -> { System.out.println(jsonObject); }, () -> { + System.out.println("Change cape error"); + }); + } + } catch(Exception e) { + System.out.println("Exception while generating mojang shared secret"); + e.printStackTrace(); } + + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index 927ef8cf..3814e2ba 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -61,6 +61,7 @@ public class NEUCape { public static float targetDist = 1/20f; private EntityPlayer currentPlayer; + private boolean keepCurrentPlayer = false; private String shaderName = "cape"; @@ -364,6 +365,8 @@ public class NEUCape { GlStateManager.enableTexture2D(); GlStateManager.enableDepth(); GlStateManager.disableCull(); + GlStateManager.disableLighting(); + GlStateManager.color(1, 1, 1, 1); if(shaderName.equals("mcworld_cape")) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); @@ -393,12 +396,13 @@ public class NEUCape { lastRender = System.currentTimeMillis(); } - private boolean notRendering = false; public void onTick(TickEvent.ClientTickEvent event, EntityPlayer player) { if(player == null) return; + if(Minecraft.getMinecraft().isGamePaused()) return; if(System.currentTimeMillis() - lastRender < 500) { - if(currentPlayer == null) { + if(currentPlayer == null || !keepCurrentPlayer) { + keepCurrentPlayer = true; currentPlayer = player; } else if(currentPlayer != player) { return; @@ -415,12 +419,8 @@ public class NEUCape { } } updateCape(player); - - notRendering = false; } else { - currentPlayer = null; - - notRendering = true; + keepCurrentPlayer = false; } } @@ -490,8 +490,6 @@ public class NEUCape { } } - TexLoc tl = new TexLoc(10, 75, Keyboard.KEY_M); - private double deltaAngleAccum; private double oldPlayerAngle; private int crouchTicks = 0; @@ -514,19 +512,6 @@ public class NEUCape { } } - if(notRendering) { - for (int y = 0; y < nodes.size(); y++) { - for (int x = 0; x < nodes.get(y).size(); x++) { - CapeNode node = nodes.get(y).get(x); - if(!node.fixed) { - Vector3f.add(node.position, capeTranslation, node.position); - node.lastPosition.set(node.position); - node.renderPosition.set(node.position); - } - } - } - } - double playerAngle = Math.toRadians(player.renderYawOffset); double deltaAngle = playerAngle - oldPlayerAngle; if(deltaAngle > Math.PI) { @@ -543,8 +528,6 @@ public class NEUCape { float factor = (float)(deltaAngleAccum*deltaAngleAccum); - tl.handleKeyboardInput(); - float capeTransLength = capeTranslation.length(); float capeTranslationFactor = 0f; @@ -715,10 +698,35 @@ public class NEUCape { private void renderCape(EntityPlayer player, float partialRenderTick) { ensureCapeNodesCreated(player); - if(System.currentTimeMillis() - lastRender > 500) { - updateCape(player); - } + + Vector3f avgPositionFixedBefore = avgFixedRenderPosition(); updateFixedCapeNodesPartial(player, partialRenderTick); + Vector3f avgPositionFixed = avgFixedRenderPosition(); + Vector3f delta = Vector3f.sub(avgPositionFixed, avgPositionFixedBefore, null); + + if(delta.lengthSquared() > 9) { + updateFixedCapeNodes(player); + + for(int y=0; y<nodes.size(); y++) { + for(int x=0; x<nodes.get(y).size(); x++) { + CapeNode node = nodes.get(y).get(x); + if(!node.fixed) { + Vector3f.add(node.renderPosition, delta, node.renderPosition); + node.position.set(node.renderPosition); + node.lastPosition.set(node.renderPosition); + } else { + node.lastPosition.set(node.position); + } + } + } + + for(int y=0; y<nodes.size(); y++) { + for(int x=0; x<nodes.get(y).size(); x++) { + nodes.get(y).get(x).renderNode(); + } + } + return; + } for(int y=0; y<nodes.size(); y++) { for(int x=0; x<nodes.get(y).size(); x++) { @@ -728,22 +736,22 @@ public class NEUCape { if(node.fixed) continue; - Vector3f avgPositionFixed = avgFixedRenderPosition(); - Vector3f newPosition = new Vector3f(); newPosition.x = node.lastPosition.x + (node.position.x - node.lastPosition.x) * partialRenderTick; newPosition.y = node.lastPosition.y + (node.position.y - node.lastPosition.y) * partialRenderTick; newPosition.z = node.lastPosition.z + (node.position.z - node.lastPosition.z) * partialRenderTick; int length = node.oldRenderPosition.length; + int fps = Minecraft.getDebugFPS(); if(fps < 50) { length = 2; } else if(fps < 100) { - length = 2+(int)((fps-50)/50f*3); + length = 2 + (int)((fps-50)/50f*3); } if(node.oldRenderPosition[length-1] == null) { + Arrays.fill(node.oldRenderPosition, Vector3f.sub(newPosition, avgPositionFixed, null)); node.renderPosition = newPosition; } else { Vector3f accum = new Vector3f(); @@ -751,7 +759,7 @@ public class NEUCape { Vector3f.add(accum, node.oldRenderPosition[i], accum); Vector3f.add(accum, avgPositionFixed, accum); } - accum.scale(1/(float)length); + accum.scale(1/(float)(length)); float blendFactor = 0.5f+0.3f*y/(float)(nodes.size()-1); //0.5/0.5 -> 0.8/0.2 //0-1 accum.scale(blendFactor); @@ -760,11 +768,13 @@ public class NEUCape { node.renderPosition = accum; } - for(int i=node.oldRenderPosition.length-1; i>=0; i--) { - if(i > 0) { - node.oldRenderPosition[i] = node.oldRenderPosition[i-1]; - } else { - node.oldRenderPosition[i] = Vector3f.sub(node.renderPosition, avgPositionFixed, null); + if(!Minecraft.getMinecraft().isGamePaused()) { + for(int i=node.oldRenderPosition.length-1; i>=0; i--) { + if(i > 0) { + node.oldRenderPosition[i] = node.oldRenderPosition[i-1]; + } else { + node.oldRenderPosition[i] = Vector3f.sub(node.renderPosition, avgPositionFixed, null); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java index 6fd3db78..890155e8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java @@ -42,8 +42,8 @@ public class DungeonBlocks { } public static boolean isOverriding() { - return OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.dungeonBlock.enableDungBlockOverlay && - (NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungeonBlocksEverywhere || + return OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.dungeons.enableDungBlockOverlay && + (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonBlocksEverywhere || (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))); } @@ -141,15 +141,15 @@ public class DungeonBlocks { static { dynamicPreloadMap.put(new ResourceLocation("textures/entity/bat.png"), - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungBatColour); + NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour); dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal.png"), - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungChestColour); + NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour); dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal_double.png"), - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungChestColour); + NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour); dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped.png"), - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungTrappedChestColour); + NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour); dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped_double.png"), - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungTrappedChestColour); + NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour); } public static void tick() { @@ -192,13 +192,13 @@ public class DungeonBlocks { HashMap<TextureAtlasSprite, Integer> spriteMap = new HashMap<>(); spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"), - SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungCrackedColour)); + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungCrackedColour)); spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"), - SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungDispenserColour)); + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungDispenserColour)); spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"), - SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungLeverColour)); + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungLeverColour)); spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"), - SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungTripWireColour)); + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungTripWireColour)); for(Map.Entry<TextureAtlasSprite, Integer> entry : spriteMap.entrySet()) { if(((entry.getValue() >> 24) & 0xFF) < 10) continue; 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 019fe9ee..8a591398 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -19,6 +19,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemMap; @@ -88,6 +89,7 @@ public class DungeonMap { private Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>(); private Set<MapPosition> rawPlayerMarkerMapPositions = new HashSet<>(); private Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>(); + private HashMap<String, Integer> playerIdMap = new HashMap<>(); private Map<String, ResourceLocation> playerSkinMap = new HashMap<>(); @@ -655,7 +657,7 @@ public class DungeonMap { pixelWidth = pixelHeight = 12; } GlStateManager.color(1, 1, 1, 1); - if((!NotEnoughUpdates.INSTANCE.config.dungeonMapOpen.showOwnHeadAsMarker || + if((!NotEnoughUpdates.INSTANCE.config.dungeons.showOwnHeadAsMarker || playerMarkerMapPositions.size() <= 1 || minU != 1/4f) && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 && playerSkinMap.containsKey(entry.getKey())) { @@ -818,6 +820,7 @@ public class DungeonMap { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.enableDepth(); + GlStateManager.disableLighting(); } @@ -1013,8 +1016,10 @@ public class DungeonMap { if(colourMap[0].length != 128) return; this.colourMap = colourMap; + boolean searchForPlayers = false; if(System.currentTimeMillis() - lastClearCache > 1000) { roomMap.clear(); + searchForPlayers = true; startRoomX = -1; startRoomY = -1; connectorSize = -1; @@ -1140,58 +1145,66 @@ public class DungeonMap { } } - for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - if(player instanceof AbstractClientPlayer && actualPlayers.contains(player.getName())) { - AbstractClientPlayer aplayer = (AbstractClientPlayer) player; - ResourceLocation skin = aplayer.getLocationSkin(); - if(skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) { - playerSkinMap.put(player.getName(), skin); + actualPlayers.add(Minecraft.getMinecraft().thePlayer.getName()); + if(searchForPlayers) { + for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if(player instanceof AbstractClientPlayer && actualPlayers.contains(player.getName())) { + AbstractClientPlayer aplayer = (AbstractClientPlayer) player; + ResourceLocation skin = aplayer.getLocationSkin(); + if(skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) { + playerSkinMap.put(player.getName(), skin); + playerIdMap.put(player.getName(), player.getEntityId()); + } } } } - actualPlayers.add(Minecraft.getMinecraft().thePlayer.getName()); playerEntityMapPositions.clear(); if(usePlayerPositions) { - for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - if(actualPlayers.contains(player.getName())) { - float roomX = (float)player.posX / (roomSizeBlocks+1); - float roomY = (float)player.posZ / (roomSizeBlocks+1); - - float playerRoomOffsetX = (float) Math.floor(roomX); - float playerConnOffsetX = (float) Math.floor(roomX); - float playerRoomOffsetY = (float) Math.floor(roomY); - float playerConnOffsetY = (float) Math.floor(roomY); - - float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1); - if(roomXInBlocks < 2) { //0,1 - playerConnOffsetX -= 2/5f-roomXInBlocks/5f; - } else if(roomXInBlocks > roomSizeBlocks-2) { //31,30,29 - playerRoomOffsetX++; - playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-2))/5f; - } else { - playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-4); - } + for(String playerName : actualPlayers) { + if(playerIdMap.containsKey(playerName)) { + Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(playerIdMap.get(playerName)); + if(entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + + float roomX = (float)player.posX / (roomSizeBlocks+1); + float roomY = (float)player.posZ / (roomSizeBlocks+1); + + float playerRoomOffsetX = (float) Math.floor(roomX); + float playerConnOffsetX = (float) Math.floor(roomX); + float playerRoomOffsetY = (float) Math.floor(roomY); + float playerConnOffsetY = (float) Math.floor(roomY); + + float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1); + if(roomXInBlocks < 2) { //0,1 + playerConnOffsetX -= 2/5f-roomXInBlocks/5f; + } else if(roomXInBlocks > roomSizeBlocks-2) { //31,30,29 + playerRoomOffsetX++; + playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-2))/5f; + } else { + playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-4); + } - float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1); - if(roomYInBlocks < 2) { //0,1 - playerConnOffsetY -= 2/5f-roomYInBlocks/5f; - } else if(roomYInBlocks > roomSizeBlocks-2) { //31,30,29 - playerRoomOffsetY++; - playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-2))/5f; - } else { - playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-4); - } + float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1); + if(roomYInBlocks < 2) { //0,1 + playerConnOffsetY -= 2/5f-roomYInBlocks/5f; + } else if(roomYInBlocks > roomSizeBlocks-2) { //31,30,29 + playerRoomOffsetY++; + playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-2))/5f; + } else { + playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-4); + } - playerRoomOffsetX -= startRoomX/(roomSize+connectorSize); - playerRoomOffsetY -= startRoomY/(roomSize+connectorSize); - playerConnOffsetX -= startRoomX/(roomSize+connectorSize); - playerConnOffsetY -= startRoomY/(roomSize+connectorSize); + playerRoomOffsetX -= startRoomX/(roomSize+connectorSize); + playerRoomOffsetY -= startRoomY/(roomSize+connectorSize); + playerConnOffsetX -= startRoomX/(roomSize+connectorSize); + playerConnOffsetY -= startRoomY/(roomSize+connectorSize); - MapPosition pos = new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY); - pos.rotation = (player.prevRotationYawHead + (player.rotationYawHead-player.prevRotationYawHead)*partialTicks) % 360; - if(pos.rotation < 0) pos.rotation += 360; - playerEntityMapPositions.put(player.getName(), pos); + MapPosition pos = new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY); + pos.rotation = (player.prevRotationYawHead + (player.rotationYawHead-player.prevRotationYawHead)*partialTicks) % 360; + if(pos.rotation < 0) pos.rotation += 360; + playerEntityMapPositions.put(player.getName(), pos); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java index c6f00c56..651f75b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java @@ -77,13 +77,13 @@ public class DungeonWin { } public static void displayWin() { - if(NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeonWin.enableDungeonWin) return; + if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return; startTime = System.currentTimeMillis(); confetti.clear(); } public static void tick() { - if(NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeonWin.enableDungeonWin) return; + if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return; if(System.currentTimeMillis() - startTime > 5000) return; int deltaTime = (int)(System.currentTimeMillis() - startTime); @@ -142,7 +142,7 @@ public class DungeonWin { public static void onChatMessage(ClientChatReceivedEvent e) { if(e.type == 2) return; - if(NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeonWin.enableDungeonWin) return; + if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return; long currentTime = System.currentTimeMillis(); String unformatted = Utils.cleanColour(e.message.getUnformattedText()); if(e.message.getFormattedText().startsWith(EnumChatFormatting.RESET+" ")) { @@ -196,8 +196,8 @@ public class DungeonWin { } public static void render(float partialTicks) { - if(NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeonWin.enableDungeonWin) return; - int maxTime = Math.min(30000, NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis); + if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return; + int maxTime = Math.min(30000, NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis); if(System.currentTimeMillis() - startTime > maxTime) return; int deltaTime = (int)(System.currentTimeMillis() - startTime); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java index 827f9498..5e1634e9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java @@ -118,7 +118,7 @@ public class SBGamemodes { } public static Gamemode getGamemode() { - String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile(); + String currentProfile = SBInfo.getInstance().currentProfile; if(currentProfile == null || currentProfile.isEmpty()) return null; 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 e9f246fa..45502cf2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java @@ -42,7 +42,7 @@ public abstract class InfoPane extends Gui { BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor, width, height, boxLeft, overlay.getBoxPadding()-5, - boxRight-boxLeft, height-overlay.getBoxPadding()*2+10); + boxRight-boxLeft, height-overlay.getBoxPadding()*2+10, true); drawRect(boxLeft, overlay.getBoxPadding() - 5, boxRight, height - overlay.getBoxPadding() + 5, bg.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 8eb3430b..7e073bbd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -1,9 +1,12 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.block.Block; +import net.minecraft.block.BlockCrops; +import net.minecraft.block.BlockPackedIce; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -46,6 +49,9 @@ public class CustomItemEffects { private static final int MAX_BUILDERS_BLOCKS = 241; + private HashSet<BlockPos> zapperBlocks = new HashSet<>(); + private boolean zapperDirty = false; + public long aoteUseMillis = 0; public long lastUsedHyperion = 0; @@ -69,14 +75,16 @@ public class CustomItemEffects { public void onTick(TickEvent.RenderTickEvent event) { if(Minecraft.getMinecraft().thePlayer == null) return; + zapperDirty = true; + long currentTime = System.currentTimeMillis(); int delta = (int)(currentTime - lastMillis); lastMillis = currentTime; if(delta <= 0) return; - if(aoteTeleportationMillis > NotEnoughUpdates.INSTANCE.config.smoothAOTE.smoothTpMillis*2) { - aoteTeleportationMillis = NotEnoughUpdates.INSTANCE.config.smoothAOTE.smoothTpMillis*2; + if(aoteTeleportationMillis > NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis*2) { + aoteTeleportationMillis = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis*2; } if(aoteTeleportationMillis < 0) aoteTeleportationMillis = 0; @@ -139,11 +147,11 @@ public class CustomItemEffects { } } - if(NotEnoughUpdates.INSTANCE.config.smoothAOTE.smoothTpMillis <= 0 + if(NotEnoughUpdates.INSTANCE.config.itemOverlays.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 && shadowWarp; + boolean aote = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothAOTE && internal.equals("ASPECT_OF_THE_END"); + boolean hyp = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothHyperion && shadowWarp; if(aote || hyp) { aoteUseMillis = System.currentTimeMillis(); if(aoteTeleportationCurr == null) { @@ -191,13 +199,13 @@ public class CustomItemEffects { if(!Minecraft.getMinecraft().theWorld.isAirBlock(blockPos) && Minecraft.getMinecraft().theWorld.getBlockState(blockPos).getBlock().isFullCube()) { - if(NotEnoughUpdates.INSTANCE.config.bonemerangOverlay.showBreak) { + if(NotEnoughUpdates.INSTANCE.config.itemOverlays.showBreak) { bonemerangBreak = true; } break; } - if(NotEnoughUpdates.INSTANCE.config.bonemerangOverlay.highlightTargeted) { + if(NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted) { List<Entity> entities = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().thePlayer, bb); for(Entity entity : entities) { if(entity instanceof EntityLivingBase && !(entity instanceof EntityArmorStand)) { @@ -226,7 +234,7 @@ public class CustomItemEffects { Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); } - } else if(NotEnoughUpdates.INSTANCE.config.builderWand.enableWandOverlay && + } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay && Minecraft.getMinecraft().objectMouseOver != null && Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { @@ -279,7 +287,7 @@ public class CustomItemEffects { String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+itemCount; int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); - if(NotEnoughUpdates.INSTANCE.config.builderWand.wandBlockCount) { + if(NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) { if(usingDirtWand) { Utils.drawItemStack(new ItemStack(Items.gold_nugget), scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, scaledResolution.getScaledHeight()/2+10+4); @@ -379,6 +387,31 @@ public class CustomItemEffects { return false; } + private static final List<BlockPos> zapperOffsets = new ArrayList<>(); + static { + zapperOffsets.add(new BlockPos(0, 0, -1)); + zapperOffsets.add(new BlockPos(0, 0, 1)); + zapperOffsets.add(new BlockPos(-1, 0, 0)); + zapperOffsets.add(new BlockPos(1, 0, 0)); + zapperOffsets.add(new BlockPos(0, 1, 0)); + zapperOffsets.add(new BlockPos(0, -1, 0)); + } + private static final HashSet<Block> cropBlocksZapper = new HashSet<>(); + private static final HashSet<Block> otherBannedBlocksZapper = new HashSet<>(); + static { + cropBlocksZapper.add(Blocks.wheat); + cropBlocksZapper.add(Blocks.carrots); + cropBlocksZapper.add(Blocks.potatoes); + cropBlocksZapper.add(Blocks.pumpkin); + cropBlocksZapper.add(Blocks.pumpkin_stem); + cropBlocksZapper.add(Blocks.melon_block); + cropBlocksZapper.add(Blocks.melon_stem); + cropBlocksZapper.add(Blocks.cactus); + cropBlocksZapper.add(Blocks.reeds); + + otherBannedBlocksZapper.add(Blocks.farmland); + } + @SubscribeEvent public void renderBlockOverlay(DrawBlockHighlightEvent event) { if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) { @@ -392,7 +425,72 @@ public class CustomItemEffects { double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks; double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks; - if(NotEnoughUpdates.INSTANCE.config.treecap.enableTreecapOverlay && + if(heldInternal.equals("BLOCK_ZAPPER")) { + boolean privateIs = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals("dynamic"); + if (!privateIs || !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableZapperOverlay || + event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + zapperBlocks.clear(); + return; + } + if(zapperDirty) { + zapperDirty = false; + + zapperBlocks.clear(); + LinkedList<BlockPos> returnablePositions = new LinkedList<>(); + + BlockPos pos = event.target.getBlockPos(); + IBlockState firstBlockState = Minecraft.getMinecraft().theWorld.getBlockState(pos); + Block block = firstBlockState.getBlock(); + + BlockPos above = pos.add(0, 1, 0); + Block aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock(); + + if(!cropBlocksZapper.contains(aboveBlock) && !cropBlocksZapper.contains(block) && + !otherBannedBlocksZapper.contains(block) && !block.hasTileEntity(firstBlockState) && + block.getBlockHardness(Minecraft.getMinecraft().theWorld, pos) >= 0) { + for(int i=0; i<164; i++) { + zapperBlocks.add(pos); + returnablePositions.remove(pos); + + List<BlockPos> availableNeighbors = new ArrayList<>(); + + for(BlockPos offset : zapperOffsets) { + BlockPos newPos = pos.add(offset); + + if(zapperBlocks.contains(newPos)) continue; + + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(newPos); + if(state != null && state.getBlock() == block) { + above = newPos.add(0, 1, 0); + aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock(); + if(!cropBlocksZapper.contains(aboveBlock)) { + availableNeighbors.add(newPos); + } + } + } + + if(availableNeighbors.size() >= 2) { + returnablePositions.add(pos); + pos = availableNeighbors.get(0); + } else if(availableNeighbors.size() == 1) { + pos = availableNeighbors.get(0); + } else if(returnablePositions.isEmpty()) { + break; + } else { + i--; + pos = returnablePositions.getLast(); + } + } + } + } + for(BlockPos pos : zapperBlocks) { + Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock(); + drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, pos) + .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2), + 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.zapperOverlayColour); + } + + } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableTreecapOverlay && (heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) { int maxWood = 10; if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35; @@ -452,7 +550,7 @@ public class CustomItemEffects { drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate) .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2), - random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.treecap.treecapOverlayColour); + random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.treecapOverlayColour); } } } @@ -461,7 +559,7 @@ public class CustomItemEffects { GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } - } else if(NotEnoughUpdates.INSTANCE.config.builderWand.enableWandOverlay) { + } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay) { if(heldInternal.equals("BUILDERS_WAND")) { int maxBlocks = MAX_BUILDERS_BLOCKS; if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { @@ -489,7 +587,7 @@ public class CustomItemEffects { itemCount = countItemsInInventoryAndStorage(matchStack); } - String special = (candidatesOld.size() <= itemCount) ? NotEnoughUpdates.INSTANCE.config.builderWand.wandOverlayColour : + String special = (candidatesOld.size() <= itemCount) ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour : "0:255:255:0:0"; if(candidatesOld.size() <= maxBlocks) { @@ -530,7 +628,7 @@ public class CustomItemEffects { GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - String special = NotEnoughUpdates.INSTANCE.config.builderWand.wandOverlayColour; + String special = NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour; AxisAlignedBB bb = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, hover); drawBlock((int)bb.minX, (int)bb.minY, (int)bb.minZ+1, Blocks.dirt.getDefaultState(), diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java index e4b4fff9..8e2874d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java @@ -59,6 +59,8 @@ public class CustomSkulls implements IResourceManagerReloadListener { private ResourceLocation configuration = new ResourceLocation("notenoughupdates:custom_skull_textures/customskull.json"); protected final TextureMap textureMap = new TextureMap("custom_skull_textures"); + public static ItemCameraTransforms.TransformType mostRecentTransformType = ItemCameraTransforms.TransformType.NONE; + protected final Map<ResourceLocation, TextureAtlasSprite> sprites = Maps.<ResourceLocation, TextureAtlasSprite>newHashMap(); private final FaceBakery faceBakery = new FaceBakery(); @@ -118,7 +120,7 @@ public class CustomSkulls implements IResourceManagerReloadListener { } } - Minecraft.getMinecraft().getTextureManager().loadTickableTexture(atlas, textureMap); + Minecraft.getMinecraft().getTextureManager().loadTexture(atlas, textureMap); } catch(Exception e) { } } @@ -230,17 +232,29 @@ public class CustomSkulls implements IResourceManagerReloadListener { return false; } - if(skull.modelBaked != null) { + if(skull.modelBaked != null && skull.model != null) { Minecraft.getMinecraft().getTextureManager().bindTexture(atlas); GlStateManager.pushMatrix(); GlStateManager.disableCull(); + GlStateManager.enableLighting(); GlStateManager.translate(xOffset + 0.5F, yOffset, zOffset + 0.5F); GlStateManager.enableRescaleNormal(); GlStateManager.enableAlpha(); - GlStateManager.scale(1, 1, -1); - GlStateManager.translate(-0.5f, 0.25f, -0.5f); + + GlStateManager.rotate(rotationDeg, 0, 1, 0); + + GlStateManager.translate(0, 0.25f, 0); + + if(xOffset == -0.5 && yOffset == 0 && zOffset == -0.5 && rotationDeg == 180) { + skull.model.getAllTransforms().applyTransform(ItemCameraTransforms.TransformType.HEAD); + } else { + skull.model.getAllTransforms().applyTransform(mostRecentTransformType); + } + + GlStateManager.translate(-0.5f, 0, -0.5f); + renderModel(skull.modelBaked, 0xffffffff); GlStateManager.popMatrix(); } else if(skull.texture != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java index 186f4abc..caa1441c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java @@ -31,11 +31,6 @@ import java.util.*; public class DwarvenMinesTextures { - /*private static final HashSet<BlockPos> blocks = new HashSet<>(); - private static final HashSet<ChunkCoordIntPair> ignoredChunks = new HashSet<>(); - private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> ignoredBlocks = new HashMap<>(); - private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> whitelistBlocks = new HashMap<>();*/ - private static class IgnoreColumn { boolean always; int minY; 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 9a648221..96f86c36 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.MiningOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; @@ -120,6 +121,10 @@ public class DwarvenMinesWaypoints { if(SBInfo.getInstance().getLocation() == null) return; if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; + + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if(hidden == null) return; + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; ContainerChest container = (ContainerChest) chest.inventorySlots; @@ -130,20 +135,20 @@ public class DwarvenMinesWaypoints { ItemStack stack = lower.getStackInSlot(i); if(stack == null) continue; if(stack.getDisplayName().equals(EnumChatFormatting.YELLOW+"Commission Milestones")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 5; + hidden.commissionMilestone = 5; String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); for(String line : lore) { String clean = Utils.cleanColour(line); if(clean.equals("Tier I Rewards:")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 0; + hidden.commissionMilestone = 0; } else if(clean.equals("Tier II Rewards:")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 1; + hidden.commissionMilestone = 1; } else if(clean.equals("Tier III Rewards:")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 2; + hidden.commissionMilestone = 2; } else if(clean.equals("Tier IV Rewards:")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 3; + hidden.commissionMilestone = 3; } else if(clean.equals("Tier V Rewards:")) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 4; + hidden.commissionMilestone = 4; } } return; @@ -230,20 +235,25 @@ public class DwarvenMinesWaypoints { } if(commissionFinished) { for(Emissary emissary : Emissary.values()) { - if(NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone >= emissary.minMilestone) { - - EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; - double dX = emissary.loc.x + 0.5f - p.posX; - double dY = emissary.loc.y + 0.188f - p.posY; - double dZ = emissary.loc.z + 0.5f - p.posZ; - - double distSq = dX*dX + dY*dY + dZ*dZ; - if(distSq >= 12*12) { - renderWayPoint(EnumChatFormatting.GOLD+emissary.name, - new Vector3f(emissary.loc).translate(0.5f, 2.488f, 0.5f), - event.partialTicks); + + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if(hidden != null) { + if(hidden.commissionMilestone >= emissary.minMilestone) { + + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + double dX = emissary.loc.x + 0.5f - p.posX; + double dY = emissary.loc.y + 0.188f - p.posY; + double dZ = emissary.loc.z + 0.5f - p.posZ; + + double distSq = dX*dX + dY*dY + dZ*dZ; + if(distSq >= 12*12) { + renderWayPoint(EnumChatFormatting.GOLD+emissary.name, + new Vector3f(emissary.loc).translate(0.5f, 2.488f, 0.5f), + event.partialTicks); + } } } + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java index a2276b0e..414ba42d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java @@ -53,7 +53,7 @@ public class ItemCooldowns { } public static long getTreecapCooldownWithPet(){ - if (NotEnoughUpdates.INSTANCE.config.treecap.enableMonkeyCheck && PetInfoOverlay.currentPet != null) { + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck && PetInfoOverlay.currentPet != null) { PetInfoOverlay.Pet pet = PetInfoOverlay.currentPet; if (pet.petLevel != null && pet.petType.equalsIgnoreCase("monkey") && diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index b3ce3835..5c80cf32 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -16,7 +16,6 @@ import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; @@ -302,26 +301,28 @@ public class PetInfoOverlay extends TextOverlay { } String etaStr = null; - float remaining = currentPet.petLevel.currentLevelRequirement - currentPet.petLevel.levelXp; - if(remaining > 0) { - if(xpGain < 1000) { - etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " + - EnumChatFormatting.YELLOW+"N/A"; - } else { - etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " + - EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpGain); + String etaMaxStr = null; + if(currentPet.petLevel.level < 100) { + float remaining = currentPet.petLevel.currentLevelRequirement - currentPet.petLevel.levelXp; + if(remaining > 0) { + if(xpGain < 1000) { + etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " + + EnumChatFormatting.YELLOW+"N/A"; + } else { + etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " + + EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpGain); + } } - } - String etaMaxStr = null; - float remainingMax = currentPet.petLevel.maxXP - currentPet.petLevel.totalXp; - if(remaining > 0) { - if(xpGain < 1000) { - etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " + - EnumChatFormatting.YELLOW+"N/A"; - } else { - etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " + - EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remainingMax)*1000*60*60/(long)xpGain); + float remainingMax = currentPet.petLevel.maxXP - currentPet.petLevel.totalXp; + if(remaining > 0) { + if(xpGain < 1000) { + etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " + + EnumChatFormatting.YELLOW+"N/A"; + } else { + etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " + + EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remainingMax)*1000*60*60/(long)xpGain); + } } } @@ -352,15 +353,14 @@ public class PetInfoOverlay extends TextOverlay { } public void update() { - if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.treecap.enableMonkeyCheck - && !NotEnoughUpdates.INSTANCE.config.notifications.showWrongPetMsg) { + if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) { overlayStrings = null; return; } NEUConfig config = NotEnoughUpdates.INSTANCE.config; int updateTime = 60000; - if((config.treecap.enableMonkeyCheck || config.notifications.showWrongPetMsg) && !config.petOverlay.enablePetInfo) + if((config.itemOverlays.enableMonkeyCheck) && !config.petOverlay.enablePetInfo) updateTime = 300000; if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { @@ -509,6 +509,8 @@ public class PetInfoOverlay extends TextOverlay { float totalGain = 0; for(Map.Entry<String, XPInformation.SkillInfo> entry : skillInfoMap.entrySet()) { + if(entry.getValue().level == 50 && entry.getValue().fromApi) continue; + float skillXp = entry.getValue().totalXp; if(skillInfoMapLast.containsKey(entry.getKey())) { float skillXpLast = skillInfoMapLast.get(entry.getKey()); @@ -585,7 +587,7 @@ public class PetInfoOverlay extends TextOverlay { private HashMap<String, String> itemMap = null; - @SubscribeEvent(priority = EventPriority.HIGHEST) + @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public void onTooltip(ItemTooltipEvent event) { for(String line : event.toolTip) { if(line.startsWith("\u00a7o\u00a77[Lvl ")) { @@ -626,7 +628,7 @@ public class PetInfoOverlay extends TextOverlay { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChatReceived(ClientChatReceivedEvent event) { NEUConfig config = NotEnoughUpdates.INSTANCE.config; - if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && (config.petOverlay.enablePetInfo || config.treecap.enableMonkeyCheck || config.notifications.showWrongPetMsg)) { + if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && (config.petOverlay.enablePetInfo || config.itemOverlays.enableMonkeyCheck)) { if(event.type == 0) { String chatMessage = Utils.cleanColour(event.message.getUnformattedText()); @@ -652,7 +654,9 @@ public class PetInfoOverlay extends TextOverlay { rarity = Rarity.getRarityFromColor(col); } - String pet = Utils.cleanColour(petStringMatch.substring(1)).trim().toUpperCase(); + String pet = Utils.cleanColour(petStringMatch.substring(1)) + .replaceAll("[^\\w ]", "").trim() + .replace(" ", "_").toUpperCase(); if(petList.containsKey(pet + ";" + rarity.petId)) { Set<Pet> pets = petList.get(pet + ";" + rarity.petId); @@ -663,14 +667,16 @@ public class PetInfoOverlay extends TextOverlay { } } else { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"[NEU] Can't find pet \u00a7" + petStringMatch + - " are you sure API key is correct? Try doing /api new and rejoining hypixel.")); + EnumChatFormatting.RED + " are you sure API key is correct? Try doing /api new and rejoining hypixel.")); } } else if(chatMessage.toLowerCase().startsWith("you summoned your")) { clearPet(); - String pet = chatMessage.trim().toUpperCase().replace("YOU SUMMONED YOUR ", "").replace("!", "").replace(" ", "_"); + String pet = chatMessage.trim().toUpperCase().replace("YOU SUMMONED YOUR ", "") + .replaceAll("[^\\w ]", "").trim() + .replace(" ", "_"); Rarity rarity = event.message.getSiblings().size() == 3 ? Rarity.getRarityFromColor(event.message.getSiblings().get(1).getChatStyle().getColor()) : Rarity.COMMON; if(petList.containsKey(pet + ";" + rarity.petId)) { @@ -683,8 +689,8 @@ public class PetInfoOverlay extends TextOverlay { currentPet = getClosestPet(pet, rarity.petId, lastItemHovered, lastLevelHovered); } } else { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"[NEU] Can't find pet " + pet + ";" + rarity.petId + - " are you sure API key is correct? Try doing /api new and rejoining hypixel.")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"[NEU] Can't find pet " + pet+";"+rarity.petId + + EnumChatFormatting.RED + " are you sure API key is correct? Try doing /api new and rejoining hypixel.")); } } else if(chatMessage.toLowerCase().startsWith("you despawned your")) { clearPet(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java index 0034a82c..4a343f9e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java @@ -718,6 +718,10 @@ public class CalendarOverlay { } } + if(event.id.equals("dark_auction")) { + timeUntil -= 30*1000; + } + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java index f4228ce0..73ab69c9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java @@ -80,7 +80,7 @@ public class GuiEnchantColour extends GuiScreen { fontRendererObj.drawString("COL", guiLeft+136, guiTop+7, 4210752); fontRendererObj.drawString("DEL", guiLeft+161, guiTop+7, 4210752); - Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2, guiTop+ySize-20, false, 4210752); + Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2+1, guiTop+ySize-20, false, 4210752); int yIndex = 0; for(String str : enchantColours) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java new file mode 100644 index 00000000..36987677 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java @@ -0,0 +1,18 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscfeatures.CustomSkulls; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ItemCameraTransforms.class) +public class MixinItemCameraTransforms { + + @Inject(method="applyTransform", at=@At("HEAD")) + public void applyTransform(ItemCameraTransforms.TransformType type, CallbackInfo ci) { + CustomSkulls.mostRecentTransformType = type; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java index 10509dd1..f20a5557 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -7,10 +7,7 @@ import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.Packet; import net.minecraft.network.play.client.C13PacketPlayerAbilities; -import net.minecraft.network.play.server.S03PacketTimeUpdate; -import net.minecraft.network.play.server.S23PacketBlockChange; -import net.minecraft.network.play.server.S2FPacketSetSlot; -import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.*; import org.lwjgl.opengl.Display; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -27,7 +24,7 @@ public class MixinNetHandlerPlayClient { public void handlePlayerPosLook_setPositionAndRotation(EntityPlayer player, double x, double y, double z, float yaw, float pitch) { if(CustomItemEffects.INSTANCE.aoteTeleportationCurr != null) { CustomItemEffects.INSTANCE.aoteTeleportationMillis += - Math.max(0, Math.min(300, NotEnoughUpdates.INSTANCE.config.smoothAOTE.smoothTpMillis)); + Math.max(0, Math.min(300, NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis)); } player.setPositionAndRotation(x, y, z, yaw, pitch); } @@ -56,6 +53,12 @@ public class MixinNetHandlerPlayClient { } } + @Inject(method="handlePlayerListHeaderFooter", at=@At("HEAD")) + public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn, CallbackInfo ci) { + SBInfo.getInstance().header = packetIn.getHeader().getFormattedText().length() == 0 ? null : packetIn.getHeader(); + SBInfo.getInstance().footer = packetIn.getFooter().getFormattedText().length() == 0 ? null : packetIn.getFooter(); + } + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java index 106f9f94..e65b8155 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java @@ -20,7 +20,7 @@ public class MixinRender { public void bindEntityTexture(Entity entity, CallbackInfoReturnable<Boolean> cir) { if(entity instanceof EntityBat && DungeonBlocks.isOverriding()) { if(DungeonBlocks.bindModifiedTexture(new ResourceLocation("textures/entity/bat.png"), - SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungBatColour))) { + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour))) { cir.setReturnValue(true); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java index 12888dcb..b94561ce 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java @@ -34,7 +34,7 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> { @Inject(method = "doRender(Lnet/minecraft/entity/projectile/EntityFishHook;DDDFF)V", at=@At(value = "HEAD"), cancellable = true) public void render(EntityFishHook entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { - if(!NotEnoughUpdates.INSTANCE.config.rodColours.enableRodColours || entity == null) return; + if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableRodColours || entity == null) return; String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(entity.angler.getHeldItem()); if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && internalname != null && entity.angler != null && @@ -103,9 +103,9 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> { String specialColour; if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { - specialColour = NotEnoughUpdates.INSTANCE.config.rodColours.ownRodColour; + specialColour = NotEnoughUpdates.INSTANCE.config.itemOverlays.ownRodColour; } else { - specialColour = NotEnoughUpdates.INSTANCE.config.rodColours.otherRodColour; + specialColour = NotEnoughUpdates.INSTANCE.config.itemOverlays.otherRodColour; } int colourI = SpecialColour.specialToChromaRGB(specialColour); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java index f7c2435a..e2f7f2e4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java @@ -21,8 +21,8 @@ public abstract class MixinTileEntitySpecialRenderer { location.getResourcePath().equals("textures/entity/chest/normal_double.png") || location.getResourcePath().equals("textures/entity/chest/trapped.png") || location.getResourcePath().equals("textures/entity/chest/trapped_double.png")) { - String colour = location.getResourcePath().contains("trapped") ? NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungTrappedChestColour : - NotEnoughUpdates.INSTANCE.config.dungeonBlock.dungChestColour; + String colour = location.getResourcePath().contains("trapped") ? NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour : + NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour; if(DungeonBlocks.bindModifiedTexture(location, SpecialColour.specialToChromaRGB(colour))) { info.cancel(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java index 6c640390..fff1c449 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java @@ -18,7 +18,7 @@ public class MixinWorld { @Inject(method="spawnParticle(IZDDDDDD[I)V", at=@At("HEAD"), cancellable = true) public void spawnParticle(int particleID, boolean p_175720_2_, double xCood, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) { - if(NotEnoughUpdates.INSTANCE.config.smoothAOTE.disableHyperionParticles && + if(NotEnoughUpdates.INSTANCE.config.itemOverlays.disableHyperionParticles && System.currentTimeMillis() - CustomItemEffects.INSTANCE.lastUsedHyperion < 500) { if(particleID == 1) { ci.cancel(); 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 60c28a37..5a04d535 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -9,12 +9,14 @@ import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.*; import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; import io.github.moulberry.notenoughupdates.overlays.*; +import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; public class NEUConfig extends Config { @@ -38,7 +40,7 @@ public class NEUConfig extends Config { if(Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; if(wrapper.element instanceof NEUConfigEditor) { - activeConfigCategory = ((NEUConfigEditor)wrapper.element).getSelectedCategory(); + activeConfigCategory = ((NEUConfigEditor)wrapper.element).getSelectedCategoryName(); } } final String activeConfigCategoryF = activeConfigCategory; @@ -92,7 +94,7 @@ public class NEUConfig extends Config { @Expose @Category( name = "Item List", - desc = "Modify the item list which shows when opening an inventory" + desc = "Item List" ) public Itemlist itemlist = new Itemlist(); @@ -112,17 +114,10 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Price Info (Auction)", - desc = "Price Info (Auction)" + name = "Item Overlays", + desc = "Item Overlays" ) - public PriceInfoAuc priceInfoAuc = new PriceInfoAuc(); - - @Expose - @Category( - name = "Price Info (Bazaar)", - desc = "Price Info (Bazaar)" - ) - public PriceInfoBaz priceInfoBaz = new PriceInfoBaz(); + public ItemOverlays itemOverlays = new ItemOverlays(); @Expose @Category( @@ -133,18 +128,10 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Dungeon Profit", - desc = "Dungeon Profit" + name = "Dungeons", + desc = "Dungeons" ) - public DungeonProfit dungeonProfit = new DungeonProfit(); - - - @Expose - @Category( - name = "Dungeon Solvers", - desc = "Dungeon Solvers" - ) - public DungeonSolvers dungeonSolvers = new DungeonSolvers(); + public Dungeons dungeons = new Dungeons(); @Expose @@ -191,13 +178,6 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Treecap Overlay", - desc = "Treecap Overlay" - ) - public Treecap treecap = new Treecap(); - - @Expose - @Category( name = "Pet Overlay", desc = "Pet Overlay" ) @@ -205,29 +185,6 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Builders Wand Overlay", - desc = "Builders Wand Overlay" - ) - public BuilderWand builderWand = new BuilderWand(); - - - @Expose - @Category( - name = "Dungeon Map", - desc = "Dungeon Map" - ) - public DungeonMapOpen dungeonMapOpen = new DungeonMapOpen(); - - @Expose - @Category( - name = "Smooth AOTE", - desc = "Smooth AOTE" - ) - public SmoothAOTE smoothAOTE = new SmoothAOTE(); - - - @Expose - @Category( name = "AH Search GUI", desc = "AH Search GUI" ) @@ -235,20 +192,6 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Dungeon Block Overlay", - desc = "Dungeon Block Overlay" - ) - public DungeonBlock dungeonBlock = new DungeonBlock(); - - @Expose - @Category( - name = "Bonemerang Overlay", - desc = "Bonemerang Overlay" - ) - public BonemerangOverlay bonemerangOverlay = new BonemerangOverlay(); - - @Expose - @Category( name = "Accessory Bag Overlay", desc = "Accessory Bag Overlay" ) @@ -256,20 +199,6 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Custom Rod Colours", - desc = "Custom Rod Colours" - ) - public RodColours rodColours = new RodColours(); - - @Expose - @Category( - name = "Dungeon Win Overlay", - desc = "Dungeon Win Overlay" - ) - public DungeonWin dungeonWin = new DungeonWin(); - - @Expose - @Category( name = "Api Key", desc = "Api Key" ) @@ -336,11 +265,20 @@ public class NEUConfig extends Config { @Expose @ConfigOption( + name = "RAM Warning", + desc = "Warning when game starts with lots of RAM allocated\n"+ + "\u00a7cBefore disabling this, please seriously read the message. If you complain about FPS issues without listening to the warning, that's your fault." + ) + @ConfigEditorBoolean + public boolean doRamNotif = true; + + /*@Expose + @ConfigOption( name = "Wrong Pet", desc = "Gives a notification in chat whenever you're using a pet that doesnt match the same xp you're gathering." ) @ConfigEditorBoolean - public boolean showWrongPetMsg = false; + public boolean showWrongPetMsg = false;*/ } public static class Itemlist { @@ -502,6 +440,42 @@ public class NEUConfig extends Config { } public static class TooltipTweaks { + @ConfigOption( + name = "Tooltip Price Information", + desc = "" + ) + @ConfigEditorAccordion(id = 0) + public boolean priceInfoAccordion = false; + + @Expose + @ConfigOption( + name = "Price Info (Auc)", + desc = "\u00a7rSelect what price information you would like to see on auctionable item tooltips\n" + + "\u00a7eDrag text to rearrange" + ) + @ConfigEditorDraggableList( + exampleText = {"\u00a7eLowest BIN", + "\u00a7eAH Price", + "\u00a7eAH Sales", + "\u00a7eRaw Craft Cost", + "\u00a7eAVG Lowest BIN", + "\u00a7eDungeon Costs"} + ) + @ConfigAccordionId(id = 0) + public List<Integer> priceInfoAuc = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 5)); + + @Expose + @ConfigOption( + name = "Price Info (Baz)", + desc = "\u00a7rSelect what price information you would like to see on bazaar item tooltips\n" + + "\u00a7eDrag text to rearrange" + ) + @ConfigEditorDraggableList( + exampleText = {"\u00a7eBuy", "\u00a7eSell", "\u00a7eBuy (Insta)", "\u00a7eSell (Insta)", "\u00a7eRaw Craft Cost"} + ) + @ConfigAccordionId(id = 0) + public List<Integer> priceInfoBaz = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4)); + @Expose @ConfigOption( name = "Price Info (Inv)", @@ -547,128 +521,207 @@ public class NEUConfig extends Config { public int tooltipBorderOpacity = 200; } - public static class PriceInfoAuc { + public static class ItemOverlays { + @ConfigOption( + name = "Treecapitator Overlay", + desc = "" + ) + @ConfigEditorAccordion(id = 0) + public boolean treecapAccordion = false; + @Expose @ConfigOption( - name = "Line 1", - desc = "Set the price information displayed on Line #1" + name = "Enable Treecap Overlay", + desc = "Show which blocks will be broken when using a Jungle Axe or Treecapitator" ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean enableTreecapOverlay = true; + + @Expose + @ConfigOption( + name = "Overlay Colour", + desc = "Change the colour of the overlay" ) - public int line1 = 1; + @ConfigEditorColour + @ConfigAccordionId(id = 0) + public String treecapOverlayColour = "00:50:64:224:208"; @Expose @ConfigOption( - name = "Line 2", - desc = "Set the price information displayed on Line #2" + name = "Enable Monkey Pet Check", + desc = "Will check use the API to check what pet you're using\nto determine the cooldown based off of if you have monkey pet." ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean enableMonkeyCheck = true; + + @ConfigOption( + name = "Builder's Wand Overlay", + desc = "" ) - public int line2 = 2; + @ConfigEditorAccordion(id = 1) + public boolean wandAccordion = false; @Expose @ConfigOption( - name = "Line 3", - desc = "Set the price information displayed on Line #3" + name = "Enable Wand Overlay", + desc = "Show which blocks will be placed when using the Builder's Wand" ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean enableWandOverlay = true; + + @Expose + @ConfigOption( + name = "Wand Block Count", + desc = "Shows the total count of a block in your inventory" ) - public int line3 = 3; + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean wandBlockCount = true; @Expose @ConfigOption( - name = "Line 4", - desc = "Set the price information displayed on Line #4" + name = "Overlay Colour", + desc = "Change the colour of the ghost block outline" ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + @ConfigEditorColour + @ConfigAccordionId(id = 1) + public String wandOverlayColour = "00:50:64:224:208"; + + @ConfigOption( + name = "Block Zapper Overlay", + desc = "" ) - public int line4 = 4; + @ConfigEditorAccordion(id = 5) + public boolean zapperAccordion = false; @Expose @ConfigOption( - name = "Line 5", - desc = "Set the price information displayed on Line #5" - ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + name = "Enable Zapper Overlay", + desc = "Show which blocks will be destroyed when using the Block Zapper" ) - public int line5 = 6; + @ConfigEditorBoolean + @ConfigAccordionId(id = 5) + public boolean enableZapperOverlay = true; @Expose @ConfigOption( - name = "Line 6", - desc = "Set the price information displayed on Line #6" + name = "Overlay Colour", + desc = "Change the colour of the ghost block outline" ) - @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} + @ConfigEditorColour + @ConfigAccordionId(id = 5) + public String zapperOverlayColour = "0:102:171:5:0"; + + @ConfigOption( + name = "Smooth AOTE", + desc = "" ) - public int line6 = 0; - } + @ConfigEditorAccordion(id = 2) + public boolean aoteAccordion = false; - public static class PriceInfoBaz { @Expose @ConfigOption( - name = "Line 1", - desc = "Set the price information displayed on Line #1" + name = "Enable Smooth AOTE", + desc = "Teleport smoothly to your destination when using AOTE" ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean enableSmoothAOTE = true; + + @Expose + @ConfigOption( + name = "Enable Smooth Hyperion", + desc = "Teleport smoothly to your destination when using Hyperion" ) - public int line1 = 1; + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean enableSmoothHyperion = true; @Expose @ConfigOption( - name = "Line 2", - desc = "Set the price information displayed on Line #2" + name = "Smooth TP Time", + desc = "Change the amount of time (milliseconds) taken to teleport" ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + @ConfigEditorSlider( + minValue = 0, + maxValue = 500, + minStep = 25 ) - public int line2 = 2; + @ConfigAccordionId(id = 2) + public int smoothTpMillis = 175; @Expose @ConfigOption( - name = "Line 3", - desc = "Set the price information displayed on Line #3" + name = "Disable Hyperion Particles", + desc = "Remove the explosion effect when using a hyperion" ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean disableHyperionParticles = true; + + @ConfigOption( + name = "Bonemerang Overlay", + desc = "" ) - public int line3 = 3; + @ConfigEditorAccordion(id = 3) + public boolean bonemerangAccordion = false; @Expose @ConfigOption( - name = "Line 4", - desc = "Set the price information displayed on Line #4" - ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + name = "Highlight Targeted Entities", + desc = "Highlight entities that will be hit by your bonemerang" ) - public int line4 = 4; + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean highlightTargeted = true; @Expose @ConfigOption( - name = "Line 5", - desc = "Set the price information displayed on Line #5" + name = "Break Warning", + desc = "Show a warning below your crosshair if the bonemerang will break on a block" ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showBreak = true; + + @ConfigOption( + name = "Custom Rod Colours", + desc = "" ) - public int line5 = 5; + @ConfigEditorAccordion(id = 4) + public boolean rodAccordion = false; @Expose @ConfigOption( - name = "Line 6", - desc = "Set the price information displayed on Line #6" + name = "Enable Rod Colours", + desc = "Change the colour of your and other players' rod lines\n" + + "Also fixes the position of the rod line" ) - @ConfigEditorDropdown( - values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + @ConfigEditorBoolean + @ConfigAccordionId(id = 4) + public boolean enableRodColours = true; + + @Expose + @ConfigOption( + name = "Own Rod Colour", + desc = "Change the colour of your own rod lines" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 4) + public String ownRodColour = "0:255:0:0:0"; + + + @Expose + @ConfigOption( + name = "Other Rod Colour", + desc = "Change the colour of other players' rod lines" ) - public int line6 = 0; + @ConfigEditorColour + @ConfigAccordionId(id = 4) + public String otherRodColour = "0:255:0:0:0"; } public static class SkillOverlays { @@ -720,7 +773,43 @@ public class NEUConfig extends Config { public int farmingStyle = 0; } - public static class DungeonProfit { + public static class Dungeons { + @ConfigOption( + name = "Dungeon Map", + desc = "" + ) + @ConfigEditorAccordion(id = 0) + public boolean dungeonMapAccordion = false; + + @Expose + @ConfigOption( + name = "Edit Dungeon Map", + desc = "The NEU dungeon map has it's own editor (/neumap).\n" + + "Click the button on the left to open it" + ) + @ConfigEditorButton( + runnableId = 0, + buttonText = "Edit" + ) + @ConfigAccordionId(id = 0) + public int editDungeonMap = 0; + + @Expose + @ConfigOption( + name = "Show Own Head As Marker", + desc = "If you have the \"Head\" icon style selected, don't replace your green marker with a head" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean showOwnHeadAsMarker = false; + + @ConfigOption( + name = "Dungeon Profit", + desc = "" + ) + @ConfigEditorAccordion(id = 1) + public boolean dungeonProfitAccordion = false; + @Expose @ConfigOption( name = "Profit Type", @@ -729,6 +818,7 @@ public class NEUConfig extends Config { @ConfigEditorDropdown( values = {"Lowest BIN", "24 AVG Lowest Bin", "Auction AVG"} ) + @ConfigAccordionId(id = 1) public int profitType = 0; @Expose @@ -742,10 +832,137 @@ public class NEUConfig extends Config { @ConfigEditorDropdown( values = {"Overlay", "GUI Title", "Lore", "Off"} ) + @ConfigAccordionId(id = 1) public int profitDisplayLoc = 0; - } - public static class DungeonSolvers { + + @ConfigOption( + name = "Dungeon Win Overlay", + desc = "" + ) + @ConfigEditorAccordion(id = 3) + public boolean dungeonWinAccordion = false; + + @Expose + @ConfigOption( + name = "Enable Dungeon Win", + desc = "Show a fancy win screen and stats when completing a dungeon" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean enableDungeonWin = true; + + @Expose + @ConfigOption( + name = "Dungeon Win Time", + desc = "Change the amount of time (milliseconds) that the win screen shows for" + ) + @ConfigEditorSlider( + minValue = 0, + maxValue = 20000, + minStep = 500 + ) + @ConfigAccordionId(id = 3) + public int dungeonWinMillis = 8000; + + @ConfigOption( + name = "Dungeon Block Overlay", + desc = "" + ) + @ConfigEditorAccordion(id = 2) + public boolean dungeonBlocksAccordion = false; + + @Expose + @ConfigOption( + name = "Enable Block Overlay", + desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean enableDungBlockOverlay = true; + + @Expose + @ConfigOption( + name = "Show Overlay Everywhere", + desc = "Show the dungeon block overlay even when not inside dungeons. Should only be used for testing." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean dungeonBlocksEverywhere = false; + + @Expose + @ConfigOption( + name = "Slow Update", + desc = "Updates the colour every second instead of every tick.\n" + + "\u00A7cWARNING: This will cause all texture animations (eg. flowing water) to update slowly.\n" + + "This should only be used on low-end machines" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean slowDungeonBlocks = false; + + @Expose + @ConfigOption( + name = "Cracked Bricks", + desc = "Change the colour of: Cracked Bricks" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungCrackedColour = "0:255:7:255:217"; + + @Expose + @ConfigOption( + name = "Dispensers", + desc = "Change the colour of: Dispensers" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungDispenserColour = "0:255:255:76:0"; + + @Expose + @ConfigOption( + name = "Levers", + desc = "Change the colour of: Levers" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungLeverColour = "0:252:24:249:255"; + + @Expose + @ConfigOption( + name = "Tripwire String", + desc = "Change the colour of: Tripwire String" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungTripWireColour = "0:255:255:0:0"; + + @Expose + @ConfigOption( + name = "Normal Chests", + desc = "Change the colour of: Normal Chests" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungChestColour = "0:255:0:163:36"; + + @Expose + @ConfigOption( + name = "Trapped Chests", + desc = "Change the colour of: Trapped Chests" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungTrappedChestColour = "0:255:0:163:36"; + + @Expose + @ConfigOption( + name = "Bats", + desc = "Change the colour of: Bats" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String dungBatColour = "0:255:12:255:0"; } public static class EnchSolvers { @@ -849,38 +1066,12 @@ public class NEUConfig extends Config { } public static class Mining { - @Expose - @ConfigOption( - name = "Puzzler Solver", - desc = "Show the correct block to mine for the puzzler puzzle in Dwarven Mines" - ) - @ConfigEditorBoolean - public boolean puzzlerSolver = true; - - @Expose - @ConfigOption( - name = "Titanium Alert", - desc = "Show an alert whenever titanium appears nearby" - ) - @ConfigEditorBoolean - public boolean titaniumAlert = true; - - - @Expose @ConfigOption( - name = "Don't Mine Stone", - desc = "Prevent mining stone blocks in mining areas" + name = "Waypoints", + desc = "" ) - @ConfigEditorBoolean - public boolean dontMineStone = true; - - @Expose - @ConfigOption( - name = "Reveal Mist Creepers", - desc = "Make the creepers in the Dwarven Mines mist visible" - ) - @ConfigEditorBoolean - public boolean revealMistCreepers = true; + @ConfigEditorAccordion(id = 0) + public boolean waypointsAccordion = false; @Expose @ConfigOption( @@ -892,6 +1083,7 @@ public class NEUConfig extends Config { values = {"Hide", "Commissions Only", "Always"}, initialIndex = 1 ) + @ConfigAccordionId(id = 0) public int locWaypoints = 1; @Expose @@ -904,14 +1096,23 @@ public class NEUConfig extends Config { values = {"Hide", "Commission End", "Always"}, initialIndex = 1 ) + @ConfigAccordionId(id = 0) public int emissaryWaypoints = 1; + @ConfigOption( + name = "Drill Fuel Bar", + desc = "" + ) + @ConfigEditorAccordion(id = 1) + public boolean drillAccordion = false; + @Expose @ConfigOption( name = "Drill Fuel Bar", desc = "Show a fancy drill fuel bar when holding a drill in mining areas" ) @ConfigEditorBoolean + @ConfigAccordionId(id = 1) public boolean drillFuelBar = true; @Expose @@ -924,6 +1125,7 @@ public class NEUConfig extends Config { maxValue = 400, minStep = 10 ) + @ConfigAccordionId(id = 1) public int drillFuelBarWidth = 200; @Expose @@ -935,8 +1137,15 @@ public class NEUConfig extends Config { runnableId = 2, buttonText = "Edit" ) + @ConfigAccordionId(id = 1) public Position drillFuelBarPosition = new Position(0, -100, true, false); + @ConfigOption( + name = "Dwarven Overlay", + desc = "" + ) + @ConfigEditorAccordion(id = 2) + public boolean overlayAccordion = false; @Expose @ConfigOption( @@ -944,6 +1153,7 @@ public class NEUConfig extends Config { desc = "Show an overlay with useful information on the screen while in Dwarven Mines" ) @ConfigEditorBoolean + @ConfigAccordionId(id = 2) public boolean dwarvenOverlay = true; @Expose @@ -954,10 +1164,11 @@ public class NEUConfig extends Config { ) @ConfigEditorDraggableList( exampleText = {"\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", - "\u00a73Mithril Powder: \u00a726,243", - "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", - "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"} + "\u00a73Mithril Powder: \u00a726,243", + "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", + "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"} ) + @ConfigAccordionId(id = 2) public List<Integer> dwarvenText = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); @Expose @@ -969,6 +1180,7 @@ public class NEUConfig extends Config { runnableId = 1, buttonText = "Edit" ) + @ConfigAccordionId(id = 2) public Position overlayPosition = new Position(10, 100); @Expose @@ -979,7 +1191,40 @@ public class NEUConfig extends Config { @ConfigEditorDropdown( values = {"Background", "No Shadow", "Shadow", "Full Shadow"} ) + @ConfigAccordionId(id = 2) public int overlayStyle = 0; + + @Expose + @ConfigOption( + name = "Puzzler Solver", + desc = "Show the correct block to mine for the puzzler puzzle in Dwarven Mines" + ) + @ConfigEditorBoolean + public boolean puzzlerSolver = true; + + @Expose + @ConfigOption( + name = "Titanium Alert", + desc = "Show an alert whenever titanium appears nearby" + ) + @ConfigEditorBoolean + public boolean titaniumAlert = true; + + @Expose + @ConfigOption( + name = "Don't Mine Stone", + desc = "Prevent mining stone blocks in mining areas" + ) + @ConfigEditorBoolean + public boolean dontMineStone = true; + + @Expose + @ConfigOption( + name = "Reveal Mist Creepers", + desc = "Make the creepers in the Dwarven Mines mist visible" + ) + @ConfigEditorBoolean + public boolean revealMistCreepers = true; } public static class NeuAuctionHouse { @@ -1122,33 +1367,6 @@ public class NEUConfig extends Config { public boolean customTradePriceStyle = true; } - public static class Treecap { - @Expose - @ConfigOption( - name = "Enable Treecap Overlay", - desc = "Show which blocks will be broken when using a Jungle Axe or Treecapitator" - ) - @ConfigEditorBoolean - public boolean enableTreecapOverlay = true; - - @Expose - @ConfigOption( - name = "Overlay Colour", - desc = "Change the colour of the overlay" - ) - @ConfigEditorColour - public String treecapOverlayColour = "00:50:64:224:208"; - - @Expose - @ConfigOption( - name = "Enable Monkey Pet Check", - desc = "Will check use the API to check what pet you're using\nto determine the cooldown based off of if you have monkey pet." - ) - @ConfigEditorBoolean - - public boolean enableMonkeyCheck = true; - } - public static class PetOverlay { @Expose @ConfigOption( @@ -1206,54 +1424,6 @@ public class NEUConfig extends Config { public int petInfoOverlayStyle = 0; } - public static class BuilderWand { - @Expose - @ConfigOption( - name = "Enable Wand Overlay", - desc = "Show which blocks will be placed when using the Builder's Wand" - ) - @ConfigEditorBoolean - public boolean enableWandOverlay = true; - - @Expose - @ConfigOption( - name = "Wand Block Count", - desc = "Shows the total count of a block in your inventory" - ) - @ConfigEditorBoolean - public boolean wandBlockCount = true; - - @Expose - @ConfigOption( - name = "Overlay Colour", - desc = "Change the colour of the ghost block outline" - ) - @ConfigEditorColour - public String wandOverlayColour = "00:50:64:224:208"; - } - - public static class DungeonMapOpen { - @Expose - @ConfigOption( - name = "Edit Dungeon Map", - desc = "The NEU dungeon map has it's own editor (/neumap).\n" + - "Click the button on the left to open it" - ) - @ConfigEditorButton( - runnableId = 0, - buttonText = "Edit" - ) - public int editDungeonMap = 0; - - @Expose - @ConfigOption( - name = "Show Own Head As Marker", - desc = "If you have the \"Head\" icon style selected, don't replace your green marker with a head" - ) - @ConfigEditorBoolean - public boolean showOwnHeadAsMarker = false; - } - public static class AuctionHouseSearch { @Expose @ConfigOption( @@ -1289,108 +1459,6 @@ public class NEUConfig extends Config { public boolean escFullClose = true; } - public static class DungeonBlock { - @Expose - @ConfigOption( - name = "Enable Block Overlay", - desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons" - ) - @ConfigEditorBoolean - public boolean enableDungBlockOverlay = true; - - @Expose - @ConfigOption( - name = "Show Overlay Everywhere", - desc = "Show the dungeon block overlay even when not inside dungeons. Should only be used for testing." - ) - @ConfigEditorBoolean - public boolean dungeonBlocksEverywhere = false; - - @Expose - @ConfigOption( - name = "Slow Update", - desc = "Updates the colour every second instead of every tick.\n" + - "\u00A7cWARNING: This will cause all texture animations (eg. flowing water) to update slowly.\n" + - "This should only be used on low-end machines" - ) - @ConfigEditorBoolean - public boolean slowDungeonBlocks = false; - - @Expose - @ConfigOption( - name = "Cracked Bricks", - desc = "Change the colour of: Cracked Bricks" - ) - @ConfigEditorColour - public String dungCrackedColour = "0:255:7:255:217"; - - @Expose - @ConfigOption( - name = "Dispensers", - desc = "Change the colour of: Dispensers" - ) - @ConfigEditorColour - public String dungDispenserColour = "0:255:255:76:0"; - - @Expose - @ConfigOption( - name = "Levers", - desc = "Change the colour of: Levers" - ) - @ConfigEditorColour - public String dungLeverColour = "0:252:24:249:255"; - - @Expose - @ConfigOption( - name = "Tripwire String", - desc = "Change the colour of: Tripwire String" - ) - @ConfigEditorColour - public String dungTripWireColour = "0:255:255:0:0"; - - @Expose - @ConfigOption( - name = "Normal Chests", - desc = "Change the colour of: Normal Chests" - ) - @ConfigEditorColour - public String dungChestColour = "0:255:0:163:36"; - - @Expose - @ConfigOption( - name = "Trapped Chests", - desc = "Change the colour of: Trapped Chests" - ) - @ConfigEditorColour - public String dungTrappedChestColour = "0:255:0:163:36"; - - @Expose - @ConfigOption( - name = "Bats", - desc = "Change the colour of: Bats" - ) - @ConfigEditorColour - public String dungBatColour = "0:255:12:255:0"; - } - - public static class BonemerangOverlay { - @Expose - @ConfigOption( - name = "Highlight Targeted Entities", - desc = "Highlight entities that will be hit by your bonemerang" - ) - @ConfigEditorBoolean - public boolean highlightTargeted = true; - - @Expose - @ConfigOption( - name = "Break Warning", - desc = "Show a warning below your crosshair if the bonemerang will break on a block" - ) - @ConfigEditorBoolean - public boolean showBreak = true; - } - public static class AccessoryBag { @Expose @ConfigOption( @@ -1401,95 +1469,6 @@ public class NEUConfig extends Config { public boolean enableOverlay = true; } - public static class SmoothAOTE { - @Expose - @ConfigOption( - name = "Enable Smooth AOTE", - desc = "Teleport smoothly to your destination when using AOTE" - ) - @ConfigEditorBoolean - public boolean enableSmoothAOTE = true; - - @Expose - @ConfigOption( - name = "Enable Smooth Hyperion", - desc = "Teleport smoothly to your destination when using Hyperion" - ) - @ConfigEditorBoolean - public boolean enableSmoothHyperion = true; - - @Expose - @ConfigOption( - name = "Smooth TP Time", - desc = "Change the amount of time (milliseconds) taken to teleport" - ) - @ConfigEditorSlider( - minValue = 0, - maxValue = 500, - minStep = 25 - ) - public int smoothTpMillis = 175; - - - @Expose - @ConfigOption( - name = "Disable Hyperion Particles", - desc = "Remove the explosion effect when using a hyperion" - ) - @ConfigEditorBoolean - public boolean disableHyperionParticles = true; - } - - public static class RodColours { - @Expose - @ConfigOption( - name = "Enable Rod Colours", - desc = "Change the colour of your and other players' rod lines\n" + - "Also fixes the position of the rod line" - ) - @ConfigEditorBoolean - public boolean enableRodColours = true; - - @Expose - @ConfigOption( - name = "Own Rod Colour", - desc = "Change the colour of your own rod lines" - ) - @ConfigEditorColour - public String ownRodColour = "0:255:0:0:0"; - - - @Expose - @ConfigOption( - name = "Other Rod Colour", - desc = "Change the colour of other players' rod lines" - ) - @ConfigEditorColour - public String otherRodColour = "0:255:0:0:0"; - } - - public static class DungeonWin { - @Expose - @ConfigOption( - name = "Enable Dungeon Win", - desc = "Show a fancy win screen and stats when completing a dungeon" - ) - @ConfigEditorBoolean - public boolean enableDungeonWin = true; - - @Expose - @ConfigOption( - name = "Dungeon Win Time", - desc = "Change the amount of time (milliseconds) that the win screen shows for" - ) - @ConfigEditorSlider( - minValue = 0, - maxValue = 20000, - minStep = 500 - ) - public int dungeonWinMillis = 8000; - } - public static class ApiKey { @Expose @ConfigOption( @@ -1514,8 +1493,28 @@ public class NEUConfig extends Config { return arr; } - public static class Hidden { + public HiddenProfileSpecific getProfileSpecific() { + if(SBInfo.getInstance().currentProfile == null) { + return null; + } + return hidden.profileSpecific.computeIfAbsent(SBInfo.getInstance().currentProfile, k-> new HiddenProfileSpecific()); + } + + public static class HiddenProfileSpecific { + @Expose public long godPotionDrunk = 0; + @Expose public long puzzlerCompleted = 0; + @Expose public long firstCakeAte = 0; + @Expose public long fetchurCompleted = 0; + @Expose public long commissionsCompleted = 0; + @Expose public long experimentsCompleted = 0; + @Expose public long cookieBuffRemaining = 0; + @Expose public int commissionMilestone = 0; + } + + public static class Hidden { + @Expose public HashMap<String, HiddenProfileSpecific> profileSpecific = new HashMap<>(); + @Expose public boolean enableItemEditing = false; @Expose public boolean cacheRenderedItempane = true; @Expose public boolean autoupdate = true; @@ -1523,7 +1522,6 @@ public class NEUConfig extends Config { @Expose public String overlayQuickCommand = ""; @Expose public boolean dev = false; @Expose public boolean loadedModBefore = false; - @Expose public boolean doRamNotif = true; @Expose public String selectedCape = null; @Expose public int compareMode = 0; @Expose public int sortMode = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index 83e0859f..ff4b0180 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -1,15 +1,19 @@ package io.github.moulberry.notenoughupdates.options; import com.google.common.collect.Lists; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GlScissorStack; import io.github.moulberry.notenoughupdates.core.GuiElement; +import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditor; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorAccordion; import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -17,16 +21,15 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; import java.awt.*; import java.net.URI; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.*; import java.util.List; -import java.util.Map; public class NEUConfigEditor extends GuiElement { @@ -45,6 +48,8 @@ public class NEUConfigEditor extends GuiElement { "https://patreon.com/moulberry" }; + private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png"); + private final long openedMillis; private String selectedCategory = null; @@ -53,6 +58,15 @@ public class NEUConfigEditor extends GuiElement { private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig; + private TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>(); + private HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption = new HashMap<>(); + + private Set<ConfigProcessor.ProcessedCategory> searchedCategories = null; + private Map<ConfigProcessor.ProcessedCategory, Set<Integer>> searchedAccordions = null; + private Set<ConfigProcessor.ProcessedOption> searchedOptions = null; + + private LerpingInteger minimumSearchSize = new LerpingInteger(0, 150); + private GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0); public NEUConfigEditor(Config config) { this(config, null); @@ -62,6 +76,18 @@ public class NEUConfigEditor extends GuiElement { this.openedMillis = System.currentTimeMillis(); this.processedConfig = ConfigProcessor.create(config); + for(ConfigProcessor.ProcessedCategory category : processedConfig.values()) { + for(ConfigProcessor.ProcessedOption option : category.options.values()) { + categoryForOption.put(option, category); + + String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc; + combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); + for(String word : combined.split("[ _]")) { + searchOptionMap.computeIfAbsent(word, k->new HashSet<>()).add(option); + } + } + } + if(categoryOpen != null) { for(Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { if(category.getValue().name.equalsIgnoreCase(categoryOpen)) { @@ -89,18 +115,96 @@ public class NEUConfigEditor extends GuiElement { } private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() { - return processedConfig; + LinkedHashMap<String, ConfigProcessor.ProcessedCategory> newMap = new LinkedHashMap<>(processedConfig); + if(searchedCategories != null) newMap.values().retainAll(searchedCategories); + return newMap; + } + + private LinkedHashMap<String, ConfigProcessor.ProcessedOption> getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) { + LinkedHashMap<String, ConfigProcessor.ProcessedOption> newMap = new LinkedHashMap<>(cat.options); + + if(searchedOptions != null) { + Set<ConfigProcessor.ProcessedOption> retain = new HashSet<>(); + retain.addAll(searchedOptions); + + if(searchedAccordions != null) { + Set<Integer> visibleAccordions = searchedAccordions.get(cat); + + if(visibleAccordions != null && !visibleAccordions.isEmpty()) { + for(ConfigProcessor.ProcessedOption option : newMap.values()) { + if(option.editor instanceof GuiOptionEditorAccordion) { + int accordionId = ((GuiOptionEditorAccordion)option.editor).getAccordionId(); + + if(visibleAccordions.contains(accordionId)) { + retain.add(option); + } + } + } + } + + } + + newMap.values().retainAll(retain); + } + return newMap; } public String getSelectedCategory() { return selectedCategory; } + public String getSelectedCategoryName() { + return processedConfig.get(selectedCategory).name; + } + private void setSelectedCategory(String category) { selectedCategory = category; optionsScroll.setValue(0); } + public void search() { + String search = searchField.getText().trim().replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); + searchedCategories = null; + searchedOptions = null; + searchedAccordions = null; + + if(!search.isEmpty()) { + searchedCategories = new HashSet<>(); + searchedAccordions = new HashMap<>(); + + for(String word : search.split(" ")) { + if(word.trim().isEmpty()) continue; + + Set<ConfigProcessor.ProcessedOption> options = new HashSet<>(); + + Map<String, Set<ConfigProcessor.ProcessedOption>> map = NotEnoughUpdates.INSTANCE.manager + .subMapWithKeysThatAreSuffixes(word, searchOptionMap); + + map.values().forEach(options::addAll); + + if(!options.isEmpty()) { + if(searchedOptions == null) { + searchedOptions = new HashSet<>(options); + } else { + searchedOptions.retainAll(options); + } + } + } + + if(searchedOptions == null) { + searchedOptions = new HashSet<>(); + } else { + for(ConfigProcessor.ProcessedOption option : searchedOptions) { + ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option); + if(cat == null) continue; + + searchedCategories.add(cat); + searchedAccordions.computeIfAbsent(cat, k->new HashSet<>()).add(option.accordionId); + } + } + } + } + public void render() { optionsScroll.tick(); categoryScroll.tick(); @@ -172,8 +276,11 @@ public class NEUConfigEditor extends GuiElement { float catBarSize = 1; int catY = -categoryScroll.getValue(); - for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { - if(getSelectedCategory() == null) { + + LinkedHashMap<String, ConfigProcessor.ProcessedCategory> currentConfigEditing = getCurrentConfigEditing(); + for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) { + String selectedCategory = getSelectedCategory(); + if(selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { setSelectedCategory(entry.getKey()); } String catName = entry.getValue().name; @@ -212,20 +319,45 @@ public class NEUConfigEditor extends GuiElement { TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", fr, x+75, y+44, false, 120, 0xa368ef); - RenderUtils.drawFloatingRectDark(x+149, y+29, - xSize-154, ySize-34, false); - - if(getSelectedCategory() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - - TextRenderUtils.drawStringCenteredScaledMaxWidth(cat.desc, - fr, x+xSize/2+72, y+44, true, xSize-154-innerPadding*2, 0xb0b0b0); - } + RenderUtils.drawFloatingRectDark(x+149, y+29, xSize-154, ySize-34, false); innerLeft = x+149+innerPadding; innerRight =x+xSize-5-innerPadding; - //innerTop = y+29+innerPadding; innerBottom = y+ySize-5-innerPadding; + + Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_ICON); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(innerRight-20, innerTop-(20+innerPadding)/2-9, 18, 18, GL11.GL_NEAREST); + + minimumSearchSize.tick(); + boolean shouldShow = !searchField.getText().trim().isEmpty() || searchField.getFocus(); + if(shouldShow && minimumSearchSize.getTarget() < 30) { + minimumSearchSize.setTarget(30); + minimumSearchSize.resetTimer(); + } else if(!shouldShow && minimumSearchSize.getTarget() > 0) { + minimumSearchSize.setTarget(0); + minimumSearchSize.resetTimer(); + } + + int rightStuffLen = 20; + if(minimumSearchSize.getValue() > 1) { + int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10; + if(!shouldShow) strLen = 0; + + int len = Math.max(strLen, minimumSearchSize.getValue()); + searchField.setSize(len, 18); + searchField.render(innerRight-25-len, innerTop-(20+innerPadding)/2-9); + + rightStuffLen += 5 + len; + } + + if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + + TextRenderUtils.drawStringScaledMaxWidth(cat.desc, + fr, innerLeft+5, y+40, true, innerRight-innerLeft-rightStuffLen-10, 0xb0b0b0); + } + Gui.drawRect(innerLeft, innerTop, innerLeft+1, innerBottom, 0xff08080E); //Left Gui.drawRect(innerLeft+1, innerTop, innerRight, innerTop+1, 0xff08080E); //Top Gui.drawRect(innerRight-1, innerTop+1, innerRight, innerBottom, 0xff303036); //Right @@ -235,18 +367,33 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.push(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, scaledResolution); float barSize = 1; int optionY = -optionsScroll.getValue(); - if(getSelectedCategory() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - int optionWidth = innerRight-innerLeft-20; + if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + int optionWidthDefault = innerRight-innerLeft-20; GlStateManager.enableDepth(); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2*innerPadding; + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } int optionHeight = editor.getHeight(); if(innerTop+5+optionY+optionHeight > innerTop+1 && innerTop+5+optionY < innerBottom-1) { - editor.render(innerLeft+5, innerTop+5+optionY, optionWidth); + editor.render((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth); } optionY += optionHeight + 5; } @@ -259,21 +406,36 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.pop(scaledResolution); GL11.glDisable(GL11.GL_SCISSOR_TEST); - if(getSelectedCategory() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { int optionYOverlay = -optionsScroll.getValue(); - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - int optionWidth = innerRight-innerLeft-20; + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + int optionWidthDefault = innerRight-innerLeft-20; GlStateManager.translate(0, 0, 10); GlStateManager.enableDepth(); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2*innerPadding; + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } int optionHeight = editor.getHeight(); if(innerTop+5+optionYOverlay+optionHeight > innerTop+1 && innerTop+5+optionYOverlay < innerBottom-1) { - editor.renderOverlay(innerLeft+5, innerTop+5+optionYOverlay, optionWidth); + editor.renderOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionYOverlay, optionWidth); } optionYOverlay += optionHeight + 5; } @@ -338,6 +500,24 @@ public class NEUConfigEditor extends GuiElement { int innerLeft = x+149+innerPadding; int innerRight = x+xSize-5-innerPadding; + if(Mouse.getEventButtonState()) { + searchField.setFocus(mouseX >= innerRight-20 && mouseX <= innerRight-2 && + mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9); + + if(minimumSearchSize.getValue() > 1) { + int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10; + int len = Math.max(strLen, minimumSearchSize.getValue()); + + if(mouseX >= innerRight-25-len && mouseX <= innerRight-25 && + mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9) { + String old = searchField.getText(); + searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); + + if(!searchField.getText().equals(old)) search(); + } + } + } + int dWheel = Mouse.getEventDWheel(); if(mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { if(dWheel < 0) { @@ -347,11 +527,9 @@ public class NEUConfigEditor extends GuiElement { dWheel = 1; } if(mouseX < innerLeft) { - boolean resetTimer = true; int newTarget = categoryScroll.getTarget() - dWheel*30; if(newTarget < 0) { newTarget = 0; - resetTimer = false; } float catBarSize = 1; @@ -360,6 +538,7 @@ public class NEUConfigEditor extends GuiElement { if(getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } + catY += 15; if(catY > 0) { catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+newTarget)); @@ -369,29 +548,37 @@ public class NEUConfigEditor extends GuiElement { int barMax = (int)Math.floor((catY+5+newTarget)-catBarSize*(catY+5+newTarget)); if(newTarget > barMax) { newTarget = barMax; - resetTimer = false; } - //if(categoryScroll.getTimeSpent() <= 0 || (resetTimer && categoryScroll.getTarget() != newTarget)) { categoryScroll.resetTimer(); - //} categoryScroll.setTarget(newTarget); } else { - boolean resetTimer = true; int newTarget = optionsScroll.getTarget() - dWheel*30; if(newTarget < 0) { newTarget = 0; - resetTimer = false; } float barSize = 1; int optionY = -newTarget; if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } optionY += editor.getHeight() + 5; if(optionY > 0) { @@ -403,11 +590,9 @@ public class NEUConfigEditor extends GuiElement { int barMax = (int)Math.floor((optionY+5+newTarget)-barSize*(optionY+5+newTarget)); if(newTarget > barMax) { newTarget = barMax; - resetTimer = false; - } - if(optionsScroll.getTimeSpent() <= 0 || (resetTimer && optionsScroll.getTarget() != newTarget)) { - optionsScroll.resetTimer(); } + optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5*Math.abs(newTarget - optionsScroll.getValue())))); + optionsScroll.resetTimer(); optionsScroll.setTarget(newTarget); } } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { @@ -441,14 +626,28 @@ public class NEUConfigEditor extends GuiElement { int optionY = -optionsScroll.getValue(); if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidth = innerRight-innerLeft-20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + int optionWidthDefault = innerRight-innerLeft-20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2*innerPadding; + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } - if(editor.mouseInputOverlay(innerLeft+5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + if(editor.mouseInputOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; @@ -459,14 +658,29 @@ public class NEUConfigEditor extends GuiElement { mouseY > innerTop && mouseY < innerBottom) { optionY = -optionsScroll.getValue(); if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidth = innerRight-innerLeft-20; + int optionWidthDefault = innerRight-innerLeft-20; ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2*innerPadding; + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } - if(editor.mouseInput(innerLeft+5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + if(editor.mouseInput((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; @@ -478,13 +692,45 @@ public class NEUConfigEditor extends GuiElement { } public boolean keyboardInput() { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + + int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500); + + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int innerPadding = 20/adjScaleFactor; + int innerWidth = xSize-154-innerPadding*2; + + if(Keyboard.getEventKeyState()) { + Keyboard.enableRepeatEvents(true); + String old = searchField.getText(); + searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(searchField.getText(), innerWidth/2-20)); + + if(!searchField.getText().equals(old)) search(); + } + if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + Set<Integer> activeAccordions = new HashSet<>(); + for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if(option.accordionId >= 0) { + if(!activeAccordions.contains(option.accordionId)) { + continue; + } + } + GuiOptionEditor editor = option.editor; if(editor == null) { continue; } + if(editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if(accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } if(editor.keyboardInput()) { return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 152d201d..81c2b342 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -134,6 +134,7 @@ public class AuctionSearchOverlay { Minecraft.getMinecraft().fontRendererObj.drawString("Enter Query:", width/2-100, topY-10, 0xdddddd, true); + textField.setFocus(true); textField.setText(searchString); textField.setSize(149, 20); textField.setCustomBorderColour(0xffffff); 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 ecb4ee5b..e6310022 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java @@ -23,7 +23,6 @@ public class FarmingOverlay extends TextOverlay { private long lastUpdate = -1; private int counterLast = -1; private int counter = -1; - private boolean dicerHeld = false; private float cropsPerSecondLast = 0; private float cropsPerSecond = 0; private LinkedList<Integer> counterQueue = new LinkedList<>(); @@ -60,7 +59,6 @@ public class FarmingOverlay extends TextOverlay { if(!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) { counter = -1; overlayStrings = null; - dicerHeld = false; return; } @@ -93,9 +91,6 @@ public class FarmingOverlay extends TextOverlay { } else { skillType = "Farming"; } - if(internalname != null && (internalname.equals("MELON_DICER") || internalname.equals("PUMPKIN_DICER"))) { - dicerHeld = true; - } skillInfoLast = skillInfo; skillInfo = XPInformation.getInstance().getSkillInfo(skillType); @@ -156,7 +151,7 @@ public class FarmingOverlay extends TextOverlay { cropsPerSecond = (first - last)/3f; } - if(counter != -1 || dicerHeld) { + if(counter != -1) { overlayStrings = new ArrayList<>(); } else { overlayStrings = null; @@ -168,7 +163,7 @@ public class FarmingOverlay extends TextOverlay { public void updateFrequent() { super.updateFrequent(); - if(counter < 0 && !dicerHeld) { + if(counter < 0) { overlayStrings = null; } else { HashMap<Integer, String> lineMap = new HashMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 5cb58dcd..dc0ec8f4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.util.EnumChatFormatting; @@ -23,6 +24,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.*; import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static net.minecraft.util.EnumChatFormatting.*; @@ -32,10 +35,54 @@ public class MiningOverlay extends TextOverlay { super(position, dummyStrings, styleSupplier); } + private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+"); + private static Map<String, Integer> commissionMaxes = new HashMap<>(); public static Map<String, Float> commissionProgress = new LinkedHashMap<>(); @Override public void update() { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) chest.inventorySlots; + IInventory lower = container.getLowerChestInventory(); + String containerName = lower.getDisplayName().getUnformattedText(); + + if(containerName.equals("Commissions") && lower.getSizeInventory() >= 18) { + for(int i=9; i<18; i++) { + ItemStack stack = lower.getStackInSlot(i); + if(stack != null && stack.hasTagCompound()) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + String name = null; + int numberValue = -1; + for(String line : lore) { + if(line.startsWith("\u00a77\u00a79")) { + String textAfter = line.substring(4); + if(!textAfter.contains("\u00a7") && !textAfter.equals("Rewards") && !textAfter.equals("Progress")) { + name = textAfter; + } + } + if(name != null) { + String clean = Utils.cleanColour(line).trim(); + if(clean.isEmpty()) { + break; + } else { + Matcher matcher = NUMBER_PATTERN.matcher(clean); + if(matcher.find()) { + try { + numberValue = Integer.parseInt(matcher.group()); + } catch(NumberFormatException ignored) {} + } + } + } + } + if(name != null && numberValue > 0) { + commissionMaxes.put(name, numberValue); + } + } + } + } + } + overlayStrings = null; /*if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { @@ -176,10 +223,14 @@ public class MiningOverlay extends TextOverlay { } else if(entry.getValue() >= 0.25) { col = GOLD; } + if(true && commissionMaxes.containsKey(entry.getKey())) { + int max = commissionMaxes.get(entry.getKey()); + commissionsStrings.add(DARK_AQUA+entry.getKey() + ": " + col+Math.round(entry.getValue()*max)+"/"+max); + } else { + String valS = Utils.floatToString(entry.getValue()*100, 1); - String valS = Utils.floatToString(entry.getValue()*100, 1); - - commissionsStrings.add(DARK_AQUA+entry.getKey() + ": " + col+valS+"%"); + commissionsStrings.add(DARK_AQUA+entry.getKey() + ": " + col+valS+"%"); + } } } /*boolean hasAny = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index 55ed608b..e5f7b2a8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.overlays; import com.google.common.collect.Lists; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import java.util.ArrayList; @@ -14,9 +15,18 @@ public class OverlayManager { public static MiningOverlay miningOverlay; public static FarmingOverlay farmingOverlay; public static PetInfoOverlay petInfoOverlay; + public static TimersOverlay timersOverlay; public static final List<TextOverlay> textOverlays = new ArrayList<>(); static { + textOverlays.add(timersOverlay = new TimersOverlay(new Position(50, 100), ArrayList::new, () -> { + int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; + if(style >= 0 && style < TextOverlayStyle.values().length) { + return TextOverlayStyle.values()[style]; + } + return TextOverlayStyle.BACKGROUND; + })); + List<String> miningDummy = Lists.newArrayList("\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", "\u00a73Mithril Powder: \u00a726,243", "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java new file mode 100644 index 00000000..a2a1817f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -0,0 +1,338 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.Ordering; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.world.WorldSettings; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.*; +import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static net.minecraft.util.EnumChatFormatting.*; + +public class TimersOverlay extends TextOverlay { + + public TimersOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) { + super(position, dummyStrings, styleSupplier); + } + + private static final Pattern CAKE_PATTERN = Pattern.compile("\u00a7r\u00a7d\u00a7lYum! \u00a7r\u00a7eYou gain .+ \u00a7r\u00a7efor \u00a7r\u00a7a48 \u00a7r\u00a7ehours!\u00a7r"); + private static final Pattern PUZZLER_PATTERN = Pattern.compile("\u00a7r\u00a7dPuzzler\u00a7r\u00a76 gave you .+ \u00a7r\u00a76for solving the puzzle!\u00a7r"); + private static final Pattern FETCHUR_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rthanks thats probably what i needed\u00a7r"); + private static final Pattern FETCHUR2_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rcome back another time, maybe tmrw\u00a7r"); + private static final Pattern GODPOT_PATTERN = Pattern.compile("\u00a7r\u00a7a\u00a7lGULP! \u00a7r\u00a7eThe \u00a7r\u00a7cGod Potion \u00a7r\u00a7egrants you" + + " powers for \u00a7r\u00a7924 hours\u00a7r\u00a7e!\u00a7r"); + + private boolean hideGodpot = false; + + @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) + public void onChatMessageReceived(ClientChatReceivedEvent event) { + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if(hidden == null) return; + + if(event.type == 0) { + long currentTime = System.currentTimeMillis(); + + Matcher cakeMatcher = CAKE_PATTERN.matcher(event.message.getFormattedText()); + if(cakeMatcher.matches()) { + hidden.firstCakeAte = currentTime; + return; + } + + Matcher puzzlerMatcher = PUZZLER_PATTERN.matcher(event.message.getFormattedText()); + if(puzzlerMatcher.matches()) { + hidden.puzzlerCompleted = currentTime; + return; + } + + Matcher fetchurMatcher = FETCHUR_PATTERN.matcher(event.message.getFormattedText()); + if(fetchurMatcher.matches()) { + hidden.fetchurCompleted = currentTime; + return; + } + + Matcher fetchur2Matcher = FETCHUR2_PATTERN.matcher(event.message.getFormattedText()); + if(fetchur2Matcher.matches()) { + hidden.fetchurCompleted = currentTime; + return; + } + + Matcher godpotMatcher = GODPOT_PATTERN.matcher(event.message.getFormattedText()); + if(godpotMatcher.matches()) { + hidden.godPotionDrunk = currentTime; + return; + } + } + } + + private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile("\u00a77You have \u00a7r\u00a7e(\\d+) \u00a7r\u00a77active effects."); + + @Override + public void update() { + long currentTime = System.currentTimeMillis(); + + NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if(hidden == null) return; + + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) chest.inventorySlots; + IInventory lower = container.getLowerChestInventory(); + String containerName = lower.getDisplayName().getUnformattedText(); + + if(containerName.equals("Commissions") && lower.getSizeInventory() >= 18) { + if(hidden.commissionsCompleted == 0) { + hidden.commissionsCompleted = currentTime; + } + for(int i=9; i<18; i++) { + ItemStack stack = lower.getStackInSlot(i); + if(stack != null && stack.hasTagCompound()) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + for(String line : lore) { + if(line.contains("(Daily")) { + hidden.commissionsCompleted = 0; + break; + } + } + } + } + } else if(containerName.equals("Experimentation Table") && lower.getSizeInventory() >= 36) { + ItemStack stack = lower.getStackInSlot(31); + if(stack != null) { + if(stack.getItem() == Items.blaze_powder) { + if(hidden.experimentsCompleted == 0) { + hidden.experimentsCompleted = currentTime; + } + } else { + hidden.experimentsCompleted = 0; + } + } + } + } + + boolean foundCookieBuffText = false; + if(SBInfo.getInstance().footer != null) { + String formatted = SBInfo.getInstance().footer.getFormattedText(); + for(String line : formatted.split("\n")) { + Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line); + if(activeEffectsMatcher.find()) { + String numEffectsS = activeEffectsMatcher.group(1); + try { + int numEffects = Integer.parseInt(numEffectsS); + hideGodpot = numEffects > 25; + } catch(NumberFormatException ignored) {} + } else if(line.contains("\u00a7d\u00a7lCookie Buff")) { + foundCookieBuffText = true; + } else if(foundCookieBuffText) { + String cleanNoSpace = line.replaceAll("(\u00a7.| )", ""); + + hidden.cookieBuffRemaining = 0; + StringBuilder number = new StringBuilder(); + for(int i=0; i<cleanNoSpace.length(); i++) { + char c = cleanNoSpace.charAt(i); + + if(c >= '0' && c <= '9') { + number.append(c); + } else { + if(number.length() == 0) { + hidden.cookieBuffRemaining = 0; + break; + } + if("ydhms".contains(""+c)) { + try { + int val = Integer.parseInt(number.toString()); + switch(c) { + case 'y': hidden.cookieBuffRemaining += val*365*24*60*60*1000; break; + case 'd': hidden.cookieBuffRemaining += val*24*60*60*1000; break; + case 'h': hidden.cookieBuffRemaining += val*60*60*1000; break; + case 'm': hidden.cookieBuffRemaining += val*60*1000; break; + case 's': hidden.cookieBuffRemaining += val*1000; break; + } + } catch(NumberFormatException e) { + hidden.cookieBuffRemaining = 0; + break; + } + + number = new StringBuilder(); + } else { + hidden.cookieBuffRemaining = 0; + break; + } + } + } + + break; + } + } + } + + overlayStrings = new ArrayList<>(); + + long cakeEnd = hidden.firstCakeAte + 1000*60*60*48 - currentTime; + if(cakeEnd < 0) { + overlayStrings.add(DARK_AQUA+"Cakes: "+YELLOW+"Ready!"); + } else { + overlayStrings.add(DARK_AQUA+"Cakes: "+YELLOW+Utils.prettyTime(cakeEnd)); + } + + long puzzlerEnd = hidden.puzzlerCompleted + 1000*60*60*24 - currentTime; + if(puzzlerEnd < 0) { + overlayStrings.add(DARK_AQUA+"Puzzler: "+YELLOW+"Ready!"); + } else { + overlayStrings.add(DARK_AQUA+"Puzzler: "+YELLOW+Utils.prettyTime(puzzlerEnd)); + } + + if(!hideGodpot) { + long godpotEnd = hidden.godPotionDrunk + 1000*60*60*24 - currentTime; + if(godpotEnd < 0) { + overlayStrings.add(DARK_AQUA+"Godpot: "+YELLOW+"Inactive!"); + } else { + overlayStrings.add(DARK_AQUA+"Godpot: "+YELLOW+Utils.prettyTime(puzzlerEnd)); + } + } + + long midnightReset = (currentTime-18000000)/86400000*86400000+18000000; + long fetchurComplete = hidden.fetchurCompleted; + if(fetchurComplete < midnightReset) { + overlayStrings.add(DARK_AQUA+"Fetchur: "+YELLOW+"Ready!"); + } else { + overlayStrings.add(DARK_AQUA+"Fetchur: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + } + + if(hidden.commissionsCompleted < midnightReset) { + overlayStrings.add(DARK_AQUA+"Commissions: "+YELLOW+"Ready!"); + } else { + overlayStrings.add(DARK_AQUA+"Commissions: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + } + + if(hidden.experimentsCompleted < midnightReset) { + overlayStrings.add(DARK_AQUA+"Experiments: "+YELLOW+"Ready!"); + } else { + overlayStrings.add(DARK_AQUA+"Experiments: "+YELLOW+Utils.prettyTime(midnightReset + 86400000 - currentTime)); + } + + if(hidden.cookieBuffRemaining <= 0) { + overlayStrings.add(DARK_AQUA+"Cookie Buff: "+YELLOW+"Inactive!"); + } else { + overlayStrings.add(DARK_AQUA+"Cookie Buff: "+YELLOW+Utils.prettyTime(hidden.cookieBuffRemaining)); + } + + /*List<NetworkPlayerInfo> players = playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + Minecraft.getMinecraft().thePlayer.sendQueue. + for(NetworkPlayerInfo info : players) { + String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); + if(name.contains("Mithril Powder:")) { + mithrilPowder = DARK_AQUA+Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); + } + if(name.equals(RESET.toString()+BLUE+BOLD+"Forges"+RESET)) { + commissions = false; + forges = true; + continue; + } else if(name.equals(RESET.toString()+BLUE+BOLD+"Commissions"+RESET)) { + commissions = true; + forges = false; + continue; + } + String clean = StringUtils.cleanColour(name); + if(forges && clean.startsWith(" ")) { + char firstChar = clean.trim().charAt(0); + if(firstChar < '0' || firstChar > '9') { + forges = false; + } else { + if(name.contains("LOCKED")) continue; + if(name.contains("EMPTY")) { + forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + } else { + forgeStrings.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + } + } + } else if(commissions && clean.startsWith(" ")) { + String[] split = clean.trim().split(": "); + if(split.length == 2) { + if(split[1].endsWith("%")) { + try { + float progress = Float.parseFloat(split[1].replace("%", ""))/100; + progress = LerpUtils.clampZeroOne(progress); + commissionProgress.put(split[0], progress); + } catch(Exception ignored) {} + } else { + commissionProgress.put(split[0], 1.0f); + } + } + } else { + commissions = false; + forges = false; + } + }*/ + + /*boolean hasAny = false; + if(NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) { + overlayStrings.addAll(commissionsStrings); + hasAny = true; + } + if(NotEnoughUpdates.INSTANCE.config.mining.powderOverlay) { + if(mithrilPowder != null) { + if(hasAny) overlayStrings.add(null); + overlayStrings.add(DARK_AQUA+mithrilPowder); + hasAny = true; + } + } + if(NotEnoughUpdates.INSTANCE.config.mining.forgeOverlay) { + if(hasAny) overlayStrings.add(null); + overlayStrings.addAll(forgeStrings); + }*/ + + /*for(int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { + switch(index) { + case 0: + overlayStrings.addAll(commissionsStrings); break; + case 1: + overlayStrings.add(mithrilPowder); break; + case 2: + overlayStrings.addAll(forgeStrings); break; + case 3: + overlayStrings.addAll(forgeStringsEmpty); break; + } + } + + if(overlayStrings.isEmpty()) overlayStrings = null;*/ + } + + private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator()); + + @SideOnly(Side.CLIENT) + static class PlayerComparator implements Comparator<NetworkPlayerInfo> { + private PlayerComparator() { } + + public int compare(NetworkPlayerInfo o1, NetworkPlayerInfo o2) { + ScorePlayerTeam team1 = o1.getPlayerTeam(); + ScorePlayerTeam team2 = o2.getPlayerTeam(); + return ComparisonChain.start().compareTrueFirst( + o1.getGameType() != WorldSettings.GameType.SPECTATOR, + o2.getGameType() != WorldSettings.GameType.SPECTATOR) + .compare(team1 != null ? team1.getRegisteredName() : "", team2 != null ? team2.getRegisteredName() : "") + .compare(o1.getGameProfile().getName(), o2.getGameProfile().getName()).result(); + } + } + + +} 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 3d186de2..f8023e18 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1350,6 +1350,7 @@ public class GuiProfileViewer extends GuiScreen { int displayLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(display); int halfDisplayLen = displayLen/2; + GlStateManager.pushMatrix(); GlStateManager.translate(x, y, 0); drawRect(-halfDisplayLen-1-28, -1, halfDisplayLen+1-28, 8, new Color(0, 0, 0, 100).getRGB()); @@ -1357,11 +1358,11 @@ public class GuiProfileViewer extends GuiScreen { Minecraft.getMinecraft().fontRendererObj.drawString(display, -halfDisplayLen-28, 0, 0, true); ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item); - GlStateManager.scale(3.5f, 3.5f, 1); GlStateManager.enableDepth(); + GlStateManager.translate(-55, 0, 0); + GlStateManager.scale(3.5f, 3.5f, 1); Utils.drawItemStack(stack, 0, 0); - GlStateManager.scale(-1/3.5f, 1/3.5f, 1); - GlStateManager.translate(-x, -y, 0); + GlStateManager.popMatrix(); break; } } @@ -2527,6 +2528,11 @@ public class GuiProfileViewer extends GuiScreen { Arrays.fill(entityPlayer.inventory.armorInventory, null); } } + System.out.println(entityPlayer.getUniqueID().toString()); + if(entityPlayer.getUniqueID().toString().equals("ae6193ab-494a-4719-b6e7-d50392c8f012")) { + entityPlayer.inventory.armorInventory[3] = NotEnoughUpdates.INSTANCE.manager.jsonToStack( + NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SMALL_BACKPACK")); + } } if(entityPlayer != null && playerLocationSkin == null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java index 9c9cba53..f7d5157f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java @@ -135,7 +135,7 @@ public class HypixelApi { } public String generateApiUrl(String apiKey, String method, HashMap<String, String> args) { - StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method + (apiKey != null ? ("?key=" + apiKey) : "")); + StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method + (apiKey != null ? ("?key=" + apiKey.replace(" ", "")) : "")); boolean first = true; for(Map.Entry<String, String> entry : args.entrySet()) { if(first && apiKey == null) { 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 090b3b59..13317776 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -5,11 +5,13 @@ 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.client.network.NetworkPlayerInfo; 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.minecraft.util.IChatComponent; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.event.world.WorldEvent; @@ -31,6 +33,9 @@ public class SBInfo { private static final Pattern timePattern = Pattern.compile(".+(am|pm)"); + public IChatComponent footer; + public IChatComponent header; + public String location = ""; public String date = ""; public String time = ""; @@ -51,6 +56,8 @@ public class SBInfo { private long joinedWorld = -1; private JsonObject locraw = null; + public String currentProfile = null; + @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; @@ -120,6 +127,14 @@ public class SBInfo { } try { + for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); + final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; + if(name.startsWith(profilePrefix)) { + currentProfile = Utils.cleanColour(name.substring(profilePrefix.length())); + } + } + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); //ยง707/14/20 diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java index 0652ee9d..c3535ab4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java @@ -27,6 +27,7 @@ public class XPInformation { public float totalXp; public float currentXp; public float currentXpMax; + public boolean fromApi = false; } private HashMap<String, SkillInfo> skillInfoMap = new HashMap<>(); @@ -68,7 +69,7 @@ public class XPInformation { JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp"); for(int i=0; i<levelingArray.size(); i++) { float cap = levelingArray.get(i).getAsFloat(); - if(maxXp <= cap) { + if(maxXp > 0 && maxXp <= cap) { break; } @@ -101,6 +102,7 @@ public class XPInformation { info.currentXpMax = skillInfo.get("maxxp_skill_"+skill).getAsFloat(); info.level = (int)level; info.currentXp = (level%1)*info.currentXpMax; + info.fromApi = true; skillInfoMap.put(skill.toLowerCase(), info); } diff --git a/src/main/resources/assets/notenoughupdates/capes/soldier.png b/src/main/resources/assets/notenoughupdates/capes/soldier.png Binary files differnew file mode 100644 index 00000000..7dbc8565 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/capes/soldier.png diff --git a/src/main/resources/assets/notenoughupdates/capes/soldier_preview.png b/src/main/resources/assets/notenoughupdates/capes/soldier_preview.png Binary files differnew file mode 100644 index 00000000..5c8b1d8b --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/capes/soldier_preview.png diff --git a/src/main/resources/assets/notenoughupdates/core/search.png b/src/main/resources/assets/notenoughupdates/core/search.png Binary files differnew file mode 100644 index 00000000..4af69f6e --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/core/search.png diff --git a/src/main/resources/assets/notenoughupdates/hhh.json b/src/main/resources/assets/notenoughupdates/hhh.json deleted file mode 100644 index 1d34aafc..00000000 --- a/src/main/resources/assets/notenoughupdates/hhh.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "credit": "Made with Blockbench", - "textures": { - "0": "Desktop/hhhh", - "particle": "Desktop/hhhh" - }, - "elements": [ - { - "from": [4, -4, 4], - "to": [12, 4, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [12, 4, 12]}, - "faces": { - "north": {"uv": [0, 0, 8, 8], "texture": "#0"}, - "east": {"uv": [0, 0, 8, 8], "texture": "#0"}, - "south": {"uv": [0, 0, 8, 8], "texture": "#0"}, - "west": {"uv": [0, 0, 8, 8], "texture": "#0"}, - "up": {"uv": [0, 0, 8, 8], "texture": "#0"}, - "down": {"uv": [0, 0, 8, 8], "texture": "#0"} - } - } - ] -}
\ No newline at end of file diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 3b8669cb..3fc98025 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -26,6 +26,7 @@ "MixinRendererLivingEntity", "GuiEditSignAccessor", "MixinGuiScreen", - "MixinTileEntitySkullRenderer" + "MixinTileEntitySkullRenderer", + "MixinItemCameraTransforms" ] }
\ No newline at end of file |