aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-08-17 00:13:03 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-08-17 00:13:03 +1000
commit0c23f52d2be811d74a3b6ef598dd9de7ccb763ab (patch)
tree74bf92e821268b2c18527e0dc02c6587e3d5b5bb /src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
parent0d3a0d7355dac828a97977730bc3acc4dee7e1b4 (diff)
downloadnotenoughupdates-0c23f52d2be811d74a3b6ef598dd9de7ccb763ab.tar.gz
notenoughupdates-0c23f52d2be811d74a3b6ef598dd9de7ccb763ab.tar.bz2
notenoughupdates-0c23f52d2be811d74a3b6ef598dd9de7ccb763ab.zip
1.1.3
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java1005
1 files changed, 39 insertions, 966 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index fbcd3de3..6e01e409 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -9,73 +9,53 @@ import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
+import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes;
+import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes;
import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane;
import io.github.moulberry.notenoughupdates.infopanes.CosmeticsInfoPane;
-import io.github.moulberry.notenoughupdates.mixins.MixinRenderItem;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.questing.GuiQuestLine;
-import io.github.moulberry.notenoughupdates.questing.SBScoreboardData;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.gui.inventory.*;
-import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.client.shader.Framebuffer;
-import net.minecraft.client.shader.Shader;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
-import net.minecraft.init.Blocks;
-import net.minecraft.inventory.ContainerChest;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.Scoreboard;
-import net.minecraft.util.*;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.Session;
import net.minecraftforge.client.ClientCommandHandler;
-import net.minecraftforge.client.event.*;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
-import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.StringUtils;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.GL11;
import javax.swing.*;
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.Proxy;
-import java.text.NumberFormat;
-import java.util.*;
+import java.util.ArrayList;
import java.util.List;
-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 java.util.Set;
+import java.util.UUID;
-import static io.github.moulberry.notenoughupdates.GuiTextures.*;
-
-@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION)
+@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true)
public class NotEnoughUpdates {
public static final String MODID = "notenoughupdates";
public static final String VERSION = "1.1-REL";
@@ -91,11 +71,6 @@ public class NotEnoughUpdates {
private long secondLastChatMessage = 0;
private String currChatMessage = null;
- private boolean hoverInv = false;
- private boolean focusInv = false;
-
- private boolean joinedSB = false;
-
//Stolen from Biscut and used for detecting whether in skyblock
private static final Set<String> SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58");
@@ -134,12 +109,25 @@ public class NotEnoughUpdates {
}
});
+ SimpleCommand gamemodesCommand = new SimpleCommand("neugamemodes", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ boolean upgradeOverride = args.length == 1 && args[0].equals("upgradeOverride");
+ openGui = new GuiGamemodes(upgradeOverride);
+ }
+ });
+
SimpleCommand enchantColourCommand = new SimpleCommand("neuec", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
openGui = new GuiEnchantColour();
}
});
+ SimpleCommand resetRepoCommand = new SimpleCommand("neuresetrepo", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ manager.resetRepo();
+ }
+ });
+
public static ProfileViewer profileViewer;
SimpleCommand.ProcessCommandRunnable viewProfileRunnable = new SimpleCommand.ProcessCommandRunnable() {
@@ -295,14 +283,19 @@ public class NotEnoughUpdates {
@EventHandler
public void preinit(FMLPreInitializationEvent event) {
INSTANCE = this;
+
MinecraftForge.EVENT_BUS.register(this);
+ MinecraftForge.EVENT_BUS.register(new NEUEventListener(this));
MinecraftForge.EVENT_BUS.register(CapeManager.getInstance());
+ MinecraftForge.EVENT_BUS.register(new SBGamemodes());
File f = new File(event.getModConfigurationDirectory(), "notenoughupdates");
f.mkdirs();
ClientCommandHandler.instance.registerCommand(collectionLogCommand);
ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
ClientCommandHandler.instance.registerCommand(linksCommand);
+ ClientCommandHandler.instance.registerCommand(gamemodesCommand);
+ ClientCommandHandler.instance.registerCommand(resetRepoCommand);
ClientCommandHandler.instance.registerCommand(viewProfileCommand);
ClientCommandHandler.instance.registerCommand(viewProfileShortCommand);
ClientCommandHandler.instance.registerCommand(viewProfileShort2Command);
@@ -383,7 +376,7 @@ public class NotEnoughUpdates {
}
}
- private void displayLinks(JsonObject update) {
+ public void displayLinks(JsonObject update) {
String discord_link = update.get("discord_link").getAsString();
String youtube_link = update.get("youtube_link").getAsString();
String update_link = update.get("update_link").getAsString();
@@ -426,940 +419,20 @@ public class NotEnoughUpdates {
Minecraft.getMinecraft().thePlayer.addChatMessage(links);
}
- private void displayUpdateMessageIfOutOfDate() {
- File repo = manager.repoLocation;
- if(repo.exists()) {
- File updateJson = new File(repo, "update.json");
- try {
- JsonObject o = manager.getJsonFromFile(updateJson);
-
- String version = o.get("version").getAsString();
-
- if(!VERSION.equalsIgnoreCase(version)) {
- String update_msg = o.get("update_msg").getAsString();
- String discord_link = o.get("discord_link").getAsString();
- String youtube_link = o.get("youtube_link").getAsString();
- String update_link = o.get("update_link").getAsString();
- String github_link = o.get("github_link").getAsString();
- String other_text = o.get("other_text").getAsString();
- String other_link = o.get("other_link").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));
- }
-
- displayLinks(o);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
-
- }
- } catch(Exception ignored) {}
- }
- }
-
- /**
- * 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 HashMap<String, Long> newItemAddMap = new HashMap<>();
- private long lastLongUpdate = 0;
- private long lastSkyblockScoreboard = 0;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(event.phase != TickEvent.Phase.START) return;
-
- boolean longUpdate = false;
+ if (event.phase != TickEvent.Phase.START) return;
long currentTime = System.currentTimeMillis();
- if(currentTime - lastLongUpdate > 1000) {
- longUpdate = true;
- lastLongUpdate = currentTime;
- }
- if(openGui != null) {
+
+ if (openGui != null) {
Minecraft.getMinecraft().displayGuiScreen(openGui);
openGui = null;
}
- if(longUpdate) {
- updateSkyblockScoreboard();
- if(hasSkyblockScoreboard()) {
- lastSkyblockScoreboard = currentTime;
- if(!joinedSB && manager.config.showUpdateMsg.value) {
- joinedSB = true;
- displayUpdateMessageIfOutOfDate();
- if(!manager.config.loadedModBefore.value) {
- manager.config.loadedModBefore.value = true;
- try { manager.saveConfig(); } catch(IOException e) {}
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.BLUE+"It seems this is your first time using NotEnoughUpdates."));
- ChatComponentText clickText = new ChatComponentText(
- EnumChatFormatting.YELLOW+"Click this message if you would like to view a short tutorial.");
- clickText.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neututorial"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(clickText);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- }
- }
- SBScoreboardData.getInstance().tick();
- //GuiQuestLine.questLine.tick();
- }
- if(currentTime - lastSkyblockScoreboard < 5*60*1000) { //5 minutes
- manager.auctionManager.tick();
- } else {
- manager.auctionManager.markNeedsUpdate();
- }
- //ItemRarityHalo.resetItemHaloCache();
- }
if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
lastChatMessage = currentTime;
Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
currChatMessage = null;
}
- if(longUpdate && hasSkyblockScoreboard()) {
- if(manager.getCurrentProfile() == null || manager.getCurrentProfile().length() == 0) {
- ProfileViewer.Profile profile = profileViewer.getProfile(
- Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), (json) -> {});
- if(profile != null) {
- String latest = profile.getLatestProfile();
- if(latest != null) {
- manager.setCurrentProfileBackup(profile.getLatestProfile());
- }
- }
- }
- if(manager.getCurrentProfile() != null && 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 = manager.getInternalNameForItem(stack);
- if(internalname != null) {
- ArrayList<String> log = manager.config.collectionLog.value.computeIfAbsent(
- 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 { manager.saveConfig(); } catch(IOException ignored) {}
- }
- } else {
- newItemAddMap.put(internalname, System.currentTimeMillis());
- }
- }
- }
- }
- }
-
- @SubscribeEvent(priority=EventPriority.HIGHEST)
- public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre event) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) {
- if(((GuiProfileViewer)Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) {
- event.setCanceled(true);
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderGameOverlay(RenderGameOverlayEvent event) {
- if(event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) &&
- Minecraft.getMinecraft().currentScreen instanceof GuiContainer && overlay.isUsingMobsFilter()) {
- event.setCanceled(true);
- }
- }
-
- /**
- * 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) {
- manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis();
-
- if(event.gui == null && manager.auctionManager.customAH.isRenderOverAuctionView() &&
- !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) {
- event.gui = new CustomAHGui();
- }
-
- if(!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) {
- manager.auctionManager.customAH.setRenderOverAuctionView(false);
- } else if(event.gui instanceof GuiChest && (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();
-
- 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) {
- overlay.reset();
- manager.loadConfig();
- }
- //CLOSE
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer
- && event.gui == null) {
- try {
- manager.saveConfig();
- } catch(IOException e) {}
- }
- if(event.gui != null && manager.config.dev.value) {
- 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 = 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 = manager.getItemInformation().get(resInternalname);
- json.addProperty("crafttext", "Requires: " + col);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
- manager.writeJsonDefaultDir(json, resInternalname+".json");
- manager.loadItem(resInternalname);
- }
- }
- }
-
- /*JsonArray arr = null;
- File f = new File(manager.configLocation, "missing.json");
- try(InputStream instream = new FileInputStream(f)) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(instream, StandardCharsets.UTF_8));
- JsonObject json = 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);
- 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 = manager.getInternalNameForItem(stack);
- if(!manager.getItemInformation().containsKey(internalname)) {
- manager.writeItemToFile(stack);
- }
- internalname += ":"+stack.stackSize;
- }
- recipe.addProperty(y[i/9]+x[j], internalname);
- }
- }
-
- JsonObject json = 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));
- manager.writeJsonDefaultDir(json, resInternalname+".json");
- manager.loadItem(resInternalname);*/
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }, 200, TimeUnit.MILLISECONDS);
- return;
- }
- }
- }
-
- /**
- * 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)
- public void onGuiChat(ClientChatReceivedEvent e) {
- String r = null;
- String unformatted = Utils.cleanColour(e.message.getUnformattedText());
- if(unformatted.startsWith("You are playing on profile: ")) {
- 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:
- manager.setCurrentProfile(unformatted.substring("Your profile was changed to: ".length()).split(" ")[0].trim());
- } else if(unformatted.startsWith("Your new API key is ")) {
- manager.config.apiKey.value = unformatted.substring("Your new API key is ".length());
- try { manager.saveConfig(); } catch(IOException ioe) {}
- }
- 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 = "";
- }
- if(r != null) {
- if(manager.failViewItem(r)) {
- e.setCanceled(true);
- }
- missingRecipe.set(true);
- }
- //System.out.println(e.message);
- if(unformatted.startsWith("Sending to server") &&
- isOnSkyblock() && manager.config.streamerMode.value && 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);
- }
- }
- }
-
- /**
- * 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).
- *
- * 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)
- *
- * All of this only matters if players are using gui scale auto which may result in the inventory being drawn
- * over the various panes.
- * @param event
- */
- @SubscribeEvent
- public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
- if((shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && isOnSkyblock()) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
-
- boolean hoverPane = event.getMouseX() < width*overlay.getInfoPaneOffsetFactor() ||
- event.getMouseX() > width*overlay.getItemPaneOffsetFactor();
-
- if(event.gui instanceof GuiContainer) {
- try {
- int xSize = (int) Utils.getField(GuiContainer.class, event.gui, "xSize", "field_146999_f");
- int ySize = (int) Utils.getField(GuiContainer.class, event.gui, "ySize", "field_147000_g");
- int guiLeft = (int) Utils.getField(GuiContainer.class, event.gui, "guiLeft", "field_147003_i");
- int guiTop = (int) Utils.getField(GuiContainer.class, event.gui, "guiTop", "field_147009_r");
-
- 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) {
- npe.printStackTrace();
- 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 {
- overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv);
- } catch(ConcurrentModificationException e) {e.printStackTrace();}
- GL11.glTranslatef(0, 0, 10);
- }
- }
- }
-
- @SubscribeEvent
- public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) {
- if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) {
- 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*overlay.getWidthMult()/3 || event.mouseX > width-width*overlay.getWidthMult()/3) {
- manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
- overlay.render(event.mouseX, event.mouseY, false);
- } else {
- overlay.render(event.mouseX, event.mouseY, false);
- manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
- }
-
- }
- }
-
- 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;
- }
-
- /**
- * 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))
- * @param event
- */
- @SubscribeEvent
- public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) {
- if(!(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView())) {
- if(shouldRenderOverlay(event.gui) && isOnSkyblock()) {
- renderDungeonChestOverlay(event.gui);
-
- if(!focusInv) {
- GL11.glTranslatef(0, 0, 300);
- overlay.render(event.mouseX, event.mouseY, hoverInv && focusInv);
- GL11.glTranslatef(0, 0, -300);
- }
- overlay.renderOverlay(event.mouseX, event.mouseY);
- }
- }
- }
-
- private void renderDungeonChestOverlay(GuiScreen gui) {
- if(gui instanceof GuiChest && manager.auctionManager.activeAuctions > 0) {
- try {
- int xSize = (int) Utils.getField(GuiContainer.class, gui, "xSize", "field_146999_f");
- int ySize = (int) Utils.getField(GuiContainer.class, gui, "ySize", "field_147000_g");
- int guiLeft = (int) Utils.getField(GuiContainer.class, gui, "guiLeft", "field_147003_i");
- int guiTop = (int) Utils.getField(GuiContainer.class, gui, "guiTop", "field_147009_r");
-
- 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;
- String line6 = Utils.cleanColour(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());
- }
-
- boolean missing = false;
- int totalValue = 0;
- for(int i=0; i<5; i++) {
- ItemStack item = lower.getStackInSlot(11+i);
- String internal = manager.getInternalNameForItem(item);
- if(internal != null) {
- float worth = manager.auctionManager.getLowestBin(internal);
-
- if(worth == -1) worth = manager.getCraftCost(internal).craftCost;
-
- if(worth > 0) {
- totalValue += worth;
- } else {
- missing = true;
- break;
- }
- }
- }
- int profitLoss = totalValue - chestCost;
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
- String valueString;
- if(!missing) {
- valueString = EnumChatFormatting.BLUE+"Chest value: " + EnumChatFormatting.GOLD
- + EnumChatFormatting.BOLD + format.format(totalValue) + " coins";
- } else {
- valueString = EnumChatFormatting.BLUE+"Couldn't find item on AH. Item is very rare!";
- }
- String plString;
- if(missing) {
- plString = "";
- } else if(profitLoss >= 0) {
- plString = EnumChatFormatting.BLUE+"Profit/loss: " + EnumChatFormatting.DARK_GREEN
- + EnumChatFormatting.BOLD + "+" + format.format(profitLoss) + " coins";
- } else {
- plString = EnumChatFormatting.BLUE+"Profit/loss: " + EnumChatFormatting.RED
- + EnumChatFormatting.BOLD + "-" + format.format(-profitLoss) + " coins";
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth);
- GL11.glColor4f(1, 1, 1, 1);
- GlStateManager.disableLighting();
- Utils.drawTexturedRect(guiLeft+xSize+4, guiTop, 180, 45, 0, 180/256f, 0, 45/256f, GL11.GL_NEAREST);
-
- Utils.drawStringCenteredScaledMaxWidth(valueString, Minecraft.getMinecraft().fontRendererObj, guiLeft+xSize+4+90,
- guiTop+14, true, 170, Color.BLACK.getRGB());
- Utils.drawStringCenteredScaledMaxWidth(plString, Minecraft.getMinecraft().fontRendererObj, guiLeft+xSize+4+90,
- guiTop+28, true, 170, Color.BLACK.getRGB());
- }
- } 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.
- * @param event
- */
- @SubscribeEvent
- public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
- if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) {
- event.setCanceled(true);
- manager.auctionManager.customAH.handleMouseInput();
- overlay.mouseInput();
- return;
- }
- if(shouldRenderOverlay(event.gui) && !(hoverInv && focusInv) && isOnSkyblock()) {
- if(overlay.mouseInput()) {
- event.setCanceled(true);
- }
- }<