diff options
author | BuildTools <james.jenour@protonmail.com> | 2021-01-18 23:59:09 +0800 |
---|---|---|
committer | BuildTools <james.jenour@protonmail.com> | 2021-01-18 23:59:09 +0800 |
commit | 3255cfce951367c9303297205f64577ef1eac650 (patch) | |
tree | f43ceb889dc96aed62b378bdc4f5fe3fd3fd95ac /src/main/java | |
parent | c9cc530adfb39085fe4b0f9a60e0ca6e4bbb8eb9 (diff) | |
download | NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.tar.gz NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.tar.bz2 NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.zip |
gravy
Diffstat (limited to 'src/main/java')
30 files changed, 1161 insertions, 131 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 8d71992e..cafbff05 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -2,6 +2,9 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.APIManager; +import io.github.moulberry.notenoughupdates.util.Constants; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; @@ -11,7 +14,7 @@ import java.util.Locale; public class ItemPriceInformation { - public static boolean addToTooltip(List<String> tooltip, String internalname) { + public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) { JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); @@ -106,6 +109,44 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBinAvg)+" coins"); } break; + case 6: + if(Constants.ESSENCECOSTS == null) break; + JsonObject essenceCosts = Constants.ESSENCECOSTS; + if(!essenceCosts.has(internalname)) { + break; + } + JsonObject itemCosts = essenceCosts.get(internalname).getAsJsonObject(); + String essenceType = itemCosts.get("type").getAsString(); + + int dungeonItemLevel = -1; + if(stack != null && stack.hasTagCompound() && + stack.getTagCompound().hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = stack.getTagCompound().getCompoundTag("ExtraAttributes"); + + if (ea.hasKey("dungeon_item_level", 99)) { + dungeonItemLevel = ea.getInteger("dungeon_item_level"); + } + } + if(dungeonItemLevel == -1) { + int dungeonizeCost = 0; + if(itemCosts.has("dungeonize")) { + dungeonizeCost = itemCosts.get("dungeonize").getAsInt(); + } + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Dungeonize Cost: " + + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+dungeonizeCost+" "+essenceType); + } else if(dungeonItemLevel >= 0 && dungeonItemLevel <= 4) { + String costType = (dungeonItemLevel+1)+""; + + int upgradeCost = itemCosts.get(costType).getAsInt(); + StringBuilder star = new StringBuilder(); + for(int i=0; i<=dungeonItemLevel; i++) { + star.append('\u272A'); + } + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Upgrade to "+ + EnumChatFormatting.GOLD+star+EnumChatFormatting.YELLOW+EnumChatFormatting.BOLD+": " + + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+upgradeCost+" "+essenceType); + } + break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 1111a580..e0a487b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -10,6 +10,7 @@ import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; +import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; @@ -134,6 +135,8 @@ public class NEUEventListener { private long notificationDisplayMillis = 0; private List<String> notificationLines = null; + private static Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); + /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. @@ -160,6 +163,37 @@ public class NEUEventListener { } DungeonWin.tick(); if(longUpdate) { + FairySouls.tick(); + if(TradeWindow.hypixelTradeWindowActive()) { + for(int i=0; i<16; i++) { + int x = i % 4; + int y = i / 4; + int containerIndex = y*9+x+5; + + GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen); + + ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex); + if(stack != null && BAD_ITEM_REGEX.matcher(Utils.cleanColour(stack.getDisplayName())).find()) { + Minecraft.getMinecraft().ingameGUI.displayTitle( + null, null, + 4, 200, 4); + Minecraft.getMinecraft().ingameGUI.displayTitle( + null, + EnumChatFormatting.RED+"WARNING: GLITCHED ITEM DETECTED IN TRADE WINDOW. CANCELLING TRADE", + -1, -1, -1); + Minecraft.getMinecraft().ingameGUI.displayTitle( + EnumChatFormatting.RED+"YOU ARE TRADING WITH A SCAMMER!", + null, + -1, -1, -1); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ + "WARNING: The person you are trading with just tried to give you a glitched item.\n" + + "The item is NOT worth what they say it is worth.\n" + + "Report this scammer immediately and ignore them!")); + break; + } + } + } + NotEnoughUpdates.INSTANCE.overlay.redrawItems(); CapeManager.onTickSlow(); @@ -636,10 +670,16 @@ public class NEUEventListener { } if(focusInv) { try { - neu.overlay.render(hoverInv && focusInv); + neu.overlay.render(hoverInv); } catch(ConcurrentModificationException e) {e.printStackTrace();} GL11.glTranslatef(0, 0, 10); } + if(hoverInv) { + renderDungeonChestOverlay(event.gui); + if(neu.config.accessoryBag.enableOverlay) { + AccessoryBagOverlay.renderOverlay(); + } + } } } @@ -708,7 +748,7 @@ public class NEUEventListener { } } - if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) { renderDungeonChestOverlay(event.gui); if(neu.config.accessoryBag.enableOverlay) { AccessoryBagOverlay.renderOverlay(); @@ -943,6 +983,8 @@ public class NEUEventListener { ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); + JsonObject essenceJson = new JsonObject(); + /** * Sends a kbd event to NEUOverlay, cancelling if NEUOverlay#keyboardInput returns true. * Also includes a dev function used for creating custom named json files with recipes. @@ -976,6 +1018,62 @@ public class NEUEventListener { } } if(neu.config.hidden.dev && neu.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null && + Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.getEventKeyState()) { + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if(gui instanceof GuiChest) { + GuiChest eventGui = (GuiChest) event.gui; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + + if(!lower.getDisplayName().getUnformattedText().endsWith("Essence")) return; + + for(int i=0; i<lower.getSizeInventory(); i++) { + ItemStack stack = lower.getStackInSlot(i); + + String internalname = neu.manager.getInternalNameForItem(stack); + if(internalname != null) { + String[] lore = neu.manager.getLoreFromNBT(stack.getTagCompound()); + + for(String line : lore) { + if(line.contains(":") && (line.startsWith("\u00A77Upgrade to") || + line.startsWith("\u00A77Convert to Dungeon Item"))) { + String[] split = line.split(":"); + String after = Utils.cleanColour(split[1]); + StringBuilder costS = new StringBuilder(); + for(char c : after.toCharArray()) { + if(c >= '0' && c <= '9') { + costS.append(c); + } + } + int cost = Integer.parseInt(costS.toString()); + String[] afterSplit = after.split(" "); + String type = afterSplit[afterSplit.length-2]; + + if(!essenceJson.has(internalname)) { + essenceJson.add(internalname, new JsonObject()); + } + JsonObject obj = essenceJson.get(internalname).getAsJsonObject(); + obj.addProperty("type", type); + + if(line.startsWith("\u00A77Convert to Dungeon Item")) { + obj.addProperty("dungeonize", cost); + } else if(line.startsWith("\u00A77Upgrade to")) { + int stars = 0; + for(char c : line.toCharArray()) { + if(c == '\u272A') stars++; + } + if(stars > 0) { + obj.addProperty(stars+"", cost); + } + } + } + } + } + } + System.out.println(essenceJson); + } + } + if(neu.config.hidden.dev && neu.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null && Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.getEventKeyState()) { GuiScreen gui = Minecraft.getMinecraft().currentScreen; if(gui instanceof GuiChest) { @@ -1284,7 +1382,7 @@ public class NEUEventListener { newTooltip.add(""); newTooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]"); } else { - ItemPriceInformation.addToTooltip(newTooltip, internalname); + ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack); } } } @@ -1443,7 +1541,7 @@ public class NEUEventListener { event.toolTip.addAll(newTooltip); if(neu.config.tooltipTweaks.showPriceInfoInvItem) { - ItemPriceInformation.addToTooltip(event.toolTip, internalname); + ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index edaa8335..12a95484 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -264,6 +264,7 @@ public class NEUOverlay extends Gui { @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { if(Mouse.getEventButtonState()) { + Minecraft.getMinecraft().thePlayer.closeScreen(); Minecraft.getMinecraft().displayGuiScreen(new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config))); } } @@ -1930,11 +1931,12 @@ public class NEUOverlay extends Gui { //Render tooltip JsonObject json = tooltipToDisplay.get(); if(json != null) { - List<String> text = manager.jsonToStack(json).getTooltip(Minecraft.getMinecraft().thePlayer, false); + ItemStack stack = manager.jsonToStack(json); + List<String> text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); String internalname = json.get("internalname").getAsString(); if(!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) { - ItemPriceInformation.addToTooltip(text, internalname); + ItemPriceInformation.addToTooltip(text, internalname, stack); } boolean hasClick = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index d5e6b927..6b787964 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -17,9 +17,7 @@ import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; -import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; -import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; -import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; +import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.HelpGUI; @@ -160,7 +158,7 @@ public class NotEnoughUpdates { ChatStyle style = new ChatStyle(); style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GRAY+"Click to copy to clipboard"))); - style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "neurename copyuuid")); + style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/neurename copyuuid")); ChatComponentText text = new ChatComponentText(EnumChatFormatting.YELLOW+"[NEU] The UUID of your currently held item is: " + EnumChatFormatting.GREEN + heldUUID); @@ -865,6 +863,7 @@ public class NotEnoughUpdates { }); private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + private File neuDir; /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. @@ -874,10 +873,10 @@ public class NotEnoughUpdates { public void preinit(FMLPreInitializationEvent event) { INSTANCE = this; - File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); - f.mkdirs(); + neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); + neuDir.mkdirs(); - configFile = new File(f, "configNew.json"); + configFile = new File(neuDir, "configNew.json"); if(configFile.exists()) { try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { @@ -885,6 +884,8 @@ public class NotEnoughUpdates { } catch(Exception e) { } } + FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); + if(config == null) { config = new NEUConfig(); saveConfig(); @@ -900,6 +901,8 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); MinecraftForge.EVENT_BUS.register(new DungeonMap()); MinecraftForge.EVENT_BUS.register(new SunTzu()); + MinecraftForge.EVENT_BUS.register(new MiningStuff()); + MinecraftForge.EVENT_BUS.register(new FairySouls()); ClientCommandHandler.instance.registerCommand(collectionLogCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); @@ -924,10 +927,11 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(settingsCommand3); ClientCommandHandler.instance.registerCommand(dungeonWinTest); ClientCommandHandler.instance.registerCommand(calendarCommand); + ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand()); BackgroundBlur.registerListener(); - manager = new NEUManager(this, f); + manager = new NEUManager(this, neuDir); manager.loadItemInformation(); overlay = new NEUOverlay(manager); profileViewer = new ProfileViewer(manager); @@ -937,14 +941,13 @@ public class NotEnoughUpdates { } Runtime.getRuntime().addShutdownHook(new Thread(() -> { - File tmp = new File(f, "tmp"); + File tmp = new File(neuDir, "tmp"); if(tmp.exists()) { for(File tmpFile : tmp.listFiles()) { tmpFile.delete(); } tmp.delete(); } - saveConfig(); })); } @@ -956,6 +959,8 @@ public class NotEnoughUpdates { try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(config)); } + + FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); } catch(IOException ignored) {} } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index aad69686..70cb436b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -348,7 +348,7 @@ public class CustomAH extends Gui { tooltip.add(""); tooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]"); } else { - ItemPriceInformation.addToTooltip(tooltip, internalname); + ItemPriceInformation.addToTooltip(tooltip, internalname, auc.getStack()); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java index 97fc3dcc..85f88a9f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java @@ -36,6 +36,9 @@ public class GuiElementBoolean extends GuiElement { this.previewValue = value; this.clickRadius = clickRadius; this.toggleCallback = toggleCallback; + this.lastMillis = System.currentTimeMillis(); + + if(value) animation = 36; } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java index 5b9509a3..7ca8ddf2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java @@ -54,8 +54,9 @@ public abstract class GuiOptionEditor { public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY); public abstract boolean keyboardInput(); - public boolean mouseInputGlobal(int x, int y, int width, int mouseX, int mouseY) { + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { return false; } + public void renderOverlay(int x, int y, int width) {}; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java index 482f6823..d9e8f5a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java @@ -36,16 +36,17 @@ public class GuiOptionEditorColour extends GuiOptionEditor { GlStateManager.color(r/255f, g/255f, b/255f, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16); + } + @Override + public void renderOverlay(int x, int y, int width) { if(colourElement != null) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); colourElement.render(); - GL11.glEnable(GL11.GL_SCISSOR_TEST); } } @Override - public boolean mouseInputGlobal(int x, int y, int width, int mouseX, int mouseY) { + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { if(colourElement != null && colourElement.mouseInput(mouseX, mouseY)) { return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java index 8b0d5eb3..20779e01 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java @@ -27,21 +27,43 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { @Override public void render(int x, int y, int width) { super.render(x, y, width); - int height = getHeight(); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int dropdownWidth = Math.min(width/3-10, 80); - int left = x+width/6-dropdownWidth/2; - int top = y+height-7-14; + if(!open) { + int height = getHeight(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int dropdownWidth = Math.min(width/3-10, 80); + int left = x+width/6-dropdownWidth/2; + int top = y+height-7-14; + + String selectedString = " - Select - "; + if(selected >= 0 && selected < values.length) { + selectedString = values[selected]; + } + + RenderUtils.drawFloatingRectWithAlpha(left, top, dropdownWidth, 14, 0xff, false); + TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xff404040, 2); - String selectedString = " - Select - "; - if(selected >= 0 && selected < values.length) { - selectedString = values[selected]; + TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false, + dropdownWidth-16, 0xff404040); + //fr.drawString(selectedString, left+3, top+3, 0xff404040); } + } + @Override + public void renderOverlay(int x, int y, int width) { if(open) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.translate(0, 0, 10); + String selectedString = " - Select - "; + if(selected >= 0 && selected < values.length) { + selectedString = values[selected]; + } + + int height = getHeight(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int dropdownWidth = Math.min(width/3-10, 80); + int left = x+width/6-dropdownWidth/2; + int top = y+height-7-14; int dropdownHeight = 13 + 12*values.length; @@ -61,7 +83,6 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { option = "<NONE>"; } TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xff404040); - //fr.drawString(option, left+3, top+3+dropdownY, 0xff404040); dropdownY += 12; } @@ -70,17 +91,6 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false, dropdownWidth-16, 0xff404040); - //fr.drawString(selectedString, left+3, top+3, 0xff404040); - - GlStateManager.translate(0, 0, -10); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } else { - RenderUtils.drawFloatingRectWithAlpha(left, top, dropdownWidth, 14, 0xff, false); - TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xff404040, 2); - - TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false, - dropdownWidth-16, 0xff404040); - //fr.drawString(selectedString, left+3, top+3, 0xff404040); } } @@ -103,7 +113,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { } @Override - public boolean mouseInputGlobal(int x, int y, int width, int mouseX, int mouseY) { + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { int height = getHeight(); int left = x+width/6-40; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java index cedf368b..89feaf17 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java @@ -83,7 +83,7 @@ public class GuiElementSlider extends GuiElement { Utils.drawTexturedRect(notchX, y+(HEIGHT-4)/2, 2, 4, GL11.GL_NEAREST); } - Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new); Utils.drawTexturedRect(x+sliderAmountI-4, y, 8, HEIGHT, GL11.GL_NEAREST); } 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 cdc2c4fd..516169c9 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 @@ -45,6 +45,10 @@ public class LerpingInteger { } } + public int getTimeSpent() { + return timeSpent; + } + public void resetTimer() { this.timeSpent = 0; this.lastMillis = System.currentTimeMillis(); 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 712ac09a..777a91cc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -45,7 +45,7 @@ public class CapeManager { private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, true }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false }; public static CapeManager getInstance() { return INSTANCE; 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 ce59b7c6..59cbfee5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -383,10 +383,10 @@ public class DungeonMap { } public void render(int centerX, int centerY) { - boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1; - boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0; + boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1 && OpenGlHelper.isFramebufferEnabled(); + boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0 && OpenGlHelper.areShadersSupported(); - if((useFb && !OpenGlHelper.isFramebufferEnabled()) || (useShd && !OpenGlHelper.areShadersSupported())) { + /*if((useFb && !OpenGlHelper.isFramebufferEnabled()) || (useShd && !OpenGlHelper.areShadersSupported())) { Utils.drawStringCentered(EnumChatFormatting.RED+"NEU Dungeon Map requires framebuffers & shaders", Minecraft.getMinecraft().fontRendererObj, centerX, centerY-10, true, 0); Utils.drawStringCentered(EnumChatFormatting.RED+"Turn off Optifine Fast Render", @@ -394,7 +394,7 @@ public class DungeonMap { Utils.drawStringCentered(EnumChatFormatting.RED+"If that doesn't work, join NEU discord for support", Minecraft.getMinecraft().fontRendererObj, centerX, centerY+10, true, 0); return; - } + }*/ ScaledResolution scaledResolution = Utils.pushGuiScale(2); 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 284ec1a3..1bcd7fe8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java @@ -150,7 +150,6 @@ public class DungeonWin { lastDungeonFinish = currentTime; String score = matcher.group(1); - System.out.println(score); switch (score.toUpperCase()) { case "S+": TEAM_SCORE = SPLUS; break; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java new file mode 100644 index 00000000..70a701e0 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -0,0 +1,364 @@ +package io.github.moulberry.notenoughupdates.miscfeatures; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.commands.SimpleCommand; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +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 net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.util.*; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +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.lwjgl.opengl.GL11; +import org.lwjgl.util.vector.Vector3f; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class FairySouls { + + private static HashMap<String, Set<Integer>> foundSouls = new HashMap<>(); + private static List<BlockPos> currentSoulList = null; + private static List<BlockPos> currentSoulListClose = null; + + private static boolean enabled = false; + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + currentSoulList = null; + } + + public static void load(File file, Gson gson) { + if(file.exists()) { + try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { + HashMap<String, List<Number>> foundSoulsList = gson.fromJson(reader, HashMap.class); + + foundSouls = new HashMap<>(); + for(Map.Entry<String, List<Number>> entry : foundSoulsList.entrySet()) { + HashSet<Integer> set = new HashSet<>(); + for(Number n : entry.getValue()) { + set.add(n.intValue()); + } + foundSouls.put(entry.getKey(), set); + } + + return; + } catch(Exception e) {} + } + foundSouls = new HashMap<>(); + } + + public static void save(File file, Gson gson) { + try { + file.createNewFile(); + + try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) { + writer.write(gson.toJson(foundSouls)); + } + } catch(IOException ignored) {} + } + + @SubscribeEvent + public void onChatReceived(ClientChatReceivedEvent event) { + if(event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") || + event.message.getFormattedText().equals("\u00A7d\u00A7lSOUL! \u00A7fYou found a \u00A7r\u00A7dFairy Soul\u00A7r\u00A7f!\u00A7r")) { + String location = SBInfo.getInstance().getLocation(); + if(location == null) return; + + int closestIndex = -1; + double closestDistSq = 10*10; + for(int i=0; i<currentSoulList.size(); i++) { + BlockPos pos = currentSoulList.get(i); + + double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()); + + if(distSq < closestDistSq) { + closestDistSq = distSq; + closestIndex = i; + } + } + if(closestIndex != -1) { + Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>()); + found.add(closestIndex); + } + } + } + + public static void tick() { + if(!enabled) return; + + if(Minecraft.getMinecraft().theWorld == null) { + currentSoulList = null; + return; + } + + JsonObject fairySouls = Constants.FAIRYSOULS; + String location = SBInfo.getInstance().getLocation(); + if(location == null) { + currentSoulList = null; + return; + } + + if(currentSoulList == null) { + if(fairySouls.has(location) && fairySouls.get(location).isJsonArray()) { + JsonArray locations = fairySouls.get(location).getAsJsonArray(); + currentSoulList = new ArrayList<>(); + for(int i=0; i<locations.size(); i++) { + try { + String coord = locations.get(i).getAsString(); + + String[] split = coord.split(","); + if(split.length == 3) { + String xS = split[0]; + String yS = split[1]; + String zS = split[2]; + + int x = Integer.parseInt(xS); + int y = Integer.parseInt(yS); + int z = Integer.parseInt(zS); + + currentSoulList.add(new BlockPos(x, y , z)); + } + } catch(Exception ignored) {} + } + } + } + + if(currentSoulList != null && !currentSoulList.isEmpty()) { + TreeMap<Double, BlockPos> distanceSqMap = new TreeMap<>(); + + Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>()); + + for(int i=0; i<currentSoulList.size(); i++) { + if(found.contains(i)) continue; + + BlockPos pos = currentSoulList.get(i); + double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()); + distanceSqMap.put(distSq, pos); + } + + int maxSouls = 15; + int souls = 0; + currentSoulListClose = new ArrayList<>(); + for(BlockPos pos : distanceSqMap.values()) { + currentSoulListClose.add(pos); + if(++souls >= maxSouls) break; + } + } + } + + private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); + + private static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult, float partialTicks) { + int height = 300; + int bottomOffset = 0; + int topOffset = bottomOffset + height; + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GlStateManager.disableLighting(); + GlStateManager.enableCull(); + GlStateManager.enableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + + double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; + double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); + + float r = ((rgb >> 16) & 0xFF) / 255f; + float g = ((rgb >> 8) & 0xFF) / 255f; + float b = (rgb & 0xFF) / 255f; + double d2 = time * 0.025D * -1.5D; + double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; + double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; + double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; + double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; + double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; + double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; + double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; + double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; + double d14 = -1.0D + d1; + double d15 = (double)(height) * 2.5D + d14; + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + tessellator.draw(); + + GlStateManager.disableCull(); + double d12 = -1.0D + d1; + double d13 = height + d12; + + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + tessellator.draw(); + } + + @SubscribeEvent + public void onRenderLast(RenderWorldLastEvent event) { + if(!enabled) return; + + String location = SBInfo.getInstance().getLocation(); + if(location == null) return; + if(currentSoulList == null || currentSoulList.isEmpty()) return; + + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; + + Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(aoteInterpPos != null) { + viewerX = aoteInterpPos.x; + viewerY = aoteInterpPos.y; + viewerZ = aoteInterpPos.z; + } + + Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>()); + + int rgb = 0xa839ce; + for(int i=0; i<currentSoulListClose.size(); i++) { + BlockPos currentSoul = currentSoulListClose.get(i); + double x = currentSoul.getX() - viewerX; + double y = currentSoul.getY() - viewerY; + double z = currentSoul.getZ() - viewerZ; + + double distSq = x*x + y*y + z*z; + + AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x+1, y+1, z+1); + + GlStateManager.disableDepth(); + GlStateManager.disableCull(); + GlStateManager.disableTexture2D(); + CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, rgb)); + + if(distSq > 10*10) { + renderBeaconBeam(x, y, z, rgb, 1.0f, event.partialTicks); + } + } + + GlStateManager.disableLighting(); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + } + + public static class FairySoulsCommand extends SimpleCommand { + + public FairySoulsCommand() { + super("neusouls", new ProcessCommandRunnable() { + @Override + public void processCommand(ICommandSender sender, String[] args) { + if(args.length != 1) { + printHelp(); + return; + } + String subcommand = args[0].toLowerCase(); + + switch (subcommand) { + case "help": + printHelp(); + return; + case "on": + case "enable": + print(EnumChatFormatting.DARK_PURPLE+"Enabled fairy soul waypoints"); + enabled = true; + return; + case "off": + case "disable": + print(EnumChatFormatting.DARK_PURPLE+"Disabled fairy soul waypoints"); + enabled = false; + return; + case "clear": { + String location = SBInfo.getInstance().getLocation(); + if(currentSoulList == null || location == null) { + print(EnumChatFormatting.RED+"No fairy souls found in your current world"); + } else { + Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>()); + for(int i=0; i<currentSoulList.size(); i++) { + found.add(i); + } + print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as found"); + } + } + return; + case "unclear": + String location = SBInfo.getInstance().getLocation(); + if(location == null) { + print(EnumChatFormatting.RED+"No fairy souls found in your current world"); + } else { + print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as not found"); + foundSouls.remove(location); + } + return; + } + + print(EnumChatFormatting.RED+"Unknown subcommand: " + subcommand); + } + }); + } + + private static void print(String s) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(s)); + } + + private static void printHelp() { + print(""); + print(EnumChatFormatting.DARK_PURPLE.toString()+EnumChatFormatting.BOLD+" NEU Fairy Soul Waypoint Guide"); + print(EnumChatFormatting.LIGHT_PURPLE+"Shows waypoints for every fairy soul in your world"); + print(EnumChatFormatting.LIGHT_PURPLE+"Clicking a fairy soul automatically removes it from the list"); + print(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+" Commands:"); + print(EnumChatFormatting.YELLOW+"/neusouls help - Display this message"); + print(EnumChatFormatting.YELLOW+"/neusouls on/off - Enable/disable the waypoint markers"); + print(EnumChatFormatting.YELLOW+"/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted"); + print(""); + } + + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java new file mode 100644 index 00000000..97bb8377 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -0,0 +1,160 @@ +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +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.BlockStone; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.util.vector.Vector3f; +import org.lwjgl.util.vector.Vector4f; + +public class MiningStuff { + + private static BlockPos overlayLoc = null; + private static long titaniumNotifMillis = 0; + + public static void processBlockChangePacket(S23PacketBlockChange packetIn) { + IBlockState state = packetIn.getBlockState(); + if(SBInfo.getInstance().getLocation() != null && + SBInfo.getInstance().getLocation().startsWith("mining_") && + state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) { + BlockPos pos = packetIn.getBlockPosition(); + + IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos); + if(existingBlock == null) return; + if(existingBlock.getBlock() == Blocks.stone && existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + + double distSq = pos.distanceSq(player); + + if(distSq < 8*8) { + titaniumNotifMillis = System.currentTimeMillis(); + } + } + } + + @SubscribeEvent + public void onRenderOverlay(RenderGameOverlayEvent.Post event) { + int delta = (int)(System.currentTimeMillis() - titaniumNotifMillis); + int notifLen = 5000; + int fadeLen = 500; + if(delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + + GlStateManager.pushMatrix(); + GlStateManager.translate((float)(width / 2), (float)(height / 2), 0.0F); + GlStateManager.scale(4.0F, 4.0F, 4.0F); + + int colour1 = 0xcc; + int colour2 = 0xff; + + double factor = (Math.sin(delta*2*Math.PI/1000)+1)/2; + int colour = (int)(colour1*factor + colour2*(1-factor)); + + int alpha = 255; + if(delta < fadeLen) { + alpha = delta*255/fadeLen; + } else if(delta > notifLen-fadeLen) { + alpha = (notifLen-delta)*255/fadeLen; + } + + if(alpha > 10) { + TextRenderUtils.drawStringCenteredScaledMaxWidth("Titanium has spawned nearby!", Minecraft.getMinecraft().fontRendererObj, + 0, 0, true, width/4-20, colour | (colour << 8) | (colour << 16) | (alpha << 24)); + } + + + GlStateManager.popMatrix(); + } + } + + public static Vector3f getCreeperColour() { + return new Vector3f(0, 1, 0); + } + + @SubscribeEvent + public void renderWorldLast(RenderWorldLastEvent event) { + if(overlayLoc == null) return; + + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; + + AxisAlignedBB bb = new AxisAlignedBB( + overlayLoc.getX()-viewerX, + overlayLoc.getY()-viewerY, + overlayLoc.getZ()-viewerZ, + overlayLoc.getX()+1-viewerX, + overlayLoc.getY()+1-viewerY, + overlayLoc.getZ()+1-viewerZ).expand(0.01f, 0.01f, 0.01f); + + //181 / 195 / 135 + + GlStateManager.disableCull(); + CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, 0xff0000)); + GlStateManager.enableCull(); + GlStateManager.enableTexture2D(); + } + + @SubscribeEvent + public void onLoadWorld(WorldEvent.Load event) { + overlayLoc = null; + } + + @SubscribeEvent + public void onChatRecevied(ClientChatReceivedEvent event) { + if(event.message.getFormattedText().startsWith("\u00A7e[NPC] \u00A7dPuzzler") && + event.message.getUnformattedText().contains(":")) { + String clean = Utils.cleanColour(event.message.getUnformattedText()); + clean = clean.split(":")[1].trim(); + + BlockPos pos = new BlockPos(181, 195, 135); + + for(int i=0; i<clean.length(); i++) { + char c = clean.charAt(i); + + if(c == '\u25C0') { //Left + pos = pos.add(1, 0, 0); + } else if(c == '\u25B2') { //Up + pos = pos.add(0, 0, 1); + } else if(c == '\u25BC') { //Down + pos = pos.add(0, 0, -1); + } else if(c == '\u25B6') { //Right + pos = pos.add(-1, 0, 0); + } else { + return; + } + } + + overlayLoc = pos; + } + } + + public static void blockClicked(BlockPos loc) { + if(loc.equals(overlayLoc)) { + overlayLoc = null; + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index 233e8819..75c9415c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -354,7 +354,24 @@ public class AccessoryBagOverlay { missingInternal.sort(getItemComparator()); for(String internal : missingInternal) { - missing.add(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internal))); + boolean hasDup = false; + + if(talisman_upgrades.has(internal)) { + JsonArray upgrades = talisman_upgrades.get(internal).getAsJsonArray(); + for(int j=0; j<upgrades.size(); j++) { + String upgrade = upgrades.get(j).getAsString(); + if(missingInternal.contains(upgrade)) { + hasDup = true; + break; + } + } + } + + ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internal), false); + if(hasDup) { + stack.setStackDisplayName(stack.getDisplayName()+"*"); + } + missing.add(stack); } } if(missing.isEmpty()) { @@ -375,9 +392,73 @@ public class AccessoryBagOverlay { } if(missing.size() > 11) { - Utils.drawStringCenteredScaledMaxWidth("+" + (missing.size()-10) + " More", + Utils.drawStringCenteredScaledMaxWidth("Show All", Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70, new Color(80, 80, 80).getRGB()); + + final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + final int scaledWidth = scaledresolution.getScaledWidth(); + final int scaledHeight = scaledresolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + + if(mouseX > x && mouseX < x+80 && + mouseY > y+11+121 && mouseY < y+21+121) { + List<String> text = new ArrayList<>(); + StringBuilder line = new StringBuilder(); + int leftMaxSize = 0; + int middleMaxSize = 0; + for(int i=0; i<missing.size(); i += 3) { + leftMaxSize = Math.max(leftMaxSize, Minecraft.getMinecraft().fontRendererObj. + getStringWidth(missing.get(i).getDisplayName())); + } + for(int i=1; i<missing.size(); i += 3) { + middleMaxSize = Math.max(middleMaxSize, Minecraft.getMinecraft().fontRendererObj. + getStringWidth(missing.get(i).getDisplayName())); + } + for(int i=0; i<missing.size(); i++) { + if(i % 3 == 0 && i > 0) { + text.add(line.toString()); + line = new StringBuilder(); + } + StringBuilder name = new StringBuilder(missing.get(i).getDisplayName()); + int nameLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.toString()); + + int padSize = -1; + if(i % 3 == 0) padSize = leftMaxSize; + if(i % 3 == 1) padSize = middleMaxSize; + if(padSize > 0) { + float padNum = (padSize - nameLen) / 4.0f; + int remainder = (int)((padNum % 1) * 4); + while(padNum >= 1) { + if(remainder > 0) { + name.append(EnumChatFormatting.BOLD).append(" "); + remainder--; + } else { + name.append(EnumChatFormatting.RESET).append(" "); + } + padNum--; + } + } + line.append('\u00A7').append(Utils.getPrimaryColourCode(missing.get(i).getDisplayName())); + if(i < 9) { + line.append((char)('\u2776'+i)).append(' '); + } else { + line.append("\u2b24 "); + } + line.append(name); + if(i % 3 < 2) line.append(" "); + } + + GlStateManager.pushMatrix(); + GlStateManager.scale(2f/scaledresolution.getScaleFactor(), 2f/scaledresolution.getScaleFactor(), 1); + Utils.drawHoveringText(text, + mouseX*scaledresolution.getScaleFactor()/2, + mouseY*scaledresolution.getScaleFactor()/2, + scaledWidth*scaledresolution.getScaleFactor()/2, + scaledHeight*scaledresolution.getScaleFactor()/2, -1, Minecraft.getMinecraft().fontRendererObj); + GlStateManager.popMatrix(); + } } } } @@ -465,6 +546,9 @@ public class AccessoryBagOverlay { cost2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o2).craftCost; } + if(cost1 == -1 && cost2 == -1) return o1.compareTo(o2); + if(cost1 == -1) return 1; + if(cost2 == -1) return -1; if(cost1 < cost2) return -1; if(cost1 > cost2) return 1; 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 c54a0218..0034a82c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java @@ -694,11 +694,6 @@ public class CalendarOverlay { } } - if(nextEvent == null) { - nextEvent = firstEvent; - timeUntilNext = timeUntilFirst; - } - if(nextEvent != null) { renderToast(nextEvent, timeUntilNext); } @@ -883,9 +878,12 @@ public class CalendarOverlay { } } - if(nextEvent == null) { - nextEvent = firstEvent; - timeUntilNext = timeUntilFirst; + if(nextEvent == null && firstEvent != null) { + String[] split = firstEvent.id.split(":"); + if(eventFavourites.contains(split[0])) { + nextEvent = firstEvent; + timeUntilNext = timeUntilFirst; + } } if(nextEvent != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 371da939..91d3b981 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -55,31 +55,38 @@ public class TradeWindow { private static int lastBackpackX; private static int lastBackpackY; - public static boolean tradeWindowActive() { - if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return false; - if(!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false; + public static boolean hypixelTradeWindowActive() { + if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false; GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; if(guiScreen instanceof GuiChest) { GuiChest eventGui = (GuiChest) guiScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if(containerName.trim().startsWith("You ")) { - return true; - } + return containerName.trim().startsWith("You "); + } + return false; + } + + public static boolean tradeWindowActive() { + if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return false; + if(!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false; + + if(hypixelTradeWindowActive()) { + return true; } - lastTradeMillis = -1; - ourTradeIndexes = new Integer[16]; - theirTradeIndexes = new Integer[16]; - theirTradeOld = new String[16]; - theirTradeChangesMillis = new Long[16]; + if(lastTradeMillis != -99) { + lastTradeMillis = -99; + ourTradeIndexes = new Integer[16]; + theirTradeIndexes = new Integer[16]; + theirTradeOld = new String[16]; + theirTradeChangesMillis = new Long[16]; + } return false; } - private static TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M); - private static void drawStringShadow(String str, float x, float y, int len) { for(int xOff=-2; xOff<=2; xOff++) { for(int yOff=-2; yOff<=2; yOff++) { @@ -296,7 +303,6 @@ public class TradeWindow { List<String> tooltipToDisplay = null; ItemStack stackToRender = null; int tooltipLen = -1; - tl.handleKeyboardInput(); //Set index mappings //Our slots diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java new file mode 100644 index 00000000..68e0a7c3 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java @@ -0,0 +1,55 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityFX; +import org.lwjgl.util.vector.Vector3f; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(EffectRenderer.class) +public class MixinEffectRenderer { + + /*@Redirect(method="renderParticles", at=@At( + value = "FIELD", + opcode = Opcodes.PUTSTATIC, + target = "Lnet/minecraft/client/particle/EntityFX;interpPosX:D") + ) + public void renderParticles_interpPosX(double interpPosX) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + EntityFX.interpPosX = currentPosition.x; + } + EntityFX.interpPosX = interpPosX; + } + + @Redirect(method="renderParticles", at=@At( + value = "FIELD", + opcode = Opcodes.PUTSTATIC, + target = "Lnet/minecraft/client/particle/EntityFX;interpPosY:D") + ) + public void renderParticles_interpPosY(double interpPosY) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + EntityFX.interpPosY = currentPosition.y; + } + EntityFX.interpPosY = interpPosY; + } + + @Redirect(method="renderParticles", at=@At( + value = "FIELD", + opcode = Opcodes.PUTSTATIC, + target = "Lnet/minecraft/client/particle/EntityFX;interpPosZ:D") + ) + public void renderParticles_interpPosZ(double interpPosZ) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + EntityFX.interpPosZ = currentPosition.z; + } + EntityFX.interpPosZ = interpPosZ; + }*/ + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCreeperCharge.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCreeperCharge.java new file mode 100644 index 00000000..e6c9f048 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCreeperCharge.java @@ -0,0 +1,26 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge; +import net.minecraft.entity.monster.EntityCreeper; +import org.lwjgl.util.vector.Vector3f; +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.Redirect; + +@Mixin(LayerCreeperCharge.class) +public class MixinLayerCreeperCharge { + + /*@Redirect(method="doRenderLayer", at=@At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V")) + public void doRenderLayer_color(float red, float green, float blue, float alpha) { + Vector3f col = MiningStuff.getCreeperColour(); + GlStateManager.color(col.getX(), col.getY(), col.getZ(), alpha); + }*/ + + + +} 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 19bcdacf..c0e15d52 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -3,8 +3,10 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.network.play.server.S2FPacketSetSlot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -31,6 +33,11 @@ public class MixinNetHandlerPlayClient { EnchantingSolvers.processInventoryContents(); } + @Inject(method="handleBlockChange", at=@At("HEAD")) + public void handleBlockChange(S23PacketBlockChange packetIn, CallbackInfo ci) { + MiningStuff.processBlockChangePacket(packetIn); + } + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java new file mode 100644 index 00000000..0e978640 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java @@ -0,0 +1,21 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; +import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +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.CallbackInfoReturnable; + +@Mixin(PlayerControllerMP.class) +public class MixinPlayerControllerMP { + + @Inject(method="clickBlock", at=@At("HEAD")) + public void clickBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable<Boolean> cir) { + MiningStuff.blockClicked(loc); + } + +} 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 3aa7d122..c2582508 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -426,7 +426,7 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #1" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) public int line1 = 1; @@ -436,7 +436,7 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #2" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) public int line2 = 2; @@ -446,7 +446,7 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #3" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) public int line3 = 3; @@ -456,7 +456,7 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #4" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) public int line4 = 4; @@ -466,9 +466,9 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #5" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) - public int line5 = 0; + public int line5 = 6; @Expose @ConfigOption( @@ -476,7 +476,7 @@ public class NEUConfig extends Config { desc = "Set the price information displayed on Line #6" ) @ConfigEditorDropdown( - values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN"} + values = {"", "Lowest BIN", "AH Price", "AH Sales", "Raw Craft Cost", "AVG Lowest BIN", "Dungeon Costs"} ) public int line6 = 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 3d006383..2a8a2c04 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -49,7 +49,8 @@ public class NEUConfigEditor extends GuiElement { private String selectedCategory = null; - private LerpingInteger optionsScroll = new LerpingInteger(0, 150); + private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); + private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig; @@ -73,6 +74,7 @@ public class NEUConfigEditor extends GuiElement { public void render() { optionsScroll.tick(); + categoryScroll.tick(); List<String> tooltipToDisplay = null; @@ -139,7 +141,8 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.push(0, innerTop+1, scaledResolution.getScaledWidth(), innerBottom-1, scaledResolution); - int categoryIndex = 0; + float catBarSize = 1; + int catY = -categoryScroll.getValue(); for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { if(getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); @@ -151,9 +154,29 @@ public class NEUConfigEditor extends GuiElement { catName = EnumChatFormatting.GRAY + catName; } TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, - fr, x+75, y+70+categoryIndex*15, false, 140, -1); - categoryIndex++; + fr, x+75, y+70+catY, false, 100, -1); + catY += 15; + if(catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+categoryScroll.getValue())); + } + } + + float catBarStart = categoryScroll.getValue() / (float)(catY + categoryScroll.getValue()); + float catBarEnd = catBarStart+catBarSize; + if(catBarEnd > 1) { + catBarEnd = 1; + if(categoryScroll.getTarget()/(float)(catY + categoryScroll.getValue())+catBarSize < 1) { + int target = optionsScroll.getTarget(); + categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue()))); + categoryScroll.setTarget(target); + } else { + categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue()))); + } } + int catDist = innerBottom-innerTop-12; + Gui.drawRect(innerLeft+2, innerTop+5, innerLeft+7, innerBottom-5, 0xff101010); + Gui.drawRect(innerLeft+3, innerTop+6+(int)(catDist*catBarStart), innerLeft+6, + innerTop+6+(int)(catDist*catBarEnd), 0xff303030); GlScissorStack.pop(scaledResolution); @@ -181,7 +204,6 @@ public class NEUConfigEditor extends GuiElement { Gui.drawRect(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, 0x6008080E); //Middle GlScissorStack.push(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, scaledResolution); - float barSize = 1; int optionY = -optionsScroll.getValue(); if(getSelectedCategory() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { @@ -207,6 +229,30 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.pop(scaledResolution); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + if(getSelectedCategory() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + int optionYOverlay = -optionsScroll.getValue(); + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + int optionWidth = innerRight-innerLeft-20; + + GlStateManager.translate(0, 0, 10); + GlStateManager.enableDepth(); + for(ConfigProcessor.ProcessedOption option : cat.options.values()) { + GuiOptionEditor editor = option.editor; + if(editor == null) { + continue; + } + int optionHeight = editor.getHeight(); + if(innerTop+5+optionYOverlay+optionHeight > innerTop+1 && innerTop+5+optionYOverlay < innerBottom-1) { + editor.renderOverlay(innerLeft+5, innerTop+5+optionYOverlay, optionWidth); + } + optionYOverlay += optionHeight + 5; + } + GlStateManager.disableDepth(); + GlStateManager.translate(0, 0, -10); + } + GL11.glEnable(GL11.GL_SCISSOR_TEST); + float barStart = optionsScroll.getValue() / (float)(optionY + optionsScroll.getValue()); float barEnd = barStart+barSize; if(barEnd > 1) { @@ -271,52 +317,83 @@ public class NEUConfigEditor extends GuiElement { if(dWheel > 0) { dWheel = 1; } - boolean resetTimer = true; - int newTarget = optionsScroll.getTarget() - dWheel*30; - if(newTarget < 0) { - newTarget = 0; - resetTimer = false; - } + if(mouseX < innerLeft) { + boolean resetTimer = true; + int newTarget = categoryScroll.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()) { - GuiOptionEditor editor = option.editor; - if(editor == null) { - continue; + float catBarSize = 1; + int catY = -newTarget; + for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { + if(getSelectedCategory() == null) { + setSelectedCategory(entry.getKey()); } - optionY += editor.getHeight() + 5; + catY += 15; + if(catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+newTarget)); + } + } - if(optionY > 0) { - barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5 + newTarget)); + 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()) { + GuiOptionEditor editor = option.editor; + if(editor == null) { + continue; + } + optionY += editor.getHeight() + 5; + + if(optionY > 0) { + barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5 + newTarget)); + } } } - } - int barMax = (int)Math.floor((optionY+5+newTarget)-barSize*(optionY+5+newTarget)); - if(newTarget > barMax) { - newTarget = barMax; - resetTimer = false; - } - if(resetTimer && optionsScroll.getTarget() != newTarget) { - optionsScroll.resetTimer(); + 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.setTarget(newTarget); } - optionsScroll.setTarget(newTarget); } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { if(getCurrentConfigEditing() != null) { - int categoryIndex = 0; + int catY = -categoryScroll.getValue(); for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { if(getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } if(mouseX >= x+5 && mouseX <= x+145 && - mouseY >= y+70+categoryIndex*15-7 && mouseY <= y+70+categoryIndex*15+7) { + mouseY >= y+70+catY-7 && mouseY <= y+70+catY+7) { setSelectedCategory(entry.getKey()); return true; } - categoryIndex++; + catY += 15; } } @@ -342,7 +419,7 @@ public class NEUConfigEditor extends GuiElement { if(editor == null) { continue; } - if(editor.mouseInputGlobal(innerLeft+5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { + if(editor.mouseInputOverlay(innerLeft+5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; 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 601cd362..bd3fad1b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.profileviewer; import com.google.common.base.Splitter; +import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -709,10 +710,67 @@ public class GuiProfileViewer extends GuiScreen { Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Until Cata "+floorLevelTo+": ", EnumChatFormatting.WHITE.toString()+shortNumberFormat(floorLevelToXP, 0), x, y+16, sectionWidth); + if(mouseX > x && mouseX < x + sectionWidth && + mouseY > y+16 && mouseY < y+24) { + float xpF5 = 2000; + float xpF6 = 4000; + float xpF7 = 20000; + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + xpF5 *= 1.1; + xpF6 *= 1.1; + xpF7 *= 1.1; + } + + long runsF5 = (int)Math.ceil(floorLevelToXP/xpF5); + long runsF6 = (int)Math.ceil(floorLevelToXP/xpF6); + long runsF7 = (int)Math.ceil(floorLevelToXP/xpF7); + + float timeF5 = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time_s_plus.5"), 0); + float timeF6 = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time_s_plus.6"), 0); + float timeF7 = Utils.getElementAsFloat(Utils.getElement(profileInfo, + "dungeons.dungeon_types.catacombs.fastest_time_s_plus.7"), 0); + + tooltipToDisplay = Lists.newArrayList( + String.format("# F5 Runs (%s xp) : %d", shortNumberFormat(xpF5, 0), runsF5), + String.format("# F6 Runs (%s xp) : %d", shortNumberFormat(xpF6, 0), runsF6), + String.format("# F7 Runs (%s xp) : %d", shortNumberFormat(xpF7, 0), runsF7), + "" + ); + boolean hasTime = false; + if(timeF5 > 1000) { + tooltipToDisplay.add(String.format("Expected Time (F5) : %s", Utils.prettyTime(runsF5*(long)(timeF5*1.2)))); + hasTime = true; + } + if(timeF6 > 1000) { + tooltipToDisplay.add(String.format("Expected Time (F6) : %s", Utils.prettyTime(runsF6*(long)(timeF6*1.2)))); + hasTime = true; + } + if(timeF7 > 1000) { + tooltipToDisplay.add(String.format("Expected Time (F7) : %s", Utils.prettyTime(runsF7*(long)(timeF7*1.2)))); + hasTime = true; + } + if(hasTime) { + tooltipToDisplay.add(""); + } + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + tooltipToDisplay.add("[Hold "+EnumChatFormatting.YELLOW+"SHIFT"+EnumChatFormatting.GRAY+" to show without Expert Ring]"); + } + if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) tooltipToDisplay.add(""); + tooltipToDisplay.add("Number of runs is calculated as [Remaining XP]/[XP per Run]."); + tooltipToDisplay.add("The [XP per Run] is the average xp gained from an S+ run"); + tooltipToDisplay.add("The "+EnumChatFormatting.DARK_PURPLE+"Catacombs Expert Ring"+EnumChatFormatting.GRAY+ + " is assumed to be used, unless "+EnumChatFormatting.YELLOW+"SHIFT"+EnumChatFormatting.GRAY+" is held."); + tooltipToDisplay.add("[Time per run] is calculated using fastestSPlus x 120%"); + } else { + tooltipToDisplay.add("[Hold "+EnumChatFormatting.YELLOW+"CTRL"+EnumChatFormatting.GRAY+" to see details]"); + } + } + dungeonLevelTextField.setSize(20, 10); dungeonLevelTextField.render(x+22, y+29); - //fontRendererObj.drawString("Calculate", - // x+sectionWidth-17-fontRendererObj.getStringWidth("Calculate"), y+30, 0xffffffff); int calcLen = fontRendererObj.getStringWidth("Calculate"); Utils.renderShadowedString(EnumChatFormatting.WHITE+"Calculate", x+sectionWidth-17-calcLen/2f, y+30, 100); @@ -753,7 +811,7 @@ public class GuiProfileViewer extends GuiScreen { Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (Total) ", EnumChatFormatting.WHITE.toString()+shortNumberFormat(secrets, 0), x, miscTopY+20, sectionWidth); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (/Run) ", - EnumChatFormatting.WHITE.toString()+(Math.round(secrets/totalRunsF5*100)/100f), x, miscTopY+30, sectionWidth); + EnumChatFormatting.WHITE.toString()+(Math.round(secrets/Math.max(1, totalRunsF5)*100)/100f), x, miscTopY+30, sectionWidth); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Mob Kills (Total) ", EnumChatFormatting.WHITE.toString()+shortNumberFormat(mobKills, 0), x, miscTopY+40, sectionWidth); @@ -785,12 +843,15 @@ public class GuiProfileViewer extends GuiScreen { "dungeons.dungeon_types.catacombs.fastest_time_s."+floorTime), 0); float timeSPLUS = Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.fastest_time_s_plus."+floorTime), 0); + String timeNormStr = timeNorm <= 0 ? "N/A" : Utils.prettyTime((long)timeNorm); + String timeSStr = timeS <= 0 ? "N/A" : Utils.prettyTime((long)timeS); + String timeSPlusStr = timeSPLUS <= 0 ? "N/A" : Utils.prettyTime((long)timeSPLUS); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" ", - EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeNorm), x, y3+10, sectionWidth); + EnumChatFormatting.WHITE.toString()+timeNormStr, x, y3+10, sectionWidth); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S", - EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeS), x, y3+20, sectionWidth); + EnumChatFormatting.WHITE.toString()+timeSStr, x, y3+20, sectionWidth); Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S+", - EnumChatFormatting.WHITE.toString()+Utils.prettyTime((long)timeSPLUS), x, y3+30, sectionWidth); + EnumChatFormatting.WHITE.toString()+timeSPlusStr, x, y3+30, sectionWidth); } //Completions diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java index d5233bbd..5ef407f3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -12,6 +12,8 @@ public class Constants { public static JsonObject PETNUMS; public static JsonObject PETS; public static JsonObject PARENTS; + public static JsonObject ESSENCECOSTS; + public static JsonObject FAIRYSOULS; public static void reload() { BONUSES = Utils.getConstant("bonuses"); @@ -22,6 +24,8 @@ public class Constants { PETNUMS = Utils.getConstant("petnums"); PETS = Utils.getConstant("pets"); PARENTS = Utils.getConstant("parents"); + ESSENCECOSTS = Utils.getConstant("essencecosts"); + FAIRYSOULS = Utils.getConstant("fairy_souls"); } static { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java index 5bb15ef3..0740274e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java @@ -97,7 +97,7 @@ public class GuiTextures { public static final ResourceLocation slider_on_cap = new ResourceLocation("notenoughupdates:core/slider/slider_on_cap.png"); public static final ResourceLocation slider_on_notch = new ResourceLocation("notenoughupdates:core/slider/slider_on_notch.png"); public static final ResourceLocation slider_on_segment = new ResourceLocation("notenoughupdates:core/slider/slider_on_segment.png"); - + public static final ResourceLocation slider_button_new = new ResourceLocation("notenoughupdates:core/slider/slider_button.png"); } 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 f5df9305..3e44dbda 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -53,12 +53,11 @@ public class SBInfo { try { JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(event.message.getUnformattedText(), JsonObject.class); if(obj.has("server")) { - event.setCanceled(true); + if(System.currentTimeMillis() - lastLocRaw < 5000) event.setCanceled(true); if(obj.has("gametype") && obj.has("mode") && obj.has("map")) { locraw = obj; } } - } catch(Exception e) { e.printStackTrace(); } @@ -73,7 +72,8 @@ public class SBInfo { } public void tick() { - if(locraw == null && (System.currentTimeMillis() - lastLocRaw) > 20000) { + if(Minecraft.getMinecraft().theWorld != null && + locraw == null && (System.currentTimeMillis() - lastLocRaw) > 20000) { lastLocRaw = System.currentTimeMillis(); NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw"); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 3f4e96bc..f8621f2b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -776,7 +776,6 @@ public class Utils { } catch (Exception ignored) { } } - System.out.println(constant + " = null"); return null; } @@ -827,7 +826,7 @@ public class Utils { file.delete(); } - public static Color getPrimaryColour(String displayname) { + public static char getPrimaryColourCode(String displayname) { int lastColourCode = -99; int currentColour = 0; int[] mostCommon = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; @@ -856,7 +855,11 @@ public class Utils { } } - int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode("0123456789abcdef".charAt(currentColour)); + return "0123456789abcdef".charAt(currentColour); + } + + public static Color getPrimaryColour(String displayname) { + int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(getPrimaryColourCode(displayname)); return new Color(colourInt).darker(); } |