diff options
author | Lulonaut <67191924+Lulonaut@users.noreply.github.com> | 2022-03-03 04:05:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 22:05:45 -0500 |
commit | d44f33636eb301ff029bf41d7f1decb3340efb54 (patch) | |
tree | bbb78767f035222212b006207255a5dada9bdff8 | |
parent | db59eba3fd9121c7c0a88363994876c5b582c08c (diff) | |
download | NotEnoughUpdates-d44f33636eb301ff029bf41d7f1decb3340efb54.tar.gz NotEnoughUpdates-d44f33636eb301ff029bf41d7f1decb3340efb54.tar.bz2 NotEnoughUpdates-d44f33636eb301ff029bf41d7f1decb3340efb54.zip |
NeuEventListener changes and dead code removal (#88)
* hide Hypixel reforge stats
* unused import?
* better comments
* 2.1.md 🙂
* 2.1.md 🙂
* minor cleanup
* api
* remove collectionLog and morus and cape.png
* remove FancyPortals and panorama dev cmd
Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
35 files changed, 3135 insertions, 4969 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index e824a9a0..e47b0f67 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,7 +59,6 @@ mixin { repositories { mavenCentral() - flatDir { dirs("deps/") } maven("https://repo.spongepowered.org/maven/") } diff --git a/cape.png b/cape.png Binary files differdeleted file mode 100644 index a2a2d5f7..00000000 --- a/cape.png +++ /dev/null diff --git a/deps/Morus-1.0.jar b/deps/Morus-1.0.jar Binary files differdeleted file mode 100644 index 92276d72..00000000 --- a/deps/Morus-1.0.jar +++ /dev/null diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java index d83035d0..feb18c66 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java @@ -3,7 +3,7 @@ package io.github.moulberry.notenoughupdates; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class NEUApi { - static boolean disableInventoryButtons = false; + public static boolean disableInventoryButtons = false; public static void setInventoryButtonsToDisabled() { disableInventoryButtons = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java deleted file mode 100644 index 84289e34..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ /dev/null @@ -1,2842 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import com.google.common.collect.Lists; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import io.github.moulberry.notenoughupdates.auction.CustomAHGui; -import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; -import io.github.moulberry.notenoughupdates.core.BackgroundBlur; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.core.util.MiscUtils; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; -import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; -import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; -import io.github.moulberry.notenoughupdates.miscfeatures.*; -import io.github.moulberry.notenoughupdates.miscgui.*; -import io.github.moulberry.notenoughupdates.options.NEUConfig; -import io.github.moulberry.notenoughupdates.overlays.*; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.util.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.gui.inventory.GuiEditSign; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.event.ClickEvent; -import net.minecraft.init.Items; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.*; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.client.event.*; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.apache.commons.lang3.text.WordUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import javax.swing.*; -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.io.File; -import java.io.IOException; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.List; -import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static io.github.moulberry.notenoughupdates.overlays.SlayerOverlay.*; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.dungeon_chest_worth; - -public class NEUEventListener { - - private final NotEnoughUpdates neu; - - private boolean hoverInv = false; - private boolean focusInv = false; - - private boolean joinedSB = false; - - public NEUEventListener(NotEnoughUpdates neu) { - this.neu = neu; - } - - private void displayUpdateMessageIfOutOfDate() { - File repo = neu.manager.repoLocation; - if (repo.exists()) { - File updateJson = new File(repo, "update.json"); - try { - JsonObject o = neu.manager.getJsonFromFile(updateJson); - - String version = o.get("version").getAsString(); - String preVersion = o.get("pre_version").getAsString(); - - boolean shouldUpdate = !NotEnoughUpdates.VERSION.equalsIgnoreCase(version); - boolean shouldPreUpdate = !NotEnoughUpdates.PRE_VERSION.equalsIgnoreCase(preVersion); - - if (o.has("version_id") && o.get("version_id").isJsonPrimitive()) { - int version_id = o.get("version_id").getAsInt(); - shouldUpdate = version_id > NotEnoughUpdates.VERSION_ID; - } - if (o.has("pre_version_id") && o.get("pre_version_id").isJsonPrimitive()) { - int pre_version_id = o.get("pre_version_id").getAsInt(); - shouldPreUpdate = pre_version_id > NotEnoughUpdates.PRE_VERSION_ID; - } - - if (shouldUpdate) { - String update_msg = o.get("update_msg").getAsString(); - - int first_len = -1; - for (String line : update_msg.split("\n")) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int len = fr.getStringWidth(line); - if (first_len == -1) { - first_len = len; - } - int missing_len = first_len - len; - if (missing_len > 0) { - StringBuilder sb = new StringBuilder(line); - for (int i = 0; i < missing_len / 8; i++) { - sb.insert(0, " "); - } - line = sb.toString(); - } - line = line.replaceAll("\\{version}", version); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); - } - - neu.displayLinks(o); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - } else if (shouldPreUpdate && NotEnoughUpdates.VERSION_ID == o.get("version").getAsInt()) { - String pre_update_msg = o.get("pre_update_msg").getAsString(); - - int first_len = -1; - for (String line : pre_update_msg.split("\n")) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int len = fr.getStringWidth(line); - if (first_len == -1) { - first_len = len; - } - int missing_len = first_len - len; - if (missing_len > 0) { - StringBuilder sb = new StringBuilder(line); - for (int i = 0; i < missing_len / 8; i++) { - sb.insert(0, " "); - } - line = sb.toString(); - } - line = line.replaceAll("\\{pre_version}", preVersion); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); - } - - neu.displayLinks(o); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - } - } catch (Exception ignored) { - } - } - } - - @SubscribeEvent - public void onWorldLoad(WorldEvent.Unload event) { - NotEnoughUpdates.INSTANCE.saveConfig(); - CrystalMetalDetectorSolver.reset(false); - } - - private static long notificationDisplayMillis = 0; - private static List<String> notificationLines = null; - private static boolean showNotificationOverInv = false; - - private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); - private static final Pattern SLAYER_XP = - Pattern.compile(" (Spider|Zombie|Wolf|Enderman) Slayer LVL (\\d) - (?:Next LVL in ([\\d,]+) XP!|LVL MAXED OUT!)"); - - /** - * 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. - * 2)Adds unique items to the collection log - */ - private boolean preloadedItems = false; - private long lastLongUpdate = 0; - private long lastSkyblockScoreboard = 0; - - private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10); - private final List<ItemStack> toPreload = new ArrayList<>(); - - private int inventoryLoadedTicks = 0; - private String loadedInvName = ""; - public static boolean inventoryLoaded = false; - - public static void displayNotification(List<String> lines, boolean showForever) { - displayNotification(lines, showForever, false); - } - - public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) { - if (showForever) { - notificationDisplayMillis = -420; - } else { - notificationDisplayMillis = System.currentTimeMillis(); - } - notificationLines = lines; - showNotificationOverInv = overInventory; - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - Keyboard.enableRepeatEvents( - Minecraft.getMinecraft().currentScreen != null && (Minecraft.getMinecraft().currentScreen instanceof GuiChat - || Minecraft.getMinecraft().currentScreen instanceof GuiEditSign || - Minecraft.getMinecraft().currentScreen instanceof GuiScreenBook)); - if (event.phase != TickEvent.Phase.START) return; - if (Minecraft.getMinecraft().theWorld == null) return; - if (Minecraft.getMinecraft().thePlayer == null) return; - - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest cc = (ContainerChest) chest.inventorySlots; - - if (!loadedInvName.equals(cc.getLowerChestInventory().getDisplayName().getUnformattedText())) { - loadedInvName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - inventoryLoaded = false; - inventoryLoadedTicks = 3; - } - - if (!inventoryLoaded) { - if (cc.getLowerChestInventory().getStackInSlot(cc.getLowerChestInventory().getSizeInventory() - 1) != null) { - inventoryLoaded = true; - } else { - for (ItemStack stack : chest.inventorySlots.getInventory()) { - if (stack != null) { - if (--inventoryLoadedTicks <= 0) { - inventoryLoaded = true; - } - break; - } - } - } - } - } else { - inventoryLoaded = false; - inventoryLoadedTicks = 3; - } - - if ((Keyboard.isKeyDown(Keyboard.KEY_NUMPAD1) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD4) && - Keyboard.isKeyDown(Keyboard.KEY_NUMPAD9))) { - ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!"); - component.appendText("\n"); - component.appendText("\n\u00a77Reason: \u00a7rSuspicious account activity/Other"); - component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal"); - component.appendText("\n"); - component.appendText("\n\u00a77Ban ID: \u00a7r#49871982"); - component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!"); - Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component); - return; - } - - if (neu.hasSkyblockScoreboard()) { - if (!preloadedItems) { - preloadedItems = true; - List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values()); - for (JsonObject json : list) { - itemPreloader.submit(() -> { - ItemStack stack = neu.manager.jsonToStack(json, true, true); - if (stack.getItem() == Items.skull) toPreload.add(stack); - }); - } - } else if (!toPreload.isEmpty()) { - Utils.drawItemStack(toPreload.get(0), -100, -100); - toPreload.remove(0); - } else { - itemPreloader.shutdown(); - } - - for (TextOverlay overlay : OverlayManager.textOverlays) { - overlay.shouldUpdateFrequent = true; - } - } - - boolean longUpdate = false; - long currentTime = System.currentTimeMillis(); - if (currentTime - lastLongUpdate > 1000) { - longUpdate = true; - lastLongUpdate = currentTime; - } - if (!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) { - DungeonBlocks.tick(); - } - DungeonWin.tick(); - - String containerName = null; - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { - GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - - if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) { - GuiCustomEnchant.getInstance().tick(); - } - } - - if (longUpdate) { - CrystalOverlay.tick(); - FairySouls.tick(); - XPInformation.getInstance().tick(); - ProfileApiSyncer.getInstance().tick(); - ItemCustomizeManager.tick(); - BackgroundBlur.markDirty(); - NPCRetexturing.getInstance().tick(); - StorageOverlay.getInstance().markDirty(); - - if (neu.hasSkyblockScoreboard()) { - for (TextOverlay overlay : OverlayManager.textOverlays) { - overlay.tick(); - } - } - - NotEnoughUpdates.INSTANCE.overlay.redrawItems(); - CapeManager.onTickSlow(); - - NotEnoughUpdates.profileViewer.putNameUuid( - Minecraft.getMinecraft().thePlayer.getName(), - Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "") - ); - - if (NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) { - DungeonBlocks.tick(); - } - - if (System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 && - System.currentTimeMillis() - SBInfo.getInstance().unloadedWorld > 500) { - neu.updateSkyblockScoreboard(); - } - CapeManager.getInstance().tick(); - - if (containerName != null) { - if (!containerName.trim().startsWith("Accessory Bag")) { - AccessoryBagOverlay.resetCache(); - } - } else { - AccessoryBagOverlay.resetCache(); - } - - if (neu.hasSkyblockScoreboard()) { - SBInfo.getInstance().tick(); - lastSkyblockScoreboard = currentTime; - if (!joinedSB) { - joinedSB = true; - - //SBGamemodes.loadFromFile(); - - if (NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) { - displayUpdateMessageIfOutOfDate(); - } - - if (NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) { - long maxMemoryMB = Runtime.getRuntime().maxMemory() / 1024L / 1024L; - if (maxMemoryMB > 4100) { - notificationDisplayMillis = System.currentTimeMillis(); - notificationLines = new ArrayList<>(); - notificationLines.add(EnumChatFormatting.GRAY + "Too much memory allocated!"); - notificationLines.add(String.format( - EnumChatFormatting.DARK_GRAY + "NEU has detected %03dMB of memory allocated to Minecraft!", - maxMemoryMB - )); - notificationLines.add(EnumChatFormatting.GRAY + "It is recommended to allocated between 2-4GB of memory"); - notificationLines.add( - EnumChatFormatting.GRAY + "More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available"); - notificationLines.add(""); - notificationLines.add( - EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry"); - } - } - - if (!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) { - NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore = true; - if (Constants.MISC == null || !Constants.MISC.has("featureslist")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "" + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "WARNING: " + EnumChatFormatting.RESET + - EnumChatFormatting.RED + "Could not load Feature List URL from repo.")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "" + EnumChatFormatting.RED + "Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" + - EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD + - "restart your game" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " + - EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "If that doesn't fix it" + - EnumChatFormatting.RESET + EnumChatFormatting.RED + - ", please join discord.gg/moulberry and post in #neu-support")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "" + EnumChatFormatting.GOLD + "To view the feature list after restarting type /neufeatures")); - } else { - String url = Constants.MISC.get("featureslist").getAsString(); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.BLUE + "It seems this is your first time using NotEnoughUpdates.")); - ChatComponentText clickTextFeatures = new ChatComponentText( - EnumChatFormatting.YELLOW + - "Click this message if you would like to view a list of NotEnoughUpdate's Features."); - clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url)); - Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures); - } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - ChatComponentText clickTextHelp = new ChatComponentText( - EnumChatFormatting.YELLOW + - "Click this message if you would like to view a list of NotEnoughUpdate's commands."); - clickTextHelp.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neuhelp")); - Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextHelp); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - } - } - } - if (currentTime - lastSkyblockScoreboard < 5 * 60 * 1000) { //5 minutes - neu.manager.auctionManager.tick(); - } else { - neu.manager.auctionManager.markNeedsUpdate(); - } - } - - /*if(longUpdate && neu.hasSkyblockScoreboard()) { - if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { - ProfileViewer.Profile profile = NotEnoughUpdates.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), - callback->{}); - if(profile != null) { - String latest = profile.getLatestProfile(); - if(latest != null) { - neu.manager.setCurrentProfileBackup(profile.getLatestProfile()); - } - } - }*/ - /*if(neu.manager.getCurrentProfile() != null && neu.manager.getCurrentProfile().length() > 0) { - HashSet<String> newItem = new HashSet<>(); - if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && - !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) { - boolean usableContainer = true; - for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) { - if(stack == null) { - continue; - } - if(stack.hasTagCompound()) { - NBTTagCompound tag = stack.getTagCompound(); - if(tag.hasKey("ExtraAttributes", 10)) { - continue; - } - } - usableContainer = false; - break; - } - if(!usableContainer) { - if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest container = (ContainerChest) chest.inventorySlots; - String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); - - if(containerName.equals("Accessory Bag") || containerName.startsWith("Wardrobe")) { - usableContainer = true; - } - } - } - if(usableContainer) { - for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { - processUniqueStack(stack, newItem); - } - for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) { - processUniqueStack(stack, newItem); - } - } - } else { - for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { - processUniqueStack(stack, newItem); - } - } - newItemAddMap.keySet().retainAll(newItem); - } - }*/ - } - - /*private void processUniqueStack(ItemStack stack, HashSet<String> newItem) { - if(stack != null && stack.hasTagCompound()) { - String internalname = neu.manager.getInternalNameForItem(stack); - if(internalname != null) { - /*ArrayList<String> log = neu.manager.config.collectionLog.value.computeIfAbsent( - neu.manager.getCurrentProfile(), k -> new ArrayList<>()); - if(!log.contains(internalname)) { - newItem.add(internalname); - if(newItemAddMap.containsKey(internalname)) { - if(System.currentTimeMillis() - newItemAddMap.get(internalname) > 1000) { - log.add(internalname); - try { neu.manager.saveConfig(); } catch(IOException ignored) {} - } - } else { - newItemAddMap.put(internalname, System.currentTimeMillis()); - } - } - } - } - }*/ - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre<EntityPlayer> event) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) { - if (((GuiProfileViewer) Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) { - event.setCanceled(true); - } - } - } - - @SubscribeEvent - public void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) { - if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && - Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) { - event.setCanceled(true); - } - if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.PLAYER_LIST)) { - GlStateManager.enableDepth(); - } - } - - @SubscribeEvent - public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) { - if (neu.hasSkyblockScoreboard() && event.type.equals(RenderGameOverlayEvent.ElementType.ALL)) { - DungeonWin.render(event.partialTicks); - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, -200); - for (TextOverlay overlay : OverlayManager.textOverlays) { - if (OverlayManager.dontRenderOverlay != null && - OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) { - continue; - } - GlStateManager.translate(0, 0, -1); - GlStateManager.enableDepth(); - overlay.render(); - } - GlStateManager.popMatrix(); - OverlayManager.dontRenderOverlay = null; - } - if (Keyboard.isKeyDown(Keyboard.KEY_X)) { - notificationDisplayMillis = 0; - } - - if (event.type == RenderGameOverlayEvent.ElementType.ALL) { - renderNotification(); - } - - } - - private static void renderNotification() { - - long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); - boolean display = timeRemaining > 0 || notificationDisplayMillis == -420; - if (display && notificationLines != null && notificationLines.size() > 0) { - int width = 0; - int height = notificationLines.size() * 10 + 10; - - for (String line : notificationLines) { - int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8; - if (len > width) { - width = len; - } - } - - ScaledResolution sr = Utils.pushGuiScale(2); - - int midX = sr.getScaledWidth() / 2; - int topY = sr.getScaledHeight() * 3 / 4 - height / 2; - RenderUtils.drawFloatingRectDark(midX - width / 2, sr.getScaledHeight() * 3 / 4 - height / 2, width, height); - /*Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2, - midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C); - Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2, - midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);*/ - - int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close"); - Minecraft.getMinecraft().fontRendererObj.drawString("[X] Close", midX + width / 2f - 3 - xLen, - topY + 3, 0xFFFF5555, false - ); - - if (notificationDisplayMillis > 0) { - Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining / 1000) + "s", midX - width / 2f + 3, - topY + 3, 0xFFaaaaaa, false - ); - } - - Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj, - midX, topY + 4 + 5, false, -1 - ); - for (int i = 1; i < notificationLines.size(); i++) { - String line = notificationLines.get(i); - Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj, - midX, topY + 4 + 5 + 2 + i * 10, false, -1 - ); - } - - Utils.pushGuiScale(-1); - } - } - - public static long lastGuiClosed = 0; - - /** - * When opening a GuiContainer, will reset the overlay and load the config. - * When closing a GuiContainer, will save the config. - * Also includes a dev feature used for automatically acquiring crafting information from the "Crafting Table" GUI. - */ - AtomicBoolean missingRecipe = new AtomicBoolean(false); - - @SubscribeEvent - public void onGuiOpen(GuiOpenEvent event) { - NEUApi.disableInventoryButtons = false; - - if ((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper || - Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) && - event.gui == null && !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) && - System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.lastOpenedGui < 500) { - NotEnoughUpdates.INSTANCE.lastOpenedGui = 0; - event.setCanceled(true); - return; - } - - if (!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) { - CalendarOverlay.setEnabled(false); - } - - if (Minecraft.getMinecraft().currentScreen != null) { - lastGuiClosed = System.currentTimeMillis(); - } - - neu.manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis(); - BetterContainers.reset(); - inventoryLoaded = false; - inventoryLoadedTicks = 3; - - if (event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() && - !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { - event.gui = new CustomAHGui(); - } - - if (!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) { - neu.manager.auctionManager.customAH.setRenderOverAuctionView(false); - } else if (event.gui instanceof GuiChest && (neu.manager.auctionManager.customAH.isRenderOverAuctionView() || - Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { - GuiChest chest = (GuiChest) event.gui; - ContainerChest container = (ContainerChest) chest.inventorySlots; - String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); - - neu.manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") || - containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid") || - containerName.trim().equals("Confirm Purchase")); - } - - //OPEN - if (Minecraft.getMinecraft().currentScreen == null - && event.gui instanceof GuiContainer) { - neu.overlay.reset(); - } - if (event.gui != null && NotEnoughUpdates.INSTANCE.config.hidden.dev) { - if (event.gui instanceof GuiChest) { - GuiChest eventGui = (GuiChest) event.gui; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - IInventory lower = cc.getLowerChestInventory(); - ses.schedule(() -> { - if (Minecraft.getMinecraft().currentScreen != event.gui) { - return; - } - if (lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) { - try { - ItemStack res = lower.getStackInSlot(25); - String resInternalname = neu.manager.getInternalNameForItem(res); - - if (lower.getStackInSlot(48) != null) { - String backName = null; - NBTTagCompound tag = lower.getStackInSlot(48).getTagCompound(); - if (tag.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = tag.getCompoundTag("display"); - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - backName = nbttaglist1.getStringTagAt(0); - } - } - - if (backName != null) { - String[] split = backName.split(" "); - if (split[split.length - 1].contains("Rewards")) { - String col = backName.substring( - split[0].length() + 1, - backName.length() - split[split.length - 1].length() - 1 - ); - - JsonObject json = neu.manager.getItemInformation().get(resInternalname); - json.addProperty("crafttext", "Requires: " + col); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "Added: " + resInternalname)); - neu.manager.writeJsonDefaultDir(json, resInternalname + ".json"); - neu.manager.loadItem(resInternalname); - } - } - } - - /*JsonArray arr = null; - File f = new File(neu.manager.configLocation, "missing.json"); - try(InputStream instream = new FileInputStream(f)) { - BufferedReader reader = new BufferedReader(new InputStreamReader(instream, StandardCharsets.UTF_8)); - JsonObject json = neu.manager.gson.fromJson(reader, JsonObject.class); - arr = json.getAsJsonArray("missing"); - } catch(IOException e) {} - try { - JsonObject json = new JsonObject(); - JsonArray newArr = new JsonArray(); - for(JsonElement e : arr) { - if(!e.getAsString().equals(resInternalname)) { - newArr.add(e); - } - } - json.add("missing", newArr); - neu.manager.writeJson(json, f); - } catch(IOException e) {}*/ - - - - /*JsonObject recipe = new JsonObject(); - - String[] x = {"1","2","3"}; - String[] y = {"A","B","C"}; - - for(int i=0; i<=18; i+=9) { - for(int j=0; j<3; j++) { - ItemStack stack = lower.getStackInSlot(10+i+j); - String internalname = ""; - if(stack != null) { - internalname = neu.manager.getInternalNameForItem(stack); - if(!neu.manager.getItemInformation().containsKey(internalname)) { - neu.manager.writeItemToFile(stack); - } - internalname += ":"+stack.stackSize; - } - recipe.addProperty(y[i/9]+x[j], internalname); - } - } - - JsonObject json = neu.manager.getJsonForItem(res); - json.add("recipe", recipe); - json.addProperty("internalname", resInternalname); - json.addProperty("clickcommand", "viewrecipe"); - json.addProperty("modver", NotEnoughUpdates.VERSION); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname)); - neu.manager.writeJsonDefaultDir(json, resInternalname+".json"); - neu.manager.loadItem(resInternalname);*/ - } catch (Exception e) { - e.printStackTrace(); - } - } - }, 200, TimeUnit.MILLISECONDS); - } - } - } - - /*@SubscribeEvent - public void onPlayerInteract(EntityInteractEvent event) { - if(!event.isCanceled() && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && - Minecraft.getMinecraft().thePlayer.isSneaking() && - Minecraft.getMinecraft().ingameGUI != null) { - if(event.target instanceof EntityPlayer) { - for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); - if(name.contains("Status: "+EnumChatFormatting.RESET+EnumChatFormatting.BLUE+"Guest")) { - NotEnoughUpdates.INSTANCE.sendChatMessage("/trade " + event.target.getName()); - event.setCanceled(true); - break; - } - } - } - } - }*/ - - private IChatComponent processChatComponent(IChatComponent chatComponent) { - IChatComponent newComponent; - if (chatComponent instanceof ChatComponentText) { - ChatComponentText text = (ChatComponentText) chatComponent; - - newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat())); - newComponent.setChatStyle(text.getChatStyle().createShallowCopy()); - - for (IChatComponent sibling : text.getSiblings()) { - newComponent.appendSibling(processChatComponent(sibling)); - } - } else if (chatComponent instanceof ChatComponentTranslation) { - ChatComponentTranslation trans = (ChatComponentTranslation) chatComponent; - - Object[] args = trans.getFormatArgs(); - Object[] newArgs = new Object[args.length]; - for (int i = 0; i < trans.getFormatArgs().length; i++) { - if (args[i] instanceof IChatComponent) { - newArgs[i] = processChatComponent((IChatComponent) args[i]); - } else { - newArgs[i] = args[i]; - } - } - newComponent = new ChatComponentTranslation(trans.getKey(), newArgs); - - for (IChatComponent sibling : trans.getSiblings()) { - newComponent.appendSibling(processChatComponent(sibling)); - } - } else { - newComponent = chatComponent.createCopy(); - } - - return newComponent; - } - - private String processText(String text) { - if (SBInfo.getInstance().getLocation() == null) return text; - if (!SBInfo.getInstance().getLocation().startsWith("mining_") && - !SBInfo.getInstance().getLocation().equals("crystal_hollows")) - return text; - - if (Minecraft.getMinecraft().thePlayer == null) return text; - if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text; - - return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN + "\\S+ Drill Fuel", "")); - } - - private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) { - - if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 > 0 && chatComponent.getChatStyle() != null && - chatComponent.getChatStyle().getChatClickEvent() != null && - chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND && - NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - if (chatComponent.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) { - String username = chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15); - if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) { - chatComponent.setChatStyle(Utils.createClickStyle( - ClickEvent.Action.RUN_COMMAND, - "/pv " + username, - "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + - username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s profile in " + - EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD + "NEU's" + EnumChatFormatting.RESET + - EnumChatFormatting.YELLOW + " profile viewer." - )); - return chatComponent; - } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) { - chatComponent.setChatStyle(Utils.createClickStyle( - ClickEvent.Action.RUN_COMMAND, - "/ah " + username, - "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + - username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page" - )); - return chatComponent; - } - } // wanted to add this for guild but guild uses uuid :sad: - } - return chatComponent; - } - - /** - * 1) When receiving "You are playing on profile" messages, will set the current profile. - * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI) - * 3) Replaces lobby join notifications when streamer mode is active - */ - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - public void onGuiChat(ClientChatReceivedEvent e) { - if (e.type == 2) { - CrystalMetalDetectorSolver.process(e.message); - e.message = processChatComponent(e.message); - return; - } else if (e.type == 0) { - e.message = replaceSocialControlsWithPV(e.message); - } - - DungeonWin.onChatMessage(e); - - String r = null; - String unformatted = Utils.cleanColour(e.message.getUnformattedText()); - Matcher matcher = SLAYER_XP.matcher(unformatted); - if (unformatted.startsWith("You are playing on profile: ")) { - neu.manager.setCurrentProfile(unformatted - .substring("You are playing on profile: ".length()) - .split(" ")[0].trim()); - } else if (unformatted.startsWith("Your profile was changed to: ")) {//Your profile was changed to: - neu.manager.setCurrentProfile(unformatted - .substring("Your profile was changed to: ".length()) - .split(" ")[0].trim()); - } else if (unformatted.startsWith("Your new API key is ")) { - NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = unformatted.substring("Your new API key is ".length()); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "[NEU] API Key automatically configured")); - NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.substring(0, 36); - } else if (unformatted.startsWith("Player List Info is now disabled!")) { - SBInfo.getInstance().hasNewTab = false; - } else if (unformatted.startsWith("Player List Info is now enabled!")) { - SBInfo.getInstance().hasNewTab = true; - } - if (e.message.getFormattedText().equals(EnumChatFormatting.RESET.toString() + - EnumChatFormatting.RED + "You haven't unlocked this recipe!" + EnumChatFormatting.RESET)) { - r = EnumChatFormatting.RED + "You haven't unlocked this recipe!"; - } else if (e.message.getFormattedText().startsWith(EnumChatFormatting.RESET.toString() + - EnumChatFormatting.RED + "Invalid recipe ")) { - r = ""; - } else if (unformatted.equals(" NICE! SLAYER BOSS SLAIN!")) { - SlayerOverlay.isSlain = true; - } else if (unformatted.equals(" SLAYER QUEST STARTED!")) { - SlayerOverlay.isSlain = false; - if (timeSinceLastBoss == 0) { - SlayerOverlay.timeSinceLastBoss = System.currentTimeMillis(); - } else { - timeSinceLastBoss2 = timeSinceLastBoss; - timeSinceLastBoss = System.currentTimeMillis(); - } - } else if (unformatted.startsWith(" RNGesus Meter:")) { - RNGMeter = unformatted.substring(" RNGesus Meter: -------------------- ".length()); - } else if (matcher.matches()) { - //matcher.group(1); - SlayerOverlay.slayerLVL = matcher.group(2); - if (!SlayerOverlay.slayerLVL.equals("9")) { - SlayerOverlay.slayerXp = matcher.group(3); - } else { - slayerXp = "maxed"; - } - } else if (unformatted.startsWith("Sending to server") || - (unformatted.startsWith("Your Slayer Quest has been cancelled!"))) { - SlayerOverlay.slayerQuest = false; - SlayerOverlay.unloadOverlayTimer = System.currentTimeMillis(); - } - if (e.message - .getFormattedText() - .contains(EnumChatFormatting.YELLOW + "Visit the Auction House to collect your item!")) { - if (NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid != null && - System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBidMillis < 5000) { - NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction " + - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.niceAucId( - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid)); - } - } - if (r != null) { - if (neu.manager.failViewItem(r)) { - e.setCanceled(true); - } - missingRecipe.set(true); - } - //System.out.println(e.message); - if (unformatted.startsWith("Sending to server") && - neu.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode && - e.message instanceof ChatComponentText) { - String m = e.message.getFormattedText(); - String m2 = StreamerMode.filterChat(e.message.getFormattedText()); - if (!m.equals(m2)) { - e.message = new ChatComponentText(m2); - } - } - if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && - SBInfo.getInstance().getLocation().equals("crystal_hollows")) { - CrystalMetalDetectorSolver.reset(true); - } - if (unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || - unformatted.startsWith(" ") || unformatted.startsWith("✦") || - unformatted.equals(" You've earned a Crystal Loot Bundle!")) - OverlayManager.crystalHollowOverlay.message(unformatted); - } - - public static boolean drawingGuiScreen = false; - - /** - * Sets hoverInv and focusInv variables, representing whether the NEUOverlay should render behind the inventory when - * (hoverInv == true) and whether mouse/kbd inputs shouldn't be sent to NEUOverlay (focusInv == true). - * <p> - * If hoverInv is true, will render the overlay immediately (resulting in the inventory being drawn over the GUI) - * If hoverInv is false, the overlay will render in #onGuiScreenDraw (resulting in the GUI being drawn over the inv) - * <p> - * All of this only matters if players are using gui scale auto which may result in the inventory being drawn - * over the various panes. - */ - @SubscribeEvent - public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) { - if (showNotificationOverInv) { - - renderNotification(); - - } - if ((shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && neu.isOnSkyblock()) { - ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledresolution.getScaledWidth(); - - boolean hoverPane = event.getMouseX() < width * neu.overlay.getInfoPaneOffsetFactor() || - event.getMouseX() > width * neu.overlay.getItemPaneOffsetFactor(); - - if (event.gui instanceof GuiContainer) { - try { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; - - hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && - event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; - - if (hoverPane) { - if (!hoverInv) focusInv = false; - } else { - focusInv = true; - } - } catch (NullPointerException npe) { - focusInv = !hoverPane; - } - } - if (event.gui instanceof GuiItemRecipe) { - GuiItemRecipe guiItemRecipe = ((GuiItemRecipe) event.gui); - hoverInv = event.getMouseX() > guiItemRecipe.guiLeft && - event.getMouseX() < guiItemRecipe.guiLeft + guiItemRecipe.xSize && - event.getMouseY() > guiItemRecipe.guiTop && event.getMouseY() < guiItemRecipe.guiTop + guiItemRecipe.ySize; - - if (hoverPane) { - if (!hoverInv) focusInv = false; - } else { - focusInv = true; - } - } - if (focusInv) { - try { - neu.overlay.render(hoverInv); - } catch (ConcurrentModificationException e) { - e.printStackTrace(); - } - GL11.glTranslatef(0, 0, 10); - } - if (hoverInv) { - renderDungeonChestOverlay(event.gui); - if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { - AccessoryBagOverlay.renderOverlay(); - } - } - } - - drawingGuiScreen = true; - } - - private boolean doInventoryButtons = false; - - @SubscribeEvent - public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) { - doInventoryButtons = false; - - if (AuctionSearchOverlay.shouldReplace()) { - AuctionSearchOverlay.render(); - event.setCanceled(true); - return; - } - if (RancherBootOverlay.shouldReplace()) { - RancherBootOverlay.render(); - event.setCanceled(true); - return; - } - - String containerName = null; - GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; - if (guiScreen instanceof GuiChest) { - GuiChest eventGui = (GuiChest) guiScreen; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - } - - if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) { - GuiCustomEnchant.getInstance().render(event.renderPartialTicks); - event.setCanceled(true); - return; - } - - boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); - boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); - boolean customAhActive = - event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); - - if (storageOverlayActive) { - StorageOverlay.getInstance().render(); - event.setCanceled(true); - return; - } - - if (tradeWindowActive || customAhActive) { - event.setCanceled(true); - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - - //Dark background - Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680); - - if (event.mouseX < width * neu.overlay.getWidthMult() / 3 || - event.mouseX > width - width * neu.overlay.getWidthMult() / 3) { - if (customAhActive) { - neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); - } else if (tradeWindowActive) { - TradeWindow.render(event.mouseX, event.mouseY); - } - neu.overlay.render(false); - } else { - neu.overlay.render(false); - if (customAhActive) { - neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); - } else if (tradeWindowActive) { - TradeWindow.render(event.mouseX, event.mouseY); - } - } - } - - if (CalendarOverlay.isEnabled() || event.isCanceled()) return; - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) - && event.gui instanceof GuiContainer) { - doInventoryButtons = true; - - int zOffset = 50; - - GlStateManager.translate(0, 0, zOffset); - - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; - - if (!NEUApi.disableInventoryButtons) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (NEUOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (NEUOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - - GlStateManager.color(1, 1, 1, 1f); - - GlStateManager.enableDepth(); - GlStateManager.enableAlpha(); - Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); - Utils.drawTexturedRect(x, y, 18, 18, - button.backgroundIndex * 18 / 256f, (button.backgroundIndex * 18 + 18) / 256f, - 18 / 256f, 36 / 256f, GL11.GL_NEAREST - ); - - if (button.icon != null && !button.icon.trim().isEmpty()) { - GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1); - } - } - } - GlStateManager.translate(0, 0, -zOffset); - } - } - - private static boolean shouldRenderOverlay(Gui gui) { - boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe; - if (gui instanceof GuiChest) { - GuiChest eventGui = (GuiChest) gui; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if (containerName.trim().equals("Fast Travel")) { - validGui = false; - } - } - return validGui; - } - - private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png"); - private NEUConfig.InventoryButton buttonHovered = null; - private long buttonHoveredMillis = 0; - public static boolean disableCraftingText = false; - - /** - * Will draw the NEUOverlay over the inventory if focusInv == false. (z-translation of 300 is so that NEUOverlay - * will draw over Items in the inventory (which render at a z value of about 250)) - */ - @SubscribeEvent - public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) { - drawingGuiScreen = false; - disableCraftingText = false; - - String containerName = null; - GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; - if (guiScreen instanceof GuiChest) { - GuiChest eventGui = (GuiChest) guiScreen; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - - if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) - return; - } - - boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); - boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); - boolean customAhActive = - event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); - - if (!(tradeWindowActive || storageOverlayActive || customAhActive)) { - if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - GlStateManager.pushMatrix(); - if (!focusInv) { - GL11.glTranslatef(0, 0, 300); - neu.overlay.render(hoverInv && focusInv); - GL11.glTranslatef(0, 0, -300); - } - GlStateManager.popMatrix(); - } - } - - if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) { - renderDungeonChestOverlay(event.gui); - if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { - AccessoryBagOverlay.renderOverlay(); - } - } - - boolean hoveringButton = false; - if (!doInventoryButtons) return; - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && - event.gui instanceof GuiContainer) { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; - - if (!NEUApi.disableInventoryButtons) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (NEUOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (NEUOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - - if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) { - disableCraftingText = true; - } - - if (event.mouseX >= x && event.mouseX <= x + 18 && - event.mouseY >= y && event.mouseY <= y + 18) { - hoveringButton = true; - long currentTime = System.currentTimeMillis(); - - if (buttonHovered != button) { - buttonHoveredMillis = currentTime; - buttonHovered = button; - } - - if (currentTime - buttonHoveredMillis > 600) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } - - Utils.drawHoveringText(Lists.newArrayList("\u00a77" + command), event.mouseX, event.mouseY, - event.gui.width, event.gui.height, -1, Minecraft.getMinecraft().fontRendererObj - ); - } - } - } - } - } - if (!hoveringButton) buttonHovered = null; - - if (AuctionBINWarning.getInstance().shouldShow()) { - AuctionBINWarning.getInstance().render(); - } - } - - private void renderDungeonChestOverlay(GuiScreen gui) { - if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return; - - if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) { - try { - int xSize = ((GuiContainer) gui).xSize; - int ySize = ((GuiContainer) gui).ySize; - int guiLeft = ((GuiContainer) gui).guiLeft; - int guiTop = ((GuiContainer) gui).guiTop; - - GuiChest eventGui = (GuiChest) gui; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - IInventory lower = cc.getLowerChestInventory(); - - ItemStack rewardChest = lower.getStackInSlot(31); - if (rewardChest != null && - rewardChest.getDisplayName().endsWith(EnumChatFormatting.GREEN + "Open Reward Chest")) { - int chestCost = 0; - try { - String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]); - StringBuilder cost = new StringBuilder(); - for (int i = 0; i < line6.length(); i++) { - char c = line6.charAt(i); - if ("0123456789".indexOf(c) >= 0) { - cost.append(c); - } - } - if (cost.length() > 0) { - chestCost = Integer.parseInt(cost.toString()); - } - } catch (Exception ignored) { - } - - String missingItem = null; - int totalValue = 0; - HashMap<String, Float> itemValues = new HashMap<>(); - for (int i = 0; i < 5; i++) { - ItemStack item = lower.getStackInSlot(11 + i); - String internal = neu.manager.getInternalNameForItem(item); - if (internal != null) { - internal = internal.replace("\u00CD", "I").replace("\u0130", "I"); - float bazaarPrice = -1; - JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal); - if (bazaarInfo != null && bazaarInfo.has("curr_sell")) { - bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat(); - } - if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; - - float worth = -1; - if (bazaarPrice > 0) { - worth = bazaarPrice; - } else { - switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) { - case 1: - worth = neu.manager.auctionManager.getItemAvgBin(internal); - break; - case 2: - JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); - if (auctionInfo != null) { - if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); - } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); - } - } - break; - default: - worth = neu.manager.auctionManager.getLowestBin(internal); - } - if (worth <= 0) { - worth = neu.manager.auctionManager.getLowestBin(internal); - if (worth <= 0) { - worth = neu.manager.auctionManager.getItemAvgBin(internal); - if (worth <= 0) { - JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); - if (auctionInfo != null) { - if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); - } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); - } - } - } - } - } - } - - if (worth > 0 && totalValue >= 0) { - totalValue += worth; - String display = item.getDisplayName(); - - if (display.contains("Enchanted Book")) { - NBTTagCompound tag = item.getTagCompound(); - if (tag != null && tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - NBTTagCompound enchants = ea.getCompoundTag("enchantments"); - - int highestLevel = -1; - for (String enchname : enchants.getKeySet()) { - int level = enchants.getInteger(enchname); - if (level > highestLevel) { - display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully( - enchname.replace("_", " ") - .replace("Ultimate", "") - .trim()) + " " + level; - } - } - } - } - - itemValues.put(display, worth); - } else { - if (totalValue != -1) { - missingItem = internal; - } - totalValue = -1; - } - } - } - - NumberFormat format = NumberFormat.getInstance(Locale.US); - String valueStringBIN1; - String valueStringBIN2; - if (totalValue >= 0) { - valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): "; - valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins"; - } else { - valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: "; - valueStringBIN2 = missingItem; - } - - int profitLossBIN = totalValue - chestCost; - - boolean kismetUsed = false; - // checking for kismet - Slot slot = (eventGui.inventorySlots.getSlot(50)); - if (slot.getHasStack()) { - String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(slot.getStack().getTagCompound()); - for (String line : lore) { - if (line.contains("You already rerolled a chest!")) { - kismetUsed = true; - break; - } - } - } - int kismetPrice = neu.manager.auctionManager.getLowestBin("KISMET_FEATHER"); - String kismetStr = EnumChatFormatting.RED + format.format(kismetPrice) + " coins"; - if (neu.config.dungeons.useKismetOnDungeonProfit) - profitLossBIN = kismetUsed ? profitLossBIN - kismetPrice : profitLossBIN; - - String profitPrefix = EnumChatFormatting.DARK_GREEN.toString(); - String lossPrefix = EnumChatFormatting.RED.toString(); - String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix; - - String plStringBIN; - if (profitLossBIN >= 0) { - plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins"; - } else { - plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; - } - - if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) { - int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(plStringBIN); - GlStateManager.disableLighting(); - GlStateManager.translate(0, 0, 200); - Minecraft.getMinecraft().fontRendererObj.drawString(plStringBIN, guiLeft + xSize - 5 - w, guiTop + 5, - 0xffffffff, true - ); - GlStateManager.translate(0, 0, -200); - return; - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth); - GL11.glColor4f(1, 1, 1, 1); - GlStateManager.disableLighting(); - Utils.drawTexturedRect(guiLeft + xSize + 4, guiTop, 180, 101, 0, 180 / 256f, 0, 101 / 256f, GL11.GL_NEAREST); - - Utils.renderAlignedString(valueStringBIN1, valueStringBIN2, - guiLeft + xSize + 4 + 10, guiTop + 14, 160 - ); - if (neu.config.dungeons.useKismetOnDungeonProfit && kismetUsed) { - Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Kismet Feather: ", kismetStr, - guiLeft + xSize + 4 + 10, guiTop + 24, 160 - ); - } - if (totalValue >= 0) { - Utils.renderAlignedString( - EnumChatFormatting.YELLOW + "Profit/Loss: ", - plStringBIN, - guiLeft + xSize + 4 + 10, - guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 34 : 24) : 24), - 160 - ); - } - - int index = 0; - for (Map.Entry<String, Float> entry : itemValues.entrySet()) { - Utils.renderAlignedString( - entry.getKey(), - prefix + - format.format(entry.getValue().intValue()), - guiLeft + xSize + 4 + 10, - guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 39 : 29) : 29) + (++index) * 10, - 160 - ); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public void drawStringShadow(String str, float x, float y, int len) { - for (int xOff = -2; xOff <= 2; xOff++) { - for (int yOff = -2; yOff <= 2; yOff++) { - if (Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str), - Minecraft.getMinecraft().fontRendererObj, - x + xOff / 2f, y + yOff / 2f, false, len, - new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB() - ); - } - } - } - - Utils.drawStringCenteredScaledMaxWidth(str, - Minecraft.getMinecraft().fontRendererObj, - x, y, false, len, - new Color(64, 64, 64, 255).getRGB() - ); - } - - /** - * Sends a mouse event to NEUOverlay if the inventory isn't hovered AND focused. - * Will also cancel the event if if NEUOverlay#mouseInput returns true. - */ - @SubscribeEvent(priority = EventPriority.LOW) - public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) { - if (Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) { - event.setCanceled(true); - return; - } - - 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 (AuctionBINWarning.getInstance().shouldShow()) { - AuctionBINWarning.getInstance().mouseInput(mouseX, mouseY); - event.setCanceled(true); - return; - } - - if (!event.isCanceled()) { - Utils.scrollTooltip(Mouse.getEventDWheel()); - } - if (AuctionSearchOverlay.shouldReplace()) { - AuctionSearchOverlay.mouseEvent(); - event.setCanceled(true); - return; - } - if (RancherBootOverlay.shouldReplace()) { - RancherBootOverlay.mouseEvent(); - event.setCanceled(true); - return; - } - - String containerName = null; - GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; - if (guiScreen instanceof GuiChest) { - GuiChest eventGui = (GuiChest) guiScreen; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if (containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 && - eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && - Mouse.getEventButton() >= 0) { - event.setCanceled(true); - if (Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && - eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null) { - NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound(); - if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) { - String username = tag.getCompoundTag("SkullOwner").getString("Name"); - Utils.playPressSound(); - ViewProfileCommand.RUNNABLE.accept(new String[]{username}); - } - } - } - } - - if (GuiCustomEnchant.getInstance().shouldOverride(containerName) && - GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) { - event.setCanceled(true); - return; - } - - boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); - boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); - boolean customAhActive = - event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); - - if (storageOverlayActive) { - if (StorageOverlay.getInstance().mouseInput(mouseX, mouseY)) { - event.setCanceled(true); - } - return; - } - - if (tradeWindowActive || customAhActive) { - event.setCanceled(true); - if (customAhActive) { - neu.manager.auctionManager.customAH.handleMouseInput(); - } else if (tradeWindowActive) { - TradeWindow.handleMouseInput(); - } - neu.overlay.mouseInput(); - return; - } - - if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - if (!NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay || !AccessoryBagOverlay.mouseClick()) { - if (!(hoverInv && focusInv)) { - if (neu.overlay.mouseInput()) { - event.setCanceled(true); - } - } else { - neu.overlay.mouseInputInv(); - } - } - } - if (event.isCanceled()) return; - if (!doInventoryButtons) return; - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && - Mouse.getEventButton() >= 0 - && event.gui instanceof GuiContainer) { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; - if (!NEUApi.disableInventoryButtons) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (NEUOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (NEUOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - - if (mouseX >= x && mouseX <= x + 18 && mouseY >= y && mouseY <= y + 18) { - if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { - int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; - if ((clickType == 0 && Mouse.getEventButtonState()) || (clickType == 1 && !Mouse.getEventButtonState())) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } - if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { - NotEnoughUpdates.INSTANCE.sendChatMessage(command); - } - } - } else { - event.setCanceled(true); - } - return; - } - } - } - } - } - - 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. - */ - @SubscribeEvent - public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) { - if (AuctionBINWarning.getInstance().shouldShow()) { - AuctionBINWarning.getInstance().keyboardInput(); - event.setCanceled(true); - return; - } - - if (AuctionSearchOverlay.shouldReplace()) { - AuctionSearchOverlay.keyEvent(); - event.setCanceled(true); - return; - } - if (RancherBootOverlay.shouldReplace()) { - RancherBootOverlay.keyEvent(); - event.setCanceled(true); - return; - } - - String containerName = null; - GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; - - if (guiScreen instanceof GuiChest) { - containerName = ((ContainerChest) ((GuiChest) guiScreen).inventorySlots) - .getLowerChestInventory() - .getDisplayName() - .getUnformattedText(); - } - - if (GuiCustomEnchant.getInstance().shouldOverride(containerName) && - GuiCustomEnchant.getInstance().keyboardInput()) { - event.setCanceled(true); - return; - } - - boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); - boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); - boolean customAhActive = - event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); - - if (storageOverlayActive) { - if (StorageOverlay.getInstance().keyboardInput()) { - event.setCanceled(true); - return; - } - } - - if (tradeWindowActive || customAhActive) { - if (customAhActive) { - if (neu.manager.auctionManager.customAH.keyboardInput()) { - event.setCanceled(true); - Minecraft.getMinecraft().dispatchKeypresses(); - } else if (neu.overlay.keyboardInput(focusInv)) { - event.setCanceled(true); - } - } else if (tradeWindowActive) { - TradeWindow.keyboardInput(); - if (Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) { - event.setCanceled(true); - Minecraft.getMinecraft().dispatchKeypresses(); - neu.overlay.keyboardInput(focusInv); - } - } - return; - } - - if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - if (neu.overlay.keyboardInput(focusInv)) { - event.setCanceled(true); - } - } - if (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.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 (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && - Minecraft.getMinecraft().theWorld != null && - Keyboard.getEventKey() == Keyboard.KEY_O && 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.getStackInSlot(23) != null && - lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) { - ItemStack res = lower.getStackInSlot(25); - String resInternalname = neu.manager.getInternalNameForItem(res); - JTextField tf = new JTextField(); - tf.setText(resInternalname); - tf.addAncestorListener(new RequestFocusListener()); - JOptionPane.showOptionDialog(null, - tf, - "Enter Name:", - JOptionPane.NO_OPTION, - JOptionPane.PLAIN_MESSAGE, - null, new String[]{"Enter"}, "Enter" - ); - resInternalname = tf.getText(); - if (resInternalname.trim().length() == 0) { - return; - } - - JsonObject recipe = new JsonObject(); - - String[] x = {"1", "2", "3"}; - String[] y = {"A", "B", "C"}; - - for (int i = 0; i <= 18; i += 9) { - for (int j = 0; j < 3; j++) { - ItemStack stack = lower.getStackInSlot(10 + i + j); - String internalname = ""; - if (stack != null) { - internalname = neu.manager.getInternalNameForItem(stack); - if (!neu.manager.getItemInformation().containsKey(internalname)) { - neu.manager.writeItemToFile(stack); - } - internalname += ":" + stack.stackSize; - } - recipe.addProperty(y[i / 9] + x[j], internalname); - } - } - - JsonObject json = neu.manager.getJsonForItem(res); - json.add("recipe", recipe); - json.addProperty("internalname", resInternalname); - json.addProperty("clickcommand", "viewrecipe"); - json.addProperty("modver", NotEnoughUpdates.VERSION); - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname)); - neu.manager.writeJsonDefaultDir(json, resInternalname + ".json"); - neu.manager.loadItem(resInternalname); - } catch (IOException ignored) { - } - } - } - } - } - - private final HashSet<String> percentStats = new HashSet<>(); - - { - percentStats.add("bonus_attack_speed"); - percentStats.add("crit_damage"); - percentStats.add("crit_chance"); - percentStats.add("sea_creature_chance"); - percentStats.add("ability_damage"); - } - - private String currentRarity = "COMMON"; - private boolean showReforgeStoneStats = true; - private boolean pressedArrowLast = false; - private boolean pressedShiftLast = false; - - private boolean copied = false; - - //just to try and optimize it a bit - private int sbaloaded = -1; - - private boolean isSbaloaded() { - if (sbaloaded == -1) { - if (Loader.isModLoaded("skyblockaddons")) { - sbaloaded = 1; - } else { - sbaloaded = 0; - } - } - return sbaloaded == 1; - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void onItemTooltipLow(ItemTooltipEvent event) { - if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; - - String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); - if (internalname == null) { - onItemToolTipInternalNameNull(event); - return; - } - - boolean hasEnchantments = - event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10); - Set<String> enchantIds = new HashSet<>(); - if (hasEnchantments) - enchantIds = - event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet(); - - JsonObject enchantsConst = Constants.ENCHANTS; - JsonArray allItemEnchs = null; - Set<String> ignoreFromPool = new HashSet<>(); - if (enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) { - try { - JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray(); - for (JsonElement element : enchantPools) { - Set<String> currentPool = new HashSet<>(); - for (JsonElement poolElement : element.getAsJsonArray()) { - String poolS = poolElement.getAsString(); - currentPool.add(poolS); - } - for (JsonElement poolElement : element.getAsJsonArray()) { - String poolS = poolElement.getAsString(); - if (enchantIds.contains(poolS)) { - ignoreFromPool.addAll(currentPool); - break; - } - } - } - - JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject(); - NBTTagCompound tag = event.itemStack.getTagCompound(); - if (tag != null) { - NBTTagCompound display = tag.getCompoundTag("display"); - if (display.hasKey("Lore", 9)) { - NBTTagList list = display.getTagList("Lore", 8); - out: - for (int i = list.tagCount(); i >= 0; i--) { - String line = list.getStringTagAt(i); - for (int j = 0; j < Utils.rarityArrC.length; j++) { - for (Map.Entry<String, JsonElement> entry : enchantsObj.entrySet()) { - if (line.contains(Utils.rarityArrC[j] + " " + entry.getKey()) || - line.contains(Utils.rarityArrC[j] + " DUNGEON " + entry.getKey())) { - allItemEnchs = entry.getValue().getAsJsonArray(); - break out; - } - } - } - } - } - } - } catch (Exception ignored) { - } - } - - boolean gotToEnchants = false; - boolean passedEnchants = false; - - boolean dungeonProfit = false; - int index = 0; - List<String> newTooltip = new ArrayList<>(); - - for (String line : event.toolTip) { - if (line.endsWith(EnumChatFormatting.DARK_GRAY + "Reforge Stone") && - NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) { - JsonObject reforgeStones = Constants.REFORGESTONES; - - if (reforgeStones != null && reforgeStones.has(internalname)) { - boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - if (!pressedShiftLast && shift) { - showReforgeStoneStats = !showReforgeStoneStats; - } - pressedShiftLast = shift; - - newTooltip.add(line); - newTooltip.add(""); - if (!showReforgeStoneStats) { - newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to show extra info]"); - } else { - newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to hide extra info]"); - } - - JsonObject reforgeInfo = reforgeStones.get(internalname).getAsJsonObject(); - JsonArray requiredRaritiesArray = reforgeInfo.get("requiredRarities").getAsJsonArray(); - - if (showReforgeStoneStats && requiredRaritiesArray.size() > 0) { - String reforgeName = Utils.getElementAsString(reforgeInfo.get("reforgeName"), ""); - - String[] requiredRarities = new String[requiredRaritiesArray.size()]; - for (int i = 0; i < requiredRaritiesArray.size(); i++) { - requiredRarities[i] = requiredRaritiesArray.get(i).getAsString(); - } - - int rarityIndex = requiredRarities.length - 1; - String rarity = requiredRarities[rarityIndex]; - for (int i = 0; i < requiredRarities.length; i++) { - String rar = requiredRarities[i]; - if (rar.equalsIgnoreCase(currentRarity)) { - rarity = rar; - rarityIndex = i; - break; - } - } - - boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT); - boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT); - if (!pressedArrowLast && (left || right)) { - if (left) { - rarityIndex--; - } else if (right) { - rarityIndex++; - } - if (rarityIndex < 0) rarityIndex = 0; - if (rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length - 1; - currentRarity = requiredRarities[rarityIndex]; - rarity = currentRarity; - } - pressedArrowLast = left || right; - - JsonElement statsE = reforgeInfo.get("reforgeStats"); - - String rarityFormatted = Utils.rarityArrMap.getOrDefault(rarity, rarity); - - JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility"); - String reforgeAbility = null; - if (reforgeAbilityE != null) { - if (reforgeAbilityE.isJsonPrimitive() && reforgeAbilityE.getAsJsonPrimitive().isString()) { - reforgeAbility = Utils.getElementAsString(reforgeInfo.get("reforgeAbility"), ""); - - } else if (reforgeAbilityE.isJsonObject()) { - if (reforgeAbilityE.getAsJsonObject().has(rarity)) { - reforgeAbility = reforgeAbilityE.getAsJsonObject().get(rarity).getAsString(); - } - } - } - - if (reforgeAbility != null && !reforgeAbility.isEmpty()) { - String text = EnumChatFormatting.BLUE + (reforgeName.isEmpty() ? "Bonus: " : reforgeName + " Bonus: ") + - EnumChatFormatting.GRAY + reforgeAbility; - boolean first = true; - for (String s : Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(text, 150)) { - newTooltip.add((first ? "" : " ") + s); - first = false; - } - newTooltip.add(""); - } - - newTooltip.add(EnumChatFormatting.BLUE + "Stats for " + rarityFormatted + - "\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]"); - - if (statsE != null && statsE.isJsonObject()) { - JsonObject stats = statsE.getAsJsonObject(); - - JsonElement statsRarE = stats.get(rarity); - if (statsRarE != null && statsRarE.isJsonObject()) { - - JsonObject statsRar = statsRarE.getAsJsonObject(); - - TreeSet<Map.Entry<String, JsonElement>> sorted = new TreeSet<>(Map.Entry.comparingByKey()); - sorted.addAll(statsRar.entrySet()); - - for (Map.Entry<String, JsonElement> entry : sorted) { - if (entry.getValue().isJsonPrimitive() && ((JsonPrimitive) entry.getValue()).isNumber()) { - float statNumF = entry.getValue().getAsFloat(); - String statNumS; - if (statNumF % 1 == 0) { - statNumS = String.valueOf(Math.round(statNumF)); - } else { - statNumS = Utils.floatToString(statNumF, 1); - } - String reforgeNamePretty = WordUtils.capitalizeFully(entry.getKey().replace("_", " ")); - String text = - EnumChatFormatting.GRAY + reforgeNamePretty + ": " + EnumChatFormatting.GREEN + "+" + statNumS; - if (percentStats.contains(entry.getKey())) { - text += "%"; - } - newTooltip.add(" " + text); - } - } - } - } - - JsonElement reforgeCostsE = reforgeInfo.get("reforgeCosts"); - int reforgeCost = -1; - if (reforgeCostsE != null) { - if (reforgeCostsE.isJsonPrimitive() && reforgeCostsE.getAsJsonPrimitive().isNumber()) { - reforgeCost = (int) Utils.getElementAsFloat(reforgeInfo.get("reforgeAbility"), -1); - - } else if (reforgeCostsE.isJsonObject()) { - if (reforgeCostsE.getAsJsonObject().has(rarity)) { - reforgeCost = (int) Utils.getElementAsFloat(reforgeCostsE.getAsJsonObject().get(rarity), -1); - } - } - } - - if (reforgeCost >= 0) { - String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD + - NumberFormat.getNumberInstance().format(reforgeCost) + " coins"; - newTooltip.add(""); - newTooltip.add(text); - } - - } - - continue; - } - - } else if (line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) { - line = line.replace( - "\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune", - Utils.chromaString("Rainbow Rune", index, false) + EnumChatFormatting.BLUE - ); - } else if (hasEnchantments) { - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && - NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) { - boolean lineHasEnch = false; - for (String s : enchantIds) { - String enchantName = WordUtils.capitalizeFully(s.replace("_", " ")); - if (line.contains(enchantName)) { - lineHasEnch = true; - break; - } - } - if (lineHasEnch) { - gotToEnchants = true; - } else { - if (gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) { - if (enchantsConst != null && allItemEnchs != null) { - List<String> missing = new ArrayList<>(); - for (JsonElement enchIdElement : allItemEnchs) { - String enchId = enchIdElement.getAsString(); - if (!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) && - !enchantIds.contains(enchId)) { - missing.add(enchId); - } - } - if (!missing.isEmpty()) { - newTooltip.add(""); - StringBuilder currentLine = - new StringBuilder(EnumChatFormatting.RED + "Missing: " + EnumChatFormatting.GRAY); - for (int i = 0; i < missing.size(); i++) { - String enchName = WordUtils.capitalizeFully(missing.get(i).replace("_", " ")); - if (currentLine.length() != 0 && - (Utils.cleanColour(currentLine.toString()).length() + enchName.length()) > 40) { - newTooltip.add(currentLine.toString()); - currentLine = new StringBuilder(); - } - if (currentLine.length() != 0 && i != 0) { - currentLine.append(", ").append(enchName); - } else { - currentLine.append(EnumChatFormatting.GRAY).append(enchName); - } - } - if (currentLine.length() != 0) { - newTooltip.add(currentLine.toString()); - } - } - } - passedEnchants = true; - } - } - } - for (String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) { - List<String> colourOps = GuiEnchantColour.splitter.splitToList(op); - String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); - String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); - String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); - String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); - String modifier = GuiEnchantColour.getColourOpIndex(colourOps, 4); - - int modifierI = GuiEnchantColour.getIntModifier(modifier); - - if (enchantName.length() == 0) continue; - if (comparator.length() == 0) continue; - if (comparison.length() == 0) continue; - if (colourCode.length() == 0) continue; - - int comparatorI = ">=<".indexOf(comparator.charAt(0)); - - int levelToFind = -1; - try { - levelToFind = Integer.parseInt(comparison); - } catch (Exception e) { - continue; - } - - if (comparatorI < 0) continue; - String regexText = "0123456789abcdefz"; - if (isSbaloaded()) { - regexText = regexText + "Z"; - } - - if (regexText.indexOf(colourCode.charAt(0)) < 0) continue; - - //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); - //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$) - Pattern pattern; - try { - pattern = Pattern.compile("(\\u00A79|\\u00A7(9|l)\\u00A7d\\u00A7l)(?<enchantName>" + enchantName + ") " + - "(?<level>[0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))((\\u00A79)?,|( \\u00A78(?:,?[0-9]+)*)?$)"); - } catch (Exception e) { - continue; - } //malformed regex - Matcher matcher = pattern.matcher(line); - int matchCount = 0; - while (matcher.find() && matchCount < 5) { - if (Utils.cleanColour(matcher.group("enchantName")).startsWith(" ")) continue; - - matchCount++; - int level = -1; - String levelStr = matcher.group("level"); - if (levelStr == null) continue; - try { - level = Integer.parseInt(levelStr); - } catch (Exception e) { - switch (levelStr) { - case "I": - level = 1; - break; - case "II": - level = 2; - break; - case "III": - level = 3; - break; - case "IV": - level = 4; - break; - case "V": - level = 5; - break; - case "VI": - level = 6; - break; - case "VII": - level = 7; - break; - case "VIII": - level = 8; - break; - case "IX": - level = 9; - break; - case "X": - level = 10; - break; - case "XI": - level = 11; - break; - case "XII": - level = 12; - break; - case "XIII": - level = 13; - break; - case "XIV": - level = 14; - break; - case "XV": - level = 15; - break; - case "XVI": - level = 16; - break; - case "XVII": - level = 17; - break; - case "XVIII": - level = 18; - break; - case "XIX": - level = 19; - break; - case "XX": - level = 20; - break; - } - } - boolean matches = false; - if (level > 0) { - switch (comparator) { - case ">": - matches = level > levelToFind; - break; - case "=": - matches = level == levelToFind; - break; - case "<": - matches = level < levelToFind; - break; - } - } - if (matches) { - String enchantText = matcher.group("enchantName"); - StringBuilder extraModifiersBuilder = new StringBuilder(); - - if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) { - extraModifiersBuilder.append(EnumChatFormatting.BOLD); - } - if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) { - extraModifiersBuilder.append(EnumChatFormatting.ITALIC); - } - if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) { - extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE); - } - if ((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) { - extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED); - } - if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) { - extraModifiersBuilder.append(EnumChatFormatting.STRIKETHROUGH); - } - - String extraMods = extraModifiersBuilder.toString(); - - if (!colourCode.equals("z")) { - line = line.replace( - "\u00A79" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); - line = line.replace( - "\u00A79\u00A7d\u00A7l" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); - line = line.replace( - "\u00A7l\u00A7d\u00A7l" + enchantText, - "\u00A7" + colourCode + extraMods + enchantText - ); - } else { - int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( - "\\u00A79" + enchantText + ".*", "")); - line = - line.replace("\u00A79" + enchantText, Utils.chromaString(enchantText, offset / 12f + index, false)); - - offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( - "\\u00A79\\u00A7d\\u00A7l" + enchantText + ".*", "")); - line = line.replace("\u00A79\u00A7d\u00A7l" + enchantText, Utils.chromaString(enchantText, - offset / 12f + index, true - )); - offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( - "\\u00A7l\\u00A7d\\u00A7l" + enchantText + ".*", "")); - line = line.replace("\u00A7l\u00A7d\u00A7l" + enchantText, Utils.chromaString(enchantText, - offset / 12f + index, true - )); - } - } - } - } - } - - newTooltip.add(line); - - if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) { - if (line.contains(EnumChatFormatting.GRAY + "Buy it now: ") || - line.contains(EnumChatFormatting.GRAY + "Bidder: ") || - line.contains(EnumChatFormatting.GRAY + "Starting bid: ")) { - - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - newTooltip.add(""); - newTooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]"); - } else { - ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack); - } - } - } - - if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 2 && - Minecraft.getMinecraft().currentScreen instanceof GuiChest) { - if (line.contains(EnumChatFormatting.GREEN + "Open Reward Chest")) { - dungeonProfit = true; - } else if (index == 7 && dungeonProfit) { - GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - IInventory lower = cc.getLowerChestInventory(); - - int chestCost = 0; - try { - String line6 = Utils.cleanColour(line); - StringBuilder cost = new StringBuilder(); - for (int i = 0; i < line6.length(); i++) { - char c = line6.charAt(i); - if ("0123456789".indexOf(c) >= 0) { - cost.append(c); - } - } - if (cost.length() > 0) { - chestCost = Integer.parseInt(cost.toString()); - } - } catch (Exception ignored) { - } - - String missingItem = null; - int totalValue = 0; - HashMap<String, Float> itemValues = new HashMap<>(); - for (int i = 0; i < 5; i++) { - ItemStack item = lower.getStackInSlot(11 + i); - String internal = neu.manager.getInternalNameForItem(item); - if (internal != null) { - internal = internal.replace("\u00CD", "I").replace("\u0130", "I"); - float bazaarPrice = -1; - JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal); - if (bazaarInfo != null && bazaarInfo.has("curr_sell")) { - bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat(); - } - if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; - - float worth = -1; - if (bazaarPrice > 0) { - worth = bazaarPrice; - } else { - switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) { - case 1: - worth = neu.manager.auctionManager.getItemAvgBin(internal); - break; - case 2: - JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); - if (auctionInfo != null) { - if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); - } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); - } - } - break; - default: - worth = neu.manager.auctionManager.getLowestBin(internal); - } - if (worth <= 0) { - worth = neu.manager.auctionManager.getLowestBin(internal); - if (worth <= 0) { - worth = neu.manager.auctionManager.getItemAvgBin(internal); - if (worth <= 0) { - JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); - if (auctionInfo != null) { - if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); - } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); - } - } - } - } - } - } - - if (worth > 0 && totalValue >= 0) { - totalValue += worth; - - String display = item.getDisplayName(); - - if (display.contains("Enchanted Book")) { - NBTTagCompound tag = item.getTagCompound(); - if (tag != null && tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - NBTTagCompound enchants = ea.getCompoundTag("enchantments"); - - int highestLevel = -1; - for (String enchname : enchants.getKeySet()) { - int level = enchants.getInteger(enchname); - if (level > highestLevel) { - display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully( - enchname.replace("_", " ") - .replace("Ultimate", "") - .trim()) + " " + level; - } - } - } - } - - itemValues.put(display, worth); - } else { - if (totalValue != -1) { - missingItem = internal; - } - totalValue = -1; - } - } - } - - NumberFormat format = NumberFormat.getInstance(Locale.US); - String valueStringBIN1; - String valueStringBIN2; - if (totalValue >= 0) { - valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): "; - valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins"; - } else { - valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: "; - valueStringBIN2 = missingItem; - } - - int profitLossBIN = totalValue - chestCost; - String profitPrefix = EnumChatFormatting.DARK_GREEN.toString(); - String lossPrefix = EnumChatFormatting.RED.toString(); - String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix; - - String plStringBIN; - if (profitLossBIN >= 0) { - plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins"; - } else { - plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; - } - - String neu = EnumChatFormatting.YELLOW + "[NEU] "; - - newTooltip.add(neu + valueStringBIN1 + " " + valueStringBIN2); - if (totalValue >= 0) { - newTooltip.add(neu + EnumChatFormatting.YELLOW + "Profit/Loss: " + plStringBIN); - } - - for (Map.Entry<String, Float> entry : itemValues.entrySet()) { - newTooltip.add(neu + entry.getKey() + prefix + "+" + - format.format(entry.getValue().intValue())); - } - } - } - - index++; - } - - for (int i = newTooltip.size() - 1; i >= 0; i--) { - String line = Utils.cleanColour(newTooltip.get(i)); - for (int i1 = 0; i1 < Utils.rarityArr.length; i1++) { - if (line.equals(Utils.rarityArr[i1])) { - if (i - 2 < 0) { - break; - } - newTooltip.addAll(i - 1, petToolTipXPExtend(event)); - break; - } - } - } - - pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT); - - 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 (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) { - ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); - } - - if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUHIDEPETTOOLTIP") && - NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip) { - event.toolTip.clear(); - } - } - - private final Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))"); - - private void onItemToolTipInternalNameNull(ItemTooltipEvent event) { - petToolTipXPExtendPetMenu(event); - } - - private List<String> petToolTipXPExtend(ItemTooltipEvent event) { - List<String> tooltipText = new ArrayList<>(); - if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { - if (event.itemStack.getTagCompound().hasKey("DisablePetExp")) { - if (event.itemStack.getTagCompound().getBoolean("DisablePetExp")) { - return tooltipText; - } - } - //7 is just a random number i chose, prob no pets with less lines than 7 - if (event.toolTip.size() > 7) { - if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) { - - GuiProfileViewer.PetLevel petlevel = null; - - //this is the item itself - NBTTagCompound tag = event.itemStack.getTagCompound(); - if (tag.hasKey("ExtraAttributes")) { - if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) { - JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson( - tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class); - if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { - JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); - String petName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); - //Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); - petlevel = GuiProfileViewer.getPetLevel( - petName, - Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)), - exp.getAsLong() - ); - } - } - } - - if (petlevel != null) { - tooltipText.add(""); - if (petlevel.totalXp > petlevel.maxXP) { - tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "MAX LEVEL"); - } else { - tooltipText.add( - EnumChatFormatting.GRAY + "Progress to Level " + (int) Math.floor(petlevel.level + 1) + ": " + - EnumChatFormatting.YELLOW + Utils.round(petlevel.levelPercentage * 100, 1) + "%"); - int levelpercentage = Math.round(petlevel.levelPercentage * 20); - tooltipText.add( - EnumChatFormatting.DARK_GREEN + String.join("", Collections.nCopies(levelpercentage, "-")) + - EnumChatFormatting.WHITE + String.join("", Collections.nCopies(20 - levelpercentage, "-"))); - tooltipText.add( - EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) + - EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + - myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); - } - } - } - } - } - return tooltipText; - } - - private static final String petToolTipRegex = - "((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*"; - - private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) { - if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { - //7 is just a random number i chose, prob no pets with less lines than 7 - if (event.toolTip.size() > 7) { - if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) { - GuiProfileViewer.PetLevel petlevel = null; - - int xpLine = -1; - for (int i = event.toolTip.size() - 1; i >= 0; i--) { - Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i)); - if (matcher.matches()) { - xpLine = i; - event.toolTip.set(xpLine, matcher.group(1)); - break; - } else if (event.toolTip.get(i).matches("MAX LEVEL")) { - return; - } - } - - PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack( - event.itemStack.getDisplayName(), - NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound()) - ); - if (pet == null) { - return; - } - petlevel = pet.petLevel; - - if (petlevel == null || xpLine == -1) { - return; - } - - event.toolTip.add( - xpLine + 1, - EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) + - EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + - myFormatter.format(petlevel.currentLevelRequirement) - ); - - } - } - } - } - - DecimalFormat myFormatter = new DecimalFormat("###,###.###"); - - /** - * This method does the following: - * Move the pet inventory display tooltip to the left to avoid conflicts - * Remove reforge stats for Legendary items from Hypixel if enabled - * Show NBT data when holding LCONTROL - */ - @SubscribeEvent - public void onItemTooltip(ItemTooltipEvent event) { - if (!neu.isOnSkyblock()) return; - if (event.toolTip == null) return; - //Render the pet inventory display tooltip to the left to avoid things from other mods rendering over the tooltip - if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUPETINVDISPLAY")) { - GlStateManager.translate(-200, 0, 0); - } - - if (event.toolTip.size() > 2 && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.hideDefaultReforgeStats) { - String secondLine = StringUtils.stripControlCodes(event.toolTip.get(1)); - if (secondLine.equals("Reforge Stone")) { - Integer startIndex = null; - Integer cutoffIndex = null; - //loop from the back of the List to find the wanted index sooner - for (int i = event.toolTip.size() - 1; i >= 0; i--) { - //rarity or mining level requirement - String line = StringUtils.stripControlCodes(event.toolTip.get(i)); - if (line.contains("REFORGE STONE") || line.contains("Requires Mining Skill Level")) { - cutoffIndex = i; - } - - //The line where the Hypixel stats start - if (line.contains("(Legendary):")) { - startIndex = i; - break; - } - } - if (startIndex != null && cutoffIndex != null && startIndex < cutoffIndex) { - event.toolTip.subList(startIndex, cutoffIndex).clear(); - } - } - } - - if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && NotEnoughUpdates.INSTANCE.config.hidden.dev && - event.toolTip.size() > 0 && - event.toolTip.get(event.toolTip.size() - 1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) { - event.toolTip.remove(event.toolTip.size() - 1); - - StringBuilder sb = new StringBuilder(); - String nbt = event.itemStack.getTagCompound().toString(); - int indent = 0; - for (char c : nbt.toCharArray()) { - boolean newline = false; - if (c == '{' || c == '[') { - indent++; - newline = true; - } else if (c == '}' || c == ']') { - indent--; - sb.append("\n"); - for (int i = 0; i < indent; i++) sb.append(" "); - } else if (c == ',') { - newline = true; - } else if (c == '\"') { - sb.append(EnumChatFormatting.RESET.toString() + EnumChatFormatting.GRAY); - } - - sb.append(c); - if (newline) { - sb.append("\n"); - for (int i = 0; i < indent; i++) sb.append(" "); - } - } - event.toolTip.add(sb.toString()); - if (Keyboard.isKeyDown(Keyboard.KEY_H)) { - if (!copied) { - copied = true; - StringSelection selection = new StringSelection(sb.toString()); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); - } - } else { - copied = false; - } - } else if (NotEnoughUpdates.INSTANCE.packDevEnabled) { - event.toolTip.add(""); - event.toolTip.add(EnumChatFormatting.AQUA + "NEU Pack Dev Info:"); - event.toolTip.add("Press " + EnumChatFormatting.GOLD + "[KEY]" + EnumChatFormatting.GRAY + " to copy line"); - - String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); - - boolean k = Keyboard.isKeyDown(Keyboard.KEY_K); - boolean m = Keyboard.isKeyDown(Keyboard.KEY_M); - boolean n = Keyboard.isKeyDown(Keyboard.KEY_N); - - event.toolTip.add( - EnumChatFormatting.AQUA + "Internal Name: " + EnumChatFormatting.GRAY + internal + EnumChatFormatting.GOLD + - " [K]"); - if (!copied && k) { - MiscUtils.copyToClipboard(internal); - } - - if (event.itemStack.getTagCompound() != null) { - NBTTagCompound tag = event.itemStack.getTagCompound(); - - if (tag.hasKey("SkullOwner", 10)) { - GameProfile gameprofile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner")); - - if (gameprofile != null) { - event.toolTip.add(EnumChatFormatting.AQUA + "Skull UUID: " + EnumChatFormatting.GRAY + gameprofile.getId() + - EnumChatFormatting.GOLD + " [M]"); - if (!copied && m) { - MiscUtils.copyToClipboard(gameprofile.getId().toString()); - } - - Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = - Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(gameprofile); - - if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { - MinecraftProfileTexture profTex = map.get(MinecraftProfileTexture.Type.SKIN); - event.toolTip.add( - EnumChatFormatting.AQUA + "Skull Texture Link: " + EnumChatFormatting.GRAY + profTex.getUrl() + - EnumChatFormatting.GOLD + " [N]"); - - if (!copied && n) { - MiscUtils.copyToClipboard(profTex.getUrl()); - } - } - } - } - } - - copied = k || m || n; - } - } - - @SubscribeEvent - public void onRenderLast(RenderWorldLastEvent event) { - CrystalMetalDetectorSolver.render(event.partialTicks); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index d1bfed14..d9566f0d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1,9 +1,63 @@ package io.github.moulberry.notenoughupdates; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.ascending_overlay; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.close; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.descending_overlay; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.help; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.itemPaneTabArrow; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.item_haschild; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.item_mask; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_alphabetical; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_alphabetical_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_rarity; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_rarity_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_value; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.order_value_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.quickcommand_background; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.rightarrow; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.rightarrow_overlay; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.settings; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_accessory; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_accessory_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_all; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_all_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_armor; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_armor_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_mob; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_mob_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_pet; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_pet_active; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_tool; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.sort_tool_active; + +import java.awt.Color; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.util.vector.Vector2f; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; @@ -22,6 +76,7 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph; import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.LerpingFloat; +import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -32,7 +87,11 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -56,65 +115,49 @@ import net.minecraft.util.Matrix4f; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.ClientCommandHandler; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; -import org.lwjgl.util.vector.Vector2f; - -import java.awt.Color; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; public class NEUOverlay extends Gui { - private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = - new ResourceLocation("notenoughupdates:supersecretassets/bald.png"); + private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation( + "notenoughupdates:supersecretassets/bald.png"); private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png"); private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png"); - private static final ResourceLocation ARMOR_DISPLAY = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay.png"); - private static final ResourceLocation ARMOR_DISPLAY_GREY = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay_grey.png"); - private static final ResourceLocation ARMOR_DISPLAY_DARK = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay_phq_dark.png"); - private static final ResourceLocation ARMOR_DISPLAY_FSR = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay_fsr.png"); - private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay_transparent.png"); - private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT_PET = - new ResourceLocation("notenoughupdates:armordisplay/armordisplay_transparent_pet.png"); + private static final ResourceLocation ARMOR_DISPLAY = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay.png"); + private static final ResourceLocation ARMOR_DISPLAY_GREY = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay_grey.png"); + private static final ResourceLocation ARMOR_DISPLAY_DARK = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay_phq_dark.png"); + private static final ResourceLocation ARMOR_DISPLAY_FSR = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay_fsr.png"); + private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay_transparent.png"); + private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT_PET = new ResourceLocation( + "notenoughupdates:armordisplay/armordisplay_transparent_pet.png"); private static final ResourceLocation QUESTION_MARK = new ResourceLocation("notenoughupdates:pv_unknown.png"); - private static final ResourceLocation PET_DISPLAY = - new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo.png"); - private static final ResourceLocation PET_DISPLAY_GREY = - new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_dark.png"); - private static final ResourceLocation PET_DISPLAY_DARK = - new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_phqdark.png"); - private static final ResourceLocation PET_DISPLAY_FSR = - new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_fsr.png"); - private static final ResourceLocation PET_DISPLAY_TRANSPARENT = - new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_transparent.png"); - - private static final ResourceLocation PET_ARMOR_DISPLAY = - new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor.png"); - private static final ResourceLocation PET_ARMOR_DISPLAY_GREY = - new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_dark.png"); - private static final ResourceLocation PET_ARMOR_DISPLAY_DARK = - new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_phqdark.png"); - private static final ResourceLocation PET_ARMOR_DISPLAY_FSR = - new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_fsr.png"); - private static final ResourceLocation PET_ARMOR_DISPLAY_TRANSPARENT = - new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_transparent.png"); + private static final ResourceLocation PET_DISPLAY = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplaysolo.png"); + private static final ResourceLocation PET_DISPLAY_GREY = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplaysolo_dark.png"); + private static final ResourceLocation PET_DISPLAY_DARK = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplaysolo_phqdark.png"); + private static final ResourceLocation PET_DISPLAY_FSR = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplaysolo_fsr.png"); + private static final ResourceLocation PET_DISPLAY_TRANSPARENT = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplaysolo_transparent.png"); + + private static final ResourceLocation PET_ARMOR_DISPLAY = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplayarmor.png"); + private static final ResourceLocation PET_ARMOR_DISPLAY_GREY = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplayarmor_dark.png"); + private static final ResourceLocation PET_ARMOR_DISPLAY_DARK = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplayarmor_phqdark.png"); + private static final ResourceLocation PET_ARMOR_DISPLAY_FSR = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplayarmor_fsr.png"); + private static final ResourceLocation PET_ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation( + "notenoughupdates:petdisplay/petdisplayarmor_transparent.png"); private static boolean renderingArmorHud; private static boolean renderingPetHud; @@ -249,7 +292,7 @@ public class NEUOverlay extends Gui { searchMode = !searchMode; lastSearchMode = System.currentTimeMillis(); if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) { - NEUEventListener.displayNotification(Lists.newArrayList( + NotificationHandler.displayNotification(Lists.newArrayList( "\u00a7eSearch Highlight", "\u00a77In this mode NEU will gray out non matching items in", "\u00a77your inventory or chests.", @@ -366,8 +409,7 @@ public class NEUOverlay extends Gui { } @Override - public void recalculate() { - } + public void recalculate() {} }; } @@ -384,8 +426,7 @@ public class NEUOverlay extends Gui { } @Override - public void recalculate() { - } + public void recalculate() {} @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { @@ -398,8 +439,7 @@ public class NEUOverlay extends Gui { } @Override - public void mouseClickOutside() { - } + public void mouseClickOutside() {} @Override public void render(float x, float y) { @@ -439,8 +479,7 @@ public class NEUOverlay extends Gui { } @Override - public void recalculate() { - } + public void recalculate() {} @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { @@ -457,8 +496,7 @@ public class NEUOverlay extends Gui { } @Override - public void mouseClickOutside() { - } + public void mouseClickOutside() {} @Override public void render(float x, float y) { @@ -499,16 +537,14 @@ public class NEUOverlay extends Gui { } @Override - public void recalculate() { - } + public void recalculate() {} @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return; if ((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) || - (NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && - !Mouse.getEventButtonState() && + (NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && !Mouse.getEventButtonState() && Mouse.getEventButton() != -1)) { if (quickCommandStr.contains(":")) { String command = quickCommandStr.split(":")[0].trim(); @@ -523,8 +559,7 @@ public class NEUOverlay extends Gui { } @Override - public void mouseClickOutside() { - } + public void mouseClickOutside() {} @Override public void render(float x, float y) { @@ -582,8 +617,7 @@ public class NEUOverlay extends Gui { int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth; int mouseY = Utils.peekGuiScale().getScaledHeight() - - Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - - 1; + Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1; if (mouseX > x && mouseX < x + bigItemSize) { if (mouseY > y && mouseY < y + bigItemSize) { @@ -619,8 +653,11 @@ public class NEUOverlay extends Gui { } private MBGuiGroupAligned createSearchBarGroup() { - List<MBGuiElement> children = - Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this)); + List<MBGuiElement> children = Lists.newArrayList( + createSettingsButton(this), + createSearchBar(), + createHelpButton(this) + ); return new MBGuiGroupAligned(children, false) { public int getPadding() { return getPaddingUnscaled() * 4; @@ -724,9 +761,12 @@ public class NEUOverlay extends Gui { String internalname = item.get("internalname").getAsString(); String name = item.get("displayname").getAsString(); String infoType = item.get("infoType").getAsString(); - displayInformationPane(new TextInfoPane(this, manager, "Loading", "Loading your requested information about " + - name + - ".")); + displayInformationPane(new TextInfoPane( + this, + manager, + "Loading", + "Loading your requested information about " + name + "." + )); infoPaneLoadingJob = InfoPane.create(this, manager, infoType, name, internalname, infoText) .thenAccept(this::displayInformationPane); } @@ -1214,12 +1254,14 @@ public class NEUOverlay extends Gui { return (o1, o2) -> { //1 (mult) if o1 should appear after o2 //-1 (-mult) if o2 should appear after o1 - if (getFavourites().contains(o1.get("internalname").getAsString()) && - !getFavourites().contains(o2.get("internalname").getAsString())) { + if (getFavourites().contains(o1.get("internalname").getAsString()) && !getFavourites().contains(o2 + .get("internalname") + .getAsString())) { return -1; } - if (!getFavourites().contains(o1.get("internalname").getAsString()) && - getFavourites().contains(o2.get("internalname").getAsString())) { + if (!getFavourites().contains(o1.get("internalname").getAsString()) && getFavourites().contains(o2 + .get("internalname") + .getAsString())) { return 1; } @@ -1295,8 +1337,7 @@ public class NEUOverlay extends Gui { * Checks whether an item matches the current sort mode. */ public boolean checkMatchesSort(String internalname, JsonObject item) { - if (!NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems && - item.has("vanilla") && + if (!NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems && item.has("vanilla") && item.get("vanilla").getAsBoolean()) { return false; } @@ -1308,8 +1349,7 @@ public class NEUOverlay extends Gui { } else if (getSortMode() == SORT_MODE_PET) { return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("["); } else if (getSortMode() == SORT_MODE_TOOL) { - return checkItemType( - item.get("lore").getAsJsonArray(), + return checkItemType(item.get("lore").getAsJsonArray(), "SWORD", "BOW", "AXE", @@ -1325,9 +1365,7 @@ public class NEUOverlay extends Gui { ) >= 0; } else if (getSortMode() == SORT_MODE_ARMOR) { return checkItemType( - item - .get("lore") - .getAsJsonArray(), + item.get("lore").getAsJsonArray(), "HELMET", "CHESTPLATE", "LEGGINGS", @@ -1336,8 +1374,7 @@ public class NEUOverlay extends Gui { "DUNGEON CHESTPLATE", "DUNGEON LEGGINGS", "DUNGEON BOOTS" - ) >= - 0; + ) >= 0; } else if (getSortMode() == SORT_MODE_ACCESSORY) { return checkItemType(item.get("lore").getAsJsonArray(), "ACCESSORY", "HATCCESSORY", "DUNGEON ACCESSORY") >= 0; } @@ -1812,7 +1849,9 @@ public class NEUOverlay extends Gui { ContainerChest container = (ContainerChest) chest.inventorySlots; IInventory lower = container.getLowerChestInventory(); String containerName = lower.getDisplayName().getUnformattedText(); - wardrobeOpen = containerName.contains(guiName); + if (containerName.contains(guiName)) { + wardrobeOpen = true; + } else wardrobeOpen = false; } if (guiScreen instanceof GuiInventory) { wardrobeOpen = false; @@ -1855,27 +1894,31 @@ public class NEUOverlay extends Gui { private int selectedArmor = 9; private int getEquippedArmor() { - if (!isInNamedGui("Wardrobe")) return selectedArmor; - - ItemStack nullTest1 = getChestSlotsAsItemStack(8); - ItemStack nullTest2 = getChestSlotsAsItemStack(17); - ItemStack nullTest3 = getChestSlotsAsItemStack(26); - ItemStack nullTest4 = getChestSlotsAsItemStack(35); - ItemStack nullTest5 = getChestSlotsAsItemStack(44); - if (nullTest1 != null || nullTest2 != null || nullTest3 != null || nullTest4 != null || nullTest5 != null) { - selectedArmor = 9; - } - for (int ii = 1; ii < 5; ii++) { - if (ii != 1 && selectedArmor != 9) continue; - if (getWardrobePage() != ii) continue; - for (int i = 8; i < 54; i += 9) { - ItemStack stack1 = getChestSlotsAsItemStack(i); - if (stack1 == null) continue; - String[] lore1 = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack1.getTagCompound()); - for (String line : lore1) { - if (line.contains("to unequip this armor")) { - selectedArmor = i; - break; + if (isInNamedGui("Wardrobe")) { + ItemStack nullTest1 = getChestSlotsAsItemStack(8); + ItemStack nullTest2 = getChestSlotsAsItemStack(17); + ItemStack nullTest3 = getChestSlotsAsItemStack(26); + ItemStack nullTest4 = getChestSlotsAsItemStack(35); + ItemStack nullTest5 = getChestSlotsAsItemStack(44); + if (nullTest1 != null || nullTest2 != null || nullTest3 != null || nullTest4 != null || nullTest5 != null) { + selectedArmor = 9; + } + for (int ii = 1; ii < 5; ii++) { + if (ii == 1 || selectedArmor == 9) { + if (getWardrobePage() == ii) { + for (int i = 8; i < 54; i += 9) { + ItemStack stack1 = getChestSlotsAsItemStack(i); + if (stack1 != null) { + String[] lore1 = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack1.getTagCompound()); + for (String line : lore1) { + //System.out.println(line); + if (line.contains("to unequip this armor")) { + selectedArmor = i; + break; + } + } + } + } } } } @@ -1922,7 +1965,9 @@ public class NEUOverlay extends Gui { * Renders the search bar, quick commands, item selection (right), item info (left) and armor hud gui elements. */ public void render(boolean hoverInv) { - if (disabled) return; + if (disabled) { + return; + } renderingArmorHud = false; renderingPetHud = false; GlStateManager.enableDepth(); @@ -1952,9 +1997,7 @@ public class NEUOverlay extends Gui { if (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud && NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect - && - NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && - isWardrobeSystemOnMainServer()) { + && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && isWardrobeSystemOnMainServer()) { if (getWardrobeSlot(1) != null) { slot1 = getWardrobeSlot(4); slot2 = getWardrobeSlot(3); @@ -1977,8 +2020,7 @@ public class NEUOverlay extends Gui { } if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 3) { if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3 && - NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay && - petSlot != null) { + NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay && petSlot != null) { Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT_PET); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT); @@ -2010,8 +2052,7 @@ public class NEUOverlay extends Gui { EnumChatFormatting.GREEN + "To cache your armour" ); if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) { - if (mouseY >= ((height + 60) / 2f - 105) && - mouseY <= ((height + 60) / 2f - 105) + 70 && + if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 70 && NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { if (Mouse.getEventButtonState()) { @@ -2031,8 +2072,7 @@ public class NEUOverlay extends Gui { } if (slot1 != null && slot2 != null && slot3 != null && slot4 != null) { if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) { - if (mouseY >= ((height + 60) / 2f - 105) && - mouseY <= ((height + 60) / 2f - 105) + 70 && + if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 70 && NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { if (Mouse.getEventButtonState()) { @@ -2075,20 +2115,17 @@ public class NEUOverlay extends Gui { } if (PetInfoOverlay.getCurrentPet() != null) { if (NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay - && - (NotEnoughUpdates.INSTANCE.manager - .jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId)) - .hasDisplayName() - || - NotEnoughUpdates.INSTANCE.manager - .jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get(PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1))) - .hasDisplayName()) - && - NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect && + && (NotEnoughUpdates.INSTANCE.manager + .jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId)) + .hasDisplayName() + || NotEnoughUpdates.INSTANCE.manager + .jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get(PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1))) + .hasDisplayName()) + && NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { if (!NotEnoughUpdates.INSTANCE.manager .jsonToStack( @@ -2105,9 +2142,10 @@ public class NEUOverlay extends Gui { PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId)); } petSlot.getTagCompound().setBoolean("NEUPETINVDISPLAY", true); - petSlot - .getTagCompound() - .setBoolean("NEUHIDEPETTOOLTIP", NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip); + petSlot.getTagCompound().setBoolean( + "NEUHIDEPETTOOLTIP", + NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip + ); ItemStack petInfo = petSlot; if (guiScreen instanceof GuiInventory) { @@ -2157,8 +2195,7 @@ public class NEUOverlay extends Gui { List<String> tooltipToDisplay = null; if (petInfo != null) { if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) { - if (mouseY >= ((height + 60) / 2f - 105) + 72 && - mouseY <= ((height + 60) / 2f - 105) + 88 && + if (mouseY >= ((height + 60) / 2f - 105) + 72 && mouseY <= ((height + 60) / 2f - 105) + 88 && NotEnoughUpdates.INSTANCE.config.petOverlay.sendPetsCommand) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { if (Mouse.getEventButtonState()) { @@ -2308,17 +2345,14 @@ public class NEUOverlay extends Gui { int orderIconX = leftSide + getBoxPadding() + getItemBoxXPadding() + i * scaledItemPaddedSize; drawRect(orderIconX, iconTop, scaledITEM_SIZE + orderIconX, iconTop + scaledITEM_SIZE, fg.getRGB()); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(getCompareMode() == i ? orderIconsActive[i] : orderIcons[i]); + Minecraft.getMinecraft().getTextureManager().bindTexture( + getCompareMode() == i ? orderIconsActive[i] : orderIcons[i]); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(getCompareAscending().get(i) ? ascending_overlay : descending_overlay); + Minecraft.getMinecraft().getTextureManager().bindTexture(getCompareAscending().get(i) + ? ascending_overlay + : descending_overlay); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST); GlStateManager.bindTexture(0); @@ -2341,10 +2375,8 @@ public class NEUOverlay extends Gui { for (int i = 0; i < sortIcons.length; i++) { int sortIconX = rightSide - scaledITEM_SIZE - i * scaledItemPaddedSize; drawRect(sortIconX, iconTop, scaledITEM_SIZE + sortIconX, iconTop + scaledITEM_SIZE, fg.getRGB()); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(getSortMode() == i ? sortIconsActive[i] : sortIcons[i]); + Minecraft.getMinecraft().getTextureManager().bindTexture( + getSortMode() == i ? sortIconsActive[i] : sortIcons[i]); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect(sortIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST); GlStateManager.bindTexture(0); @@ -2585,8 +2617,7 @@ public class NEUOverlay extends Gui { int sw = width * Utils.peekGuiScale().getScaleFactor(); int sh = height * Utils.peekGuiScale().getScaleFactor(); for (int i = 0; i < itemFramebuffers.length; i++) { - if (itemFramebuffers[i] == null || - itemFramebuffers[i].framebufferWidth != sw || + if (itemFramebuffers[i] == null || itemFramebuffers[i].framebufferWidth != sw || itemFramebuffers[i].framebufferHeight != sh) { if (itemFramebuffers[i] == null) { itemFramebuffers[i] = new Framebuffer(sw, sh, true); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index b6ac71a4..5ad82d56 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -1,5 +1,17 @@ package io.github.moulberry.notenoughupdates; +import java.awt.Color; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Set; + import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -8,9 +20,25 @@ import io.github.moulberry.notenoughupdates.commands.Commands; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonMap; -import io.github.moulberry.notenoughupdates.miscfeatures.*; +import io.github.moulberry.notenoughupdates.listener.ChatListener; +import io.github.moulberry.notenoughupdates.listener.ItemTooltipListener; +import io.github.moulberry.notenoughupdates.listener.NEUEventListener; +import io.github.moulberry.notenoughupdates.listener.RenderListener; +import io.github.moulberry.notenoughupdates.miscfeatures.CrystalOverlay; +import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; +import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesWaypoints; +import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; +import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; +import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; +import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; +import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere; +import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; +import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; @@ -24,14 +52,17 @@ import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.settings.KeyBinding; import net.minecraft.event.ClickEvent; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.biome.*; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenHell; +import net.minecraft.world.biome.BiomeGenJungle; +import net.minecraft.world.biome.BiomeGenMesa; +import net.minecraft.world.biome.BiomeGenSnow; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; @@ -40,12 +71,6 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import java.awt.*; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Set; - @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; @@ -194,7 +219,6 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints()); MinecraftForge.EVENT_BUS.register(new FuelBar()); - //MinecraftForge.EVENT_BUS.register(new FancyPortals()); MinecraftForge.EVENT_BUS.register(XPInformation.getInstance()); MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); @@ -205,13 +229,23 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE); - if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { - IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); - manager.registerReloadListener(CustomSkulls.getInstance()); - manager.registerReloadListener(NPCRetexturing.getInstance()); - manager.registerReloadListener(new ItemCustomizeManager.ReloadListener()); - manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); - } + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); + MinecraftForge.EVENT_BUS.register(new ChatListener(this)); + MinecraftForge.EVENT_BUS.register(new ItemTooltipListener(this)); + MinecraftForge.EVENT_BUS.register(new RenderListener(this)); + MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); + MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); + MinecraftForge.EVENT_BUS.register(new EnchantingSolvers()); + MinecraftForge.EVENT_BUS.register(new CalendarOverlay()); + MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); + 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()); + MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); + MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); this.commands = new Commands(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java deleted file mode 100644 index e789e882..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.moulberry.notenoughupdates.collectionlog; - -import java.util.HashMap; -import java.util.List; -import java.util.regex.Pattern; - -public class CollectionConstant { - public static class DropEntry { - public String type; - public Pattern regex; - public HashMap<String, String> items; - } - - public List<DropEntry> dropdata; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java deleted file mode 100644 index dac104c6..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java +++ /dev/null @@ -1,111 +0,0 @@ -package io.github.moulberry.notenoughupdates.collectionlog; - -import io.github.moulberry.notenoughupdates.core.BackgroundBlur; -import io.github.moulberry.notenoughupdates.core.GlScissorStack; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -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.opengl.GL11; - -public class GuiCollectionLog extends GuiScreen { - private static final ResourceLocation COLLECTION_LOG_TEX = new ResourceLocation("notenoughupdates:collectionlog.png"); - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - - int colwidth = 307; - int colheight = 187; - - int left = width / 2 - colwidth / 2; - int top = height / 2 - colheight / 2; - - BackgroundBlur.renderBlurredBackground(10, width, height, left, top, colwidth, colheight); - super.drawDefaultBackground(); - - Utils.drawStringCentered("\u00a7lCollection Log", fontRendererObj, width / 2, top - 27, true, 0xfff5aa00); - - String[] cats = {"Bosses", "Dragons", "Slayer", "Dungeons"}; - - GlStateManager.enableDepth(); - - GlStateManager.translate(0, 0, 2); - for (int i = 0; i < 4; i++) { - if (i == 0) { - int offset = i == 0 ? 1 : 2; - - Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(left + i * 71, top - 21, 71, 25, - (71 * offset) / 512f, (71 + 71 * offset) / 512f, 211 / 512f, (211 + 25) / 512f, GL11.GL_NEAREST - ); - - Utils.drawStringCentered(cats[i], fontRendererObj, left + i * 71 + 71 / 2, top - 8, true, 0xfff5aa00); - } - } - - GlStateManager.translate(0, 0, -1); - Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(left, top, colwidth, colheight, - 0, colwidth / 512f, 0, colheight / 512f, GL11.GL_NEAREST - ); - - GlScissorStack.push(0, top + 3, width, top + colheight - 6, scaledResolution); - int catIndex = 0; - for (int h = top + 3; h < top + colheight - 6; h += 24) { - catIndex += 2; - - Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(left, h, 100, 24, - 0, 100 / 512f, 187 / 512f, 211 / 512f, GL11.GL_NEAREST - ); - - fontRendererObj.drawString("Thing " + catIndex, left + 5, h + 2, 0xfff5aa00, true); - fontRendererObj.drawString("Thing " + (catIndex + 1), left + 5, h + 14, 0xfff5aa00, true); - } - GlScissorStack.pop(scaledResolution); - - fontRendererObj.drawString("\u00a7lSuperior Dragon", left + 119, top + 8, 0xfff5aa00, true); - fontRendererObj.drawString( - "Obtained: " + EnumChatFormatting.YELLOW + "3/5", - left + 122, - top + 23, - 0xfff5aa00, - true - ); - - String killCountText = "Kills: " + EnumChatFormatting.WHITE + "3"; - //int killCountLen = fontRendererObj.getStringWidth(killCountText); - fontRendererObj.drawString(killCountText, left + 122, top + 68, 0xfff5aa00, true); - - Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(left + colwidth - 196, top, 196, colheight, - (512 - 196) / 512f, 1, 0 / 512f, colheight / 512f, GL11.GL_NEAREST - ); - - GlStateManager.translate(0, 0, -1); - - for (int i = 0; i < 4; i++) { - if (i != 0) { - Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(left + i * 71, top - 21, 71, 25, - 0, 71 / 512f, 211 / 512f, (211 + 25) / 512f, GL11.GL_NEAREST - ); - - Utils.drawStringCentered(cats[i], fontRendererObj, left + i * 71 + 71 / 2, top - 8, true, 0xfff5aa00); - } - } - - super.drawScreen(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java index 66da4f9f..7caf09cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -3,7 +3,6 @@ package io.github.moulberry.notenoughupdates.commands.dev; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals; import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; @@ -11,24 +10,21 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Specia import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; -import net.minecraft.util.*; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.common.MinecraftForge; -import java.io.File; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; public class DevTestCommand extends ClientCommandBase { private static final List<String> DEV_TESTERS = - Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio", "throwpo", "lrg89", "dediamondpro"); + Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio", "throwpo", "lrg89", "dediamondpro", "lulonaut"); private static final String[] DEV_FAIL_STRINGS = { "No.", @@ -48,9 +44,7 @@ public class DevTestCommand extends ClientCommandBase { "", "Ok, this is actually the last message, use the command again and you'll crash I promise" }; - private int devFailIndex = 0; - private final ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor(); public DevTestCommand() { super("neudevtest"); @@ -84,10 +78,6 @@ public class DevTestCommand extends ClientCommandBase { DEV_FAIL_STRINGS[devFailIndex++])); return; } - /*if(args.length == 1) { - DupePOC.doDupe(args[0]); - return; - }*/ if (args.length >= 1 && args[0].equalsIgnoreCase("profileinfo")) { String currentProfile = SBInfo.getInstance().currentProfile; SBInfo.Gamemode gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile); @@ -146,62 +136,6 @@ public class DevTestCommand extends ClientCommandBase { double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f; double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f; Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("pansc")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + - "Taking panorama screenshot")); - - AtomicInteger perspective = new AtomicInteger(0); - FancyPortals.perspectiveId = 0; - - EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; - p.prevRotationYaw = p.rotationYaw = 0; - p.prevRotationPitch = p.rotationPitch = 90; - devES.schedule(new Runnable() { - @Override - public void run() { - Minecraft.getMinecraft().addScheduledTask(() -> { - ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-" + perspective.get() + ".png", - Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, - Minecraft.getMinecraft().getFramebuffer() - ); - }); - if (perspective.incrementAndGet() >= 6) { - FancyPortals.perspectiveId = -1; - return; - } - devES.schedule(() -> { - FancyPortals.perspectiveId = perspective.get(); - if (FancyPortals.perspectiveId == 5) { - p.prevRotationYaw = p.rotationYaw = 0; - p.prevRotationPitch = p.rotationPitch = -90; - } else if (FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) { - float yaw = 90 * FancyPortals.perspectiveId - 180; - if (yaw > 180) yaw -= 360; - p.prevRotationYaw = p.rotationYaw = yaw; - p.prevRotationPitch = p.rotationPitch = 0; - } - devES.schedule(this, 3000L, TimeUnit.MILLISECONDS); - }, 100L, TimeUnit.MILLISECONDS); - } - }, 3000L, TimeUnit.MILLISECONDS); - - return; } - - /* if(args.length == 1 && args[0].equalsIgnoreCase("update")) { - NEUEventListener.displayUpdateMessageIfOutOfDate(); - } */ - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + - "Executing dubious code")); - /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0; - Minecraft.getMinecraft().thePlayer.rotationPitch = 0; - Minecraft.getMinecraft().thePlayer.setPosition( - Math.floor(Minecraft.getMinecraft().thePlayer.posX) + Float.parseFloat(args[0]), - Minecraft.getMinecraft().thePlayer.posY, - Minecraft.getMinecraft().thePlayer.posZ);*/ - //Hot reload me yay! } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java index 4f85c26e..5d19d62c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java @@ -1,8 +1,8 @@ package io.github.moulberry.notenoughupdates.commands.help; import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; +import io.github.moulberry.notenoughupdates.util.NotificationHandler; import net.minecraft.command.ICommandSender; public class StorageViewerWhyCommand extends ClientCommandBase { @@ -13,7 +13,7 @@ public class StorageViewerWhyCommand extends ClientCommandBase { @Override public void processCommand(ICommandSender sender, String[] args) { - NEUEventListener.displayNotification(Lists.newArrayList( + NotificationHandler.displayNotification(Lists.newArrayList( "\u00a7eStorage Viewer", "\u00a77Currently, the storage viewer requires you to click twice", "\u00a77in order to switch between pages. This is because Hypixel", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java deleted file mode 100644 index 1bde7631..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog; -import io.github.moulberry.notenoughupdates.commands.ScreenCommand; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class CollectionLogCommand extends ScreenCommand { - - public CollectionLogCommand() { - super("neucl", GuiCollectionLog::new); - } - - @Override - public List<String> getCommandAliases() { - return Collections.singletonList("collectionlog"); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java deleted file mode 100644 index d33e560a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -public class GamemodesCommand extends ClientCommandBase { - - public GamemodesCommand() { - super("neugamemodes"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - boolean upgradeOverride = args.length == 1 && args[0].equals("upgradeOverride"); - NotEnoughUpdates.INSTANCE.openGui = new GuiGamemodes(upgradeOverride); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java deleted file mode 100644 index 77305904..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java +++ /dev/null @@ -1,323 +0,0 @@ -package io.github.moulberry.notenoughupdates.gamemodes; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; - -public class GuiGamemodes extends GuiScreen { - private final String currentProfile; - private SBGamemodes.Gamemode currentGamemode = null; - private final boolean upgradeOverride; - - private int guiLeft = 100; - private int guiTop = 100; - private final int xSize = 200; - private final int ySize = 232; - - public GuiGamemodes(boolean upgradeOverride) { - this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile(); - this.upgradeOverride = upgradeOverride; - } - - private boolean canChange(int from, int to) { - if (from >= to) { - return true; - } else { - return !currentGamemode.locked || upgradeOverride; - } - } - - @Override - public void updateScreen() { - if (this.currentProfile == null) { - Minecraft.getMinecraft().displayGuiScreen(null); - Minecraft.getMinecraft().thePlayer.addChatMessage( - new ChatComponentText(EnumChatFormatting.RED + "Couldn't detect current profile. Maybe try later?")); - } - - if (currentGamemode == null) { - currentGamemode = SBGamemodes.getGamemode(); - if (currentGamemode == null) { - Minecraft.getMinecraft().displayGuiScreen(null); - Minecraft.getMinecraft().thePlayer.addChatMessage( - new ChatComponentText(EnumChatFormatting.RED + "Couldn't automatically detect current profile." + - "If you have only 1 profile, try using /api new so that NEU can detect your profile.")); - } - } - - String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile(); - if (!this.currentProfile.equals(currentProfile)) { - Minecraft.getMinecraft().displayGuiScreen(null); - Minecraft.getMinecraft().thePlayer.addChatMessage( - new ChatComponentText(EnumChatFormatting.RED + "Profile change detected. Closing gamemodes menu.")); - } - } - - @Override - public void handleKeyboardInput() throws IOException { - if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { - SBGamemodes.saveToFile(); - } - - super.handleKeyboardInput(); - } - - public void drawStringShadow(String str, float x, float y, int len) { - for (int xOff = -2; xOff <= 2; xOff++) { - for (int yOff = -2; yOff <= 2; yOff++) { - if (Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringScaledMaxWidth(Utils.cleanColourNotModifiers(str), - Minecraft.getMinecraft().fontRendererObj, - x + xOff / 2f, y + yOff / 2f, false, len, - new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB() - ); - } - } - } - - Utils.drawStringScaledMaxWidth(str, - Minecraft.getMinecraft().fontRendererObj, - x, y, false, len, - new Color(64, 64, 64, 255).getRGB() - ); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - if (mouseButton == 0) { - SBGamemodes.HardcoreMode setHC = SBGamemodes.HardcoreMode.NORMAL; - SBGamemodes.IronmanMode setIM = SBGamemodes.IronmanMode.NORMAL; - int setMod = 0; - - if (mouseX > guiLeft + xSize - 27 && mouseX < guiLeft + xSize - 9) { - if (mouseY > guiTop + 30 && mouseY < guiTop + 30 + 16) { - setHC = SBGamemodes.HardcoreMode.SOFTCORE; - } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) { - setHC = SBGamemodes.HardcoreMode.HARDCORE; - } else if (mouseY > guiTop + 80 && mouseY < guiTop + 80 + 16) { - setIM = SBGamemodes.IronmanMode.IRONMAN; - } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) { - setIM = SBGamemodes.IronmanMode.IRONMANPLUS; - } else if (mouseY > guiTop + 120 && mouseY < guiTop + 120 + 16) { - setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN; - } else if (mouseY > guiTop + 140 && mouseY < guiTop + 140 + 16) { - setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS; - } else if (mouseY > guiTop + 170 && mouseY < guiTop + 170 + 16) { - setMod = SBGamemodes.MODIFIER_DEVILISH; - } else if (mouseY > guiTop + 190 && mouseY < guiTop + 190 + 16) { - setMod = SBGamemodes.MODIFIER_NOBANK; - } else if (mouseY > guiTop + 210 && mouseY < guiTop + 210 + 16) { - setMod = SBGamemodes.MODIFIER_SMALLISLAND; - } - } - - if (setHC != SBGamemodes.HardcoreMode.NORMAL) { - if (currentGamemode.hardcoreMode == setHC) { - currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL; - } else { - if (canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) { - currentGamemode.hardcoreMode = setHC; - } - } - } else if (setIM != SBGamemodes.IronmanMode.NORMAL) { - if (currentGamemode.ironmanMode == setIM) { - currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL; - } else { - if (canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) { - currentGamemode.ironmanMode = setIM; - } - } - } else if (setMod != 0) { - if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ setMod)) { - currentGamemode.gamemodeModifiers ^= setMod; - } - } - } - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawDefaultBackground(); - - guiLeft = (width - xSize) / 2; - guiTop = (height - ySize) / 2; - - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodes); - Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST); - - if (currentGamemode == null) return; - - Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj, - guiLeft + xSize / 2f, guiTop + 14, false, new Color(64, 64, 64).getRGB() - ); - - drawStringShadow(SBGamemodes.HardcoreMode.SOFTCORE.display, guiLeft + 10, guiTop + 30, xSize - 47); - drawStringShadow(SBGamemodes.HardcoreMode.HARDCORE.display, guiLeft + 10, guiTop + 50, xSize - 47); - - drawStringShadow(SBGamemodes.IronmanMode.IRONMAN.display, guiLeft + 10, guiTop + 80, xSize - 47); - drawStringShadow(SBGamemodes.IronmanMode.IRONMANPLUS.display, guiLeft + 10, guiTop + 100, xSize - 47); - drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.display, guiLeft + 10, guiTop + 120, xSize - 47); - drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.display, guiLeft + 10, guiTop + 140, xSize - 47); - - drawStringShadow(SBGamemodes.MODIFIER_DEVILISH_DISPLAY, guiLeft + 10, guiTop + 170, xSize - 47); - drawStringShadow(SBGamemodes.MODIFIER_NOBANK_DISPLAY, guiLeft + 10, guiTop + 190, xSize - 47); - drawStringShadow(SBGamemodes.MODIFIER_SMALLISLAND_DISPLAY, guiLeft + 10, guiTop + 210, xSize - 47); - - String tooltipToDisplay = null; - - GlStateManager.color(1, 1, 1, 1); - if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.SOFTCORE.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.SOFTCORE ? radial_circle_on : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 30 - 4 && mouseY < guiTop + 30 + 12) { - tooltipToDisplay = SBGamemodes.HardcoreMode.SOFTCORE.desc; - } - } - } - if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.HARDCORE.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.HARDCORE ? radial_circle_on : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 50 - 4 && mouseY < guiTop + 50 + 12) { - tooltipToDisplay = SBGamemodes.HardcoreMode.HARDCORE.desc; - } - } - } - - if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMAN.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMAN ? radial_circle_on : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 80 - 4 && mouseY < guiTop + 80 + 12) { - tooltipToDisplay = SBGamemodes.IronmanMode.IRONMAN.desc; - } - } - } - if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMANPLUS.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMANPLUS ? radial_circle_on : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 100 - 4 && mouseY < guiTop + 100 + 12) { - tooltipToDisplay = SBGamemodes.IronmanMode.IRONMANPLUS.desc; - } - } - } - if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMAN ? radial_circle_on : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 120 - 4 && mouseY < guiTop + 120 + 12) { - tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.desc; - } - } - } - if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.ordinal())) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS - ? radial_circle_on - : radial_circle_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 140 - 4 && mouseY < guiTop + 140 + 12) { - tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.desc; - } - } - } - - if (canChange( - currentGamemode.gamemodeModifiers, - currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_DEVILISH - )) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_DEVILISH) != 0 - ? radial_square_on - : radial_square_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 170 - 4 && mouseY < guiTop + 170 + 12) { - tooltipToDisplay = SBGamemodes.MODIFIER_DEVILISH_DESC; - } - } - } - if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_NOBANK)) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_NOBANK) != 0 ? radial_square_on : radial_square_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 190 - 4 && mouseY < guiTop + 190 + 12) { - tooltipToDisplay = SBGamemodes.MODIFIER_NOBANK_DESC; - } - } - } - if (canChange( - currentGamemode.gamemodeModifiers, - currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_SMALLISLAND - )) { - Minecraft.getMinecraft().getTextureManager().bindTexture( - (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_SMALLISLAND) != 0 - ? radial_square_on - : radial_square_off); - Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST); - - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST); - if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) { - if (mouseY > guiTop + 210 - 4 && mouseY < guiTop + 210 + 12) { - tooltipToDisplay = SBGamemodes.MODIFIER_SMALLISLAND_DESC; - } - } - } - - if (tooltipToDisplay != null) { - List<String> lines = new ArrayList<>(); - for (String line : tooltipToDisplay.split("\n")) { - lines.add(EnumChatFormatting.GRAY + line); - } - Utils.drawHoveringText(lines, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java deleted file mode 100644 index ddd4a4ba..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ /dev/null @@ -1,374 +0,0 @@ -package io.github.moulberry.notenoughupdates.gamemodes; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.util.SBInfo; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; -import java.io.*; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.Key; -import java.util.Base64; -import java.util.HashMap; - -public class SBGamemodes { - private static final Gson gson = new Gson(); - - public static final int MODIFIER_DEVILISH = 0b1; - public static final int MODIFIER_NOBANK = 0b10; - public static final int MODIFIER_SMALLISLAND = 0b100; - - public static final String MODIFIER_DEVILISH_DISPLAY = EnumChatFormatting.DARK_PURPLE + "Devilish"; - public static final String MODIFIER_NOBANK_DISPLAY = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank"; - public static final String MODIFIER_SMALLISLAND_DISPLAY = EnumChatFormatting.GREEN + "SmallIsland"; - - public static final String MODIFIER_DEVILISH_DESC = EnumChatFormatting.DARK_PURPLE + "Devilish\n" + - "You are NOT allowed to use fairy souls."; - public static final String MODIFIER_NOBANK_DESC = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank\n" + - "You are NOT allowed to use the bank."; - public static final String MODIFIER_SMALLISLAND_DESC = EnumChatFormatting.GREEN + "SmallIsland\n" + - "Your private island is 1/4 the normal size."; - - private static HashMap<String, Gamemode> currentGamemode = new HashMap<>(); - private static long lastDeathExemption = 0; - - public static class Gamemode { - public HardcoreMode hardcoreMode = HardcoreMode.NORMAL; - public IronmanMode ironmanMode = IronmanMode.NORMAL; - public int gamemodeModifiers = 0; - - public boolean locked = true; - } - - public enum HardcoreMode { - NORMAL("Normal", "Normal"), - SOFTCORE(EnumChatFormatting.RED + "Soft" + EnumChatFormatting.DARK_RED + "core\n" + - "You only have 1 life.\nDying will remove your hardcore status.\nDeaths to the void or 'unknown' are exempted.", - "You died.", "You fell into the void" - ), - HARDCORE(EnumChatFormatting.DARK_RED + "Hardcore\n" + - "You only have 1 life.\nDying will remove your hardcore status."); - - public final String display; - public final String desc; - private final String[] exemptions; - - HardcoreMode(String display, String... exemptions) { - this.display = display.split("\n")[0]; - this.desc = display; - this.exemptions = exemptions; - } - - public boolean isExemption(String line) { - for (String exemption : exemptions) { - if (line.contains(exemption)) return true; - } - return false; - } - } - - public enum IronmanMode { - NORMAL("Normal"), - IRONMAN(EnumChatFormatting.WHITE + "Ironman\n" + - "You are NOT allowed to trade or use the auction house.", - "You ", "Auction House", "Auctions Browser", "Auction View" - ), - IRONMANPLUS(EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD + "+\n" + - "You are NOT allowed to trade, use the auction house or bazaar.", - "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar" - ), - ULTIMATE_IRONMAN(EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman\n" + - "You are NOT allowed to trade or use the auction house.\n" + - "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).", - "You ", "Auction House", "Auctions Browser", "Auction View", "Chest", - "Wardrobe", "Weapon Rack", "Shelves" - ), - ULTIMATE_IRONMANPLUS( - EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD + - "+\n" + - "You are NOT allowed to trade, use the auction house or bazaar.\n" + - "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).", - "You ", - "Auction House", - "Auctions Browser", - "Auction View", - "Bazaar", - "Chest", - "Wardrobe", - "Weapon Rack", - "Shelves" - ); - - public final String display; - public final String desc; - private final String[] bannedInventories; - - IronmanMode(String display, String... bannedInventories) { - this.display = display.split("\n")[0]; - this.desc = display; - this.bannedInventories = bannedInventories; - } - - public boolean isBanned(String inventoryName) { - for (String banned : bannedInventories) { - if (inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true; - } - return false; - } - } - - public static Gamemode getGamemode() { - String currentProfile = SBInfo.getInstance().currentProfile; - - if (currentProfile == null || currentProfile.isEmpty()) return null; - - return currentGamemode.computeIfAbsent(currentProfile, k -> new Gamemode()); - } - - public static void loadFromFile() { - File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation; - File gamemodeFile = new File( - configDir, - "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json" - ); - gamemodeFile.getParentFile().mkdirs(); - - if (!gamemodeFile.exists()) { - return; - } - - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(gamemodeFile), - StandardCharsets.UTF_8 - )) - ) { - String line = reader.readLine(); - String decoded = decrypt(line); - currentGamemode = gson.fromJson(decoded, GamemodeWrapper.class).currentGamemode; - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static class GamemodeWrapper { - private final HashMap<String, Gamemode> currentGamemode; - - public GamemodeWrapper(HashMap<String, Gamemode> currentGamemode) { - this.currentGamemode = currentGamemode; - } - } - - public static void saveToFile() { - File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation; - File gamemodeFile = new File( - configDir, - "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json" - ); - gamemodeFile.getParentFile().mkdirs(); - - try { - gamemodeFile.createNewFile(); - - try ( - BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(gamemodeFile), StandardCharsets.UTF_8)) - ) { - JsonObject obj = new JsonObject(); - writer.write(encrypt(gson.toJson(new GamemodeWrapper(currentGamemode), GamemodeWrapper.class))); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static Key getKeyFromPlayerUUID() { - byte[] bytes = ByteBuffer.allocate(2 * Long.SIZE / Byte.SIZE) - .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getLeastSignificantBits()) - .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getMostSignificantBits()) - .array(); - SecretKeySpec key = new SecretKeySpec(bytes, "AES"); - - return key; - } - - public static String encrypt(String value) { - try { - Cipher cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.ENCRYPT_MODE, getKeyFromPlayerUUID()); - String encrypt = Base64.getEncoder().encodeToString(cipher.doFinal(value.getBytes())); - return encrypt; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static String decrypt(String encrypted) { - try { - Cipher cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.DECRYPT_MODE, getKeyFromPlayerUUID()); - byte[] b64Decoded = Base64.getDecoder().decode(encrypted); - byte[] bytes = cipher.doFinal(b64Decoded); - - return new String(bytes); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static void setGamemode(Gamemode gamemode) { - String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile(); - - if (currentProfile == null || currentProfile.isEmpty()) return; - - currentGamemode.put(currentProfile, gamemode); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - - if (!"Your Island".equals(SBInfo.getInstance().location)) return; - - if ((getGamemode().gamemodeModifiers & MODIFIER_SMALLISLAND) != 0) { - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - if (Math.abs(event.pos.getX()) > 40 || Math.abs(event.pos.getZ()) > 40) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NPC] Builder" + - EnumChatFormatting.WHITE + ": Sorry, " + Minecraft.getMinecraft().thePlayer.getName() + - ", due to budget cuts your skyblock island is now only 80 blocks wide.")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" + - EnumChatFormatting.AQUA + " if you would like to build further out)")); - - event.setCanceled(true); - } - } - } - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (event.phase != TickEvent.Phase.START) return; - - if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - - boolean inDungeons = SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals( - "dungeon"); - - getGamemode().locked = !(EnumChatFormatting.YELLOW + "Break a log").equals(SBInfo.getInstance().objective); - - IronmanMode ironmanMode = getGamemode().ironmanMode; - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if (gui instanceof GuiChest) { - GuiChest eventGui = (GuiChest) gui; - ContainerChest cc = (ContainerChest) eventGui.inventorySlots; - String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - - if (containerName.equals("Bank") && (getGamemode().gamemodeModifiers & MODIFIER_NOBANK) != 0) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NPC] Banker" + - EnumChatFormatting.WHITE + ": Hi, " + Minecraft.getMinecraft().thePlayer.getName() + - ", you would like to create an account and make a deposit?")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NPC] Banker" + - EnumChatFormatting.WHITE + ": Alright, I've invested your money into ...")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[" + - EnumChatFormatting.WHITE + "YouTube" + EnumChatFormatting.RED + "] Nullzee" + - EnumChatFormatting.WHITE + ": Hows it going everyone, welcome to my ultimate bazaar flipping guide ...")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NPC] Banker" + - EnumChatFormatting.WHITE + - ": Hmm, it seems as though the economy has crashed. All your money is gone. Poof. Vanished.")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[IDIOT] You" + - EnumChatFormatting.WHITE + ": ... never again ...")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" + - EnumChatFormatting.AQUA + " if you would like to use the bank)")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - } else if (containerName.equals("Fairy") && (getGamemode().gamemodeModifiers & MODIFIER_DEVILISH) != 0) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NPC] " + EnumChatFormatting.LIGHT_PURPLE + "Tia the Fairy" + - EnumChatFormatting.WHITE + ": Oh no, " + Minecraft.getMinecraft().thePlayer.getName() + - ", you have sold your soul to the devil... please go away!")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" + - EnumChatFormatting.AQUA + " if you would like to use fairy souls)")); - } else if (!inDungeons && ironmanMode.isBanned(containerName)) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA + "You cannot access this inventory/menu because of your")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - " " + ironmanMode.display + EnumChatFormatting.AQUA + " status!")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" + - EnumChatFormatting.AQUA + " if you would like to downgrade the status)")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - } - } - } - - @SubscribeEvent - public void onChatMessage(ClientChatReceivedEvent event) { - if (event.type != 0) return; - - /*if(Keyboard.isKeyDown(Keyboard.KEY_K)) { - boolean has = false; - for(char c : event.message.getFormattedText().toCharArray()) { - if((int)c > 200) { - if(!has) System.out.println("-----START"); - has = true; - System.out.println((int)c); - } - } - if(has) System.out.println("-----END"); - }*/ - if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - - String message = event.message.getFormattedText(); - if (message.contains("\u2620")) { //Death symbol ( ☠) - HardcoreMode hardcoreMode = getGamemode().hardcoreMode; - if (hardcoreMode != HardcoreMode.NORMAL) { - if (hardcoreMode.isExemption(message)) { - lastDeathExemption = System.currentTimeMillis(); - } - } - } - - if (System.currentTimeMillis() - lastDeathExemption > 1000 && - message.contains("!") && message.startsWith( - EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED + "You died")) { - if (getGamemode().hardcoreMode != HardcoreMode.NORMAL) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED.toString() + EnumChatFormatting.OBFUSCATED + "AAA" + - EnumChatFormatting.RED + " You have lost your " + - getGamemode().hardcoreMode.display + EnumChatFormatting.RED + " status! " + - EnumChatFormatting.RED + EnumChatFormatting.OBFUSCATED + "AAA")); - getGamemode().hardcoreMode = HardcoreMode.NORMAL; - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java deleted file mode 100644 index bbdbabd2..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java +++ /dev/null @@ -1,534 +0,0 @@ -package io.github.moulberry.notenoughupdates.infopanes; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NEUManager; -import io.github.moulberry.notenoughupdates.NEUOverlay; -import io.github.moulberry.notenoughupdates.util.NEUResourceManager; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.client.shader.Shader; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.item_mask; - -public class CollectionLogInfoPane extends ScrollableInfoPane { - private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$"; - private final String petRegex = ".*?;[0-4]$"; - - TreeSet<String> items = new TreeSet<>(getItemComparator()); - - private int buttonHover = -1; - - private int previousAcquiredCount = 0; - private int previousScroll = 0; - private int previousX = 0; - private int previousFilter = 0; - - private final long lastUpdate = 0; - - private static final int FILTER_ALL = 0; - private static final int FILTER_WEAPON = 1; - private static final int FILTER_ARMOR = 2; - private static final int FILTER_ACCESSORY = 3; - private static final int FILTER_PET = 4; - private static final int FILTER_DUNGEON = 5; - private static final int FILTER_SLAYER_ZOMBIE = 6; - private static final int FILTER_SLAYER_WOLF = 7; - private static final int FILTER_SLAYER_SPIDER = 8; - private int filterMode = FILTER_ALL; - private final String[] filterPrettyNames = new String[]{ - "ALL", "WEAPON", "ARMOR", - "ACCESSORY", "PET", "DUNGEON", "ZOMBIE SLAYER", "WOLF SLAYER", "SPIDER SLAYER" - }; - - private Framebuffer itemFramebuffer = null; - private Framebuffer itemBGFramebuffer = null; - private Framebuffer itemFramebufferGrayscale = null; - private Shader grayscaleShader = null; - - private final int updateCounter = 0; - - public CollectionLogInfoPane(NEUOverlay overlay, NEUManager manager) { - super(overlay, manager); - refreshItems(); - } - - private boolean loreContains(JsonArray lore, String str) { - for (int i = 0; i < lore.size(); i++) { - String line = lore.get(i).getAsString(); - if (line.contains(str)) return true; - } - return false; - } - - private void refreshItems() { - items.clear(); - for (String internalname : manager.getItemInformation().keySet()) { - if (!manager.auctionManager.isVanillaItem(internalname) && !internalname.matches(mobRegex)) { - JsonObject item = manager.getItemInformation().get(internalname); - JsonArray lore = manager.getItemInformation().get(internalname).get("lore").getAsJsonArray(); - switch (filterMode) { - case FILTER_WEAPON: - if (overlay.checkItemType(lore, "SWORD", "BOW", "WAND") < 0) continue; - break; - case FILTER_ARMOR: - if (overlay.checkItemType(lore, "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS") < 0) continue; - break; - case FILTER_ACCESSORY: - if (overlay.checkItemType(lore, "ACCESSORY") < 0) continue; - break; - case FILTER_PET: - if (!internalname.matches(petRegex) || !item.get("displayname").getAsString().contains("[")) - continue; - break; - case FILTER_DUNGEON: - if (Utils.checkItemType(lore, true, "DUNGEON") < 0) continue; - break; - case FILTER_SLAYER_ZOMBIE: - if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("ZOMBIE")) - continue; - break; - case FILTER_SLAYER_WOLF: - if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("WOLF")) - continue; - break; - case FILTER_SLAYER_SPIDER: - if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("SPIDER")) - continue; - break; - } - items.add(internalname); - } - } - } - - private Map<String, ArrayList<String>> getAcquiredItems() { - return null;//manager.config.collectionLog.value; - } - - private Comparator<String> getItemComparator() { - return (o1, o2) -> { - float cost1 = manager.auctionManager.getLowestBin(o1); - float cost2 = manager.auctionManager.getLowestBin(o2); - - if (cost1 == -1) cost1 = manager.auctionManager.getCraftCost(o1).craftCost; - if (cost2 == -1) cost2 = manager.auctionManager.getCraftCost(o2).craftCost; - - if (cost1 < cost2) return 1; - if (cost1 > cost2) return -1; - - return o1.compareTo(o2); - }; - } - - public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) { - super.mouseInput(width, height, mouseX, mouseY, mouseDown); - if (mouseDown) { - if (buttonHover == 0) { - if (Mouse.getEventButton() == 0) { - filterMode++; - if (filterMode >= filterPrettyNames.length) { - filterMode = 0; - } - } else if (Mouse.getEventButton() == 1) { - filterMode--; - if (filterMode < 0) { - filterMode = filterPrettyNames.length - 1; - } - } - } - refreshItems(); - } - } - - public void render( - int width, - int height, - Color bg, - Color fg, - ScaledResolution scaledresolution, - int mouseX, - int mouseY - ) { - int paneWidth = (int) (width / 3 * overlay.getWidthMult()); - int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor()); - int leftSide = rightSide - paneWidth; - int padding = overlay.getBoxPadding(); - - renderDefaultBackground(width, height, bg); - - renderControls(height, padding, leftSide + padding, rightSide - padding, 20, fg); - renderCollectionLog(fg, width, height, leftSide + padding, rightSide - padding, padding + 25, height - padding); - } - - private float getCompletedness() { - int total = items.size(); - int own = 0; - for (String item : items) { - if (getAcquiredItems() != null && - getAcquiredItems().containsKey(manager.getCurrentProfile()) && - getAcquiredItems().get(manager.getCurrentProfile()).contains(item)) { - own++; - } - - } - return own / (float) total; - } - - private final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ - EnumChatFormatting.RED, - EnumChatFormatting.GOLD, - EnumChatFormatting.YELLOW, - EnumChatFormatting.GREEN, - EnumChatFormatting.AQUA, - EnumChatFormatting.LIGHT_PURPLE, - EnumChatFormatting.DARK_PURPLE - }; - - private String getCompletednessString() { - float completedness = getCompletedness(); - String text = (int) (completedness * 100) + "% Complete"; - if (completedness >= 1) { - StringBuilder rainbowText = new StringBuilder(); - for (int i = 0; i < text.length(); i++) { - char c = text.charAt(i); - int index = (int) (i - System.currentTimeMillis() / 100) % rainbow.length; - if (index < 0) index += rainbow.length; - rainbowText.append(rainbow[index]).append(c); - } - text = rainbowText.toString(); - } - return text; - } - - private void renderControls(int height, int top, int left, int right, int ySize, Color fg) { - ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - - int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); - int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); - - buttonHover = -1; - - int totalAvailable = right - left; - int controlPadding = 3; - String[] controls = new String[]{ - "Filter: " + filterPrettyNames[filterMode], - getCompletednessString() - }; - int numControls = controls.length; - int available = totalAvailable - (numControls - 1) * controlPadding; - int controlSize = available / numControls; - int extraPadding = (available % controlSize) / 2; - - for (int i = 0; i < numControls; i++) { - int width = controlSize + controlPadding; - int x = left + extraPadding + i * width; - - if (mouseX > x && mouseX < x + controlSize) { - if (mouseY > top && mouseY < top + ySize) { - buttonHover = i; - } - } - - drawRect(x, top, x + controlSize, top + ySize, - new Color(177, 177, 177).getRGB() - ); - drawRect(x + 1, top + 1, x + controlSize, top + ySize, - new Color(50, 50, 50).getRGB() - ); - drawRect(x + 1, top + 1, x + controlSize - 1, top + ySize - 1, fg.getRGB()); - Utils.drawStringCenteredScaledMaxWidth(controls[i], Minecraft.getMinecraft().fontRendererObj, - x + width / 2f, top + ySize / 2f, true, controlSize - 4, Color.WHITE.getRGB() - ); - } - } - - public int getCurrentAcquiredCount() { - if (getAcquiredItems() == null) return 0; - if (!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0; - return getAcquiredItems().get(manager.getCurrentProfile()).size(); - } - - private void renderCollectionLog(Color fg, int width, int height, int left, int right, int top, int bottom) { - ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - - int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); - int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); - - if (itemFramebuffer != null && grayscaleShader != null && - (itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) { - grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix( - width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor())); - } - - itemFramebuffer = checkFramebufferSizes(itemFramebuffer, width, height, - scaledresolution.getScaleFactor() - ); - itemBGFramebuffer = checkFramebufferSizes(itemBGFramebuffer, width, height, - scaledresolution.getScaleFactor() - ); - itemFramebufferGrayscale = checkFramebufferSizes(itemFramebufferGrayscale, width, height, - scaledresolution.getScaleFactor() - ); - - /*if(!manager.config.cacheRenderedItempane.value || previousAcquiredCount != getCurrentAcquiredCount() || - previousScroll != scrollHeight.getValue() || previousX != left || previousFilter != filterMode || - System.currentTimeMillis() - lastUpdate > 5000) { - lastUpdate = System.currentTimeMillis(); - renderItemsToImage(itemFramebuffer, fg, left+5, right, top+1, bottom); - renderItemBGToImage(itemBGFramebuffer, fg, left+5, right, top+1, bottom); - }*/ - previousAcquiredCount = getCurrentAcquiredCount(); - previousScroll = scrollHeight.getValue(); - previousX = left; - previousFilter = filterMode; - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - renderFromImage(itemBGFramebuffer, width, height, left, right, top, bottom); - renderFromImage(itemFramebuffer, width, height, left, right, top, bottom); - - if (grayscaleShader == null) { - try { - grayscaleShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()), - "grayscale", - itemFramebuffer, itemFramebufferGrayscale - ); - grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix( - width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor())); - } catch (Exception e) { - return; - } - } - - GL11.glPushMatrix(); - grayscaleShader.loadShader(0); - GlStateManager.enableDepth(); - GL11.glPopMatrix(); - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - - itemFramebufferGrayscale.bindFramebufferTexture(); - - AtomicReference<ItemStack> tooltipToDisplay = new AtomicReference<>(null); - - AtomicBoolean isTop = new AtomicBoolean(false); - AtomicInteger lowestY = new AtomicInteger(-1); - - String[] items = getItemList(); - GlStateManager.color(1f, 1f, 1f, 1f); - iterateItemSlots(new ItemSlotConsumer() { - @Override - public void consume(int x, int y, int id) { - if (id < items.length) { - String internalname = items[id]; - if (id == 0) isTop.set(true); - - int leftI = x - 1; - int rightI = x + 17; - int topI = y - 1; - int bottomI = y + 17; - - lowestY.set(Math.max(bottomI, lowestY.get())); - - if (mouseX > leftI && mouseX < rightI) { - if (mouseY > topI && mouseY < bottomI) { - tooltipToDisplay.set(manager.jsonToStack(manager.getItemInformation().get(internalname), true)); - } - } - - if (getAcquiredItems() != null && - getAcquiredItems().containsKey(manager.getCurrentProfile()) && - getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) { - return; - } - - topI = Math.max(topI, top); - bottomI = Math.min(bottomI, bottom); - - Utils.drawTexturedRect(leftI, topI, rightI - leftI, bottomI - topI, - leftI / (float) width, rightI / (float) width, - (height - topI) / (float) height, (height - bottomI) / (float) height - ); - } - } - }, left + 5, right, top + 1, bottom); - - if (!isTop.get()) { - if (lowestY.get() == -1) { - scrollHeight.setValue(0); - } else { - int dist = bottom - lowestY.get() - 10; - if (dist > 0) { - scrollHeight.setValue(scrollHeight.getValue() - dist); - } - } - } - - itemFramebufferGrayscale.unbindFramebufferTexture(); - - ItemStack displayStack = tooltipToDisplay.get(); - if (displayStack != null) { - List<String> text = displayStack.getTooltip(Minecraft.getMinecraft().thePlayer, true); - Utils.drawHoveringText(text, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); - } - } - - private String[] getItemList() { - String[] items_arr = new String[items.size()]; - int i = 0; - for (String internalname : items) { - items_arr[i++] = internalname; - } - return items_arr; - } - - private int limCol(int col) { - return Math.min(255, Math.max(0, col)); - } - - private void renderItems(int left, int right, int top, int bottom) { - String[] items = getItemList(); - iterateItemSlots(new ItemSlotConsumer() { - public void consume(int x, int y, int id) { - if (id < items.length) { - String internalname = items[id]; - - ItemStack stack = manager.jsonToStack(manager.getItemInformation().get(internalname)); - Utils.drawItemStack(stack, x, y); - } - } - }, left, right, top, bottom); - } - - private void renderItemBackgrounds(Color fg, int left, int right, int top, int bottom) { - Color fgCustomOpacity = - null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true); - Color fgGold = null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true); - - String[] items = getItemList(); - iterateItemSlots(new ItemSlotConsumer() { - public void consume(int x, int y, int id) { - if (id < items.length) { - String internalname = items[id]; - - Color color = fgCustomOpacity; - if (getAcquiredItems() != null && - getAcquiredItems().containsKey(manager.getCurrentProfile()) && - getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) { - color = fgGold; - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask); - /*if(manager.config.itemStyle.value) { - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, - color.getBlue() / 255f, color.getAlpha() / 255f); - Utils.drawTexturedRect(x - 1, y - 1, overlay.ITEM_SIZE + 2, overlay.ITEM_SIZE + 2, GL11.GL_NEAREST); - } else { - drawRect(x-1, y-1, x+overlay.ITEM_SIZE+1, y+overlay.ITEM_SIZE+1, color.getRGB()); - }*/ - GlStateManager.bindTexture(0); - } - } - }, left, right, top, bottom); - } - - /** - * Checks whether the screen size has changed, if so it reconstructs the itemPane framebuffer and marks that the - * itemPane should be redrawn. - */ - private Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height, int scaleFactor) { - int sw = width * scaleFactor; - int sh = height * scaleFactor; - - if (framebuffer == null || framebuffer.framebufferWidth != sw || framebuffer.framebufferHeight != sh) { - if (framebuffer == null) { - framebuffer = new Framebuffer(sw, sh, true); - } else { - framebuffer.createBindFramebuffer(sw, sh); - } - framebuffer.setFramebufferFilter(GL11.GL_NEAREST); - } - return framebuffer; - } - - private void renderItemsToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) { - GL11.glPushMatrix(); - framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(false); - - renderItems(left, right, top, bottom); - - framebuffer.unbindFramebuffer(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - GL11.glPopMatrix(); - } - - private void renderItemBGToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) { - GL11.glPushMatrix(); - framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(false); - - renderItemBackgrounds(fg, left, right, top, bottom); - - framebuffer.unbindFramebuffer(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - GL11.glPopMatrix(); - } - - private void renderFromImage( - Framebuffer framebuffer, - int width, - int height, - int left, - int right, - int top, - int bottom - ) { - framebuffer.bindFramebufferTexture(); - GlStateManager.color(1f, 1f, 1f, 1f); - Utils.drawTexturedRect(left, top, right - left, bottom - top, - left / (float) width, right / (float) width, - (height - top) / (float) height, (height - bottom) / (float) height - ); - framebuffer.unbindFramebufferTexture(); - } - - private abstract static class ItemSlotConsumer { - public abstract void consume(int x, int y, int id); - } - - public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int left, int right, int top, int bottom) { - int scrolledTop = top - scrollHeight.getValue(); - - int id = 0; - int extraSize = NEUOverlay.ITEM_SIZE + NEUOverlay.ITEM_PADDING; - for (int y = scrolledTop; y < bottom; y += extraSize) { - for (int x = left; x < right - extraSize; x += extraSize) { - if (y > top - extraSize) { - itemSlotConsumer.consume(x, y, id); - } - if (++id >= items.size()) { - return; - } - } - } - } - - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java new file mode 100644 index 00000000..633cd80f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -0,0 +1,219 @@ +package io.github.moulberry.notenoughupdates.listener; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; +import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.event.ClickEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static io.github.moulberry.notenoughupdates.overlays.SlayerOverlay.*; + +public class ChatListener { + private final NotEnoughUpdates neu; + private static final Pattern SLAYER_XP = Pattern.compile( + " (Spider|Zombie|Wolf|Enderman) Slayer LVL (\\d) - (?:Next LVL in ([\\d,]+) XP!|LVL MAXED OUT!)"); + AtomicBoolean missingRecipe = new AtomicBoolean(false); + + public ChatListener(NotEnoughUpdates neu) { + this.neu = neu; + } + + private String processText(String text) { + if (SBInfo.getInstance().getLocation() == null) return text; + if (!SBInfo.getInstance().getLocation().startsWith("mining_") && !SBInfo.getInstance().getLocation().equals( + "crystal_hollows")) + return text; + + if (Minecraft.getMinecraft().thePlayer == null) return text; + if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text; + + return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN + "\\S+ Drill Fuel", "")); + } + + private IChatComponent processChatComponent(IChatComponent chatComponent) { + IChatComponent newComponent; + if (chatComponent instanceof ChatComponentText) { + ChatComponentText text = (ChatComponentText) chatComponent; + + newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat())); + newComponent.setChatStyle(text.getChatStyle().createShallowCopy()); + + for (IChatComponent sibling : text.getSiblings()) { + newComponent.appendSibling(processChatComponent(sibling)); + } + } else if (chatComponent instanceof ChatComponentTranslation) { + ChatComponentTranslation trans = (ChatComponentTranslation) chatComponent; + + Object[] args = trans.getFormatArgs(); + Object[] newArgs = new Object[args.length]; + for (int i = 0; i < trans.getFormatArgs().length; i++) { + if (args[i] instanceof IChatComponent) { + newArgs[i] = processChatComponent((IChatComponent) args[i]); + } else { + newArgs[i] = args[i]; + } + } + newComponent = new ChatComponentTranslation(trans.getKey(), newArgs); + + for (IChatComponent sibling : trans.getSiblings()) { + newComponent.appendSibling(processChatComponent(sibling)); + } + } else { + newComponent = chatComponent.createCopy(); + } + + return newComponent; + } + + private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) { + + if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 > 0 && chatComponent.getChatStyle() != null && + chatComponent.getChatStyle().getChatClickEvent() != null && + chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND && + NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + if (chatComponent.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) { + String username = chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15); + if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) { + chatComponent.setChatStyle(Utils.createClickStyle( + ClickEvent.Action.RUN_COMMAND, + "/pv " + username, + "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + + username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s profile in " + + EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD + "NEU's" + EnumChatFormatting.RESET + + EnumChatFormatting.YELLOW + " profile viewer." + )); + return chatComponent; + } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) { + chatComponent.setChatStyle(Utils.createClickStyle( + ClickEvent.Action.RUN_COMMAND, + "/ah " + username, + "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + + username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page" + )); + return chatComponent; + } + } // wanted to add this for guild but guild uses uuid :sad: + } + return chatComponent; + } + + /** + * 1) When receiving "You are playing on profile" messages, will set the current profile. + * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI) + * 3) Replaces lobby join notifications when streamer mode is active + */ + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) + public void onGuiChat(ClientChatReceivedEvent e) { + if (e.type == 2) { + CrystalMetalDetectorSolver.process(e.message); + e.message = processChatComponent(e.message); + return; + } else if (e.type == 0) { + e.message = replaceSocialControlsWithPV(e.message); + } + + DungeonWin.onChatMessage(e); + + String r = null; + String unformatted = Utils.cleanColour(e.message.getUnformattedText()); + Matcher matcher = SLAYER_XP.matcher(unformatted); + if (unformatted.startsWith("You are playing on profile: ")) { + neu.manager.setCurrentProfile(unformatted + .substring("You are playing on profile: ".length()) + .split(" ")[0].trim()); + } else if (unformatted.startsWith("Your profile was changed to: ")) {//Your profile was changed to: + neu.manager.setCurrentProfile(unformatted + .substring("Your profile was changed to: ".length()) + .split(" ")[0].trim()); + } else if (unformatted.startsWith("Your new API key is ")) { + NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = unformatted.substring("Your new API key is ".length()).substring( + 0, + 36 + ); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.YELLOW + "[NEU] API Key automatically configured")); + } else if (unformatted.startsWith("Player List Info is now disabled!")) { + SBInfo.getInstance().hasNewTab = false; + } else if (unformatted.startsWith("Player List Info is now enabled!")) { + SBInfo.getInstance().hasNewTab = true; + } + if (e.message.getFormattedText().equals( + EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED + "You haven't unlocked this recipe!" + + EnumChatFormatting.RESET)) { + r = EnumChatFormatting.RED + "You haven't unlocked this recipe!"; + } else if (e.message.getFormattedText().startsWith( + EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED + "Invalid recipe ")) { + r = ""; + } else if (unformatted.equals(" NICE! SLAYER BOSS SLAIN!")) { + SlayerOverlay.isSlain = true; + } else if (unformatted.equals(" SLAYER QUEST STARTED!")) { + SlayerOverlay.isSlain = false; + if (timeSinceLastBoss == 0) { + SlayerOverlay.timeSinceLastBoss = System.currentTimeMillis(); + } else { + timeSinceLastBoss2 = timeSinceLastBoss; + timeSinceLastBoss = System.currentTimeMillis(); + } + } else if (unformatted.startsWith(" RNGesus Meter:")) { + RNGMeter = unformatted.substring(" RNGesus Meter: -------------------- ".length()); + } else if (matcher.matches()) { + //matcher.group(1); + SlayerOverlay.slayerLVL = matcher.group(2); + if (!SlayerOverlay.slayerLVL.equals("9")) { + SlayerOverlay.slayerXp = matcher.group(3); + } else { + slayerXp = "maxed"; + } + } else if (unformatted.startsWith("Sending to server") || (unformatted.startsWith( + "Your Slayer Quest has been cancelled!"))) { + SlayerOverlay.slayerQuest = false; + SlayerOverlay.unloadOverlayTimer = System.currentTimeMillis(); + } + if (e.message.getFormattedText().contains( + EnumChatFormatting.YELLOW + "Visit the Auction House to collect your item!")) { + if (NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid != null && + System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBidMillis < 5000) { + NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction " + + NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.niceAucId(NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid)); + } + } + if (r != null) { + if (neu.manager.failViewItem(r)) { + e.setCanceled(true); + } + missingRecipe.set(true); + } + if (unformatted.startsWith("Sending to server") && neu.isOnSkyblock() && + NotEnoughUpdates.INSTANCE.config.misc.streamerMode && e.message instanceof ChatComponentText) { + String m = e.message.getFormattedText(); + String m2 = StreamerMode.filterChat(e.message.getFormattedText()); + if (!m.equals(m2)) { + e.message = new ChatComponentText(m2); + } + } + if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && + SBInfo.getInstance().getLocation().equals("crystal_hollows")) { + CrystalMetalDetectorSolver.reset(true); + } + if (unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || + unformatted.startsWith(" ") || unformatted.startsWith("✦") || unformatted.equals( + " You've earned a Crystal Loot Bundle!")) + OverlayManager.crystalHollowOverlay.message(unformatted); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java new file mode 100644 index 00000000..52729143 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -0,0 +1,980 @@ +package io.github.moulberry.notenoughupdates.listener; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import io.github.moulberry.notenoughupdates.ItemPriceInformation; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.util.MiscUtils; +import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; +import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StringUtils; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.commons.lang3.text.WordUtils; +import org.lwjgl.input.Keyboard; + +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.List; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ItemTooltipListener { + private static final String petToolTipRegex = + "((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*"; + private final NotEnoughUpdates neu; + private final Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))"); + private final HashSet<String> percentStats = new HashSet<>(); + DecimalFormat myFormatter = new DecimalFormat("###,###.###"); + private String currentRarity = "COMMON"; + private boolean copied = false; + private boolean showReforgeStoneStats = true; + private boolean pressedArrowLast = false; + private boolean pressedShiftLast = false; + private int sbaloaded = -1; + + public ItemTooltipListener(NotEnoughUpdates neu) { + this.neu = neu; + percentStats.add("bonus_attack_speed"); + percentStats.add("crit_damage"); + percentStats.add("crit_chance"); + percentStats.add("sea_creature_chance"); + percentStats.add("ability_damage"); + } + + private boolean isSkyblockAddonsLoaded() { + if (sbaloaded == -1) { + if (Loader.isModLoaded("skyblockaddons")) { + sbaloaded = 1; + } else { + sbaloaded = 0; + } + } + return sbaloaded == 1; + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onItemTooltipLow(ItemTooltipEvent event) { + if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; + + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + if (internalname == null) { + onItemToolTipInternalNameNull(event); + return; + } + + boolean hasEnchantments = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey( + "enchantments", + 10 + ); + Set<String> enchantIds = new HashSet<>(); + if (hasEnchantments) + enchantIds = + event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet(); + + JsonObject enchantsConst = Constants.ENCHANTS; + JsonArray allItemEnchs = null; + Set<String> ignoreFromPool = new HashSet<>(); + if (enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) { + try { + JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray(); + for (JsonElement element : enchantPools) { + Set<String> currentPool = new HashSet<>(); + for (JsonElement poolElement : element.getAsJsonArray()) { + String poolS = poolElement.getAsString(); + currentPool.add(poolS); + } + for (JsonElement poolElement : element.getAsJsonArray()) { + String poolS = poolElement.getAsString(); + if (enchantIds.contains(poolS)) { + ignoreFromPool.addAll(currentPool); + break; + } + } + } + + JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject(); + NBTTagCompound tag = event.itemStack.getTagCompound(); + if (tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + out: + for (int i = list.tagCount(); i >= 0; i--) { + String line = list.getStringTagAt(i); + for (int j = 0; j < Utils.rarityArrC.length; j++) { + for (Map.Entry<String, JsonElement> entry : enchantsObj.entrySet()) { + if (line.contains(Utils.rarityArrC[j] + " " + entry.getKey()) || line.contains( + Utils.rarityArrC[j] + " DUNGEON " + entry.getKey())) { + allItemEnchs = entry.getValue().getAsJsonArray(); + break out; + } + } + } + } + } + } + } catch (Exception ignored) { + } + } + + boolean gotToEnchants = false; + boolean passedEnchants = false; + + boolean dungeonProfit = false; + int index = 0; + List<String> newTooltip = new ArrayList<>(); + + for (String line : event.toolTip) { + if (line.endsWith(EnumChatFormatting.DARK_GRAY + "Reforge Stone") && + NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) { + JsonObject reforgeStones = Constants.REFORGESTONES; + + if (reforgeStones != null && reforgeStones.has(internalname)) { + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + if (!pressedShiftLast && shift) { + showReforgeStoneStats = !showReforgeStoneStats; + } + pressedShiftLast = shift; + + newTooltip.add(line); + newTooltip.add(""); + if (!showReforgeStoneStats) { + newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to show extra info]"); + } else { + newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to hide extra info]"); + } + + JsonObject reforgeInfo = reforgeStones.get(internalname).getAsJsonObject(); + JsonArray requiredRaritiesArray = reforgeInfo.get("requiredRarities").getAsJsonArray(); + + if (showReforgeStoneStats && requiredRaritiesArray.size() > 0) { + String reforgeName = Utils.getElementAsString(reforgeInfo.get("reforgeName"), ""); + + String[] requiredRarities = new String[requiredRaritiesArray.size()]; + for (int i = 0; i < requiredRaritiesArray.size(); i++) { + requiredRarities[i] = requiredRaritiesArray.get(i).getAsString(); + } + + int rarityIndex = requiredRarities.length - 1; + String rarity = requiredRarities[rarityIndex]; + for (int i = 0; i < requiredRarities.length; i++) { + String rar = requiredRarities[i]; + if (rar.equalsIgnoreCase(currentRarity)) { + rarity = rar; + rarityIndex = i; + break; + } + } + + boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT); + boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT); + if (!pressedArrowLast && (left || right)) { + if (left) { + rarityIndex--; + } else { + rarityIndex++; + } + if (rarityIndex < 0) rarityIndex = 0; + if (rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length - 1; + currentRarity = requiredRarities[rarityIndex]; + rarity = currentRarity; + } + pressedArrowLast = left || right; + + JsonElement statsE = reforgeInfo.get("reforgeStats"); + + String rarityFormatted = Utils.rarityArrMap.getOrDefault(rarity, rarity); + + JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility"); + String reforgeAbility = null; + if (reforgeAbilityE != null) { + if (reforgeAbilityE.isJsonPrimitive() && reforgeAbilityE.getAsJsonPrimitive().isString()) { + reforgeAbility = Utils.getElementAsString(reforgeInfo.get("reforgeAbility"), ""); + + } else if (reforgeAbilityE.isJsonObject()) { + if (reforgeAbilityE.getAsJsonObject().has(rarity)) { + reforgeAbility = reforgeAbilityE.getAsJsonObject().get(rarity).getAsString(); + } + } + } + + if (reforgeAbility != null && !reforgeAbility.isEmpty()) { + String text = EnumChatFormatting.BLUE + (reforgeName.isEmpty() ? "Bonus: " : reforgeName + " Bonus: ") + + EnumChatFormatting.GRAY + reforgeAbility; + boolean first = true; + for (String s : Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(text, 150)) { + newTooltip.add((first ? "" : " ") + s); + first = false; + } + newTooltip.add(""); + } + + newTooltip.add(EnumChatFormatting.BLUE + "Stats for " + rarityFormatted + + "\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]"); + + if (statsE != null && statsE.isJsonObject()) { + JsonObject stats = statsE.getAsJsonObject(); + + JsonElement statsRarE = stats.get(rarity); + if (statsRarE != null && statsRarE.isJsonObject()) { + + JsonObject statsRar = statsRarE.getAsJsonObject(); + + TreeSet<Map.Entry<String, JsonElement>> sorted = new TreeSet<>(Map.Entry.comparingByKey()); + sorted.addAll(statsRar.entrySet()); + + for (Map.Entry<String, JsonElement> entry : sorted) { + if (entry.getValue().isJsonPrimitive() && ((JsonPrimitive) entry.getValue()).isNumber()) { + float statNumF = entry.getValue().getAsFloat(); + String statNumS; + if (statNumF % 1 == 0) { + statNumS = String.valueOf(Math.round(statNumF)); + } else { + statNumS = Utils.floatToString(statNumF, 1); + } + String reforgeNamePretty = WordUtils.capitalizeFully(entry.getKey().replace("_", " ")); + String text = + EnumChatFormatting.GRAY + reforgeNamePretty + ": " + EnumChatFormatting.GREEN + "+" + statNumS; + if (percentStats.contains(entry.getKey())) { + text += "%"; + } + newTooltip.add(" " + text); + } + } + } + } + + JsonElement reforgeCostsE = reforgeInfo.get("reforgeCosts"); + int reforgeCost = -1; + if (reforgeCostsE != null) { + if (reforgeCostsE.isJsonPrimitive() && reforgeCostsE.getAsJsonPrimitive().isNumber()) { + reforgeCost = (int) Utils.getElementAsFloat(reforgeInfo.get("reforgeAbility"), -1); + + } else if (reforgeCostsE.isJsonObject()) { + if (reforgeCostsE.getAsJsonObject().has(rarity)) { + reforgeCost = (int) Utils.getElementAsFloat(reforgeCostsE.getAsJsonObject().get(rarity), -1); + } + } + } + + if (reforgeCost >= 0) { + String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD + + NumberFormat.getNumberInstance().format(reforgeCost) + " coins"; + newTooltip.add(""); + newTooltip.add(text); + } + + } + + continue; + } + + } else if (line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) { + line = line.replace( + "\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune", + Utils.chromaString("Rainbow Rune", index, false) + EnumChatFormatting.BLUE + ); + } else if (hasEnchantments) { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && + NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) { + boolean lineHasEnch = false; + for (String s : enchantIds) { + String enchantName = WordUtils.capitalizeFully(s.replace("_", " ")); + if (line.contains(enchantName)) { + lineHasEnch = true; + break; + } + } + if (lineHasEnch) { + gotToEnchants = true; + } else { + if (gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) { + if (enchantsConst != null && allItemEnchs != null) { + List<String> missing = new ArrayList<>(); + for (JsonElement enchIdElement : allItemEnchs) { + String enchId = enchIdElement.getAsString(); + if (!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) && + !enchantIds.contains(enchId)) { + missing.add(enchId); + } + } + if (!missing.isEmpty()) { + newTooltip.add(""); + StringBuilder currentLine = new StringBuilder( + EnumChatFormatting.RED + "Missing: " + EnumChatFormatting.GRAY); + for (int i = 0; i < missing.size(); i++) { + String enchName = WordUtils.capitalizeFully(missing.get(i).replace("_", " ")); + if (currentLine.length() != 0 && + (Utils.cleanColour(currentLine.toString()).length() + enchName.length()) > 40) { + newTooltip.add(currentLine.toString()); + currentLine = new StringBuilder(); + } + if (currentLine.length() != 0 && i != 0) { + currentLine.append(", ").append(enchName); + } else { + currentLine.append(EnumChatFormatting.GRAY).append(enchName); + } + } + if (currentLine.length() != 0) { + newTooltip.add(currentLine.toString()); + } + } + } + passedEnchants = true; + } + } + } + for (String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) { + List<String> colourOps = GuiEnchantColour.splitter.splitToList(op); + String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); + String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); + String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); + String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); + String modifier = GuiEnchantColour.getColourOpIndex(colourOps, 4); + + int modifierI = GuiEnchantColour.getIntModifier(modifier); + + assert enchantName != null; + if (enchantName.length() == 0) continue; + assert comparator != null; + if (comparator.length() == 0) continue; + assert comparison != null; + if (comparison.length() == 0) continue; + assert colourCode != null; + if (colourCode.length() == 0) continue; + + int comparatorI = ">=<".indexOf(comparator.charAt(0)); + + int levelToFind; + try { + levelToFind = Integer.parseInt(comparison); + } catch (Exception e) { + continue; + } + + if (comparatorI < 0) continue; + String regexText = "0123456789abcdefz"; + if (isSkyblockAddonsLoaded()) { + regexText = regexText + "Z"; + } + + if (regexText.indexOf(colourCode.charAt(0)) < 0) continue; + + //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); + //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$) + Pattern pattern; + try { + pattern = Pattern.compile("(\\u00A79|\\u00A7(9|l)\\u00A7d\\u00A7l)(?<enchantName>" + enchantName + ") " + + "(?<level>[0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))((\\u00A79)?,|( \\u00A78(?:,?[0-9]+)*)?$)"); + } catch (Exception e) { + continue; + } //malformed regex + Matcher matcher = pattern.matcher(line); + int matchCount = 0; + while (matcher.find() && matchCount < 5) { + if (Utils.cleanColour(matcher.group("enchantName")).startsWith(" ")) continue; + + matchCount++; + int level = -1; + String levelStr = matcher.group("level"); + if (levelStr == null) continue; + try { + level = Integer.parseInt(levelStr); + } catch (Exception e) { + switch (levelStr) { + case "I": + level = 1; + break; + case "II": + level = 2; + break; + case "III": + level = 3; + break; + case "IV": + level = 4; + break; + case "V": + level = 5; + break; + case "VI": + level = 6; + break; + case "VII": + level = 7; + break; + case "VIII": + level = 8; + break; + case "IX": + level = 9; + break; + case "X": + level = 10; + break; + case "XI": + level = 11; + break; + case "XII": + level = 12; + break; + case "XIII": + level = 13; + break; + case "XIV": + level = 14; + break; + case "XV": + level = 15; + break; + case "XVI": + level = 16; + break; + case "XVII": + level = 17; + break; + case "XVIII": + level = 18; + break; + case "XIX": + level = 19; + break; + case "XX": + level = 20; + break; + } + } + boolean matches = false; + if (level > 0) { + switch (comparator) { + case ">": + matches = level > levelToFind; + break; + case "=": + matches = level == levelToFind; + break; + case "<": + matches = level < levelToFind; + break; + } + } + if (matches) { + String enchantText = matcher.group("enchantName"); + StringBuilder extraModifiersBuilder = new StringBuilder(); + + if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.BOLD); + } + if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.ITALIC); + } + if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE); + } + if ((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED); + } + if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.STRIKETHROUGH); + } + + String extraMods = extraModifiersBuilder.toString(); + + if (!colourCode.equals("z")) { + line = line.replace("\u00A79" + enchantText, "\u00A7" + colourCode + extraMods + enchantText); + line = line.replace( + "\u00A79\u00A7d\u00A7l" + enchantText, + "\u00A7" + colourCode + extraMods + enchantText + ); + line = line.replace( + "\u00A7l\u00A7d\u00A7l" + enchantText, + "\u00A7" + colourCode + extraMods + enchantText + ); + } else { + int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( + "\\u00A79" + enchantText + ".*", + "" + )); + line = line.replace( + "\u00A79" + enchantText, + Utils.chromaString(enchantText, offset / 12f + index, false) + ); + + offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( + "\\u00A79\\u00A7d\\u00A7l" + enchantText + ".*", + "" + )); + line = line.replace( + "\u00A79\u00A7d\u00A7l" + enchantText, + Utils.chromaString(enchantText, offset / 12f + index, true) + ); + offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( + "\\u00A7l\\u00A7d\\u00A7l" + enchantText + ".*", + "" + )); + line = line.replace( + "\u00A7l\u00A7d\u00A7l" + enchantText, + Utils.chromaString(enchantText, offset / 12f + index, true) + ); + } + } + } + } + } + + newTooltip.add(line); + + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) { + if (line.contains(EnumChatFormatting.GRAY + "Buy it now: ") || line.contains( + EnumChatFormatting.GRAY + "Bidder: ") || line.contains(EnumChatFormatting.GRAY + "Starting bid: ")) { + + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + newTooltip.add(""); + newTooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]"); + } else { + ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack); + } + } + } + + if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 2 && + Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + if (line.contains(EnumChatFormatting.GREEN + "Open Reward Chest")) { + dungeonProfit = true; + } else if (index == 7 && dungeonProfit) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + + int chestCost = 0; + try { + String line6 = Utils.cleanColour(line); + StringBuilder cost = new StringBuilder(); + for (int i = 0; i < line6.length(); i++) { + char c = line6.charAt(i); + if ("0123456789".indexOf(c) >= 0) { + cost.append(c); + } + } + if (cost.length() > 0) { + chestCost = Integer.parseInt(cost.toString()); + } + } catch (Exception ignored) { + } + + String missingItem = null; + int totalValue = 0; + HashMap<String, Float> itemValues = new HashMap<>(); + for (int i = 0; i < 5; i++) { + ItemStack item = lower.getStackInSlot(11 + i); + String internal = neu.manager.getInternalNameForItem(item); + if (internal != null) { + internal = internal.replace("\u00CD", "I").replace("\u0130", "I"); + float bazaarPrice = -1; + JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal); + if (bazaarInfo != null && bazaarInfo.has("curr_sell")) { + bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat(); + } + if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; + + float worth = -1; + if (bazaarPrice > 0) { + worth = bazaarPrice; + } else { + switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) { + case 1: + worth = neu.manager.auctionManager.getItemAvgBin(internal); + break; + case 2: + JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); + if (auctionInfo != null) { + if (auctionInfo.has("clean_price")) { + worth = (int) auctionInfo.get("clean_price").getAsFloat(); + } else { + worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + } + } + break; + default: + worth = neu.manager.auctionManager.getLowestBin(internal); + } + if (worth <= 0) { + worth = neu.manager.auctionManager.getLowestBin(internal); + if (worth <= 0) { + worth = neu.manager.auctionManager.getItemAvgBin(internal); + if (worth <= 0) { + JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); + if (auctionInfo != null) { + if (auctionInfo.has("clean_price")) { + worth = (int) auctionInfo.get("clean_price").getAsFloat(); + } else { + worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + } + } + } + } + } + } + + if (worth > 0 && totalValue >= 0) { + totalValue += worth; + + String display = item.getDisplayName(); + + if (display.contains("Enchanted Book")) { + NBTTagCompound tag = item.getTagCompound(); + if (tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + NBTTagCompound enchants = ea.getCompoundTag("enchantments"); + + int highestLevel = -1; + for (String enchname : enchants.getKeySet()) { + int level = enchants.getInteger(enchname); + if (level > highestLevel) { + display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(enchname + .replace("_", " ") + .replace("Ultimate", "") + .trim()) + " " + level; + } + } + } + } + + itemValues.put(display, worth); + } else { + if (totalValue != -1) { + missingItem = internal; + } + totalValue = -1; + } + } + } + + NumberFormat format = NumberFormat.getInstance(Locale.US); + String valueStringBIN1; + String valueStringBIN2; + if (totalValue >= 0) { + valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): "; + valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins"; + } else { + valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: "; + valueStringBIN2 = missingItem; + } + + int profitLossBIN = totalValue - chestCost; + String profitPrefix = EnumChatFormatting.DARK_GREEN.toString(); + String lossPrefix = EnumChatFormatting.RED.toString(); + String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix; + + String plStringBIN; + if (profitLossBIN >= 0) { + plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins"; + } else { + plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; + } + + String neu = EnumChatFormatting.YELLOW + "[NEU] "; + + newTooltip.add(neu + valueStringBIN1 + " " + valueStringBIN2); + if (totalValue >= 0) { + newTooltip.add(neu + EnumChatFormatting.YELLOW + "Profit/Loss: " + plStringBIN); + } + + for (Map.Entry<String, Float> entry : itemValues.entrySet()) { + newTooltip.add(neu + entry.getKey() + prefix + "+" + format.format(entry.getValue().intValue())); + } + } + } + + index++; + } + + for (int i = newTooltip.size() - 1; i >= 0; i--) { + String line = Utils.cleanColour(newTooltip.get(i)); + for (int i1 = 0; i1 < Utils.rarityArr.length; i1++) { + if (line.equals(Utils.rarityArr[i1])) { + if (i - 2 < 0) { + break; + } + newTooltip.addAll(i - 1, petToolTipXPExtend(event)); + break; + } + } + } + + pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT); + + event.toolTip.clear(); + event.toolTip.addAll(newTooltip); + + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) { + ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); + } + + if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUHIDEPETTOOLTIP") && + NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip) { + event.toolTip.clear(); + } + } + + private void onItemToolTipInternalNameNull(ItemTooltipEvent event) { + petToolTipXPExtendPetMenu(event); + } + + private List<String> petToolTipXPExtend(ItemTooltipEvent event) { + List<String> tooltipText = new ArrayList<>(); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { + if (event.itemStack.getTagCompound().hasKey("DisablePetExp")) { + if (event.itemStack.getTagCompound().getBoolean("DisablePetExp")) { + return tooltipText; + } + } + //7 is just a random number i chose, prob no pets with less lines than 7 + if (event.toolTip.size() > 7) { + if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) { + + GuiProfileViewer.PetLevel petlevel = null; + + //this is the item itself + NBTTagCompound tag = event.itemStack.getTagCompound(); + if (tag.hasKey("ExtraAttributes")) { + if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) { + JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(tag + .getCompoundTag("ExtraAttributes") + .getString("petInfo"), JsonObject.class); + if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { + JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); + String petName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + //Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); + petlevel = GuiProfileViewer.getPetLevel( + petName, + Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)), + exp.getAsLong() + ); + } + } + } + + if (petlevel != null) { + tooltipText.add(""); + if (petlevel.totalXp > petlevel.maxXP) { + tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "MAX LEVEL"); + } else { + tooltipText.add( + EnumChatFormatting.GRAY + "Progress to Level " + (int) Math.floor(petlevel.level + 1) + ": " + + EnumChatFormatting.YELLOW + Utils.round(petlevel.levelPercentage * 100, 1) + "%"); + int levelpercentage = Math.round(petlevel.levelPercentage * 20); + tooltipText.add( + EnumChatFormatting.DARK_GREEN + String.join("", Collections.nCopies(levelpercentage, "-")) + + EnumChatFormatting.WHITE + String.join("", Collections.nCopies(20 - levelpercentage, "-"))); + tooltipText.add( + EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) + + EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + + myFormatter.format(petlevel.currentLevelRequirement) + " EXP"); + } + } + } + } + } + return tooltipText; + } + + private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) { + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { + //7 is just a random number i chose, prob no pets with less lines than 7 + if (event.toolTip.size() > 7) { + if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) { + GuiProfileViewer.PetLevel petLevel; + + int xpLine = -1; + for (int i = event.toolTip.size() - 1; i >= 0; i--) { + Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i)); + if (matcher.matches()) { + xpLine = i; + event.toolTip.set(xpLine, matcher.group(1)); + break; + } else if (event.toolTip.get(i).matches("MAX LEVEL")) { + return; + } + } + + PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack( + event.itemStack.getDisplayName(), + NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound()) + ); + if (pet == null) { + return; + } + petLevel = pet.petLevel; + + if (petLevel == null || xpLine == -1) { + return; + } + + event.toolTip.add( + xpLine + 1, + EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petLevel.levelXp) + + EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + + myFormatter.format(petLevel.currentLevelRequirement) + ); + + } + } + } + } + + /** + * This method does the following: + * Move the pet inventory display tooltip to the left to avoid conflicts + * Remove reforge stats for Legendary items from Hypixel if enabled + * Show NBT data when holding LCONTROL + */ + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + if (!neu.isOnSkyblock()) return; + if (event.toolTip == null) return; + //Render the pet inventory display tooltip to the left to avoid things from other mods rendering over the tooltip + if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUPETINVDISPLAY")) { + GlStateManager.translate(-200, 0, 0); + } + + if (event.toolTip.size() > 2 && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.hideDefaultReforgeStats) { + String secondLine = StringUtils.stripControlCodes(event.toolTip.get(1)); + if (secondLine.equals("Reforge Stone")) { + Integer startIndex = null; + Integer cutoffIndex = null; + //loop from the back of the List to find the wanted index sooner + for (int i = event.toolTip.size() - 1; i >= 0; i--) { + //rarity or mining level requirement + String line = StringUtils.stripControlCodes(event.toolTip.get(i)); + if (line.contains("REFORGE STONE") || line.contains("Requires Mining Skill Level")) { + cutoffIndex = i; + } + + //The line where the Hypixel stats start + if (line.contains("(Legendary):")) { + startIndex = i; + break; + } + } + if (startIndex != null && cutoffIndex != null && startIndex < cutoffIndex) { + event.toolTip.subList(startIndex, cutoffIndex).clear(); + } + } + } + + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && NotEnoughUpdates.INSTANCE.config.hidden.dev && + event.toolTip.size() > 0 && event.toolTip.get(event.toolTip.size() - 1).startsWith( + EnumChatFormatting.DARK_GRAY + "NBT: ")) { + event.toolTip.remove(event.toolTip.size() - 1); + + StringBuilder sb = new StringBuilder(); + String nbt = event.itemStack.getTagCompound().toString(); + int indent = 0; + for (char c : nbt.toCharArray()) { + boolean newline = false; + if (c == '{' || c == '[') { + indent++; + newline = true; + } else if (c == '}' || c == ']') { + indent--; + sb.append("\n"); + for (int i = 0; i < indent; i++) sb.append(" "); + } else if (c == ',') { + newline = true; + } else if (c == '\"') { + sb.append(EnumChatFormatting.RESET).append(EnumChatFormatting.GRAY); + } + + sb.append(c); + if (newline) { + sb.append("\n"); + for (int i = 0; i < indent; i++) sb.append(" "); + } + } + event.toolTip.add(sb.toString()); + if (Keyboard.isKeyDown(Keyboard.KEY_H)) { + if (!copied) { + copied = true; + StringSelection selection = new StringSelection(sb.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + } + } else { + copied = false; + } + } else if (NotEnoughUpdates.INSTANCE.packDevEnabled) { + event.toolTip.add(""); + event.toolTip.add(EnumChatFormatting.AQUA + "NEU Pack Dev Info:"); + event.toolTip.add("Press " + EnumChatFormatting.GOLD + "[KEY]" + EnumChatFormatting.GRAY + " to copy line"); + + String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + + boolean k = Keyboard.isKeyDown(Keyboard.KEY_K); + boolean m = Keyboard.isKeyDown(Keyboard.KEY_M); + boolean n = Keyboard.isKeyDown(Keyboard.KEY_N); + + event.toolTip.add( + EnumChatFormatting.AQUA + "Internal Name: " + EnumChatFormatting.GRAY + internal + EnumChatFormatting.GOLD + + " [K]"); + if (!copied && k) { + MiscUtils.copyToClipboard(internal); + } + + if (event.itemStack.getTagCompound() != null) { + NBTTagCompound tag = event.itemStack.getTagCompound(); + + if (tag.hasKey("SkullOwner", 10)) { + GameProfile gameprofile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner")); + + if (gameprofile != null) { + event.toolTip.add(EnumChatFormatting.AQUA + "Skull UUID: " + EnumChatFormatting.GRAY + gameprofile.getId() + + EnumChatFormatting.GOLD + " [M]"); + if (!copied && m) { + MiscUtils.copyToClipboard(gameprofile.getId().toString()); + } + + Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = + Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(gameprofile); + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + MinecraftProfileTexture profTex = map.get(MinecraftProfileTexture.Type.SKIN); + event.toolTip.add( + EnumChatFormatting.AQUA + "Skull Texture Link: " + EnumChatFormatting.GRAY + profTex.getUrl() + + EnumChatFormatting.GOLD + " [N]"); + + if (!copied && n) { + MiscUtils.copyToClipboard(profTex.getUrl()); + } + } + } + } + } + + copied = k || m || n; + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java new file mode 100644 index 00000000..ffebdd6b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java @@ -0,0 +1,328 @@ +package io.github.moulberry.notenoughupdates.listener; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.BackgroundBlur; +import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.miscfeatures.*; +import io.github.moulberry.notenoughupdates.miscgui.AccessoryBagOverlay; +import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; +import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.util.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiScreenBook; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.event.ClickEvent; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.input.Keyboard; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static io.github.moulberry.notenoughupdates.util.NotificationHandler.notificationLines; + +public class NEUEventListener { + + private static long notificationDisplayMillis = 0; + private final NotEnoughUpdates neu; + private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10); + private final List<ItemStack> toPreload = new ArrayList<>(); + /** + * When opening a GuiContainer, will reset the overlay and load the config. + * When closing a GuiContainer, will save the config. + * Also includes a dev feature used for automatically acquiring crafting information from the "Crafting Table" GUI. + */ + private boolean joinedSB = false; + + private boolean preloadedItems = false; + private long lastLongUpdate = 0; + private long lastSkyblockScoreboard = 0; + + public NEUEventListener(NotEnoughUpdates neu) { + this.neu = neu; + } + + private void displayUpdateMessageIfOutOfDate() { + File repo = neu.manager.repoLocation; + if (repo.exists()) { + File updateJson = new File(repo, "update.json"); + try { + JsonObject o = neu.manager.getJsonFromFile(updateJson); + + String version = o.get("version").getAsString(); + String preVersion = o.get("pre_version").getAsString(); + + boolean shouldUpdate = !NotEnoughUpdates.VERSION.equalsIgnoreCase(version); + boolean shouldPreUpdate = !NotEnoughUpdates.PRE_VERSION.equalsIgnoreCase(preVersion); + + if (o.has("version_id") && o.get("version_id").isJsonPrimitive()) { + int version_id = o.get("version_id").getAsInt(); + shouldUpdate = version_id > NotEnoughUpdates.VERSION_ID; + } + if (o.has("pre_version_id") && o.get("pre_version_id").isJsonPrimitive()) { + int pre_version_id = o.get("pre_version_id").getAsInt(); + shouldPreUpdate = pre_version_id > NotEnoughUpdates.PRE_VERSION_ID; + } + + if (shouldUpdate) { + String update_msg = o.get("update_msg").getAsString(); + + int first_len = -1; + for (String line : update_msg.split("\n")) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int len = fr.getStringWidth(line); + if (first_len == -1) { + first_len = len; + } + int missing_len = first_len - len; + if (missing_len > 0) { + StringBuilder sb = new StringBuilder(line); + for (int i = 0; i < missing_len / 8; i++) { + sb.insert(0, " "); + } + line = sb.toString(); + } + line = line.replaceAll("\\{version}", version); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); + } + + neu.displayLinks(o); + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + } else if (shouldPreUpdate && NotEnoughUpdates.VERSION_ID == o.get("version").getAsInt()) { + String pre_update_msg = o.get("pre_update_msg").getAsString(); + + int first_len = -1; + for (String line : pre_update_msg.split("\n")) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int len = fr.getStringWidth(line); + if (first_len == -1) { + first_len = len; + } + int missing_len = first_len - len; + if (missing_len > 0) { + StringBuilder sb = new StringBuilder(line); + for (int i = 0; i < missing_len / 8; i++) { + sb.insert(0, " "); + } + line = sb.toString(); + } + line = line.replaceAll("\\{pre_version}", preVersion); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line)); + } + + neu.displayLinks(o); + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + } + } catch (Exception ignored) { + } + } + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Unload event) { + NotEnoughUpdates.INSTANCE.saveConfig(); + CrystalMetalDetectorSolver.reset(false); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + if (Minecraft.getMinecraft().theWorld == null) return; + if (Minecraft.getMinecraft().thePlayer == null) return; + Keyboard.enableRepeatEvents(Minecraft.getMinecraft().currentScreen != null && + (Minecraft.getMinecraft().currentScreen instanceof GuiChat || + Minecraft.getMinecraft().currentScreen instanceof GuiEditSign || + Minecraft.getMinecraft().currentScreen instanceof GuiScreenBook)); + + if ((Keyboard.isKeyDown(Keyboard.KEY_NUMPAD1) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD4) && Keyboard.isKeyDown( + Keyboard.KEY_NUMPAD9))) { + ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!"); + component.appendText("\n"); + component.appendText("\n\u00a77Reason: \u00a7rSuspicious account activity/Other"); + component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal"); + component.appendText("\n"); + component.appendText("\n\u00a77Ban ID: \u00a7r#49871982"); + component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!"); + Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component); + return; + } + + if (neu.hasSkyblockScoreboard()) { + if (!preloadedItems) { + preloadedItems = true; + List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values()); + for (JsonObject json : list) { + itemPreloader.submit(() -> { + ItemStack stack = neu.manager.jsonToStack(json, true, true); + if (stack.getItem() == Items.skull) toPreload.add(stack); + }); + } + } else if (!toPreload.isEmpty()) { + Utils.drawItemStack(toPreload.get(0), -100, -100); + toPreload.remove(0); + } else { + itemPreloader.shutdown(); + } + + for (TextOverlay overlay : OverlayManager.textOverlays) { + overlay.shouldUpdateFrequent = true; + } + } + + boolean longUpdate = false; + long currentTime = System.currentTimeMillis(); + if (currentTime - lastLongUpdate > 1000) { + longUpdate = true; + lastLongUpdate = currentTime; + } + if (!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) { + DungeonBlocks.tick(); + } + DungeonWin.tick(); + + String containerName = null; + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + + if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) { + GuiCustomEnchant.getInstance().tick(); + } + } + + if (longUpdate) { + CrystalOverlay.tick(); + FairySouls.tick(); + XPInformation.getInstance().tick(); + ProfileApiSyncer.getInstance().tick(); + ItemCustomizeManager.tick(); + BackgroundBlur.markDirty(); + NPCRetexturing.getInstance().tick(); + StorageOverlay.getInstance().markDirty(); + + if (neu.hasSkyblockScoreboard()) { + for (TextOverlay overlay : OverlayManager.textOverlays) { + overlay.tick(); + } + } + + NotEnoughUpdates.INSTANCE.overlay.redrawItems(); + CapeManager.onTickSlow(); + + NotEnoughUpdates.profileViewer.putNameUuid( + Minecraft.getMinecraft().thePlayer.getName(), + Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "") + ); + + if (NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) { + DungeonBlocks.tick(); + } + + if (System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 && + System.currentTimeMillis() - SBInfo.getInstance().unloadedWorld > 500) { + neu.updateSkyblockScoreboard(); + } + CapeManager.getInstance().tick(); + + if (containerName != null) { + if (!containerName.trim().startsWith("Accessory Bag")) { + AccessoryBagOverlay.resetCache(); + } + } else { + AccessoryBagOverlay.resetCache(); + } + + if (neu.hasSkyblockScoreboard()) { + SBInfo.getInstance().tick(); + lastSkyblockScoreboard = currentTime; + if (!joinedSB) { + joinedSB = true; + + //SBGamemodes.loadFromFile(); + + if (NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) { + displayUpdateMessageIfOutOfDate(); + } + + if (NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) { + long maxMemoryMB = Runtime.getRuntime().maxMemory() / 1024L / 1024L; + if (maxMemoryMB > 4100) { + notificationDisplayMillis = System.currentTimeMillis(); + notificationLines = new ArrayList<>(); + notificationLines.add(EnumChatFormatting.GRAY + "Too much memory allocated!"); + notificationLines.add(String.format( + EnumChatFormatting.DARK_GRAY + "NEU has detected %03dMB of memory allocated to Minecraft!", + maxMemoryMB + )); + notificationLines.add(EnumChatFormatting.GRAY + "It is recommended to allocated between 2-4GB of memory"); + notificationLines.add( + EnumChatFormatting.GRAY + "More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available"); + notificationLines.add(""); + notificationLines.add( + EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry"); + } + } + + if (!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) { + NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore = true; + if (Constants.MISC == null || !Constants.MISC.has("featureslist")) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "" + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "WARNING: " + EnumChatFormatting.RESET + + EnumChatFormatting.RED + "Could not load Feature List URL from repo.")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "" + EnumChatFormatting.RED + "Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" + + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD + + "restart your game" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " + + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "If that doesn't fix it" + + EnumChatFormatting.RESET + EnumChatFormatting.RED + + ", please join discord.gg/moulberry and post in #neu-support")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "" + EnumChatFormatting.GOLD + "To view the feature list after restarting type /neufeatures")); + } else { + String url = Constants.MISC.get("featureslist").getAsString(); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.BLUE + "It seems this is your first time using NotEnoughUpdates.")); + ChatComponentText clickTextFeatures = new ChatComponentText(EnumChatFormatting.YELLOW + + "Click this message if you would like to view a list of NotEnoughUpdate's Features."); + clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url)); + Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures); + } + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + ChatComponentText clickTextHelp = new ChatComponentText(EnumChatFormatting.YELLOW + + "Click this message if you would like to view a list of NotEnoughUpdate's commands."); + clickTextHelp.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neuhelp")); + Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextHelp); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + } + } + } + if (currentTime - lastSkyblockScoreboard < 5 * 60 * 1000) { //5 minutes + neu.manager.auctionManager.tick(); + } else { + neu.manager.auctionManager.markNeedsUpdate(); + } + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java new file mode 100644 index 00000000..9c12e732 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -0,0 +1,1183 @@ +package io.github.moulberry.notenoughupdates.listener; + +import com.google.common.collect.Lists; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NEUApi; +import io.github.moulberry.notenoughupdates.NEUOverlay; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.auction.CustomAHGui; +import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; +import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; +import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; +import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; +import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.miscgui.*; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.RancherBootOverlay; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.util.NotificationHandler; +import io.github.moulberry.notenoughupdates.util.RequestFocusListener; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ClientCommandHandler; +import net.minecraftforge.client.event.*; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.commons.lang3.text.WordUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import javax.swing.*; +import java.io.IOException; +import java.text.NumberFormat; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import static io.github.moulberry.notenoughupdates.util.GuiTextures.dungeon_chest_worth; + +public class RenderListener { + private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png"); + public static boolean disableCraftingText = false; + public static boolean drawingGuiScreen = false; + public static long lastGuiClosed = 0; + public static boolean inventoryLoaded = false; + private final NotEnoughUpdates neu; + ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); + JsonObject essenceJson = new JsonObject(); + private boolean hoverInv = false; + private boolean focusInv = false; + private boolean doInventoryButtons = false; + private NEUConfig.InventoryButton buttonHovered = null; + private long buttonHoveredMillis = 0; + private int inventoryLoadedTicks = 0; + private String loadedInvName = ""; + + public RenderListener(NotEnoughUpdates neu) { + this.neu = neu; + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre<EntityPlayer> event) { + if (Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) { + if (((GuiProfileViewer) Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) { + event.setCanceled(true); + } + } + } + + @SubscribeEvent + public void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) { + if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && + Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) { + event.setCanceled(true); + } + if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.PLAYER_LIST)) { + GlStateManager.enableDepth(); + } + } + + @SubscribeEvent + public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) { + if (neu.hasSkyblockScoreboard() && event.type.equals(RenderGameOverlayEvent.ElementType.ALL)) { + DungeonWin.render(event.partialTicks); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, -200); + for (TextOverlay overlay : OverlayManager.textOverlays) { + if (OverlayManager.dontRenderOverlay != null && + OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) { + continue; + } + GlStateManager.translate(0, 0, -1); + GlStateManager.enableDepth(); + overlay.render(); + } + GlStateManager.popMatrix(); + OverlayManager.dontRenderOverlay = null; + } + if (Keyboard.isKeyDown(Keyboard.KEY_X)) { + NotificationHandler.notificationDisplayMillis = 0; + } + + if (event.type == RenderGameOverlayEvent.ElementType.ALL) { + NotificationHandler.renderNotification(); + } + + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + if (Minecraft.getMinecraft().theWorld == null) return; + if (Minecraft.getMinecraft().thePlayer == null) return; + + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) chest.inventorySlots; + + if (!loadedInvName.equals(cc.getLowerChestInventory().getDisplayName().getUnformattedText())) { + loadedInvName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + inventoryLoaded = false; + inventoryLoadedTicks = 3; + } + + if (!inventoryLoaded) { + if (cc.getLowerChestInventory().getStackInSlot(cc.getLowerChestInventory().getSizeInventory() - 1) != null) { + inventoryLoaded = true; + } else { + for (ItemStack stack : chest.inventorySlots.getInventory()) { + if (stack != null) { + if (--inventoryLoadedTicks <= 0) { + inventoryLoaded = true; + } + break; + } + } + } + } + } else { + inventoryLoaded = false; + inventoryLoadedTicks = 3; + } + + } + + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) { + NEUApi.disableInventoryButtons = false; + + if ((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper || + Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) && event.gui == null && + !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) && + System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.lastOpenedGui < 500) { + NotEnoughUpdates.INSTANCE.lastOpenedGui = 0; + event.setCanceled(true); + return; + } + + if (!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) { + CalendarOverlay.setEnabled(false); + } + + if (Minecraft.getMinecraft().currentScreen != null) { + lastGuiClosed = System.currentTimeMillis(); + } + + neu.manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis(); + BetterContainers.reset(); + inventoryLoaded = false; + inventoryLoadedTicks = 3; + + if (event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() && + !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { + event.gui = new CustomAHGui(); + } + + if (!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) { + neu.manager.auctionManager.customAH.setRenderOverAuctionView(false); + } else if (event.gui instanceof GuiChest && (neu.manager.auctionManager.customAH.isRenderOverAuctionView() || + Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { + GuiChest chest = (GuiChest) event.gui; + ContainerChest container = (ContainerChest) chest.inventorySlots; + String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + + neu.manager.auctionManager.customAH.setRenderOverAuctionView( + containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View") || + containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")); + } + + //OPEN + if (Minecraft.getMinecraft().currentScreen == null && event.gui instanceof GuiContainer) { + neu.overlay.reset(); + } + if (event.gui != null && NotEnoughUpdates.INSTANCE.config.hidden.dev) { + if (event.gui instanceof GuiChest) { + GuiChest eventGui = (GuiChest) event.gui; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + ses.schedule(() -> { + if (Minecraft.getMinecraft().currentScreen != event.gui) { + return; + } + if (lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) { + try { + ItemStack res = lower.getStackInSlot(25); + String resInternalname = neu.manager.getInternalNameForItem(res); + + if (lower.getStackInSlot(48) != null) { + String backName = null; + NBTTagCompound tag = lower.getStackInSlot(48).getTagCompound(); + if (tag.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = tag.getCompoundTag("display"); + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + backName = nbttaglist1.getStringTagAt(0); + } + } + + if (backName != null) { + String[] split = backName.split(" "); + if (split[split.length - 1].contains("Rewards")) { + String col = backName.substring( + split[0].length() + 1, + backName.length() - split[split.length - 1].length() - 1 + ); + + JsonObject json = neu.manager.getItemInformation().get(resInternalname); + json.addProperty("crafttext", "Requires: " + col); + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "Added: " + resInternalname)); + neu.manager.writeJsonDefaultDir(json, resInternalname + ".json"); + neu.manager.loadItem(resInternalname); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }, 200, TimeUnit.MILLISECONDS); + } + } + } + + /** + * Sets hoverInv and focusInv variables, representing whether the NEUOverlay should render behind the inventory when + * (hoverInv == true) and whether mouse/kbd inputs shouldn't be sent to NEUOverlay (focusInv == true). + * <p> + * If hoverInv is true, will render the overlay immediately (resulting in the inventory being drawn over the GUI) + * If hoverInv is false, the overlay will render in #onGuiScreenDraw (resulting in the GUI being drawn over the inv) + * <p> + * All of this only matters if players are using gui scale auto which may result in the inventory being drawn + * over the various panes. + */ + @SubscribeEvent + public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) { + if (NotificationHandler.showNotificationOverInv) { + + NotificationHandler.renderNotification(); + + } + if ((NotificationHandler.shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && + neu.isOnSkyblock()) { + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledresolution.getScaledWidth(); + + boolean hoverPane = event.getMouseX() < width * neu.overlay.getInfoPaneOffsetFactor() || + event.getMouseX() > width * neu.overlay.getItemPaneOffsetFactor(); + + if (event.gui instanceof GuiContainer) { + try { + int xSize = ((GuiContainer) event.gui).xSize; + int ySize = ((GuiContainer) event.gui).ySize; + int guiLeft = ((GuiContainer) event.gui).guiLeft; + int guiTop = ((GuiContainer) event.gui).guiTop; + + hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && event.getMouseY() > guiTop && + event.getMouseY() < guiTop + ySize; + + if (hoverPane) { + if (!hoverInv) focusInv = false; + } else { + focusInv = true; + } + } catch (NullPointerException npe) { + focusInv = !hoverPane; + } + } + if (event.gui instanceof GuiItemRecipe) { + GuiItemRecipe guiItemRecipe = ((GuiItemRecipe) event.gui); + hoverInv = event.getMouseX() > guiItemRecipe.guiLeft && + event.getMouseX() < guiItemRecipe.guiLeft + guiItemRecipe.xSize && event.getMouseY() > guiItemRecipe.guiTop && + event.getMouseY() < guiItemRecipe.guiTop + guiItemRecipe.ySize; + + if (hoverPane) { + if (!hoverInv) focusInv = false; + } else { + focusInv = true; + } + } + if (focusInv) { + try { + neu.overlay.render(hoverInv); + } catch (ConcurrentModificationException e) { + e.printStackTrace(); + } + GL11.glTranslatef(0, 0, 10); + } + if (hoverInv) { + renderDungeonChestOverlay(event.gui); + if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { + AccessoryBagOverlay.renderOverlay(); + } + } + } + + drawingGuiScreen = true; + } + + @SubscribeEvent + public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) { + doInventoryButtons = false; + + if (AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.render(); + event.setCanceled(true); + return; + } + if (RancherBootOverlay.shouldReplace()) { + RancherBootOverlay.render(); + event.setCanceled(true); + return; + } + + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if (guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + + if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) { + GuiCustomEnchant.getInstance().render(event.renderPartialTicks); + event.setCanceled(true); + return; + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = + event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if (storageOverlayActive) { + StorageOverlay.getInstance().render(); + event.setCanceled(true); + return; + } + + if (tradeWindowActive || customAhActive) { + event.setCanceled(true); + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + //Dark background + Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680); + + if (event.mouseX < width * neu.overlay.getWidthMult() / 3 || + event.mouseX > width - width * neu.overlay.getWidthMult() / 3) { + if (customAhActive) { + neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); + } else { + TradeWindow.render(event.mouseX, event.mouseY); + } + neu.overlay.render(false); + } else { + neu.overlay.render(false); + if (customAhActive) { + neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); + } else { + TradeWindow.render(event.mouseX, event.mouseY); + } + } + } + + if (CalendarOverlay.isEnabled() || event.isCanceled()) return; + if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && + event.gui instanceof GuiContainer) { + doInventoryButtons = true; + + int zOffset = 50; + + GlStateManager.translate(0, 0, zOffset); + + int xSize = ((GuiContainer) event.gui).xSize; + int ySize = ((GuiContainer) event.gui).ySize; + int guiLeft = ((GuiContainer) event.gui).guiLeft; + int guiTop = ((GuiContainer) event.gui).guiTop; + + if (!NEUApi.disableInventoryButtons) { + for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if (!button.isActive()) continue; + if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft + button.x; + int y = guiTop + button.y; + if (button.anchorRight) { + x += xSize; + } + if (button.anchorBottom) { + y += ySize; + } + if (AccessoryBagOverlay.isInAccessoryBag()) { + if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { + x += 80 + 28; + } + } + if (NEUOverlay.isRenderingArmorHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { + x -= 25; + } + } + if (NEUOverlay.isRenderingPetHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { + x -= 25; + } + } + + GlStateManager.color(1, 1, 1, 1f); + + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); + Utils.drawTexturedRect( + x, + y, + 18, + 18, + button.backgroundIndex * 18 / 256f, + (button.backgroundIndex * 18 + 18) / 256f, + 18 / 256f, + 36 / 256f, + GL11.GL_NEAREST + ); + + if (button.icon != null && !button.icon.trim().isEmpty()) { + GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1); + } + } + } + GlStateManager.translate(0, 0, -zOffset); + } + } + + /** + * Will draw the NEUOverlay over the inventory if focusInv == false. (z-translation of 300 is so that NEUOverlay + * will draw over Items in the inventory (which render at a z value of about 250)) + */ + @SubscribeEvent + public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) { + drawingGuiScreen = false; + disableCraftingText = false; + + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if (guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + + if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) return; + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = + event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if (!(tradeWindowActive || storageOverlayActive || customAhActive)) { + if (NotificationHandler.shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + GlStateManager.pushMatrix(); + if (!focusInv) { + GL11.glTranslatef(0, 0, 300); + neu.overlay.render(hoverInv && focusInv); + GL11.glTranslatef(0, 0, -300); + } + GlStateManager.popMatrix(); + } + } + + if (NotificationHandler.shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) { + renderDungeonChestOverlay(event.gui); + if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) { + AccessoryBagOverlay.renderOverlay(); + } + } + + boolean hoveringButton = false; + if (!doInventoryButtons) return; + if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && + event.gui instanceof GuiContainer) { + int xSize = ((GuiContainer) event.gui).xSize; + int ySize = ((GuiContainer) event.gui).ySize; + int guiLeft = ((GuiContainer) event.gui).guiLeft; + int guiTop = ((GuiContainer) event.gui).guiTop; + + if (!NEUApi.disableInventoryButtons) { + for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if (!button.isActive()) continue; + if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft + button.x; + int y = guiTop + button.y; + if (button.anchorRight) { + x += xSize; + } + if (button.anchorBottom) { + y += ySize; + } + if (AccessoryBagOverlay.isInAccessoryBag()) { + if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { + x += 80 + 28; + } + } + if (NEUOverlay.isRenderingArmorHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { + x -= 25; + } + } + if (NEUOverlay.isRenderingPetHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { + x -= 25; + } + } + + if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) { + disableCraftingText = true; + } + + if (event.mouseX >= x && event.mouseX <= x + 18 && event.mouseY >= y && event.mouseY <= y + 18) { + hoveringButton = true; + long currentTime = System.currentTimeMillis(); + + if (buttonHovered != button) { + buttonHoveredMillis = currentTime; + buttonHovered = button; + } + + if (currentTime - buttonHoveredMillis > 600) { + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; + } + + Utils.drawHoveringText( + Lists.newArrayList("\u00a77" + command), + event.mouseX, + event.mouseY, + event.gui.width, + event.gui.height, + -1, + Minecraft.getMinecraft().fontRendererObj + ); + } + } + } + } + } + if (!hoveringButton) buttonHovered = null; + + if (AuctionBINWarning.getInstance().shouldShow()) { + AuctionBINWarning.getInstance().render(); + } + } + + private void renderDungeonChestOverlay(GuiScreen gui) { + if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return; + + if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) { + try { + int xSize = ((GuiContainer) gui).xSize; + int guiLeft = ((GuiContainer) gui).guiLeft; + int guiTop = ((GuiContainer) gui).guiTop; + + GuiChest eventGui = (GuiChest) gui; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + + ItemStack rewardChest = lower.getStackInSlot(31); + if (rewardChest != null && rewardChest.getDisplayName().endsWith( + EnumChatFormatting.GREEN + "Open Reward Chest")) { + int chestCost = 0; + try { + String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]); + StringBuilder cost = new StringBuilder(); + for (int i = 0; i < line6.length(); i++) { + char c = line6.charAt(i); + if ("0123456789".indexOf(c) >= 0) { + cost.append(c); + } + } + if (cost.length() > 0) { + chestCost = Integer.parseInt(cost.toString()); + } + } catch (Exception ignored) { + } + + String missingItem = null; + int totalValue = 0; + HashMap<String, Float> itemValues = new HashMap<>(); + for (int i = 0; i < 5; i++) { + ItemStack item = lower.getStackInSlot(11 + i); + String internal = neu.manager.getInternalNameForItem(item); + if (internal != null) { + internal = internal.replace("\u00CD", "I").replace("\u0130", "I"); + float bazaarPrice = -1; + JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal); + if (bazaarInfo != null && bazaarInfo.has("curr_sell")) { + bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat(); + } + if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; + + float worth = -1; + if (bazaarPrice > 0) { + worth = bazaarPrice; + } else { + switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) { + case 1: + worth = neu.manager.auctionManager.getItemAvgBin(internal); + break; + case 2: + JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); + if (auctionInfo != null) { + if (auctionInfo.has("clean_price")) { + worth = (int) auctionInfo.get("clean_price").getAsFloat(); + } else { + worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + } + } + break; + default: + worth = neu.manager.auctionManager.getLowestBin(internal); + } + if (worth <= 0) { + worth = neu.manager.auctionManager.getLowestBin(internal); + if (worth <= 0) { + worth = neu.manager.auctionManager.getItemAvgBin(internal); + if (worth <= 0) { + JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); + if (auctionInfo != null) { + if (auctionInfo.has("clean_price")) { + worth = (int) auctionInfo.get("clean_price").getAsFloat(); + } else { + worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + } + } + } + } + } + } + + if (worth > 0 && totalValue >= 0) { + totalValue += worth; + String display = item.getDisplayName(); + + if (display.contains("Enchanted Book")) { + NBTTagCompound tag = item.getTagCompound(); + if (tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + NBTTagCompound enchants = ea.getCompoundTag("enchantments"); + + int highestLevel = -1; + for (String enchname : enchants.getKeySet()) { + int level = enchants.getInteger(enchname); + if (level > highestLevel) { + display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(enchname + .replace("_", " ") + .replace("Ultimate", "") + .trim()) + " " + level; + } + } + } + } + + itemValues.put(display, worth); + } else { + if (totalValue != -1) { + missingItem = internal; + } + totalValue = -1; + } + } + } + + NumberFormat format = NumberFormat.getInstance(Locale.US); + String valueStringBIN1; + String valueStringBIN2; + if (totalValue >= 0) { + valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): "; + valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins"; + } else { + valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: "; + valueStringBIN2 = missingItem; + } + + int profitLossBIN = totalValue - chestCost; + + boolean kismetUsed = false; + // checking for kismet + Slot slot = (eventGui.inventorySlots.getSlot(50)); + if (slot.getHasStack()) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(slot.getStack().getTagCompound()); + for (String line : lore) { + if (line.contains("You already rerolled a chest!")) { + kismetUsed = true; + break; + } + } + } + int kismetPrice = neu.manager.auctionManager.getLowestBin("KISMET_FEATHER"); + String kismetStr = EnumChatFormatting.RED + format.format(kismetPrice) + " coins"; + if (neu.config.dungeons.useKismetOnDungeonProfit) + profitLossBIN = kismetUsed ? profitLossBIN - kismetPrice : profitLossBIN; + + String profitPrefix = EnumChatFormatting.DARK_GREEN.toString(); + String lossPrefix = EnumChatFormatting.RED.toString(); + String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix; + + String plStringBIN; + if (profitLossBIN >= 0) { + plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins"; + } else { + plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; + } + + if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) { + int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(plStringBIN); + GlStateManager.disableLighting(); + GlStateManager.translate(0, 0, 200); + Minecraft.getMinecraft().fontRendererObj.drawString( + plStringBIN, + guiLeft + xSize - 5 - w, + guiTop + 5, + 0xffffffff, + true + ); + GlStateManager.translate(0, 0, -200); + return; + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth); + GL11.glColor4f(1, 1, 1, 1); + GlStateManager.disableLighting(); + Utils.drawTexturedRect(guiLeft + xSize + 4, guiTop, 180, 101, 0, 180 / 256f, 0, 101 / 256f, GL11.GL_NEAREST); + + Utils.renderAlignedString(valueStringBIN1, valueStringBIN2, guiLeft + xSize + 4 + 10, guiTop + 14, 160); + if (neu.config.dungeons.useKismetOnDungeonProfit && kismetUsed) { + Utils.renderAlignedString( + EnumChatFormatting.YELLOW + "Kismet Feather: ", + kismetStr, + guiLeft + xSize + 4 + 10, + guiTop + 24, + 160 + ); + } + if (totalValue >= 0) { + Utils.renderAlignedString( + EnumChatFormatting.YELLOW + "Profit/Loss: ", + plStringBIN, + guiLeft + xSize + 4 + 10, + guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 34 : 24) : 24), + 160 + ); + } + + int index = 0; + for (Map.Entry<String, Float> entry : itemValues.entrySet()) { + Utils.renderAlignedString( + entry.getKey(), + prefix + format.format(entry.getValue().intValue()), + guiLeft + xSize + 4 + 10, + guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 39 : 29) : 29) + (++index) * 10, + 160 + ); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Sends a mouse event to NEUOverlay if the inventory isn't hovered AND focused. + * Will also cancel the event if if NEUOverlay#mouseInput returns true. + */ + @SubscribeEvent(priority = EventPriority.LOW) + public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) { + if (Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) { + event.setCanceled(true); + return; + } + + 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 (AuctionBINWarning.getInstance().shouldShow()) { + AuctionBINWarning.getInstance().mouseInput(mouseX, mouseY); + event.setCanceled(true); + return; + } + + if (!event.isCanceled()) { + Utils.scrollTooltip(Mouse.getEventDWheel()); + } + if (AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.mouseEvent(); + event.setCanceled(true); + return; + } + if (RancherBootOverlay.shouldReplace()) { + RancherBootOverlay.mouseEvent(); + event.setCanceled(true); + return; + } + + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if (guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if (containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 && + eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && + Mouse.getEventButton() >= 0) { + event.setCanceled(true); + if (Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && + eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null) { + NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound(); + if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) { + String username = tag.getCompoundTag("SkullOwner").getString("Name"); + Utils.playPressSound(); + ViewProfileCommand.RUNNABLE.accept(new String[]{username}); + } + } + } + } + + if (GuiCustomEnchant.getInstance().shouldOverride(containerName) && + GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) { + event.setCanceled(true); + return; + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = + event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if (storageOverlayActive) { + if (StorageOverlay.getInstance().mouseInput(mouseX, mouseY)) { + event.setCanceled(true); + } + return; + } + + if (tradeWindowActive || customAhActive) { + event.setCanceled(true); + if (customAhActive) { + neu.manager.auctionManager.customAH.handleMouseInput(); + } else { + TradeWindow.handleMouseInput(); + } + neu.overlay.mouseInput(); + return; + } + + if (NotificationHandler.shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + if (!NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay || !AccessoryBagOverlay.mouseClick()) { + if (!(hoverInv && focusInv)) { + if (neu.overlay.mouseInput()) { + event.setCanceled(true); + } + } else { + neu.overlay.mouseInputInv(); + } + } + } + if (event.isCanceled()) return; + if (!doInventoryButtons) return; + if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && + Mouse.getEventButton() >= 0 && event.gui instanceof GuiContainer) { + int xSize = ((GuiContainer) event.gui).xSize; + int ySize = ((GuiContainer) event.gui).ySize; + int guiLeft = ((GuiContainer) event.gui).guiLeft; + int guiTop = ((GuiContainer) event.gui).guiTop; + if (!NEUApi.disableInventoryButtons) { + for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if (!button.isActive()) continue; + if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft + button.x; + int y = guiTop + button.y; + if (button.anchorRight) { + x += xSize; + } + if (button.anchorBottom) { + y += ySize; + } + if (AccessoryBagOverlay.isInAccessoryBag()) { + if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { + x += 80 + 28; + } + } + if (NEUOverlay.isRenderingArmorHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { + x -= 25; + } + } + if (NEUOverlay.isRenderingPetHud()) { + if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { + x -= 25; + } + } + + if (mouseX >= x && mouseX <= x + 18 && mouseY >= y && mouseY <= y + 18) { + if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { + int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; + if ((clickType == 0 && Mouse.getEventButtonState()) || (clickType == 1 && !Mouse.getEventButtonState())) { + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; + } + if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { + NotEnoughUpdates.INSTANCE.sendChatMessage(command); + } + } + } else { + event.setCanceled(true); + } + return; + } + } + } + } + } + + /** + * 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. + */ + @SubscribeEvent + public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) { + if (AuctionBINWarning.getInstance().shouldShow()) { + AuctionBINWarning.getInstance().keyboardInput(); + event.setCanceled(true); + return; + } + + if (AuctionSearchOverlay.shouldReplace()) { + AuctionSearchOverlay.keyEvent(); + event.setCanceled(true); + return; + } + if (RancherBootOverlay.shouldReplace()) { + RancherBootOverlay.keyEvent(); + event.setCanceled(true); + return; + } + + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + + if (guiScreen instanceof GuiChest) { + containerName = ((ContainerChest) ((GuiChest) guiScreen).inventorySlots) + .getLowerChestInventory() + .getDisplayName() + .getUnformattedText(); + } + + if (GuiCustomEnchant.getInstance().shouldOverride(containerName) && + GuiCustomEnchant.getInstance().keyboardInput()) { + event.setCanceled(true); + return; + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = + event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if (storageOverlayActive) { + if (StorageOverlay.getInstance().keyboardInput()) { + event.setCanceled(true); + return; + } + } + + if (tradeWindowActive || customAhActive) { + if (customAhActive) { + if (neu.manager.auctionManager.customAH.keyboardInput()) { + event.setCanceled(true); + Minecraft.getMinecraft().dispatchKeypresses(); + } else if (neu.overlay.keyboardInput(focusInv)) { + event.setCanceled(true); + } + } else { + TradeWindow.keyboardInput(); + if (Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) { + event.setCanceled(true); + Minecraft.getMinecraft().dispatchKeypresses(); + neu.overlay.keyboardInput(focusInv); + } + } + return; + } + + if (NotificationHandler.shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + if (neu.overlay.keyboardInput(focusInv)) { + event.setCanceled(true); + } + } + if (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.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 (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && + Minecraft.getMinecraft().theWorld != null && Keyboard.getEventKey() == Keyboard.KEY_O && + 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.getStackInSlot(23) != null && lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) { + ItemStack res = lower.getStackInSlot(25); + String resInternalname = neu.manager.getInternalNameForItem(res); + JTextField tf = new JTextField(); + tf.setText(resInternalname); + tf.addAncestorListener(new RequestFocusListener()); + JOptionPane.showOptionDialog( + null, + tf, + "Enter Name:", + JOptionPane.NO_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, + new String[]{"Enter"}, + "Enter" + ); + resInternalname = tf.getText(); + if (resInternalname.trim().length() == 0) { + return; + } + + JsonObject recipe = new JsonObject(); + + String[] x = {"1", "2", "3"}; + String[] y = {"A", "B", "C"}; + + for (int i = 0; i <= 18; i += 9) { + for (int j = 0; j < 3; j++) { + ItemStack stack = lower.getStackInSlot(10 + i + j); + String internalname = ""; + if (stack != null) { + internalname = neu.manager.getInternalNameForItem(stack); + if (!neu.manager.getItemInformation().containsKey(internalname)) { + neu.manager.writeItemToFile(stack); + } + internalname += ":" + stack.stackSize; + } + recipe.addProperty(y[i / 9] + x[j], internalname); + } + } + + JsonObject json = neu.manager.getJsonForItem(res); + json.add("recipe", recipe); + json.addProperty("internalname", resInternalname); + json.addProperty("clickcommand", "viewrecipe"); + json.addProperty("modver", NotEnoughUpdates.VERSION); + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname)); + neu.manager.writeJsonDefaultDir(json, resInternalname + ".json"); + neu.manager.loadItem(resInternalname); + } catch (IOException ignored) { + } + } + } + } + } + + @SubscribeEvent + public void onRenderLast(RenderWorldLastEvent event) { + CrystalMetalDetectorSolver.render(event.partialTicks); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java index c1ce229c..811c30d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java @@ -1,8 +1,8 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.renderer.GlStateManager; @@ -69,7 +69,7 @@ public class BetterContainers { public static void bindHook(TextureManager textureManager, ResourceLocation location) { long currentMillis = System.currentTimeMillis(); - if (isChestOpen() && NEUEventListener.inventoryLoaded) { + if (isChestOpen() && RenderListener.inventoryLoaded) { int invHashcode = lastInvHashcode; if (currentMillis - lastHashcodeCheck > 50) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java deleted file mode 100644 index c550ce53..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.moulberry.notenoughupdates.miscfeatures; - -import io.github.moulberry.notenoughupdates.collectionlog.CollectionConstant; -import io.github.moulberry.notenoughupdates.util.Constants; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; - -import java.util.regex.Matcher; - -public class CollectionLogManager { - private static final CollectionLogManager INSTANCE = new CollectionLogManager(); - - public static CollectionLogManager getInstance() { - return INSTANCE; - } - - public void onEntityMetadataUpdated(int entityId) { - System.out.println("entity created:" + entityId); - WorldClient world = Minecraft.getMinecraft().theWorld; - if (world != null) { - Entity entity = world.getEntityByID(entityId); - - if (entity instanceof EntityArmorStand && entity.hasCustomName()) { - String customName = entity.getName(); - System.out.println("got name:" + customName); - for (CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) { - System.out.println("iter entry"); - if (entry.type.equalsIgnoreCase("itemdrop")) { - Matcher matcher = entry.regex.matcher(customName); - if (matcher.matches()) { - System.out.println("Match found!"); - System.out.println("Count: " + matcher.group("count")); - System.out.println("Name: " + matcher.group("itemname")); - } else { - System.out.println("Doesn't match: " + customName); - } - } - } - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java deleted file mode 100644 index 12e65e65..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java +++ /dev/null @@ -1,293 +0,0 @@ -package io.github.moulberry.notenoughupdates.miscfeatures; - -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.chunk.CompiledChunk; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.network.play.server.S07PacketRespawn; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderLivingEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.util.glu.Project; - -import java.nio.ByteBuffer; -import java.util.List; - -public class FancyPortals { - private static final ResourceLocation[] RENDERS = new ResourceLocation[6]; - - static { - for (int i = 0; i < 6; i++) { - RENDERS[i] = new ResourceLocation("notenoughupdates:portal_panoramas/nether/pansc-" + (i + 1) + ".png"); - } - } - - public static int perspectiveId = -1; - - public static boolean overridePerspective() { - if (perspectiveId >= 0 && !Keyboard.isKeyDown(Keyboard.KEY_K)) { - if (perspectiveId == 0) { - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, 7, 7, 0.0D, -100D, 100D); - GlStateManager.scale(1, 1, -1); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.translate(3.5F, 3.5F, -1.0F); - GlStateManager.rotate(-90, 1, 0, 0); - } else if (perspectiveId <= 4) { - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.rotate(perspectiveId * 90, 0, 1, 0); - GlStateManager.translate(0, -3.5f, 0); - } else { - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.rotate(-90, 1, 0, 0); - GlStateManager.translate(0, -3.5f, 0); - } - - return true; - } - return false; - } - - private static WorldRenderer surfaceWorldRenderer = null; - - private static WorldRenderer getSurfaceWorldRenderer() { - if (surfaceWorldRenderer != null && !Keyboard.isKeyDown(Keyboard.KEY_O)) { - return surfaceWorldRenderer; - } - - surfaceWorldRenderer = createSurfaceWorldRenderer(); - - return surfaceWorldRenderer; - } - - private static void drawPoint(WorldRenderer worldRenderer, int x, int y) { - float xDist = 1 - Math.abs(x - 50) / 50f; - float yDist = 1 - Math.abs(y - 50) / 50f; - float distToEdge = Math.min(xDist, yDist); - - float z = 0.4142f; - if (distToEdge < 1 / 3.5f) { - if (y > 50 && yDist < xDist) { - float circleH = 1.414f - distToEdge * 3.5f * 1.414f; - z = (float) Math.sqrt(2f - circleH * circleH); - z *= 0.4142f / 1.4142f; - } else { - float circleH = 1 - distToEdge * 3.5f; - z = (float) Math.sqrt(2f - circleH * circleH) - 1; - } - } - - worldRenderer.pos(x * 7 / 100f, y * 7 / 100f, z).tex(x / 100f, y / 100f).endVertex(); - } - - private static WorldRenderer createSurfaceWorldRenderer() { - WorldRenderer worldRenderer = new WorldRenderer(20 * 100 * 100); - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - - for (int x = 0; x < 100; x++) { - for (int y = 0; y < 100; y++) { - drawPoint(worldRenderer, x, y); - drawPoint(worldRenderer, x, y + 1); - drawPoint(worldRenderer, x + 1, y + 1); - drawPoint(worldRenderer, x + 1, y); - } - } - - return worldRenderer; - } - - private static long overridingRenderMillis = -1; - - public static void onRespawnPacket(S07PacketRespawn packet) { - if (true) return; - if (packet.getDimensionID() != Minecraft.getMinecraft().thePlayer.dimension) { - overridingRenderMillis = System.currentTimeMillis(); - } - } - - public static boolean shouldRenderLoadingScreen() { - return false; - } - - public static boolean shouldRenderWorldOverlay() { - if (overridingRenderMillis > 0) { - if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) { - RenderGlobal renderGlobal = Minecraft.getMinecraft().renderGlobal; - int loaded = 0; - for (RenderGlobal.ContainerLocalRenderInformation info : renderGlobal.renderInfos) { - CompiledChunk compiledchunk = info.renderChunk.compiledChunk; - - if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty()) { - if (++loaded >= 5) { - overridingRenderMillis = -1; - return false; - } - } - } - } - if (System.currentTimeMillis() - overridingRenderMillis > 1000) { - overridingRenderMillis = -1; - return false; - } - return true; - } - return false; - } - - public static void onUpdateCameraAndRender(float partialTicks, long nanoTime) { - if (overridingRenderMillis > 0) { - if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) { - Minecraft.getMinecraft().thePlayer.timeInPortal = 0.3f; - Minecraft.getMinecraft().thePlayer.prevTimeInPortal = 0.3f; - } - - GlStateManager.rotate(90, 0, 1, 0); - renderWorld(); - - Minecraft.getMinecraft().ingameGUI.renderGameOverlay(partialTicks); - } - } - - @SubscribeEvent - public void onRenderEntityYeeter(RenderLivingEvent.Pre<EntityLivingBase> event) { - /*if(!Keyboard.isKeyDown(Keyboard.KEY_G)) return; - event.setCanceled(true); - if(event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; - if(player.getUniqueID().version() == 4) { - event.setCanceled(true); - } - }*/ - } - - private static void renderWorld() { - for (int i = 5; i >= 0; i--) { - GlStateManager.pushMatrix(); - - GlStateManager.disableDepth(); - GlStateManager.disableLighting(); - - GlStateManager.rotate(180, 0, 0, 1); - GlStateManager.rotate(-90, 0, 1, 0); - - if (i != 0) GlStateManager.translate(0, -3.49, 0); - - switch (i) { - case 1: - GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); - break; - case 2: - GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); - break; - case 3: - GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); - break; - case 5: - GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); - break; - case 0: - GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); - break; - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(RENDERS[i]); - GlStateManager.color(1, 1, 1, 1); - if (i != 0) GlStateManager.translate(0, 0, 3.49); - - if (i != 0) { - GlStateManager.translate(-3.5f, -3.5f, 0); - WorldRenderer worldRenderer = getSurfaceWorldRenderer(); - VertexFormat vertexformat = worldRenderer.getVertexFormat(); - int stride = vertexformat.getNextOffset(); - ByteBuffer bytebuffer = worldRenderer.getByteBuffer(); - List<VertexFormatElement> list = vertexformat.getElements(); - - for (int index = 0; index < list.size(); index++) { - VertexFormatElement vertexformatelement = list.get(index); - vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer); - } - - GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount()); - - for (int index = 0; index < list.size(); index++) { - VertexFormatElement vertexformatelement = list.get(index); - vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer); - } - } else { - Utils.drawTexturedRect(-3.5f, -3.5f, 7, 7, i == 0 ? GL11.GL_NEAREST : GL11.GL_LINEAR); - } - - GlStateManager.enableDepth(); - - GlStateManager.popMatrix(); - } - } - - @SubscribeEvent - public void onRenderLast(RenderWorldLastEvent event) { - if (true) return; - if (!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled()) - Minecraft.getMinecraft().getFramebuffer().enableStencil(); - - GL11.glEnable(GL11.GL_STENCIL_TEST); - GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); - GL11.glStencilOp(GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_REPLACE); - GL11.glStencilMask(0xFF); - GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); - GlStateManager.enableDepth(); - GlStateManager.enableCull(); - GlStateManager.cullFace(GL11.GL_BACK); - - GL11.glColorMask(false, false, false, false); - - 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; - GlStateManager.pushMatrix(); - - GlStateManager.translate(-viewerX + 12 + 5 / 16f, -viewerY + 100, -viewerZ + 39); - GlStateManager.rotate(90, 0, 1, 0); - Gui.drawRect(0, 5, 3, 0, 0xffffffff); - GlStateManager.rotate(180, 0, 1, 0); - GlStateManager.translate(-3, 0, -6 / 16f); - Gui.drawRect(0, 5, 3, 0, 0xffffffff); - - GlStateManager.popMatrix(); - - GL11.glColorMask(true, true, true, true); - - // Only pass stencil test if equal to 1 - GL11.glStencilMask(0x00); - GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); - - GlStateManager.translate(-viewerX + 12, -viewerY + 100, -viewerZ + 37.5f); - - renderWorld(); - - GL11.glDisable(GL11.GL_STENCIL_TEST); - GlStateManager.enableCull(); - } -} 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 cb2b7031..281830c3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -2,11 +2,11 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import com.google.common.collect.Lists; import com.google.gson.*; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; @@ -737,7 +737,7 @@ public class PetInfoOverlay extends TextOverlay { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) { + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && RenderListener.inventoryLoaded) { GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; ContainerChest container = (ContainerChest) chest.inventorySlots; IInventory lower = container.getLowerChestInventory(); 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 8996dc7a..f2205c49 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -3,10 +3,10 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; @@ -55,8 +55,7 @@ public class AccessoryBagOverlay { Utils.createItemStack(Items.diamond_sword, EnumChatFormatting.DARK_AQUA + "Total Stat Bonuses", 0 ), - Utils.createItemStack( - Item.getItemFromBlock(Blocks.anvil), + Utils.createItemStack(Item.getItemFromBlock(Blocks.anvil), EnumChatFormatting.DARK_AQUA + "Total Stat Bonuses (from reforges)", 0 ), @@ -95,14 +94,30 @@ public class AccessoryBagOverlay { int mouseX = Mouse.getX() / scaledResolution.getScaleFactor(); int mouseY = height - Mouse.getY() / scaledResolution.getScaleFactor(); - int xSize = - (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "xSize", "field_146999_f"); - int ySize = - (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "ySize", "field_147000_g"); - int guiLeft = - (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiLeft", "field_147003_i"); - int guiTop = - (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiTop", "field_147009_r"); + int xSize = (int) Utils.getField( + GuiContainer.class, + Minecraft.getMinecraft().currentScreen, + "xSize", + "field_146999_f" + ); + int ySize = (int) Utils.getField( + GuiContainer.class, + Minecraft.getMinecraft().currentScreen, + "ySize", + "field_147000_g" + ); + int guiLeft = (int) Utils.getField( + GuiContainer.class, + Minecraft.getMinecraft().currentScreen, + "guiLeft", + "field_147003_i" + ); + int guiTop = (int) Utils.getField( + GuiContainer.class, + Minecraft.getMinecraft().currentScreen, + "guiTop", + "field_147009_r" + ); if (mouseX < guiLeft + xSize + 3 || mouseX > guiLeft + xSize + 80 + 28) return false; if (mouseY < guiTop || mouseY > guiTop + 166) return false; @@ -196,8 +211,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "# By Rarity", + Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -230,8 +244,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "Total Stats", + Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -278,8 +291,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "Reforge Stats", + Utils.drawStringCenteredScaledMaxWidth("Reforge Stats", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -322,8 +334,7 @@ public class AccessoryBagOverlay { if (duplicates == null) { JsonObject misc = Constants.MISC; if (misc == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -335,8 +346,7 @@ public class AccessoryBagOverlay { } JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); if (talisman_upgrades_element == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -378,8 +388,7 @@ public class AccessoryBagOverlay { } } if (duplicates.isEmpty()) { - Utils.drawStringCenteredScaledMaxWidth( - "No Duplicates", + Utils.drawStringCenteredScaledMaxWidth("No Duplicates", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -388,8 +397,7 @@ public class AccessoryBagOverlay { new Color(80, 80, 80).getRGB() ); } else { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: " + duplicates.size(), + Utils.drawStringCenteredScaledMaxWidth("Duplicates: " + duplicates.size(), Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -424,8 +432,7 @@ public class AccessoryBagOverlay { if (missing == null) { JsonObject misc = Constants.MISC; if (misc == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -437,8 +444,7 @@ public class AccessoryBagOverlay { } JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); if (talisman_upgrades_element == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -513,8 +519,7 @@ public class AccessoryBagOverlay { } } if (missing.isEmpty()) { - Utils.drawStringCenteredScaledMaxWidth( - "No Missing", + Utils.drawStringCenteredScaledMaxWidth("No Missing", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -523,8 +528,7 @@ public class AccessoryBagOverlay { new Color(80, 80, 80).getRGB() ); } else { - Utils.drawStringCenteredScaledMaxWidth( - "Missing: " + missing.size(), + Utils.drawStringCenteredScaledMaxWidth("Missing: " + missing.size(), Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -649,8 +653,7 @@ public class AccessoryBagOverlay { private static int mainWeapon = 1; public static void renderOptimizerOverlay(int x, int y) { - Utils.drawStringCenteredScaledMaxWidth( - "Optimizer", + Utils.drawStringCenteredScaledMaxWidth("Optimizer", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 12, @@ -683,8 +686,7 @@ public class AccessoryBagOverlay { dark ); - Utils.drawStringCenteredScaledMaxWidth( - "Force 100% CC", + Utils.drawStringCenteredScaledMaxWidth("Force 100% CC", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 27, @@ -696,8 +698,7 @@ public class AccessoryBagOverlay { Minecraft.getMinecraft().fontRendererObj, x + 20, y + 37, true, 30, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - (forceCC ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", + Utils.drawStringCenteredScaledMaxWidth((forceCC ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", Minecraft.getMinecraft().fontRendererObj, x + 60, y + 37, @@ -706,8 +707,7 @@ public class AccessoryBagOverlay { new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - "Force 100% ATKSPEED", + Utils.drawStringCenteredScaledMaxWidth("Force 100% ATKSPEED", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 47, @@ -715,8 +715,7 @@ public class AccessoryBagOverlay { 70, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - (forceAS ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", + Utils.drawStringCenteredScaledMaxWidth((forceAS ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", Minecraft.getMinecraft().fontRendererObj, x + 20, y + 57, @@ -724,8 +723,7 @@ public class AccessoryBagOverlay { 30, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - (forceAS ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", + Utils.drawStringCenteredScaledMaxWidth((forceAS ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", Minecraft.getMinecraft().fontRendererObj, x + 60, y + 57, @@ -734,8 +732,7 @@ public class AccessoryBagOverlay { new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - "Use God Potion", + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 67, @@ -743,8 +740,7 @@ public class AccessoryBagOverlay { 70, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - (useGodPot ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", + Utils.drawStringCenteredScaledMaxWidth((useGodPot ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", Minecraft.getMinecraft().fontRendererObj, x + 20, y + 77, @@ -752,8 +748,7 @@ public class AccessoryBagOverlay { 30, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - (useGodPot ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", + Utils.drawStringCenteredScaledMaxWidth((useGodPot ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", Minecraft.getMinecraft().fontRendererObj, x + 60, y + 77, @@ -762,8 +757,7 @@ public class AccessoryBagOverlay { new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - "Use God Potion", + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 87, @@ -780,8 +774,7 @@ public class AccessoryBagOverlay { true, 30, new Color(80, 80, 80).getRGB() ); - Utils.drawStringCenteredScaledMaxWidth( - "Main Weapon", + Utils.drawStringCenteredScaledMaxWidth("Main Weapon", Minecraft.getMinecraft().fontRendererObj, x + 40, y + 107, @@ -839,7 +832,7 @@ public class AccessoryBagOverlay { public static void renderOverlay() { inAccessoryBag = false; - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) { + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && RenderListener.inventoryLoaded) { GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index bce5bfbd..2d4d4382 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -1,7 +1,6 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.*; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; @@ -9,6 +8,7 @@ import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -2306,7 +2306,7 @@ public class StorageOverlay extends GuiElement { public void fastRenderCheck() { if (!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) { this.fastRender = true; - NEUEventListener.displayNotification(Lists.newArrayList( + NotificationHandler.displayNotification(Lists.newArrayList( "\u00a74Fast Render Warning", "\u00a77Due to the way fast render works, it's not compatible with NEU.", "\u00a77Please disable fast render in your options under", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java index 26923726..e98c3330 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java @@ -1,16 +1,13 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; -import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; -import net.minecraft.util.MathHelper; import net.minecraftforge.client.ForgeHooksClient; -import org.lwjgl.util.glu.Project; import org.lwjgl.util.vector.Vector3f; import org.spongepowered.asm.lib.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -19,21 +16,19 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EntityRenderer.class) public abstract class MixinEntityRenderer { @Shadow - protected abstract float getFOVModifier(float partialTicks, boolean useFOVSetting); - - @Shadow private Minecraft mc; - @Shadow private float farPlaneDistance; @Shadow + protected abstract float getFOVModifier(float partialTicks, boolean useFOVSetting); + + @Shadow protected abstract void orientCamera(float partialTicks); @Inject(method = "getFOVModifier", at = @At("RETURN"), cancellable = true) @@ -52,38 +47,6 @@ public abstract class MixinEntityRenderer { @Redirect(method = "renderWorldPass", at = @At( value = "INVOKE", - target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", - remap = false) - ) - public void perspective(float f1, float f2, float f3, float f4) { - if (!FancyPortals.overridePerspective()) { - Project.gluPerspective(f1, f2, f3, f4); - } - } - - @Inject(method = "updateCameraAndRender", at = @At("RETURN")) - public void onUpdateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) { - if (Minecraft.getMinecraft().getRenderViewEntity() == null) return; - - if (FancyPortals.shouldRenderWorldOverlay()) { - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - Project.gluPerspective(getFOVModifier(partialTicks, true), - (float) mc.displayWidth / (float) this.mc.displayHeight, 0.05F, - farPlaneDistance * MathHelper.SQRT_2 - ); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - orientCamera(partialTicks); - - FancyPortals.onUpdateCameraAndRender(partialTicks, nanoTime); - - Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); - } - } - - @Redirect(method = "renderWorldPass", at = @At( - value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;dispatchRenderLast(Lnet/minecraft/client/renderer/RenderGlobal;F)V", remap = false) ) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index 4d1545b6..9f7d8528 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -1,8 +1,8 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; @@ -100,7 +100,7 @@ public abstract class MixinGuiContainer extends GuiScreen { else if (!($this instanceof GuiChest)) BetterContainers.profileViewerStackIndex = -1; - if (slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) { + if (slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && RenderListener.drawingGuiScreen) { GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, 100 + Minecraft.getMinecraft().getRenderItem().zLevel); GlStateManager.depthMask(false); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java index 25b036ab..7b225d50 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java @@ -1,7 +1,7 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import net.minecraft.client.gui.inventory.GuiInventory; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -13,7 +13,7 @@ public class MixinGuiInventory { @Inject(method = "drawGuiContainerForegroundLayer", at = @At("HEAD"), cancellable = true) protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, CallbackInfo ci) { if (NotEnoughUpdates.INSTANCE.config.inventoryButtons.hideCrafting || - NEUEventListener.disableCraftingText) { + RenderListener.disableCraftingText) { ci.cancel(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java deleted file mode 100644 index dbdad65a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.moulberry.notenoughupdates.mixins; - -import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals; -import net.minecraft.client.LoadingScreenRenderer; -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(LoadingScreenRenderer.class) -public class MixinLoadingScreenRenderer { - @Inject(method = "setLoadingProgress", at = @At(value = "HEAD"), cancellable = true) - public void setLoadingProgress(int progress, CallbackInfo ci) { - if (progress < 0 && !FancyPortals.shouldRenderLoadingScreen()) { - ci.cancel(); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java index 4d8df949..ff71ad1e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java @@ -1,6 +1,6 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.NEUEventListener; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import net.minecraft.util.MouseHelper; import org.lwjgl.input.Mouse; import org.spongepowered.asm.mixin.Mixin; @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinMouseHelper { @Inject(method = {"ungrabMouseCursor"}, at = {@At("HEAD")}, cancellable = true) public void ungrabMouseCursor(final CallbackInfo ci) { - if (System.currentTimeMillis() - NEUEventListener.lastGuiClosed < 150L) { + if (System.currentTimeMillis() - RenderListener.lastGuiClosed < 150L) { ci.cancel(); Mouse.setGrabbed(false); } 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 d47dce2c..4c2a0485 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -61,11 +61,6 @@ public class MixinNetHandlerPlayClient { } } - @Inject(method = "handleSpawnMob", at = @At("RETURN")) - public void handleSpawnMob(S0FPacketSpawnMob packetIn, CallbackInfo ci) { - //CollectionLogManager.getInstance().onEntityMetadataUpdated(packetIn.getEntityID()); - } - @Inject(method = "handleSetSlot", at = @At("RETURN")) public void handleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) { EnchantingSolvers.processInventoryContents(false); @@ -87,14 +82,6 @@ public class MixinNetHandlerPlayClient { StorageManager.getInstance().setItemsPacket(packetIn); } - @Inject(method = "handleRespawn", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V", - shift = At.Shift.AFTER)) - public void handleOpenWindow(S07PacketRespawn packetIn, CallbackInfo ci) { - FancyPortals.onRespawnPacket(packetIn); - } - @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/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java index 630874ab..6c432ce3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java @@ -1,9 +1,9 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.ChromaColour; +import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import net.minecraft.client.Minecraft; @@ -176,7 +176,7 @@ public abstract class MixinRenderItem { @Inject(method = "renderItemIntoGUI", at = @At("HEAD")) public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) { - if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) { + if (NotEnoughUpdates.INSTANCE.overlay.searchMode && RenderListener.drawingGuiScreen) { boolean matches = false; GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField(); @@ -202,7 +202,7 @@ public abstract class MixinRenderItem { @Inject(method = "renderItemIntoGUI", at = @At("RETURN")) public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) { if (stack != null && stack.stackSize != 1) return; - if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) { + if (NotEnoughUpdates.INSTANCE.overlay.searchMode && RenderListener.drawingGuiScreen) { boolean matches = false; GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField(); @@ -233,7 +233,7 @@ public abstract class MixinRenderItem { CallbackInfo ci ) { if (stack != null && stack.stackSize != 1) { - if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) { + if (NotEnoughUpdates.INSTANCE.overlay.searchMode && RenderListener.drawingGuiScreen) { boolean matches = false; GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField(); 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 bb3b3425..dab4844d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -1,7 +1,6 @@ package io.github.moulberry.notenoughupdates.util; import com.google.gson.*; -import io.github.moulberry.notenoughupdates.collectionlog.CollectionConstant; import java.lang.reflect.Type; import java.util.concurrent.locks.ReentrantLock; @@ -40,7 +39,6 @@ public class Constants { public static JsonObject ESSENCECOSTS; public static JsonObject FAIRYSOULS; public static JsonObject REFORGESTONES; - public static CollectionConstant COLLECTIONLOG; private static final ReentrantLock lock = new ReentrantLock(); @@ -59,7 +57,6 @@ public class Constants { ESSENCECOSTS = Utils.getConstant("essencecosts", gson); FAIRYSOULS = Utils.getConstant("fairy_souls", gson); REFORGESTONES = Utils.getConstant("reforgestones", gson); - //COLLECTIONLOG = Utils.getConstant("collectionlog", gson, CollectionConstant.class); } finally { lock.unlock(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java new file mode 100644 index 00000000..492c1dd7 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java @@ -0,0 +1,112 @@ +package io.github.moulberry.notenoughupdates.util; + +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.ContainerChest; + +import java.util.List; + +public class NotificationHandler { + public static List<String> notificationLines = null; + public static boolean showNotificationOverInv = false; + public static long notificationDisplayMillis = 0; + + public static void displayNotification(List<String> lines, boolean showForever) { + displayNotification(lines, showForever, false); + } + + public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) { + if (showForever) { + notificationDisplayMillis = -420; + } else { + notificationDisplayMillis = System.currentTimeMillis(); + } + notificationLines = lines; + showNotificationOverInv = overInventory; + } + + public static void renderNotification() { + long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); + boolean display = timeRemaining > 0 || notificationDisplayMillis == -420; + if (display && notificationLines != null && notificationLines.size() > 0) { + int width = 0; + int height = notificationLines.size() * 10 + 10; + + for (String line : notificationLines) { + int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8; + if (len > width) { + width = len; + } + } + + ScaledResolution sr = Utils.pushGuiScale(2); + + int midX = sr.getScaledWidth() / 2; + int topY = sr.getScaledHeight() * 3 / 4 - height / 2; + RenderUtils.drawFloatingRectDark(midX - width / 2, sr.getScaledHeight() * 3 / 4 - height / 2, width, height); + /*Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2, + midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C); + Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2, + midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);*/ + + int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close"); + Minecraft.getMinecraft().fontRendererObj.drawString( + "[X] Close", + midX + width / 2f - 3 - xLen, + topY + 3, + 0xFFFF5555, + false + ); + + if (notificationDisplayMillis > 0) { + Minecraft.getMinecraft().fontRendererObj.drawString( + (timeRemaining / 1000) + "s", + midX - width / 2f + 3, + topY + 3, + 0xFFaaaaaa, + false + ); + } + + Utils.drawStringCentered( + notificationLines.get(0), + Minecraft.getMinecraft().fontRendererObj, + midX, + topY + 4 + 5, + false, + -1 + ); + for (int i = 1; i < notificationLines.size(); i++) { + String line = notificationLines.get(i); + Utils.drawStringCentered( + line, + Minecraft.getMinecraft().fontRendererObj, + midX, + topY + 4 + 5 + 2 + i * 10, + false, + -1 + ); + } + + Utils.pushGuiScale(-1); + } + } + + public static boolean shouldRenderOverlay(Gui gui) { + boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe; + if (gui instanceof GuiChest) { + GuiChest eventGui = (GuiChest) gui; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if (containerName.trim().equals("Fast Travel")) { + validGui = false; + } + } + return validGui; + } +} |