aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-26 12:12:25 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-26 12:12:25 +1000
commitf0293a74282cece3aa8a2a328559889d6e187209 (patch)
treee4bb3d101b8b7e70a58f521a41a44071bb6cc0fa /src/main
parent16b89f752b83aa91f1697238d785eb97a4f01f61 (diff)
downloadNotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.tar.gz
NotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.tar.bz2
NotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.zip
1.11.7
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/NotSkyblockAddonsInstallerFrame.java667
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java222
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java251
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java166
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java53
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java1253
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java37
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java472
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java127
-rw-r--r--src/main/resources/assets/notenoughupdates/button20x.pngbin0 -> 170 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/custom_ench_colour.pngbin0 -> 4530 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/folder.pngbin0 -> 454 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_0.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_0.jpg)bin26015 -> 26015 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_1.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_1.jpg)bin26016 -> 26016 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_2.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_2.jpg)bin24769 -> 24769 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_3.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_3.jpg)bin24854 -> 24854 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_4.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_4.jpg)bin26123 -> 26123 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_5.jpg (renamed from src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_5.jpg)bin24894 -> 24894 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_basic.pngbin10496 -> 5173 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_bg.pngbin0 -> 2016 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_cols.pngbin0 -> 1843 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_elements.pngbin0 -> 831 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_invs.pngbin0 -> 4446 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_pets.pngbin0 -> 3420 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/blur.json21
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh34
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh11
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json17
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh20
-rw-r--r--src/main/resources/mixins.notenoughupdates.json3
42 files changed, 3218 insertions, 323 deletions
diff --git a/src/main/java/NotSkyblockAddonsInstallerFrame.java b/src/main/java/NotSkyblockAddonsInstallerFrame.java
new file mode 100644
index 00000000..7c5a1638
--- /dev/null
+++ b/src/main/java/NotSkyblockAddonsInstallerFrame.java
@@ -0,0 +1,667 @@
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.util.Locale;
+import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+
+public class NotSkyblockAddonsInstallerFrame extends JFrame implements ActionListener, MouseListener {
+
+ private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$");
+
+ private JLabel logo = null;
+ private JLabel versionInfo = null;
+ private JLabel labelFolder = null;
+
+ private JPanel panelCenter = null;
+ private JPanel panelBottom = null;
+ private JPanel totalContentPane = null;
+
+ private JTextArea descriptionText = null;
+ private JTextArea forgeDescriptionText = null;
+
+ private JTextField textFieldFolderLocation = null;
+ private JButton buttonChooseFolder = null;
+
+ private JButton buttonInstall = null;
+ private JButton buttonOpenFolder = null;
+ private JButton buttonClose = null;
+
+ private static final int TOTAL_HEIGHT = 435;
+ private static final int TOTAL_WIDTH = 404;
+
+ private int x = 0;
+ private int y = 0;
+
+ private int w = TOTAL_WIDTH;
+ private int h;
+ private int margin;
+
+ public NotSkyblockAddonsInstallerFrame() {
+ try {
+ setName("NotEnoughUpdatesInstallerFrame");
+ setTitle("NotEnoughUpdates Installer");
+ setResizable(false);
+ setSize(TOTAL_WIDTH, TOTAL_HEIGHT);
+ setContentPane(getPanelContentPane());
+
+ getButtonFolder().addActionListener(this);
+ getButtonInstall().addActionListener(this);
+ getButtonOpenFolder().addActionListener(this);
+ getButtonClose().addActionListener(this);
+ getForgeTextArea().addMouseListener(this);
+
+ pack();
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ getFieldFolder().setText(getModsFolder().getPath());
+ getButtonInstall().setEnabled(true);
+ getButtonInstall().requestFocus();
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ NotSkyblockAddonsInstallerFrame frame = new NotSkyblockAddonsInstallerFrame();
+ frame.centerFrame(frame);
+ frame.show();
+
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ private JPanel getPanelContentPane() {
+ if (totalContentPane == null) {
+ try {
+ totalContentPane = new JPanel();
+ totalContentPane.setName("PanelContentPane");
+ totalContentPane.setLayout(new BorderLayout(5, 5));
+ totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT));
+ totalContentPane.add(getPanelCenter(), "Center");
+ totalContentPane.add(getPanelBottom(), "South");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return totalContentPane;
+ }
+
+ private JPanel getPanelCenter() {
+ if (panelCenter == null) {
+ try {
+ (panelCenter = new JPanel()).setName("PanelCenter");
+ panelCenter.setLayout(null);
+ panelCenter.add(getPictureLabel(), getPictureLabel().getName());
+ panelCenter.add(getVersionInfo(), getVersionInfo().getName());
+ panelCenter.add(getTextArea(), getTextArea().getName());
+ panelCenter.add(getForgeTextArea(), getForgeTextArea().getName());
+ panelCenter.add(getLabelFolder(), getLabelFolder().getName());
+ panelCenter.add(getFieldFolder(), getFieldFolder().getName());
+ panelCenter.add(getButtonFolder(), getButtonFolder().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelCenter;
+ }
+
+ private JLabel getPictureLabel() {
+ if (logo == null) {
+ try {
+ h = w/2;
+ margin = 5;
+
+ BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/logo.png"));
+ Image scaled = myPicture.getScaledInstance(w-margin*2, h-margin, Image.SCALE_SMOOTH);
+ logo = new JLabel(new ImageIcon(scaled));
+ logo.setName("Logo");
+ logo.setBounds(x+margin, y+margin, w-margin*2, h-margin);
+ logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18));
+ logo.setHorizontalAlignment(SwingConstants.CENTER);
+ logo.setPreferredSize(new Dimension(h*742/537, h));
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return logo;
+ }
+
+ private JLabel getVersionInfo() {
+ if (versionInfo == null) {
+ try {
+ h = 25;
+
+ versionInfo = new JLabel();
+ versionInfo.setName("LabelMcVersion");
+ versionInfo.setBounds(x, y, w, h);
+ versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
+ versionInfo.setHorizontalAlignment(SwingConstants.CENTER);
+ versionInfo.setPreferredSize(new Dimension(w, h));
+ versionInfo.setText("NEU by Moulberry, Installer by Biscuit - for Minecraft 1.8.9");
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return versionInfo;
+ }
+
+ private JTextArea getTextArea() {
+ if (descriptionText == null) {
+ try {
+ h = 60;
+ margin = 10;
+
+ descriptionText = new JTextArea();
+ descriptionText.setName("TextArea");
+ descriptionText.setBounds(x+margin, y+margin, w-margin*2, h-margin);
+ descriptionText.setEditable(false);
+ descriptionText.setHighlighter(null);
+ descriptionText.setEnabled(true);
+ descriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ descriptionText.setLineWrap(true);
+ descriptionText.setOpaque(false);
+ descriptionText.setPreferredSize(new Dimension(w-margin*2, h-margin));
+ descriptionText.setText("This installer will copy NotEnoughUpdates into your forge mods folder for you, and replace any old versions that already exist. " +
+ "Close this if you prefer to do this yourself!");
+ descriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return descriptionText;
+ }
+
+ private JTextArea getForgeTextArea() {
+ if (forgeDescriptionText == null) {
+ try {
+ h = 55;
+ margin = 10;
+
+ forgeDescriptionText = new JTextArea();
+ forgeDescriptionText.setName("TextAreaForge");
+ forgeDescriptionText.setBounds(x+margin, y+margin, w-margin*2, h-margin);
+ forgeDescriptionText.setEditable(false);
+ forgeDescriptionText.setHighlighter(null);
+ forgeDescriptionText.setEnabled(true);
+ forgeDescriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ forgeDescriptionText.setLineWrap(true);
+ forgeDescriptionText.setOpaque(false);
+ forgeDescriptionText.setPreferredSize(new Dimension(w-margin*2, h-margin));
+ forgeDescriptionText.setText("However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!");
+ forgeDescriptionText.setForeground(Color.BLUE.darker());
+ forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ forgeDescriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return forgeDescriptionText;
+ }
+
+ private JLabel getLabelFolder() {
+ if (labelFolder == null) {
+ h = 16;
+ w = 65;
+
+ x += 10; // Padding
+
+ try {
+ labelFolder = new JLabel();
+ labelFolder.setName("LabelFolder");
+ labelFolder.setBounds(x, y+2, w, h);
+ labelFolder.setPreferredSize(new Dimension(w, h));
+ labelFolder.setText("Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return labelFolder;
+ }
+
+ private JTextField getFieldFolder() {
+ if (textFieldFolderLocation == null) {
+ h = 20;
+ w = 287;
+
+ try {
+ textFieldFolderLocation = new JTextField();
+ textFieldFolderLocation.setName("FieldFolder");
+ textFieldFolderLocation.setBounds(x, y, w, h);
+ textFieldFolderLocation.setEditable(false);
+ textFieldFolderLocation.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return textFieldFolderLocation;
+ }
+
+ private JButton getButtonFolder() {
+ if (buttonChooseFolder == null) {
+ h = 20;
+ w = 25;
+
+ x += 10; // Padding
+
+ try {
+ BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/folder.png"));
+ Image scaled = myPicture.getScaledInstance(w-8, h-6, Image.SCALE_SMOOTH);
+ buttonChooseFolder = new JButton(new ImageIcon(scaled));
+ buttonChooseFolder.setName("ButtonFolder");
+ buttonChooseFolder.setBounds(x, y, w, h);
+ buttonChooseFolder.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonChooseFolder;
+ }
+
+ private JPanel getPanelBottom() {
+ if (panelBottom == null) {
+ try {
+ panelBottom = new JPanel();
+ panelBottom.setName("PanelBottom");
+ panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
+ panelBottom.setPreferredSize(new Dimension(390, 55));
+ panelBottom.add(getButtonInstall(), getButtonInstall().getName());
+ panelBottom.add(getButtonOpenFolder(), getButtonOpenFolder().getName());
+ panelBottom.add(getButtonClose(), getButtonClose().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelBottom;
+ }
+
+ private JButton getButtonInstall() {
+ if (buttonInstall == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ buttonInstall = new JButton();
+ buttonInstall.setName("ButtonInstall");
+ buttonInstall.setPreferredSize(new Dimension(w, h));
+ buttonInstall.setText("Install");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonInstall;
+ }
+
+ private JButton getButtonOpenFolder() {
+ if (buttonOpenFolder == null) {
+ w = 130;
+ h = 26;
+
+ try {
+ buttonOpenFolder = new JButton();
+ buttonOpenFolder.setName("ButtonOpenFolder");
+ buttonOpenFolder.setPreferredSize(new Dimension(w, h));
+ buttonOpenFolder.setText("Open Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonOpenFolder;
+ }
+
+ private JButton getButtonClose() {
+ if (buttonClose == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ (buttonClose = new JButton()).setName("ButtonClose");
+ buttonClose.setPreferredSize(new Dimension(w, h));
+ buttonClose.setText("Cancel");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonClose;
+ }
+
+ public void onFolderSelect() {
+ File currentDirectory = new File(getFieldFolder().getText());
+
+ JFileChooser jFileChooser = new JFileChooser(currentDirectory);
+ jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ jFileChooser.setAcceptAllFileFilterUsed(false);
+ if (jFileChooser.showOpenDialog(this) == 0) {
+ File newDirectory = jFileChooser.getSelectedFile();
+ getFieldFolder().setText(newDirectory.getPath());
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == getButtonClose()) {
+ dispose();
+ System.exit(0);
+ }
+ if (e.getSource() == getButtonFolder()) {
+ onFolderSelect();
+ }
+ if (e.getSource() == getButtonInstall()) {
+ onInstall();
+ }
+ if (e.getSource() == getButtonOpenFolder()) {
+ onOpenFolder();
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getSource() == getForgeTextArea()) {
+ try {
+ Desktop.getDesktop().browse(new URI("http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html"));
+ } catch (IOException | URISyntaxException ex) {
+ showErrorPopup(ex);
+ }
+ }
+ }
+
+ public void onInstall() {
+ try {
+ File modsFolder = new File(getFieldFolder().getText());
+ if (!modsFolder.exists()) {
+ showErrorMessage("Folder not found: " + modsFolder.getPath());
+ return;
+ }
+ if (!modsFolder.isDirectory()) {
+ showErrorMessage("Not a folder: " + modsFolder.getPath());
+ return;
+ }
+ tryInstall(modsFolder);
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ private void tryInstall(File modsFolder) {
+ File thisFile = getThisFile();
+
+ if (thisFile != null) {
+ boolean inSubFolder = false;
+ if (IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find()) {
+ inSubFolder = true;
+ }
+
+ boolean deletingFailure = false;
+ if (modsFolder.isDirectory()) { // Delete in this current folder.
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ if (inSubFolder) { // We are in the 1.8.9 folder, delete in the parent folder as well.
+ if (modsFolder.getParentFile().isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.getParentFile().listFiles());
+ if (failed) deletingFailure = true;
+ }
+ } else { // We are in the main mods folder, but the 1.8.9 subfolder exists... delete in there too.
+ File subFolder = new File(modsFolder, "1.8.9");
+ if (subFolder.exists() && subFolder.isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(subFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ }
+
+ if (deletingFailure) return;
+
+ if (thisFile.isDirectory()) {
+ showErrorMessage("This file is a directory... Are we in a development environment?");
+ return;
+ }
+
+ try {
+ Files.copy(thisFile.toPath(), new File(modsFolder, thisFile.getName()).toPath());
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ return;
+ }
+
+ showMessage("NotEnoughUpdates has been successfully installed into your mods folder.");
+ dispose();
+ System.exit(0);
+ }
+ }
+
+ private boolean findSkyblockAddonsAndDelete(File[] files) {
+ if (files == null) return false;
+
+ for (File file : files) {
+ if (!file.isDirectory() && file.getPath().endsWith(".jar")) {
+ try {
+ JarFile jarFile = new JarFile(file);
+ ZipEntry mcModInfo = jarFile.getEntry("mcmod.info");
+ if (mcModInfo != null) {
+ InputStream inputStream = jarFile.getInputStream(mcModInfo);
+ String modID = getModIDFromInputStream(inputStream);
+ if (modID.equals("notenoughupdates")) {
+ jarFile.close();
+ try {
+ boolean deleted = file.delete();
+ if (!deleted) {
+ throw new Exception();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ showErrorMessage("Was not able to delete the other NotEnoughUpdates files found in your mods folder!" + System.lineSeparator() +
+ "Please make sure that your minecraft is currently closed and try again, or feel" + System.lineSeparator() +
+ "free to open your mods folder and delete those files manually.");
+ return true;
+ }
+ continue;
+ }
+ }
+ jarFile.close();
+ } catch (Exception ex) {
+ // Just don't check the file I guess, move on to the next...
+ }
+ }
+ }
+ return false;
+ }
+
+ public void onOpenFolder() {
+ try {
+ Desktop.getDesktop().open(getModsFolder());
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ public File getModsFolder() {
+ String userHome = System.getProperty("user.home", ".");
+
+ File modsFolder = getFile(userHome, "minecraft/mods/1.8.9");
+ if (!modsFolder.exists()) {
+ modsFolder = getFile(userHome, "minecraft/mods");
+ }
+
+ if (!modsFolder.exists() && !modsFolder.mkdirs()) {
+ throw new RuntimeException("The working directory could not be created: " + modsFolder);
+ }
+ return modsFolder;
+ }
+
+ public File getFile(String userHome, String minecraftPath) {
+ File workingDirectory;
+ switch (getOperatingSystem()) {
+ case LINUX:
+ case SOLARIS: {
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case WINDOWS: {
+ String applicationData = System.getenv("APPDATA");
+ if (applicationData != null) {
+ workingDirectory = new File(applicationData, "." + minecraftPath + '/');
+ break;
+ }
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case MACOS: {
+ workingDirectory = new File(userHome, "Library/Application Support/" + minecraftPath);
+ break;
+ }
+ default: {
+ workingDirectory = new File(userHome, minecraftPath + '/');
+ break;
+ }
+ }
+ return workingDirectory;
+ }
+
+ public OperatingSystem getOperatingSystem() {
+ String osName = System.getProperty("os.name").toLowerCase(Locale.US);
+ if (osName.contains("win")) {
+ return OperatingSystem.WINDOWS;
+
+ } else if (osName.contains("mac")) {
+ return OperatingSystem.MACOS;
+
+ } else if (osName.contains("solaris") || osName.contains("sunos")) {
+
+ return OperatingSystem.SOLARIS;
+ } else if (osName.contains("linux") || osName.contains("unix")) {
+
+ return OperatingSystem.LINUX;
+ }
+ return OperatingSystem.UNKNOWN;
+ }
+
+ public void centerFrame(JFrame frame) {
+ Rectangle rectangle = frame.getBounds();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Rectangle screenRectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
+
+ int newX = screenRectangle.x + (screenRectangle.width - rectangle.width) / 2;
+ int newY = screenRectangle.y + (screenRectangle.height - rectangle.height) / 2;
+
+ if (newX < 0) newX = 0;
+ if (newY < 0) newY = 0;
+
+ frame.setBounds(newX, newY, rectangle.width, rectangle.height);
+ }
+
+ public void showMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates", JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ public void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates - Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ public enum OperatingSystem {
+ LINUX,
+ SOLARIS,
+ WINDOWS,
+ MACOS,
+ UNKNOWN
+ }
+
+ private static String getStacktraceText(Throwable ex) {
+ StringWriter stringWriter = new StringWriter();
+ ex.printStackTrace(new PrintWriter(stringWriter));
+ return stringWriter.toString().replace("\t", " ");
+ }
+
+ private static void showErrorPopup(Throwable ex) {
+ ex.printStackTrace();
+
+ JTextArea textArea = new JTextArea(getStacktraceText(ex));
+ textArea.setEditable(false);
+ Font currentFont = textArea.getFont();
+ Font newFont = new Font(Font.MONOSPACED, currentFont.getStyle(), currentFont.getSize());
+ textArea.setFont(newFont);
+
+ JScrollPane errorScrollPane = new JScrollPane(textArea);
+ errorScrollPane.setPreferredSize(new Dimension(600, 400));
+ JOptionPane.showMessageDialog(null, errorScrollPane, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ private String getVersionFromMcmodInfo() {
+ String version = "";
+ try {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("mcmod.info")));
+ while ((version = bufferedReader.readLine()) != null) {
+ if (version.contains("\"version\": \"")) {
+ version = version.split(Pattern.quote("\"version\": \""))[1];
+ version = version.substring(0, version.length() - 2);
+ break;
+ }
+ }
+ } catch (Exception ex) {
+ // It's okay, I guess just don't use the version lol.
+ }
+ return version;
+ }
+
+ private String getModIDFromInputStream(InputStream inputStream) {
+ String version = "";
+ try {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+ while ((version = bufferedReader.readLine()) != null) {
+ if (version.contains("\"modid\": \"")) {
+ version = version.split(Pattern.quote("\"modid\": \""))[1];
+ version = version.substring(0, version.length() - 2);
+ break;
+ }
+ }
+ } catch (Exception ex) {
+ // RIP, couldn't find the modid...
+ }
+ return version;
+ }
+
+ private File getThisFile() {
+ try {
+ return new File(NotSkyblockAddonsInstallerFrame.class.getProtectionDomain().getCodeSource().getLocation().toURI());
+ } catch (URISyntaxException ex) {
+ showErrorPopup(ex);
+ }
+ return null;
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {}
+
+ @Override
+ public void mouseReleased(MouseEvent e) {}
+
+ @Override
+ public void mouseEntered(MouseEvent e) {}
+
+ @Override
+ public void mouseExited(MouseEvent e) {}
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
index 4328eaf4..58eaab72 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
@@ -48,6 +48,14 @@ public class CustomItems {
"incursions on the server, some of which I, a player on this Minecraft",
"anarchy server in Minecraft, have participated in. One of this server's",
"most infamous Minecraft players on the oldest Minecraft");
+ public static JsonObject LEOCTHL = create("LEOCTHL", "dragon_egg", "--- Stats below may not be entirely accurate ---",
+ "17 legendary dragon pets",
+ "24 epic dragon pets",
+ "18 epic golem pets",
+ "12 legendary golem pets",
+ "39 legendary phoenix pets",
+ "",
+ "get flexed");
/**
* SHAAAAAAAAAAAAAAAAAAME
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
new file mode 100644
index 00000000..98b08fd8
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
@@ -0,0 +1,222 @@
+package io.github.moulberry.notenoughupdates;
+
+import com.google.common.base.Splitter;
+import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
+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.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.opengl.GL11;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class GuiEnchantColour extends GuiScreen {
+
+ public static final ResourceLocation custom_ench_colour = new ResourceLocation("notenoughupdates:custom_ench_colour.png");
+
+ private int guiLeft;
+ private int guiTop;
+ private final int xSize = 176;
+ private int ySize = 0;
+
+ private List<String> getEnchantColours() {
+ return NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value;
+ }
+
+ public static final Splitter splitter = Splitter.on(":").limit(4);
+
+ private HashMap<Integer, String> comparators = new HashMap<>();
+ private List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ List<String> enchantColours = getEnchantColours();
+
+ ySize = 53+25*enchantColours.size();
+ guiLeft = (width-xSize)/2;
+ guiTop = (height-ySize)/2;
+
+ NotEnoughUpdates.INSTANCE.manager.loadConfig();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21/78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop+ySize-32, xSize, 32, 0, 1, 46/78f, 1, GL11.GL_NEAREST);
+
+ fontRendererObj.drawString("Ench Name", guiLeft+10, guiTop+7, 4210752);
+ fontRendererObj.drawString("CMP", guiLeft+71, guiTop+7, 4210752);
+ fontRendererObj.drawString("LVL", guiLeft+96, guiTop+7, 4210752);
+ fontRendererObj.drawString("COL", guiLeft+121, guiTop+7, 4210752);
+ fontRendererObj.drawString("DEL", guiLeft+146, guiTop+7, 4210752);
+
+ Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2, guiTop+ySize-20, false, 4210752);
+
+ int yIndex = 0;
+ for(String str : enchantColours) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop+21+yIndex*25, xSize, 25, 0, 1, 21/78f, 46/78f, GL11.GL_NEAREST);
+
+ List<String> colourOps = splitter.splitToList(str);
+ String enchantName = getColourOpIndex(colourOps, 0);
+ String comparator = getColourOpIndex(colourOps, 1);
+ String comparison = getColourOpIndex(colourOps, 2);
+ String colourCode = getColourOpIndex(colourOps, 3);
+
+ if(colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
+ if(comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
+
+ Utils.drawStringCentered(comparator, fontRendererObj, guiLeft+81, guiTop+33+25*yIndex, false, 4210752);
+
+ if(guiElementTextFields.size() <= yIndex) {
+ guiElementTextFields.add(new GuiElementTextField[3]);
+ }
+ if(guiElementTextFields.get(yIndex)[0] == null) {
+ guiElementTextFields.get(yIndex)[0] = new GuiElementTextField(enchantName, GuiElementTextField.SCALE_TEXT);
+ guiElementTextFields.get(yIndex)[0].setSize(56, 20);
+ }
+ if(guiElementTextFields.get(yIndex)[1] == null) {
+ guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(comparison,
+ GuiElementTextField.SCALE_TEXT|GuiElementTextField.NUM_ONLY|GuiElementTextField.NO_SPACE);
+ guiElementTextFields.get(yIndex)[1].setSize(20, 20);
+ }
+ if(guiElementTextFields.get(yIndex)[2] == null) {
+ guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT);
+ guiElementTextFields.get(yIndex)[2].setSize(20, 20);
+ }
+ guiElementTextFields.get(yIndex)[0].setText(enchantName);
+ guiElementTextFields.get(yIndex)[1].setText(comparison);
+ comparators.put(yIndex, comparator);
+ guiElementTextFields.get(yIndex)[2].setText(colourCode);
+
+ guiElementTextFields.get(yIndex)[0].render(guiLeft+10, guiTop+23+25*yIndex);
+ guiElementTextFields.get(yIndex)[1].render(guiLeft+96, guiTop+23+25*yIndex);
+ guiElementTextFields.get(yIndex)[2].render(guiLeft+121, guiTop+23+25*yIndex);
+
+ yIndex++;
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
+ for(int i=0; i<3; i++) {
+ guiElementTextFields.get(yIndex)[i].keyTyped(typedChar, keyCode);
+ if(guiElementTextFields.get(yIndex)[i].getFocus()) {
+ int addOffset = 0;
+ if(keyCode == Keyboard.KEY_UP) {
+ addOffset -= 1;
+ } else if(keyCode == Keyboard.KEY_DOWN) {
+ addOffset += 1;
+ }
+
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex);
+ if(yIndex+addOffset < 0) {
+ addOffset = -yIndex;
+ } else if(yIndex+addOffset > NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.size()) {
+ addOffset = NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.size()-yIndex;
+ }
+ System.out.println(addOffset);
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex+addOffset,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex)));
+ NotEnoughUpdates.INSTANCE.manager.saveConfig();
+ if(addOffset != 0) {
+ GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex);
+ guiElementTextFields.add(yIndex+addOffset, guiElementTextFieldArray);
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ public String getEnchantOpString(GuiElementTextField[] tfs, String comparator) {
+ StringBuilder enchantOp = new StringBuilder();
+ enchantOp.append(tfs[0].getText());
+ enchantOp.append(":");
+ enchantOp.append(comparator);
+ enchantOp.append(":");
+ enchantOp.append(tfs[1].getText());
+ enchantOp.append(":");
+ enchantOp.append(tfs[2].getText());
+ return enchantOp.toString();
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
+ for(int i=0; i<3; i++) {
+ int x = guiLeft+10;
+ if(i == 1) x+=86;
+ else if(i == 2) x+=111;
+
+ if(mouseX > x && mouseX < x+guiElementTextFields.get(yIndex)[i].getWidth()) {
+ if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
+ guiElementTextFields.get(yIndex)[i].mouseClicked(mouseX, mouseY, mouseButton);
+ if(mouseButton == 1) {
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex)));
+ NotEnoughUpdates.INSTANCE.manager.saveConfig();
+ }
+ continue;
+ }
+ }
+ guiElementTextFields.get(yIndex)[i].otherComponentClick();
+ }
+ comparators.computeIfAbsent(yIndex, k->">");
+ if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
+ if(mouseX > guiLeft+71 && mouseX < guiLeft+71+20) {
+ switch (comparators.get(yIndex)) {
+ case ">":
+ comparators.put(yIndex, "="); break;
+ case "=":
+ comparators.put(yIndex, "<"); break;
+ default:
+ comparators.put(yIndex, ">"); break;
+ }
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex)));
+ NotEnoughUpdates.INSTANCE.manager.saveConfig();
+ } else if(mouseX > guiLeft+146 && mouseX < guiLeft+146+20) {
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex);
+ guiElementTextFields.remove(yIndex);
+ comparators.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.manager.saveConfig();
+ }
+ }
+ }
+ if(mouseX >= guiLeft+42 && mouseX <= guiLeft+42+88) {
+ if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) {
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add("[a-zA-Z ]+:>:5:9");
+ NotEnoughUpdates.INSTANCE.manager.saveConfig();
+ }
+ }
+ }
+
+ public static String getColourOpIndex(List<String> colourOps, int index) {
+ if(colourOps.size() > index) {
+ return colourOps.get(index);
+ } else {
+ switch(index) {
+ case 0:
+ return "[a-zA-Z ]+";
+ case 1:
+ return ">";
+ case 2:
+ return "5";
+ case 3:
+ return "9";
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java
new file mode 100644
index 00000000..2c70ec1e
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java
@@ -0,0 +1,251 @@
+package io.github.moulberry.notenoughupdates;
+
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.renderer.texture.TextureUtil;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.client.shader.Shader;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Matrix4f;
+import org.lwjgl.BufferUtils;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+import org.lwjgl.opengl.GL30;
+import org.lwjgl.opengl.GL45;
+
+import java.awt.*;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.util.HashMap;
+
+public class ItemRarityHalo {
+
+ public static Framebuffer itemFramebuffer1 = null;
+ public static Framebuffer itemFramebuffer2 = null;
+ public static HashMap<ItemStack, Integer> itemHaloTexMap = new HashMap<>();
+ public static Matrix4f projectionMatrix = null;
+
+ public static Shader colourShader = null;
+ public static Shader blurShaderHorz = null;
+ public static Shader blurShaderVert = null;
+
+ private static int oldScaledResolution = 0;
+
+ public static void onItemRender(ItemStack stack, int x, int y) {
+ if(x == 0 && y == 0) return;
+
+ if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ NotEnoughUpdates neu = NotEnoughUpdates.INSTANCE;
+ if(!neu.isOnSkyblock()) return;
+ if(neu.manager.config.itemHighlightOpacity.value <= 1) return;
+ if(neu.manager.getInternalNameForItem(stack) == null) return;
+
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int size = 16*scaledresolution.getScaleFactor();
+
+ if(projectionMatrix == null) {
+ projectionMatrix = Utils.createProjectionMatrix(size, size);
+ }
+
+ itemFramebuffer1 = checkFramebufferSizes(itemFramebuffer1, size, size);
+ itemFramebuffer2 = checkFramebufferSizes(itemFramebuffer2, size, size);
+
+ try {
+ if(colourShader == null) {
+ colourShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "setrgbtoalpha", itemFramebuffer1, itemFramebuffer2);
+ upload(colourShader, size, size);
+ }
+
+ if(blurShaderHorz == null) {
+ blurShaderHorz = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "blur", itemFramebuffer2, itemFramebuffer1);
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(5f);
+ blurShaderHorz.getShaderManager().getShaderUniform("AlphaMult").set(2f);
+ upload(blurShaderHorz, size, size);
+ }
+
+ if(blurShaderVert == null) {
+ blurShaderVert = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "blur", itemFramebuffer1, itemFramebuffer2);
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set(5f);
+ blurShaderVert.getShaderManager().getShaderUniform("AlphaMult").set(2f);
+ upload(blurShaderVert, size, size);
+ }
+ } catch(Exception e) { return; }
+
+ if(oldScaledResolution != scaledresolution.getScaleFactor()) {
+ resetItemHaloCache();
+ oldScaledResolution = scaledresolution.getScaleFactor();
+ }
+
+ int currentBuffer = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
+ IntBuffer currentViewport = BufferUtils.createIntBuffer(16);
+ GL11.glGetInteger(GL11.GL_VIEWPORT, currentViewport);
+ try {
+ if(!itemHaloTexMap.containsKey(stack)) {
+ int texture1 = TextureUtil.glGenTextures();
+ int texture2 = TextureUtil.glGenTextures();
+
+ GlStateManager.bindTexture(texture1);
+ GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null));
+ itemFramebuffer1.bindFramebuffer(false);
+ OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture1, 0);
+
+ GlStateManager.bindTexture(texture2);
+ GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null));
+ itemFramebuffer2.bindFramebuffer(false);
+ OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture2, 0);
+
+ itemFramebuffer1.framebufferClear();
+ itemFramebuffer2.framebufferClear();
+
+ GlStateManager.pushMatrix(); {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, size, size, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ GL11.glScalef(scaledresolution.getScaleFactor(), scaledresolution.getScaleFactor(), 1);
+
+ itemFramebuffer1.bindFramebuffer(true);
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ RenderHelper.enableGUIStandardItemLighting();
+ float zLevel = itemRender.zLevel;
+ itemRender.zLevel = -145; //Negates the z-offset of the below method.
+ itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
+ itemRender.zLevel = zLevel;
+ RenderHelper.disableStandardItemLighting();
+ } GlStateManager.popMatrix();
+
+ GlStateManager.pushMatrix(); {
+ GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ executeShader(colourShader);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ //executeShader(blurShaderHorz);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ //executeShader(blurShaderVert);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ } GlStateManager.popMatrix();
+
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(5888);
+
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
+
+ //TextureUtil.deleteTexture(texture1);
+ itemHaloTexMap.put(stack, texture2);
+ }
+
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
+
+ GlStateManager.bindTexture(itemHaloTexMap.get(stack));
+ Color color = Utils.getPrimaryColour(stack.getDisplayName());
+ GlStateManager.color(color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f,
+ NotEnoughUpdates.INSTANCE.manager.config.itemHighlightOpacity.value.floatValue()/255f);
+ Utils.drawTexturedRect(x, y, 16, 16,
+ 0, 1, 1, 0, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+ } catch(Exception e) {
+ e.printStackTrace();
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
+ }
+ }
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if(framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, true);
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ public static void resetItemHaloCache() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int size = 16*scaledresolution.getScaleFactor();
+
+ for(int tex : itemHaloTexMap.values()) {
+ TextureUtil.deleteTexture(tex);
+ }
+ itemHaloTexMap.clear();
+
+ if(NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ projectionMatrix = Utils.createProjectionMatrix(size, size);
+ upload(colourShader, size, size);
+ upload(blurShaderHorz, size, size);
+ upload(blurShaderVert, size, size);
+ }
+ }
+
+ private static void upload(Shader shader, int width, int height) {
+ if(shader == null) return;
+ shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
+ shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float)width, (float)height);
+ }
+
+ private static void executeShader(Shader shader) {
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.disableBlend();
+ GlStateManager.disableDepth();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableFog();
+ GlStateManager.disableLighting();
+ GlStateManager.disableColorMaterial();
+ GlStateManager.enableTexture2D();
+ GlStateManager.bindTexture(0);
+
+ float f = (float)shader.framebufferOut.framebufferTextureWidth;
+ float f1 = (float)shader.framebufferOut.framebufferTextureHeight;
+ GlStateManager.viewport(0, 0, (int)f, (int)f1);
+
+ shader.getShaderManager().useShader();
+ shader.getShaderManager().addSamplerTexture("DiffuseSampler", shader.framebufferIn);
+
+ shader.framebufferOut.framebufferClear();
+ shader.framebufferOut.bindFramebuffer(false);
+
+ GlStateManager.depthMask(false);
+
+ GlStateManager.enableAlpha();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(0.0D, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos((double)f, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos((double)f, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos(0.0D, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
+ tessellator.draw();
+
+ GlStateManager.depthMask(true);
+
+ shader.getShaderManager().endShader();
+
+ shader.framebufferOut.unbindFramebuffer();
+ shader.framebufferIn.unbindFramebufferTexture();
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index b879c383..680094af 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -23,6 +23,8 @@ import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -226,24 +228,29 @@ public class NEUManager {
/**
* Downloads and sets auctionPricesJson from the URL specified by AUCTIONS_PRICE_URL.
*/
+ private ExecutorService es = Executors.newCachedThreadPool();
public void updatePrices() {
if(System.currentTimeMillis() - auctionLastUpdate > 1000*60*120) { //2 hours
craftCost.clear();
System.out.println("[NEU] UPDATING PRICE INFORMATION");
auctionLastUpdate = System.currentTimeMillis();
- try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) {
- auctionPricesJson = gson.fromJson(inReader, JsonObject.class);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ es.submit(() -> {
+ try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) {
+ auctionPricesJson = gson.fromJson(inReader, JsonObject.class);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
}
}
public boolean hasAuctionInfo(String internalname) {
+ if(auctionPricesJson == null) return false;
return auctionPricesJson.has("item_data") && auctionPricesJson.get("item_data").getAsJsonObject().has(internalname);
}
public boolean hasBazaarInfo(String internalname) {
+ if(auctionPricesJson == null) return false;
return auctionPricesJson.has("bazaar") && auctionPricesJson.get("bazaar").getAsJsonObject().has(internalname);
}
@@ -276,7 +283,7 @@ public class NEUManager {
if(info == null || !info.has("price")) {
return 0;
}
- if(!auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) {
+ if(auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) {
return 0;
}
JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices");
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 25b27cc5..7db8875d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -1053,7 +1053,7 @@ public class NEUOverlay extends Gui {
} else if(getSortMode() == SORT_MODE_MOB) {
return internalname.matches(mobRegex);
} else if(getSortMode() == SORT_MODE_PET) {
- return internalname.matches(petRegex);
+ return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("[");
} else if(getSortMode() == SORT_MODE_TOOL) {
return checkItemType(item.get("lore").getAsJsonArray(),
"SWORD", "BOW", "AXE", "PICKAXE", "FISHING ROD", "WAND", "SHOVEL", "HOE") >= 0;
@@ -1099,6 +1099,9 @@ public class NEUOverlay extends Gui {
case "thirtyvirus":
searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT"));
break;
+ case "leocthl":
+ searchedItems.add(CustomItems.LEOCTHL);
+ break;
}
}
@@ -1482,16 +1485,16 @@ public class NEUOverlay extends Gui {
if(blurShaderHorz == null) {
try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(),
+ "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
} catch(Exception e) { }
}
if(blurShaderVert == null) {
try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, blurOutputVert);
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(),
+ "blur", blurOutputHorz, blurOutputVert);
blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
} catch(Exception e) { }
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 734f7ca1..efd38c55 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -11,6 +11,7 @@ import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
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;
@@ -24,6 +25,8 @@ import net.minecraft.client.gui.inventory.*;
import net.minecraft.client.renderer.GlStateManager;
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.event.ClickEvent;
import net.minecraft.init.Blocks;
@@ -37,6 +40,7 @@ import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.Matrix4f;
import net.minecraft.util.Session;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.*;
@@ -61,10 +65,13 @@ import java.lang.reflect.Modifier;
import java.net.Proxy;
import java.text.NumberFormat;
import java.util.*;
+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 static io.github.moulberry.notenoughupdates.GuiTextures.*;
@@ -127,10 +134,20 @@ public class NotEnoughUpdates {
}
});
+ SimpleCommand enchantColourCommand = new SimpleCommand("neuec", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ openGui = new GuiEnchantColour();
+ }
+ });
+
private static ProfileViewer profileViewer;
SimpleCommand viewProfileCommand = new SimpleCommand("neuprofile", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
+ /*if(!OpenGlHelper.isFramebufferEnabled()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "This feature requires FBOs to work. Try disabling Optifine's 'Fast Render'."));
+ } else*/
if(args.length != 1) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
"idiot."));
@@ -210,6 +227,7 @@ public class NotEnoughUpdates {
ClientCommandHandler.instance.registerCommand(linksCommand);
ClientCommandHandler.instance.registerCommand(viewProfileCommand);
ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand);
+ ClientCommandHandler.instance.registerCommand(enchantColourCommand);
//ClientCommandHandler.instance.registerCommand(questingCommand);
ClientCommandHandler.instance.registerCommand(neuAhCommand);
@@ -383,28 +401,39 @@ public class NotEnoughUpdates {
* 2)Adds unique items to the collection log
*/
private HashMap<String, Long> newItemAddMap = new HashMap<>();
+ private long lastLongUpdate = 0;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
+ boolean longUpdate = false;
+ long currentTime = System.currentTimeMillis();
+ if(currentTime - lastLongUpdate > 1000) {
+ longUpdate = true;
+ lastLongUpdate = currentTime;
+ }
if(openGui != null) {
Minecraft.getMinecraft().displayGuiScreen(openGui);
openGui = null;
}
- if(hasSkyblockScoreboard()) {
- manager.auctionManager.tick();
- if(!joinedSB && manager.config.showUpdateMsg.value) {
- if(displayUpdateMessageIfOutOfDate()) {
- joinedSB = false;
+ if(longUpdate) {
+ updateSkyblockScoreboard();
+ if(hasSkyblockScoreboard()) {
+ manager.auctionManager.tick();
+ if(!joinedSB && manager.config.showUpdateMsg.value) {
+ if(displayUpdateMessageIfOutOfDate()) {
+ joinedSB = false;
+ }
}
+ SBScoreboardData.getInstance().tick();
+ //GuiQuestLine.questLine.tick();
}
- SBScoreboardData.getInstance().tick();
- //GuiQuestLine.questLine.tick();
+ //ItemRarityHalo.resetItemHaloCache();
}
- if(currChatMessage != null && System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) {
- lastChatMessage = System.currentTimeMillis();
+ if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
+ lastChatMessage = currentTime;
Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
currChatMessage = null;
}
- if(hasSkyblockScoreboard() && manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) {
+ if(longUpdate && hasSkyblockScoreboard() && manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) {
HashSet<String> newItem = new HashSet<>();
if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer &&
!(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) {
@@ -512,7 +541,8 @@ public class NotEnoughUpdates {
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("BIN Auction View") || containerName.trim().equals("Confirm Bid") ||
+ containerName.trim().equals("Confirm Purchase"));
}
//OPEN
@@ -682,7 +712,7 @@ public class NotEnoughUpdates {
*/
@SubscribeEvent
public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
- if((event.gui instanceof GuiContainer || event.gui instanceof CustomAHGui) && isOnSkyblock()) {
+ if((event.gui instanceof GuiContainer || event.gui instanceof CustomAHGui || event.gui instanceof GuiItemRecipe) && isOnSkyblock()) {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledresolution.getScaledWidth();
@@ -749,7 +779,7 @@ public class NotEnoughUpdates {
@SubscribeEvent
public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) {
if(!(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView())) {
- if(event.gui instanceof GuiContainer && isOnSkyblock()) {
+ if((event.gui instanceof GuiContainer || event.gui instanceof GuiItemRecipe) && isOnSkyblock()) {
renderDungeonChestOverlay(event.gui);
@@ -1003,6 +1033,103 @@ public class NotEnoughUpdates {
}*/
}
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void onItemTooltipLow(ItemTooltipEvent event) {
+ //NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value
+ int index = 0;
+ List<String> newTooltip = new ArrayList<>();
+ for(String line : event.toolTip) {
+ for(String op : NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value) {
+ 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);
+
+ if(enchantName.length() == 0) continue;
+ if(comparator.length() == 0) continue;
+ if(comparison.length() == 0) continue;
+ if(colourCode.length() == 0) continue;
+
+ if(enchantName.contains("(") || enchantName.contains(")")) continue;
+
+ int comparatorI = ">=<".indexOf(comparator.charAt(0));
+
+ int levelToFind = -1;
+ try {
+ levelToFind = Integer.parseInt(comparison);
+ } catch(Exception e) { continue; }
+
+ if(comparatorI < 0) continue;
+ if("0123456789abcdefz".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 {
+ String prefix = "\u00A79";
+ if(enchantName.startsWith("ULT_")) prefix = "\u00A7l\u00A7d";
+ pattern = Pattern.compile(prefix+"("+enchantName+") ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)");
+ } catch(Exception e) {continue;} //malformed regex
+ Matcher matcher = pattern.matcher(line);
+ int matchCount = 0;
+ while(matcher.find() && matchCount < 5) {
+ matchCount++;
+ int level = -1;
+ String levelStr = matcher.group(2);
+ 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;
+ }
+ }
+ 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) {
+ if(!colourCode.equals("z")) {
+ line = line.replaceAll("\\u00A79"+matcher.group(1), "\u00A7"+colourCode+matcher.group(1));
+ } else {
+ line = line.replaceAll("\\u00A79"+matcher.group(1), Utils.chromaString(matcher.group(1)));
+ }
+ }
+ }
+ }
+ newTooltip.add(line);
+ }
+ event.toolTip.clear();
+ event.toolTip.addAll(newTooltip);
+ }
+
/**
* This makes it so that holding LCONTROL while hovering over an item with NBT will show the NBT of the item.
* @param event
@@ -1103,13 +1230,19 @@ public class NotEnoughUpdates {
}
}
- //Stolen from Biscut's SkyblockAddons
public boolean isOnSkyblock() {
if(!manager.config.onlyShowOnSkyblock.value) return true;
return hasSkyblockScoreboard();
}
+ private boolean hasSkyblockScoreboard;
+
public boolean hasSkyblockScoreboard() {
+ return hasSkyblockScoreboard;
+ }
+
+ //Stolen from Biscut's SkyblockAddons
+ private void updateSkyblockScoreboard() {
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.theWorld != null) {
@@ -1119,12 +1252,13 @@ public class NotEnoughUpdates {
String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", "");
for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) {
if (objectiveName.startsWith(skyblock)) {
- return true;
+ hasSkyblockScoreboard = true;
+ return;
}
}
}
}
- return false;
+ hasSkyblockScoreboard = false;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
index 53cc4639..4d30cf3e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -40,6 +40,8 @@ public class APIManager {
private JsonArray playerInformation = null;
+ public HashMap<Integer, Integer> aucUpdates = new HashMap<>();
+
public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>();
private long lastPageUpdate = 0;
@@ -141,20 +143,21 @@ public class APIManager {
public void tick() {
customAH.tick();
- if(System.currentTimeMillis() - lastPageUpdate > 5*1000) {
+ long currentTime = System.currentTimeMillis();
+ if(currentTime - lastPageUpdate > 5*1000) {
lastPageUpdate = System.currentTimeMillis();
updatePageTick();
ahNotification();
}
- if(System.currentTimeMillis() - lastProfileUpdate > 10*1000) {
+ if(currentTime - lastProfileUpdate > 10*1000) {
lastProfileUpdate = System.currentTimeMillis();
updateProfiles(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
}
- if(System.currentTimeMillis() - lastCleanup > 120*1000) {
+ if(currentTime - lastCleanup > 120*1000) {
lastCleanup = System.currentTimeMillis();
cleanup();
}
- if(System.currentTimeMillis() - lastCustomAHSearch > 60*1000) {
+ if(currentTime - lastCustomAHSearch > 60*1000) {
lastCustomAHSearch = System.currentTimeMillis();
if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) {
customAH.updateSearch();
@@ -415,11 +418,12 @@ public class APIManager {
String rarity = auction.get("tier").getAsString();
JsonArray bids = auction.get("bids").getAsJsonArray();
- for(String lvl4Max : lvl4Maxes) {
- item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1");
+ {
+ Auction old = auctionMap.get(auctionUuid);
+ if(old != null && old.highest_bid_amount != highest_bid_amount) {
+ aucUpdates.put(page, aucUpdates.computeIfAbsent(page, k->0)+1);
+ }
}
- item_lore = item_lore.replaceAll("\\u00A79([A-Za-z ]+ VI)", EnumChatFormatting.DARK_PURPLE+"$1");
- item_lore = item_lore.replaceAll("\\u00A79([A-Za-z ]+ VII)", EnumChatFormatting.RED+"$1");
try {
NBTTagCompound item_tag;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 77fa8425..2bbabd64 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -182,10 +182,12 @@ public class CustomAH extends Gui {
}
public void tick() {
- if(shouldUpdateSearch) updateSearch();
- if(shouldSortItems) {
- sortItems();
- shouldSortItems = false;
+ if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) {
+ if(shouldUpdateSearch) updateSearch();
+ if(shouldSortItems) {
+ sortItems();
+ shouldSortItems = false;
+ }
}
}
@@ -530,8 +532,7 @@ public class CustomAH extends Gui {
} catch(NullPointerException e) { //i cant be bothered
}
}
- } else if(containerName.trim().equals("Confirm Bid")) {
-
+ } else if(containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept);
this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
@@ -878,6 +879,11 @@ public class CustomAH extends Gui {
lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions);
lore.add("Total Tags: " + manager.auctionManager.totalTags);
lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions);
+ lore.add("AucUpdates(0): " + manager.auctionManager.aucUpdates.computeIfAbsent(0, k->0));
+ lore.add("AucUpdates(1): " + manager.auctionManager.aucUpdates.computeIfAbsent(1, k->0));
+ lore.add("AucUpdates(20): " + manager.auctionManager.aucUpdates.computeIfAbsent(20, k->0));
+ lore.add("AucUpdates(Last-1): " + manager.auctionManager.aucUpdates.computeIfAbsent(manager.auctionManager.aucUpdates.size()-2, k->0));
+ lore.add("AucUpdates(Last): " + manager.auctionManager.aucUpdates.computeIfAbsent(manager.auctionManager.aucUpdates.size()-1, k->0));
lore.add("");
lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!");
lore.add(EnumChatFormatting.YELLOW + "Click to refresh!");
@@ -1371,7 +1377,7 @@ public class CustomAH extends Gui {
Utils.playPressSound();
}
}
- } else if(containerName.trim().equals("Confirm Bid")) {
+ } else if(containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) {
if(mouseY > guiTop+31 && mouseY < guiTop+31+16) {
if(currentAucId != null) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
index 5f9e6af1..e4c524f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
@@ -241,19 +241,6 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
}
}
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
public int getCurrentAcquiredCount() {
if(getAcquiredItems() == null) return 0;
if(!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0;
@@ -268,7 +255,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
if(itemFramebuffer != null && grayscaleShader != null &&
(itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) {
- grayscaleShader.setProjectionMatrix(createProjectionMatrix(
+ grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor()));
}
@@ -300,7 +287,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
grayscaleShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
"grayscale",
itemFramebuffer, itemFramebufferGrayscale);
- grayscaleShader.setProjectionMatrix(createProjectionMatrix(
+ grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor()));
} catch(Exception e) {
return;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
index 3c939589..23f4ad0b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
@@ -54,7 +54,9 @@ public class GuiElementTextField extends GuiElement {
}
public void setText(String text) {
- textField.setText(text);
+ if(textField.getText() == null || !textField.getText().equals(text)) {
+ textField.setText(text);
+ }
}
public void setSize(int searchBarXSize, int searchBarYSize) {
@@ -300,6 +302,7 @@ public class GuiElementTextField extends GuiElement {
if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
if((options & NO_SPACE) != 0 && typedChar == ' ') return;
+ textField.setFocused(true);
textField.textboxKeyTyped(typedChar, keyCode);
if((options & COLOUR) != 0) {
@@ -378,11 +381,18 @@ public class GuiElementTextField extends GuiElement {
textNoColor = matcher.replaceFirst("\u00B6"+code);
}
+ int xStartOffset = 5;
+ float scale = 1;
String[] texts = text.split("\n");
for(int yOffI = 0; yOffI < texts.length; yOffI++) {
int yOff = yOffI*extraSize;
if(isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])>searchBarXSize-10) {
+ scale = (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
+ if(scale > 1) scale=1;
+ float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])*scale;
+ xStartOffset = (int)((searchBarXSize-newLen)/2f);
+
Utils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x+searchBarXSize/2f,
y+searchBarYSize/2f+yOff, false,
searchBarXSize-2, Color.WHITE.getRGB());
@@ -390,7 +400,6 @@ public class GuiElementTextField extends GuiElement {
Minecraft.getMinecraft().fontRendererObj.drawString(Utils.trimToWidth(texts[yOffI], searchBarXSize-10), x + 5,
y+(searchBarYSize-8)/2+yOff, Color.WHITE.getRGB());
}
-
}
if(focus && System.currentTimeMillis()%1000>500) {
@@ -406,22 +415,20 @@ public class GuiElementTextField extends GuiElement {
if(split.length <= numLinesBeforeCursor || split.length == 0) {
textBeforeCursorWidth = 0;
} else {
- textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1]);
+ textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
}
- drawRect(x + 5 + textBeforeCursorWidth,
+ drawRect(x + xStartOffset + textBeforeCursorWidth,
y+(searchBarYSize-8)/2-1 + yOff,
- x + 5 + textBeforeCursorWidth+1,
+ x + xStartOffset + textBeforeCursorWidth+1,
y+(searchBarYSize-8)/2+9 + yOff, Color.WHITE.getRGB());
}
String selectedText = textField.getSelectedText();
if(!selectedText.isEmpty()) {
- int leftIndex = textField.getCursorPosition() < textField.getSelectionEnd() ?
- textField.getCursorPosition() : textField.getSelectionEnd();
- int rightIndex = textField.getCursorPosition() > textField.getSelectionEnd() ?
- textField.getCursorPosition() : textField.getSelectionEnd();
+ int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd());
+ int rightIndex = Math.max(textField.getCursorPosition(), textField.getSelectionEnd());
- int texX = 0;
+ float texX = 0;
int texY = 0;
boolean sectionSignPrev = false;
boolean bold = false;
@@ -440,9 +447,9 @@ public class GuiElementTextField extends GuiElement {
if(c == '\n') {
if(i >= leftIndex && i < rightIndex) {
- drawRect(x + 5 + texX,
+ drawRect(x + xStartOffset + (int)texX,
y+(searchBarYSize-8)/2-1 + texY,
- x + 5 + texX + 3,
+ x + xStartOffset + (int)texX + 3,
y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
}
@@ -456,22 +463,22 @@ public class GuiElementTextField extends GuiElement {
int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
if(bold) len++;
if(i >= leftIndex && i < rightIndex) {
- drawRect(x + 5 + texX,
+ drawRect(x + xStartOffset + (int)texX,
y+(searchBarYSize-8)/2-1 + texY,
- x + 5 + texX + len,
+ x + xStartOffset + (int)(texX + len*scale),
y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
- Minecraft.getMinecraft().fontRendererObj.drawString(String.valueOf(c),
- x + 5 + texX,
- y+(searchBarYSize-8)/2 + texY, Color.BLACK.getRGB());
+ Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX,
+ y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
if(bold) {
- Minecraft.getMinecraft().fontRendererObj.drawString(String.valueOf(c),
- x + 5 + texX +1,
- y+(searchBarYSize-8)/2 + texY, Color.BLACK.getRGB());
+ Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX + 1,
+ y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
}
}
- texX += len;
+ texX += len*scale;
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
index 51c85b19..00fdc873 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
@@ -4,6 +4,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import net.minecraft.client.renderer.InventoryEffectRenderer;
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.ModifyVariable;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
new file mode 100644
index 00000000..67f0f7dc
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
@@ -0,0 +1,53 @@
+package io.github.moulberry.notenoughupdates.mixins;
+
+import io.github.moulberry.notenoughupdates.ItemRarityHalo;
+import io.github.moulberry.notenoughupdates.NEUResourceManager;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+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.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.client.resources.model.IBakedModel;
+import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.client.shader.Shader;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Matrix4f;
+import org.lwjgl.BufferUtils;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+import org.lwjgl.opengl.GL30;
+import org.lwjgl.util.vector.Vector4f;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import javax.vecmath.Vector3f;
+import java.awt.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.util.HashMap;
+
+@Mixin({RenderItem.class})
+public abstract class MixinRenderItem {
+
+ //Lnet/minecraft/client/renderer/entity/RenderItem;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V
+ @Inject(method="Lnet/minecraft/client/renderer/entity/RenderItem;renderItemIntoGUI(Lnet/minecraft/item/ItemStack;II)V",
+ at=@At("HEAD"), cancellable = true)
+ public void renderItemIntoGUI(ItemStack stack, int x, int y, CallbackInfo ci) {
+ if(x == 0 && y == 0 || true) return;
+ ItemRarityHalo.onItemRender(stack, x, y);
+
+ if(Keyboard.isKeyDown(Keyboard.KEY_H)) ci.cancel();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
index 1c8a6e07..8cd82568 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
@@ -1,6 +1,7 @@
package io.github.moulberry.notenoughupdates.options;
import com.google.gson.*;
+import io.github.moulberry.notenoughupdates.GuiEnchantColour;
import io.github.moulberry.notenoughupdates.NEUOverlayPlacements;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint;
@@ -137,6 +138,11 @@ public class Options {
"Item Background Opacity",
false,
"Changes the opacity of item background. Value between 0-255.", 0, 255);
+ public Option<Double> itemHighlightOpacity = new Option(
+ 178.0,
+ "Item Highlight Opacity",
+ false,
+ "Changes the opacity of item highlights. Value between 0-255.", 0, 255);
public Option<Double> panePadding = new Option(
10.0,
"Pane Padding",
@@ -206,6 +212,17 @@ public class Options {
"OverlaySearchBar",
false,
"OverlaySearchBar");
+ public Option<List<String>> enchantColours = new Option(
+ Utils.createList("[a-zA-Z ]+:\u003e:9:6",
+ "[a-zA-Z ]+:\u003e:6:c",
+ "[a-zA-Z ]+:\u003e:5:5",
+ "Experience:\u003e:3:5",
+ "Life Steal:\u003e:3:5",
+ "Scavenger:\u003e:3:5",
+ "Looting:\u003e:3:5"),
+ "enchantColours",
+ false,
+ "enchantColours");
private ArrayList<String> createDefaultQuickCommands() {
ArrayList<String> arr = new ArrayList<>();
@@ -248,6 +265,11 @@ public class Options {
buttons.add(new Button("Edit Gui Positions", "Allows you to change the position of the search bar, etc.", () -> {
Minecraft.getMinecraft().displayGuiScreen(new NEUOverlayPlacements());
}));
+
+
+ buttons.add(new Button("Edit Enchant Colours", "Allows you to change the colour of any enchant at any level.", () -> {
+ Minecraft.getMinecraft().displayGuiScreen(new GuiEnchantColour());
+ }));
}
public List<Button> getButtons() {
@@ -280,6 +302,7 @@ public class Options {
tryAddOption(ahNotification, options);
tryAddOption(bgOpacity, options);
tryAddOption(fgOpacity, options);
+ tryAddOption(itemHighlightOpacity, options);
tryAddOption(panePadding, options);
tryAddOption(tooltipBorderOpacity, options);
//Text
@@ -359,9 +382,9 @@ public class Options {
try {
if(((Option)f.get(oDefault)).value instanceof List) {
//If the default size of the list is greater than the loaded size, use the default value.
- if(((List<?>)((Option)f.get(oDefault)).value).size() > ((List<?>)((Option)f.get(oLoad)).value).size()) {
- continue;
- }
+ //if(((List<?>)((Option)f.get(oDefault)).value).size() > ((List<?>)((Option)f.get(oLoad)).value).size()) {
+ // continue;
+ //}
}
((Option)f.get(oDefault)).value = ((Option)f.get(oLoad)).value;
} catch (Exception e) { }
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index 7b16102c..2b3eb2d1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -9,6 +9,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.properties.Property;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
+import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.questing.SBScoreboardData;
import io.github.moulberry.notenoughupdates.util.TexLoc;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -28,14 +29,17 @@ import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.resources.SkinManager;
+import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.client.shader.Shader;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.EnumPlayerModelParts;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.MathHelper;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.*;
import net.minecraft.world.World;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.Charsets;
@@ -49,12 +53,26 @@ import org.lwjgl.opengl.GL20;
import java.awt.*;
import java.io.IOException;
import java.nio.charset.Charset;
+import java.text.NumberFormat;
import java.util.*;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class GuiProfileViewer extends GuiScreen {
+ private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png");
+ public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
+ public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png");
+ public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png");
+ public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
+ public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
+ public static final ResourceLocation resource_packs = new ResourceLocation("minecraft:textures/gui/resource_packs.png");
+ private static final ResourceLocation creativeInventoryTabs =
+ new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
+
+ private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
private final ProfileViewer.Profile profile;
private ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
@@ -72,7 +90,17 @@ public class GuiProfileViewer extends GuiScreen {
private List<String> tooltipToDisplay = null;
public enum ProfileViewerPage {
- BASIC
+ BASIC(new ItemStack(Items.paper)),
+ INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))),
+ COLS(new ItemStack(Items.painting)),
+ PETS(new ItemStack(Items.bone));
+
+ public final ItemStack stack;
+
+
+ ProfileViewerPage(ItemStack stack) {
+ this.stack = stack;
+ }
}
public GuiProfileViewer(ProfileViewer.Profile profile) {
@@ -84,23 +112,880 @@ public class GuiProfileViewer extends GuiScreen {
currentTime = System.currentTimeMillis();
if(startTime == 0) startTime = currentTime;
+ this.sizeX = 431;
+ this.sizeY = 202;
+ this.guiLeft = (this.width-this.sizeX)/2;
+ this.guiTop = (this.height-this.sizeY)/2;
+
super.drawScreen(mouseX, mouseY, partialTicks);
drawDefaultBackground();
+ blurBackground();
+ renderBlurredBackground(width, height, guiLeft, guiTop, sizeX, sizeY);
+
+ GlStateManager.translate(0, 0, 5);
+ renderTabs(true);
+ GlStateManager.translate(0, 0, -3);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, 0, -2);
+ renderTabs(false);
+ GlStateManager.translate(0, 0, 2);
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
switch (currentPage) {
case BASIC:
drawBasicPage(mouseX, mouseY, partialTicks);
break;
+ case INVS:
+ drawInvsPage(mouseX, mouseY, partialTicks);
+ break;
+ case COLS:
+ drawColsPage(mouseX, mouseY, partialTicks);
+ break;
+ case PETS:
+ drawPetsPage(mouseX, mouseY, partialTicks);
+ break;
}
lastTime = currentTime;
+
if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size());
+ for(String line : tooltipToDisplay) {
+ grayTooltip.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
tooltipToDisplay = null;
}
}
+ private void renderTabs(boolean renderPressed) {
+ for(int i=0; i<ProfileViewerPage.values().length; i++) {
+ ProfileViewerPage page = ProfileViewerPage.values()[i];
+ boolean pressed = page == currentPage;
+ if(pressed == renderPressed) {
+ renderTab(page.stack, i, pressed);
+ }
+ }
+ }
+
+ private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ int x = guiLeft+xIndex*28;
+ int y = guiTop-28;
+
+ float uMin = 0;
+ float uMax = 28/256f;
+ float vMin = 20/256f;
+ float vMax = 52/256f;
+ if(pressed) {
+ vMin = 52/256f;
+ vMax = 84/256f;
+
+ if(xIndex != 0) {
+ uMin = 28/256f;
+ uMax = 56/256f;
+ }
+
+ //if(!Keyboard.isKeyDown(Keyboard.KEY_A)) renderBlurredBackground(width, height, x, y, 28, 28);
+ } else {
+ //renderBlurredBackground(width, height, x, y+2, 28, 28);
+ }
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(x, y, 28, 32, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+ Utils.drawItemStack(stack, x+6, y+9);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ for(int i=0; i<ProfileViewerPage.values().length; i++) {
+ ProfileViewerPage page = ProfileViewerPage.values()[i];
+ int x = guiLeft+i*28;
+ int y = guiTop-28;
+
+ if(mouseX > x && mouseX < x+28) {
+ if(mouseY > y && mouseY < y+32) {
+ if(currentPage != page) Utils.playPressSound();
+ currentPage = page;
+ inventoryTextField.otherComponentClick();
+ return;
+ }
+ }
+ }
+ switch (currentPage) {
+ case INVS:
+ inventoryTextField.setSize(88, 20);
+ if(mouseX > guiLeft+19 && mouseX < guiLeft+19+88) {
+ if(mouseY > guiTop+sizeY-26-20 && mouseY < guiTop+sizeY-26) {
+ inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ return;
+ }
+ }
+ }
+ inventoryTextField.otherComponentClick();
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ switch (currentPage) {
+ case INVS:
+ keyTypedInvs(typedChar, keyCode);
+ inventoryTextField.keyTyped(typedChar, keyCode);
+ break;
+ case COLS:
+ keyTypedCols(typedChar, keyCode);
+ break;
+ }
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
+ super.mouseReleased(mouseX, mouseY, mouseButton);
+
+ switch (currentPage) {
+ case INVS:
+ mouseReleasedInvs(mouseX, mouseY, mouseButton);
+ break;
+ case COLS:
+ mouseReleasedCols(mouseX, mouseY, mouseButton);
+ }
+ }
+
+ protected void keyTypedInvs(char typedChar, int keyCode) throws IOException {
+ switch(keyCode) {
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_NUMPAD1:
+ selectedInventory = "inv_contents"; break;
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_NUMPAD2:
+ selectedInventory = "ender_chest_contents"; break;
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_NUMPAD3:
+ selectedInventory = "talisman_bag"; break;
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_NUMPAD4:
+ selectedInventory = "wardrobe_contents"; break;
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_NUMPAD5:
+ selectedInventory = "fishing_bag"; break;
+ case Keyboard.KEY_6:
+ case Keyboard.KEY_NUMPAD6:
+ selectedInventory = "potion_bag"; break;
+ }
+ Utils.playPressSound();
+ }
+
+ protected void keyTypedCols(char typedChar, int keyCode) throws IOException {
+ ItemStack stack = null;
+ Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator();
+ switch(keyCode) {
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_NUMPAD5:
+ stack = items.next();
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_NUMPAD4:
+ stack = items.next();
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_NUMPAD3:
+ stack = items.next();
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_NUMPAD2:
+ stack = items.next();
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_NUMPAD1:
+ stack = items.next();
+ }
+ if(stack != null) {
+ selectedCollectionCategory = stack;
+ }
+ Utils.playPressSound();
+ }
+
+ private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) {
+ if(mouseButton == 0) {
+ int i=0;
+ for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
+ int xIndex = i%3;
+ int yIndex = i/3;
+
+ int x = guiLeft+19+34*xIndex;
+ int y = guiTop+26+34*yIndex;
+
+ if(mouseX >= x && mouseX <= x+16) {
+ if(mouseY >= y && mouseY <= y+16) {
+ if(selectedInventory != entry.getKey()) Utils.playPressSound();
+ selectedInventory = entry.getKey();
+ return;
+ }
+ }
+
+ i++;
+ }
+
+ JsonObject inventoryInfo = profile.getInventoryInfo(null);
+ if(inventoryInfo == null) return;
+ JsonObject collectionInfo = profile.getCollectionInfo(null);
+ if(collectionInfo == null) return;
+
+ ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, collectionInfo, selectedInventory);
+ if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
+ if(currentInventoryIndex < 0) currentInventoryIndex = 0;
+
+ ItemStack[][] inventory = inventories[currentInventoryIndex];
+ if(inventory == null) return;
+
+ int inventoryRows = inventory.length;
+ int invSizeY = inventoryRows*18+17+7;
+
+ int y = guiTop+101-invSizeY/2;
+
+ if(mouseY > y+invSizeY && mouseY < y+invSizeY+16) {
+ if(mouseX > guiLeft+320-12 && mouseX < guiLeft+320+12) {
+ if(mouseX < guiLeft+320) {
+ currentInventoryIndex--;
+ } else {
+ currentInventoryIndex++;
+ }
+ }
+ }
+ }
+ }
+
+ private ItemStack selectedCollectionCategory = null;
+
+ private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) {
+ int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
+ int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
+ int yIndex = 0;
+ for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
+ if(mouseX > guiLeft+7 && mouseX < guiLeft+7+20) {
+ if(mouseY > guiTop+10+collectionCatYSize*yIndex && mouseY < guiTop+10+collectionCatYSize*yIndex+20) {
+ selectedCollectionCategory = stack;
+ Utils.playPressSound();
+ return;
+ }
+ }
+ yIndex++;
+ }
+ }
+
+ private void drawPetsPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_pets);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject petsInfo = profile.getPetsInfo(null);
+ if(petsInfo == null) return;
+
+ JsonArray pets = petsInfo.get("pets").getAsJsonArray();
+ for(int i=0; i<pets.size(); i++) {
+ JsonObject pet = pets.get(i).getAsJsonObject();
+
+ }
+
+ if(minions != null) {
+ for (int i = 0; i < minions.size(); i++) {
+ String minion = minions.get(i);
+ if (minion != null) {
+ JsonObject minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_1");
+ if (minionJson != null) {
+ int xIndex = i % COLLS_XCOUNT;
+ int yIndex = i / COLLS_XCOUNT;
+
+ float x = 231 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
+ float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
+ }
+ }
+ }
+ }
+ }
+
+ private String[] romans = new String[]{"I","II","III","IV","V","VI","VII","VIII","IX","X","XI",
+ "XII","XIII","XIV","XV","XVI","XVII","XIX","XX"};
+
+ private final int COLLS_XCOUNT = 5;
+ private final int COLLS_YCOUNT = 4;
+ private final float COLLS_XPADDING = (190-COLLS_XCOUNT*20)/(float)(COLLS_XCOUNT+1);
+ private final float COLLS_YPADDING = (202-COLLS_YCOUNT*20)/(float)(COLLS_YCOUNT+1);
+
+ private void drawColsPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject collectionInfo = profile.getCollectionInfo(null);
+ if(collectionInfo == null) return;
+ JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation();
+ if(resourceCollectionInfo == null) return;
+
+ int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
+ int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
+ {
+ int yIndex = 0;
+ for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
+ if(selectedCollectionCategory == null) selectedCollectionCategory = stack;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ if(stack == selectedCollectionCategory) {
+ Utils.drawTexturedRect(guiLeft+7, guiTop+10+collectionCatYSize*yIndex, 20, 20,
+ 20/256f, 0, 20/256f, 0, GL11.GL_NEAREST);
+ Utils.drawItemStackWithText(stack, guiLeft+10, guiTop+13+collectionCatYSize*yIndex, ""+(yIndex+1));
+ } else {
+ Utils.drawTexturedRect(guiLeft+7, guiTop+10+collectionCatYSize*yIndex, 20, 20,
+ 0, 20/256f, 0, 20/256f, GL11.GL_NEAREST);
+ Utils.drawItemStackWithText(stack, guiLeft+9, guiTop+12+collectionCatYSize*yIndex, ""+(yIndex+1));
+ }
+ yIndex++;
+ }
+ }
+
+ Utils.drawStringCentered(selectedCollectionCategory.getDisplayName() + " Collections", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+134, guiTop+14, true, 4210752);
+
+ JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject();
+ JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject();
+ JsonObject maxAmounts = collectionInfo.get("max_amounts").getAsJsonObject();
+ JsonObject totalAmounts = collectionInfo.get("total_amounts").getAsJsonObject();
+ JsonObject personalAmounts = collectionInfo.get("personal_amounts").getAsJsonObject();
+
+ List<String> collections = ProfileViewer.getCollectionCatToCollectionMap().get(selectedCollectionCategory);
+ if(collections != null) {
+ for(int i=0; i<collections.size(); i++) {
+ String collection = collections.get(i);
+ if(collection != null) {
+ ItemStack collectionItem = ProfileViewer.getCollectionToCollectionDisplayMap().get(collection);
+ if(collectionItem != null) {
+ int xIndex = i%COLLS_XCOUNT;
+ int yIndex = i/COLLS_XCOUNT;
+
+ float x = 39+COLLS_XPADDING+(COLLS_XPADDING+20)*xIndex;
+ float y = 7+COLLS_YPADDING+(COLLS_YPADDING+20)*yIndex;
+
+ String tierString;
+ int tier = (int)Utils.getElementAsFloat(collectionTiers.get(collection), 0);
+ if(tier > 20 || tier < 0) {
+ tierString = String.valueOf(tier);
+ } else {
+ tierString = romans[tier];
+ }
+ float amount = Utils.getElementAsFloat(totalAmounts.get(collection), 0);
+ float maxAmount = Utils.getElementAsFloat(maxAmounts.get(collection), 0);
+ Color color = new Color(128, 128, 128, 255);
+ int tierStringColour = color.getRGB();
+ float completedness = 0;
+ if(maxAmount > 0) {
+ completedness = amount/maxAmount;
+ }
+ completedness = Math.min(1, completedness);
+ if(maxAmounts.has(collection) && completedness >= 1) {
+ tierStringColour = new Color(255, 215, 0).getRGB();
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20*(1-completedness),
+ 0, 20/256f, 0, 20*(1-completedness)/256f, GL11.GL_NEAREST);
+ GlStateManager.color(1, 185/255f, 0, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y+20*(1-completedness), 20, 20*(completedness),
+ 0, 20/256f, 20*(1-completedness)/256f, 20/256f, GL11.GL_NEAREST);
+ Utils.drawItemStack(collectionItem, guiLeft+(int)x+2, guiTop+(int)y+2);
+
+ if(mouseX > guiLeft+(int)x+2 && mouseX < guiLeft+(int)x+18) {
+ if(mouseY > guiTop+(int)y+2 && mouseY < guiTop+(int)y+18) {
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(collectionItem.getDisplayName() + " " +
+ (completedness>=1?EnumChatFormatting.GOLD:EnumChatFormatting.GRAY) + tierString);
+ tooltipToDisplay.add("Collected: " + numberFormat.format(Utils.getElementAsFloat(personalAmounts.get(collection), 0)));
+ tooltipToDisplay.add("Total Collected: " + numberFormat.format(amount));
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ if(tier >= 0) {
+ Utils.drawStringCentered(tierString, fontRendererObj,
+ guiLeft+x+10, guiTop+y-4, true,
+ tierStringColour);
+ }
+
+ Utils.drawStringCentered(shortNumberFormat(amount, 0)+"", fontRendererObj,
+ guiLeft+x+10, guiTop+y+26, true,
+ color.getRGB());
+ }
+ }
+ }
+ }
+
+ Utils.drawStringCentered(selectedCollectionCategory.getDisplayName() + " Minions", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+326, guiTop+14, true, 4210752);
+
+ float MAX_MINION_TIER = 11f;
+ List<String> minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory);
+ if(minions != null) {
+ for(int i=0; i<minions.size(); i++) {
+ String minion = minions.get(i);
+ if(minion != null) {
+ JsonObject minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion+"_GENERATOR_1");
+ if(minionJson != null) {
+ int xIndex = i%COLLS_XCOUNT;
+ int yIndex = i/COLLS_XCOUNT;
+
+ float x = 231+COLLS_XPADDING+(COLLS_XPADDING+20)*xIndex;
+ float y = 7+COLLS_YPADDING+(COLLS_YPADDING+20)*yIndex;
+
+ String tierString;
+ int tier = (int)Utils.getElementAsFloat(minionTiers.get(minion), 0);
+ if(tier-1 >= romans.length || tier-1 < 0) {
+ tierString = String.valueOf(tier);
+ } else {
+ tierString = romans[tier-1];
+ }
+
+ Color color = new Color(128, 128, 128, 255);
+ int tierStringColour = color.getRGB();
+ float completedness = tier/MAX_MINION_TIER;
+
+ completedness = Math.min(1, completedness);
+ if(completedness >= 1) {
+ tierStringColour = new Color(255, 215, 0).getRGB();
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20*(1-completedness),
+ 0, 20/256f, 0, 20*(1-completedness)/256f, GL11.GL_NEAREST);
+ GlStateManager.color(1, 185/255f, 0, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y+20*(1-completedness), 20, 20*(completedness),
+ 0, 20/256f, 20*(1-completedness)/256f, 20/256f, GL11.GL_NEAREST);
+
+ Utils.drawItemStack(NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson), guiLeft+(int)x+2, guiTop+(int)y+2);
+
+ if(mouseX > guiLeft+(int)x+2 && mouseX < guiLeft+(int)x+18) {
+ if(mouseY > guiTop+(int)y+2 && mouseY < guiTop+(int)y+18) {
+ tooltipToDisplay = NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson)
+ .getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ if(tier >= 0) {
+ Utils.drawStringCentered(tierString, fontRendererObj,
+ guiLeft+x+10, guiTop+y-4, true,
+ tierStringColour);
+ }
+ }
+ }
+ }
+ }
+
+ //190
+ }
+
+ private static final LinkedHashMap<String, ItemStack> invNameToDisplayMap = new LinkedHashMap<>();
+ static {
+ invNameToDisplayMap.put("inv_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.chest), EnumChatFormatting.GRAY+"Inventory"));
+ invNameToDisplayMap.put("ender_chest_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.ender_chest), EnumChatFormatting.GRAY+"Ender Chest"));
+ invNameToDisplayMap.put("talisman_bag", Utils.createItemStack(Items.golden_apple, EnumChatFormatting.GRAY+"Accessory Bag"));
+ invNameToDisplayMap.put("wardrobe_contents", Utils.createItemStack(Items.leather_chestplate, EnumChatFormatting.GRAY+"Wardrobe"));
+ invNameToDisplayMap.put("fishing_bag", Utils.createItemStack(Items.fish, EnumChatFormatting.GRAY+"Fishing Bag"));
+ invNameToDisplayMap.put("potion_bag", Utils.createItemStack(Items.potionitem, EnumChatFormatting.GRAY+"Potion Bag"));
+ }
+
+ public int countItemsInInventory(String internalname, JsonObject inventoryInfo, String... invsToSearch) {
+ int count = 0;
+ for(String inv : invsToSearch) {
+ JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
+ for(int i=0; i<invItems.size(); i++) {
+ if(invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
+ JsonObject item = invItems.get(i).getAsJsonObject();
+ if(item.get("internalname").getAsString().equals(internalname)) {
+ if(item.has("count")) {
+ count += item.get("count").getAsInt();
+ } else {
+ count += 1;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ private static final Pattern DAMAGE_PATTERN = Pattern.compile("^Damage: \\+([0-9]+)");
+ private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: \\+([0-9]+)");
+ private static final Pattern FISHSPEED_PATTERN = Pattern.compile("^Increases fishing speed by \\+([0-9]+)");
+
+ private ItemStack[] findBestItems(JsonObject inventoryInfo, int numItems, String[] invsToSearch, String[] typeMatches, Pattern... importantPatterns) {
+ ItemStack[] bestItems = new ItemStack[numItems];
+ TreeMap<Integer, Set<ItemStack>> map = new TreeMap<>();
+ for(String inv : invsToSearch) {
+ JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
+ for(int i=0; i<invItems.size(); i++) {
+ if(invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
+ JsonObject item = invItems.get(i).getAsJsonObject();
+ JsonArray lore = item.get("lore").getAsJsonArray();
+ if(Utils.checkItemType(lore, true, typeMatches) >= 0) {
+ int importance = 0;
+ for(int j=0; j<lore.size(); j++) {
+ String line = lore.get(j).getAsString();
+ for(Pattern pattern : importantPatterns) {
+ Matcher matcher = pattern.matcher(Utils.cleanColour(line));
+ if(matcher.find()) {
+ importance += Integer.parseInt(matcher.group(1));
+ }
+ }
+ }
+ map.computeIfAbsent(importance, k->new HashSet<>()).add(
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false));
+ }
+ }
+ }
+ int i=0;
+ outer:
+ for(int key : map.descendingKeySet()) {
+ Set<ItemStack> items = map.get(key);
+ for(ItemStack item : items) {
+ bestItems[i] = item;
+ if(++i >= bestItems.length) break outer;
+ }
+ }
+
+ return bestItems;
+ }
+
+ private int getRowsForInventory(String invName) {
+ switch(invName) {
+ case "wardrobe_contents":
+ return 4;
+ }
+ return 6;
+ }
+
+ private int getIgnoredRowsForInventory(String invName) {
+ switch(invName) {
+ case "talisman_bag":
+ case "fishing_bag":
+ case "potion_bag":
+ return 1;
+ }
+ return 0;
+ }
+
+ private int getAvailableSlotsForInventory(JsonObject inventoryInfo, JsonObject collectionInfo, String invName) {
+ JsonObject misc = Utils.getConstant("misc");
+ if(misc == null) return -1;
+ JsonElement sizesElement = Utils.getElement(misc, "bag_size."+invName+".sizes");
+ JsonElement collectionElement = Utils.getElement(misc, "bag_size."+invName+".collection");
+
+ if(sizesElement == null || !sizesElement.isJsonArray()) return -1;
+ if(collectionElement == null || !collectionElement.isJsonPrimitive()) return -1;
+
+ JsonArray sizes = sizesElement.getAsJsonArray();
+ String collection = collectionElement.getAsString();
+
+ JsonElement tierElement = Utils.getElement(collectionInfo, "collection_tiers."+collection);
+
+ if(tierElement == null || !tierElement.isJsonPrimitive()) {
+ return 0;
+ }
+ int tier = tierElement.getAsInt();
+
+ int currentSlots = 0;
+ for(int i=0; i<sizes.size(); i++) {
+ JsonObject sizeInfo = sizes.get(i).getAsJsonObject();
+ if(sizeInfo.get("tier").getAsInt() <= tier) {
+ currentSlots = sizeInfo.get("slots").getAsInt();
+ }
+ }
+ return currentSlots;
+ }
+
+ private ItemStack fillerStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
+ public ItemStack[][][] getItemsForInventory(JsonObject inventoryInfo, JsonObject collectionInfo, String invName) {
+ if(inventoryItems.containsKey(invName)) return inventoryItems.get(invName);
+
+ JsonArray jsonInv = Utils.getElement(inventoryInfo, invName).getAsJsonArray();
+
+ int rowSize = 9;
+ int rows = jsonInv.size()/rowSize;
+ int maxRowsPerPage = getRowsForInventory(invName);
+ int ignoredRows = getIgnoredRowsForInventory(invName);
+ int maxInvSize = rowSize*maxRowsPerPage;
+
+ int numInventories = (jsonInv.size()-1)/maxInvSize+1;
+
+ ItemStack[][][] inventories = new ItemStack[numInventories][][];
+
+ int availableSlots = getAvailableSlotsForInventory(inventoryInfo, collectionInfo, invName);
+
+ for(int i=0; i<numInventories; i++) {
+ int thisRows = Math.min(maxRowsPerPage, rows-maxRowsPerPage*i)-ignoredRows;
+ if(thisRows <= 0) break;
+
+ ItemStack[][] items = new ItemStack[thisRows][rowSize];
+
+ int invSize = Math.min(jsonInv.size(), maxInvSize+maxInvSize*i);
+ for(int j=maxInvSize*i; j<invSize; j++) {
+ int xIndex = (j%maxInvSize)%rowSize;
+ int yIndex = (j%maxInvSize)/rowSize;
+ if(invName.equals("inv_contents")) {
+ yIndex--;
+ if(yIndex < 0) yIndex = rows-1;
+ }
+ if(yIndex >= thisRows) {
+ break;
+ }
+
+ if(jsonInv.get(j) == null || !jsonInv.get(j).isJsonObject()) {
+ if(availableSlots >= 0) {
+ if(j >= availableSlots) {
+ items[yIndex][xIndex] = fillerStack;
+ }
+ }
+ continue;
+ }
+
+ items[yIndex][xIndex] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(jsonInv.get(j).getAsJsonObject(), false);
+ }
+ inventories[i] = items;
+ }
+
+ inventoryItems.put(invName, inventories);
+ return inventories;
+ }
+
+
+ private ItemStack[] bestWeapons = null;
+ private ItemStack[] bestRods = null;
+ private ItemStack[] armorItems = null;
+ private HashMap<String, ItemStack[][][]> inventoryItems = new HashMap<>();
+ private String selectedInventory = "inv_contents";
+ private int currentInventoryIndex = 0;
+ private int arrowCount = -1;
+ private int greenCandyCount = -1;
+ private int purpleCandyCount = -1;
+ private GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+
+ private void drawInvsPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_invs);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+ inventoryTextField.setSize(88, 20);
+
+ JsonObject inventoryInfo = profile.getInventoryInfo(null);
+ if(inventoryInfo == null) return;
+ JsonObject collectionInfo = profile.getCollectionInfo(null);
+ if(collectionInfo == null) return;
+
+ if(bestWeapons == null) {
+ bestWeapons = findBestItems(inventoryInfo, 6, new String[]{"inv_contents", "ender_chest_contents"},
+ new String[]{"SWORD","BOW"}, DAMAGE_PATTERN, STRENGTH_PATTERN);
+ }
+ if(bestRods == null) {
+ bestRods = findBestItems(inventoryInfo, 3, new String[]{"inv_contents", "ender_chest_contents"},
+ new String[]{"FISHING ROD"}, FISHSPEED_PATTERN);
+ }
+
+ for(int i=0; i<bestWeapons.length; i++) {
+ if(bestWeapons[i] == null) continue;
+ ItemStack stack = bestWeapons[i];
+ Utils.drawItemStack(stack, guiLeft+143, guiTop+13+18*i);
+ if(mouseX >= guiLeft+143-1 && mouseX <= guiLeft+143+16+1) {
+ if(mouseY >= guiTop+13+18*i-1 && mouseY <= guiTop+13+18*i+16+1) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ for(int i=0; i<bestRods.length; i++) {
+ if(bestRods[i] == null) continue;
+ ItemStack stack = bestRods[i];
+ Utils.drawItemStack(stack, guiLeft+143, guiTop+137+18*i);
+ if(mouseX >= guiLeft+143-1 && mouseX <= guiLeft+143+16+1) {
+ if(mouseY >= guiTop+137+18*i-1 && mouseY <= guiTop+137+18*i+16+1) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ if(armorItems == null) {
+ armorItems = new ItemStack[4];
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ for(int i=0; i<armor.size(); i++) {
+ if(armor.get(i) == null || !armor.get(i).isJsonObject()) continue;
+ armorItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(armor.get(i).getAsJsonObject(), false);
+ }
+ }
+
+ for(int i=0; i<armorItems.length; i++) {
+ ItemStack stack = armorItems[i];
+ if(stack != null) {
+ Utils.drawItemStack(stack, guiLeft+173, guiTop+67-18*i);
+ if(stack != fillerStack) {
+ if(mouseX >= guiLeft+173-1 && mouseX <= guiLeft+173+16+1) {
+ if(mouseY >= guiTop+67-18*i-1 && mouseY <= guiTop+67-18*i+16+1) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+ }
+ }
+
+ if(arrowCount == -1) {
+ arrowCount = countItemsInInventory("ARROW", inventoryInfo, "quiver");
+ }
+ if(greenCandyCount == -1) {
+ greenCandyCount = countItemsInInventory("GREEN_CANDY", inventoryInfo, "candy_inventory_contents");
+ }
+ if(purpleCandyCount == -1) {
+ purpleCandyCount = countItemsInInventory("PURPLE_CANDY", inventoryInfo, "candy_inventory_contents");
+ }
+
+ Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ARROW")), guiLeft+173, guiTop+101,
+ ""+(arrowCount>999?shortNumberFormat(arrowCount, 0):arrowCount));
+ Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GREEN_CANDY")), guiLeft+173, guiTop+119, ""+greenCandyCount);
+ Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PURPLE_CANDY")), guiLeft+173, guiTop+137, ""+purpleCandyCount);
+ if(mouseX > guiLeft+173 && mouseX < guiLeft+173+16) {
+ if(mouseY > guiTop+101 && mouseY < guiTop+137+16) {
+ if(mouseY < guiTop+101+17) {
+ tooltipToDisplay = Utils.createList(EnumChatFormatting.WHITE+"Arrow "+EnumChatFormatting.GRAY+"x"+arrowCount);
+ } else if(mouseY < guiTop+119+17) {
+ tooltipToDisplay = Utils.createList(EnumChatFormatting.GREEN+"Green Candy "+EnumChatFormatting.GRAY+"x"+greenCandyCount);
+ } else {
+ tooltipToDisplay = Utils.createList(EnumChatFormatting.DARK_PURPLE+"Purple Candy "+EnumChatFormatting.GRAY+"x"+purpleCandyCount);
+ }
+ }
+ }
+
+ inventoryTextField.render(guiLeft+19, guiTop+sizeY-26-20);
+
+ int i=0;
+ for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
+ int xIndex = i%3;
+ int yIndex = i/3;
+
+ int x = 19+34*xIndex;
+ int y = 26+34*yIndex;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ if(entry.getKey().equals(selectedInventory)) {
+ Utils.drawTexturedRect(guiLeft+x-2, guiTop+y-2, 20, 20, 20/256f, 0,
+ 20/256f, 0, GL11.GL_NEAREST);
+ x++;
+ y++;
+ } else {
+ Utils.drawTexturedRect(guiLeft+x-2, guiTop+y-2, 20, 20, 0, 20/256f,
+ 0, 20/256f, GL11.GL_NEAREST);
+ }
+
+ Utils.drawItemStackWithText(entry.getValue(), guiLeft+x, guiTop+y, ""+(i+1));
+
+ if(mouseX >= guiLeft+x && mouseX <= guiLeft+x+16) {
+ if(mouseY >= guiTop+y && mouseY <= guiTop+y+16) {
+ tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+
+ i++;
+ }
+
+ ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, collectionInfo, selectedInventory);
+ if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
+ if(currentInventoryIndex < 0) currentInventoryIndex = 0;
+
+ ItemStack[][] inventory = inventories[currentInventoryIndex];
+ if(inventory == null) return;
+
+ int inventoryRows = inventory.length;
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+
+ int invSizeY = inventoryRows*18+17+7;
+
+ int x = guiLeft+320-176/2;
+ int y = guiTop+101-invSizeY/2;
+
+ this.drawTexturedModalRect(x, y, 0, 0, 176, inventoryRows*18+17);
+ this.drawTexturedModalRect(x, y+inventoryRows*18+17, 0, 215, 176, 7);
+
+ boolean leftHovered = false;
+ boolean rightHovered = false;
+ if(Mouse.isButtonDown(0)) {
+ if(mouseY > y+invSizeY && mouseY < y+invSizeY+16) {
+ if(mouseX > guiLeft+320-12 && mouseX < guiLeft+320+12) {
+ if(mouseX < guiLeft+320) {
+ leftHovered = true;
+ } else {
+ rightHovered = true;
+ }
+ }
+ }
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(resource_packs);
+
+ if(currentInventoryIndex > 0) {
+ Utils.drawTexturedRect(guiLeft+320-12, y+invSizeY, 12, 16,
+ 29/256f, 53/256f, !leftHovered?0:32/256f, !leftHovered?32/256f:64/256f, GL11.GL_NEAREST);
+ }
+ if(currentInventoryIndex < inventories.length-1) {
+ Utils.drawTexturedRect(guiLeft+320, y+invSizeY, 12, 16,
+ 5/256f, 29/256f, !rightHovered?0:32/256f, !rightHovered?32/256f:64/256f, GL11.GL_NEAREST);
+ }
+
+ fontRendererObj.drawString(Utils.cleanColour(invNameToDisplayMap.get(selectedInventory).getDisplayName()), x+8, y+6, 4210752);
+
+ int overlay = new Color(0, 0, 0, 100).getRGB();
+ for(int yIndex=0; yIndex<inventory.length; yIndex++) {
+ if(inventory[yIndex] == null) continue;
+
+ for(int xIndex=0; xIndex<inventory[yIndex].length; xIndex++) {
+ ItemStack stack = inventory[yIndex][xIndex];
+
+ if(stack != null) Utils.drawItemStack(stack, x+8+xIndex*18, y+18+yIndex*18);
+
+ if(inventoryTextField.getText() != null && !inventoryTextField.getText().isEmpty() &&
+ (stack == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, inventoryTextField.getText()))) {
+ GlStateManager.translate(0, 0, 50);
+ drawRect(x+8+xIndex*18, y+18+yIndex*18, x+8+xIndex*18+16, y+18+yIndex*18+16, overlay);
+ GlStateManager.translate(0, 0, -50);
+ }
+
+ if(stack == null || stack == fillerStack) continue;
+
+ if(mouseX >= x+8+xIndex*18 && mouseX <= x+8+xIndex*18+16) {
+ if(mouseY >= y+18+yIndex*18 && mouseY <= y+18+yIndex*18+16) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+ }
+ }
+
private String niceUuid(String uuidStr) {
if(uuidStr.length()!=32) return uuidStr;
@@ -129,14 +1014,14 @@ public class GuiProfileViewer extends GuiScreen {
private HashMap<String, ResourceLocation[]> panoramasMap = new HashMap<>();
public ResourceLocation[] getPanoramasForLocation(String location, String identifier) {
- if(panoramasMap.containsKey(location)) return panoramasMap.get(location);
+ if(panoramasMap.containsKey(location+identifier)) return panoramasMap.get(location+identifier);
try {
ResourceLocation[] panoramasArray = new ResourceLocation[6];
for(int i=0; i<6; i++) {
panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/"+location+"_"+identifier+"/panorama_"+i+".jpg");
Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
}
- panoramasMap.put(location, panoramasArray);
+ panoramasMap.put(location+identifier, panoramasArray);
return panoramasArray;
} catch(IOException e) {
try {
@@ -145,14 +1030,14 @@ public class GuiProfileViewer extends GuiScreen {
panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/"+location+"/panorama_"+i+".jpg");
Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
}
- panoramasMap.put(location, panoramasArray);
+ panoramasMap.put(location+identifier, panoramasArray);
return panoramasArray;
} catch(IOException e2) {
ResourceLocation[] panoramasArray = new ResourceLocation[6];
for(int i=0; i<6; i++) {
panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/unknown/panorama_"+i+".jpg");
}
- panoramasMap.put(location, panoramasArray);
+ panoramasMap.put(location+identifier, panoramasArray);
return panoramasArray;
}
}
@@ -172,14 +1057,53 @@ public class GuiProfileViewer extends GuiScreen {
: shortNumberFormat(d, iteration+1));
}
+ private void renderAlignedString(String first, String second, float x, float y, int length) {
+ if(fontRendererObj.getStringWidth(first + " " + second) >= length) {
+ 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(first + " " + second), Minecraft.getMinecraft().fontRendererObj,
+ x+length/2f+xOff/2f, y+4+yOff/2f, false, length,
+ new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
+ }
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj,
+ x+length/2f, y+4, false, length, 4210752);
+ } else {
+ for(int xOff=-2; xOff<=2; xOff++) {
+ for(int yOff=-2; yOff<=2; yOff++) {
+ if(Math.abs(xOff) != Math.abs(yOff)) {
+ fontRendererObj.drawString(Utils.cleanColourNotModifiers(first),
+ x+xOff/2f, y+yOff/2f,
+ new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false);
+ }
+ }
+ }
+
+ int secondLen = fontRendererObj.getStringWidth(second);
+ GlStateManager.color(1, 1, 1, 1);
+ fontRendererObj.drawString(first, x, y, 4210752, false);
+ for(int xOff=-2; xOff<=2; xOff++) {
+ for(int yOff=-2; yOff<=2; yOff++) {
+ if(Math.abs(xOff) != Math.abs(yOff)) {
+ fontRendererObj.drawString(Utils.cleanColourNotModifiers(second),
+ x+length-secondLen+xOff/2f, y+yOff/2f,
+ new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false);
+ }
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ fontRendererObj.drawString(second, x+length-secondLen, y, 4210752, false);
+ }
+ }
+
private void drawBasicPage(int mouseX, int mouseY, float partialTicks) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- this.sizeX = 431;
- this.sizeY = 202;
- this.guiLeft = (this.width-this.sizeX)/2;
- this.guiTop = (this.height-this.sizeY)/2;
-
String location = null;
JsonObject status = profile.getPlayerStatus();
if(status != null && status.has("mode")) {
@@ -187,7 +1111,7 @@ public class GuiProfileViewer extends GuiScreen {
}
int extraRotation = 0;
- if(Mouse.isButtonDown(0)) {
+ if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
if(backgroundClickedX == -1) {
if(mouseX > guiLeft+23 && mouseX < guiLeft+23+81) {
if(mouseY > guiTop+44 && mouseY < guiTop+44+108) {
@@ -210,10 +1134,9 @@ public class GuiProfileViewer extends GuiScreen {
String panoramaIdentifier = "day";
if(SBScoreboardData.getInstance().currentTimeDate != null) {
- if(SBScoreboardData.getInstance().currentTimeDate.before(new Date(0, 0, 0, 6, 0, 0))) {
- if(SBScoreboardData.getInstance().currentTimeDate.after(new Date(0, 0, 0, 20, 0, 0))) {
- panoramaIdentifier = "night";
- }
+ if(SBScoreboardData.getInstance().currentTimeDate.getHours() <= 6 ||
+ SBScoreboardData.getInstance().currentTimeDate.getHours() >= 20) {
+ panoramaIdentifier = "night";
}
}
@@ -224,56 +1147,70 @@ public class GuiProfileViewer extends GuiScreen {
Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
if(entityPlayer != null && profile.getHypixelProfile() != null) {
- String rank = Utils.getElementAsString(profile.getHypixelProfile().get("rank"), Utils.getElementAsString(profile.getHypixelProfile().get("newPackageRank"), "NONE"));
- EnumChatFormatting rankPlusColorECF = EnumChatFormatting.getValueByName(Utils.getElementAsString(profile.getHypixelProfile().get("rankPlusColor"), "WHITE"));
- String rankPlusColor = EnumChatFormatting.WHITE.toString();
- if(rankPlusColorECF != null) {
- rankPlusColor = rankPlusColorECF.toString();
- }
-
- JsonObject misc = Utils.getConstant("misc");
- if(misc != null) {
- if(misc.has("ranks")) {
- String rankName = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".tag"), null);
- String rankColor = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".color"), "7");
- String rankPlus = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".plus"), "");
-
- String name = entityPlayer.getName();
-
- if(misc.has("special_bois")) {
- JsonArray special_bois = misc.get("special_bois").getAsJsonArray();
- for(int i=0; i<special_bois.size(); i++) {
- if(special_bois.get(i).getAsString().equals(profile.getUuid())) {
- name = Utils.chromaString(name);
- break;
+ String playerName = null;
+ if(profile.getHypixelProfile().has("prefix")) {
+ playerName = Utils.getElementAsString(profile.getHypixelProfile().get("prefix"), "") + " " + entityPlayer.getName();
+ } else {
+ String rank;
+ String monthlyPackageRank = Utils.getElementAsString(profile.getHypixelProfile().get("monthlyPackageRank"), "NONE");
+ if(monthlyPackageRank.equals("NONE")) {
+ rank = Utils.getElementAsString(profile.getHypixelProfile().get("rank"),
+ Utils.getElementAsString(profile.getHypixelProfile().get("newPackageRank"), "NONE"));
+ } else {
+ rank = monthlyPackageRank;
+ }
+ EnumChatFormatting rankPlusColorECF = EnumChatFormatting.getValueByName(Utils.getElementAsString(profile.getHypixelProfile().get("rankPlusColor"), "WHITE"));
+ String rankPlusColor = EnumChatFormatting.WHITE.toString();
+ if(rankPlusColorECF != null) {
+ rankPlusColor = rankPlusColorECF.toString();
+ }
+
+ JsonObject misc = Utils.getConstant("misc");
+ if(misc != null) {
+ if(misc.has("ranks")) {
+ String rankName = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".tag"), null);
+ String rankColor = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".color"), "7");
+ String rankPlus = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".plus"), "");
+
+ String name = entityPlayer.getName();
+
+ if(misc.has("special_bois")) {
+ JsonArray special_bois = misc.get("special_bois").getAsJsonArray();
+ for(int i=0; i<special_bois.size(); i++) {
+ if(special_bois.get(i).getAsString().equals(profile.getUuid())) {
+ name = Utils.chromaString(name);
+ break;
+ }
}
}
- }
- String playerName = EnumChatFormatting.GRAY.toString() + name;
- if(rankName != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("\u00A7"+rankColor);
- sb.append("[");
- sb.append(rankName);
- sb.append(rankPlusColor);
- sb.append(rankPlus);
- sb.append("\u00A7"+rankColor);
- sb.append("] ");
- sb.append(name);
- playerName = sb.toString();
+ playerName = EnumChatFormatting.GRAY.toString() + name;
+ if(rankName != null) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("\u00A7"+rankColor);
+ sb.append("[");
+ sb.append(rankName);
+ sb.append(rankPlusColor);
+ sb.append(rankPlus);
+ sb.append("\u00A7"+rankColor);
+ sb.append("] ");
+ sb.append(name);
+ playerName = sb.toString();
+ }
}
+ }
- int rankPrefixLen = fr.getStringWidth(playerName);
- int halfRankPrefixLen = rankPrefixLen/2;
+ }
+ if(playerName != null) {
+ int rankPrefixLen = fr.getStringWidth(playerName);
+ int halfRankPrefixLen = rankPrefixLen/2;
- int x = guiLeft+63;
- int y = guiTop+54;
+ int x = guiLeft+63;
+ int y = guiTop+54;
- drawRect(x-halfRankPrefixLen-1, y-1, x+halfRankPrefixLen+1, y+8, new Color(0, 0, 0, 64).getRGB());
+ drawRect(x-halfRankPrefixLen-1, y-1, x+halfRankPrefixLen+1, y+8, new Color(0, 0, 0, 64).getRGB());
- fr.drawString(playerName, x-halfRankPrefixLen, y, 0, true);
- }
+ fr.drawString(playerName, x-halfRankPrefixLen, y, 0, true);
}
}
@@ -324,6 +1261,11 @@ public class GuiProfileViewer extends GuiScreen {
entityPlayer.setCustomNameTag("");
} else {
entityPlayer.refreshDisplayName();
+ byte b = 0;
+ for(EnumPlayerModelParts part : EnumPlayerModelParts.values()) {
+ b |= part.getPartMask();
+ }
+ entityPlayer.getDataWatcher().updateObject(10, b);
}
JsonObject profileInfo = profile.getProfileInformation(null);
@@ -331,17 +1273,24 @@ public class GuiProfileViewer extends GuiScreen {
JsonObject skillInfo = profile.getSkillInfo(null);
JsonObject inventoryInfo = profile.getInventoryInfo(null);
- JsonObject collectionInfo = profile. getCollectionInfo(null);
+ JsonObject collectionInfo = profile.getCollectionInfo(null);
- if(inventoryInfo != null && inventoryInfo.has("inv_armor")) {
- JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray();
+ if(backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
for(int i=0; i<entityPlayer.inventory.armorInventory.length; i++) {
- JsonElement itemElement = items.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
- entityPlayer.inventory.armorInventory[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false);
+ entityPlayer.inventory.armorInventory[i] = null;
+ }
+ } else {
+ if(inventoryInfo != null && inventoryInfo.has("inv_armor")) {
+ JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray();
+ for(int i=0; i<entityPlayer.inventory.armorInventory.length; i++) {
+ JsonElement itemElement = items.get(i);
+ if(itemElement != null && itemElement.isJsonObject()) {
+ entityPlayer.inventory.armorInventory[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false);
+ }
}
}
}
+
if(playerLocationSkin == null) {
try {
Minecraft.getMinecraft().getSkinManager().loadProfileTextures(entityPlayer.getGameProfile(), new SkinManager.SkinAvailableCallback() {
@@ -365,12 +1314,31 @@ public class GuiProfileViewer extends GuiScreen {
}
GlStateManager.color(1, 1, 1, 1);
+ JsonObject petsInfo = profile.getPetsInfo(null);
+ if(petsInfo != null) {
+ JsonElement activePetElement = petsInfo.get("active_pet");
+ if(activePetElement != null && activePetElement.isJsonObject()) {
+ JsonObject activePet = activePetElement.getAsJsonObject();
+
+ String type = activePet.get("type").getAsString();
+
+ JsonObject item = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(type+";0");
+ if(item != null) {
+ int x = guiLeft+50;
+ float y = guiTop+82+15*(float)Math.sin(((currentTime-startTime)/800f)%(2*Math.PI));
+ GlStateManager.translate(x, y, 0);
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item);
+ GlStateManager.scale(-1.5f, 1.5f, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.scale(-1/1.5f, 1/1.5f, 1);
+ GlStateManager.translate(-x, -y, 0);
+ }
+ }
+ }
drawEntityOnScreen(guiLeft+63, guiTop+128+7, 36, guiLeft+63-mouseX, guiTop+129-mouseY, entityPlayer);
-
PlayerStats.Stats stats = profile.getStats(null);
-
if(stats != null) {
Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2);
for(int i=0; i<PlayerStats.defaultStatNames.length; i++) {
@@ -382,20 +1350,7 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.color(1, 1, 1, 1);
GlStateManager.enableBlend();
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- 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(statNamePretty) + " " + val, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+172f+xOff/2f, guiTop+36+12.5f*i+yOff/2f, false, 80, new Color(0, 0, 0,
- 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawStringCenteredScaledMaxWidth(statNamePretty + " " + EnumChatFormatting.WHITE + val, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+172f, guiTop+36+12.5f*i, false, 80, 4210752);
-
+ renderAlignedString(statNamePretty, EnumChatFormatting.WHITE.toString()+val, guiLeft+132, guiTop+32+12.5f*i, 80);
if(mouseX > guiLeft+132 && mouseX < guiLeft+212) {
if(mouseY > guiTop+32+12.5f*i && mouseY < guiTop+40+12.5f*i) {
@@ -421,6 +1376,11 @@ public class GuiProfileViewer extends GuiScreen {
if(skillInfo != null) {
int position = 0;
for(Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
+ if(entry.getValue() == null || entry.getKey() == null) {
+ position++;
+ continue;
+ }
+
int yPosition = position % 7;
int xPosition = position / 7;
@@ -432,19 +1392,7 @@ public class GuiProfileViewer extends GuiScreen {
int x = guiLeft+237+86*xPosition;
int y = guiTop+31+21*yPosition;
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringCenteredYScaledMaxWidth(Utils.cleanColourNotModifiers(skillName) + " " + levelFloored, Minecraft.getMinecraft().fontRendererObj,
- x+14+xOff/2f, y+yOff/2f, false, 60, new Color(0, 0, 0,
- 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawStringCenteredYScaledMaxWidth(EnumChatFormatting.WHITE + skillName + " " + EnumChatFormatting.WHITE + levelFloored, Minecraft.getMinecraft().fontRendererObj,
- x+14, y, false, 60, 4210752);
+ renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, 60);
if(skillInfo.get("maxed_"+entry.getKey()).getAsBoolean()) {
renderGoldBar(x, y+6, 80);
@@ -466,11 +1414,11 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- GL11.glTranslatef((x), (y-8*0.7f), 0);
+ GL11.glTranslatef((x), (y-6f), 0);
GL11.glScalef(0.7f, 0.7f, 1);
Utils.drawItemStackLinear(entry.getValue(), 0, 0);
GL11.glScalef(1/0.7f, 1/0.7f, 1);
- GL11.glTranslatef(-(x), -(y-8*0.7f), 0);
+ GL11.glTranslatef(-(x), -(y-6f), 0);
position++;
}
@@ -520,7 +1468,7 @@ public class GuiProfileViewer extends GuiScreen {
0/256f, width/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
}
if(completed > 0.5f && (displayNum == 4 || displayNum == 0)) {
- width = Math.max(xSize*(completed-0.5f), xSize/2f);
+ width = Math.min(xSize*(completed-0.5f), xSize/2f);
Utils.drawTexturedRect(x+(xSize/2f), y, width, 5,
(182-(xSize/2f))/256f, (182-(xSize/2f)+width)/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
}
@@ -600,4 +1548,109 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.disableTexture2D();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ *
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float)width;
+ projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ /**
+ * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal
+ * and vertical blur separately in order to significantly save computation time.
+ * This is only possible if framebuffers are supported by the system, so this method will exit prematurely
+ * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
+ */
+ private double lastBgBlurFactor = -1;
+ private void blurBackground() {
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ if(blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if(blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert);
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderHorz != null && blurShaderVert != null) {
+ if(15 != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15);
+ lastBgBlurFactor = 15;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ float uMin = x/(float)width;
+ float uMax = (x+blurWidth)/(float)width;
+ float vMin = y/(float)height;
+ float vMax = (y+blurHeight)/(float)height;
+
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ //Utils.setScreen(width*f, height*f, f);
+ Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMax, vMin);
+ //Utils.setScreen(width, height, f);
+ blurOutputVert.unbindFramebufferTexture();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
index bf49e616..74ffb4b8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
@@ -31,8 +31,6 @@ public class Panorama {
GL11.glViewport(0, 0, width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
- tl.handleKeyboardInput();
- tl2.handleKeyboardInput();
float fov = 97;
{
@@ -60,10 +58,8 @@ public class Panorama {
GlStateManager.translate(0, 0.37f, 0.8f);
- //GlStateManager.rotate(MathHelper.sin(currentTime/1.6f) * 5.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(angle, 0.0F, 1.0F, 0.0F);
-
for (int k = 0; k < 6; ++k) {
GlStateManager.pushMatrix();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
index d0d1e5fc..2cbb09d1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
@@ -316,33 +316,6 @@ public class PlayerStats {
return bonuses;
}
- private static String[] rarityArr = new String[] {
- "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL",
- };
- private static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i).getAsString();
- for(String rarity : rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(contains) {
- if(line.trim().contains(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- } else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- }
- return -1;
- }
-
private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health: \\+([0-9]+)");
private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense: \\+([0-9]+)");
private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: \\+([0-9]+)");
@@ -372,7 +345,6 @@ public class PlayerStats {
Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
if(matcher.find()) {
int bonus = Integer.parseInt(matcher.group(1));
- //System.out.println(entry.getKey() + ":" + bonus);
stats.addStat(entry.getKey(), bonus);
}
}
@@ -380,7 +352,6 @@ public class PlayerStats {
if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
stats.addStat(STRENGTH, 2.5f);
stats.addStat(DEFENCE, 2.5f);
- System.out.println("added day");
}
if(internalname.equals("NEW_YEAR_CAKE_BAG") && item.has("item_contents")) {
@@ -423,14 +394,13 @@ public class PlayerStats {
for(JsonArray inventory : inventories) {
for(int i=0; i<inventory.size(); i++) {
JsonElement itemElement = inventory.get(i);
- //if(itemElement != null) System.out.println("item element:"+itemElement.getClass());
if(itemElement != null && itemElement.isJsonObject()) {
JsonObject item = itemElement.getAsJsonObject();
String internalname = item.get("internalname").getAsString();
if(itemBonuses.containsKey(internalname)) {
continue;
}
- if(!talismanOnly || checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCCESSORY") >= 0) {
+ if(!talismanOnly || Utils.checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCCESSORY") >= 0) {
Stats itemBonus = getStatForItem(internalname, item, item.get("lore").getAsJsonArray());
itemBonuses.put(internalname, itemBonus);
@@ -514,14 +484,9 @@ public class PlayerStats {
JsonArray talisman_bag = Utils.getElement(inventoryInfo, "talisman_bag").getAsJsonArray();
Stats passiveBonuses = getPassiveBonuses(skillInfo, profile);
- System.out.println("passive:"+new Stats(passiveBonuses, getBaseStats()));
Stats armorBonuses = getItemBonuses(false, armor);
Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
- if(passiveBonuses == null) System.out.println("passive null");
- if(armorBonuses == null) System.out.println("armorBonuses null");
- if(talismanBonuses == null) System.out.println("talismanBonuses null");
-
if(passiveBonuses == null || armorBonuses == null || talismanBonuses == null) return null;
Stats stats = getBaseStats().add(passiveBonuses).add(armorBonuses).add(talismanBonuses);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index 5706dee9..f79b4767 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -48,11 +48,202 @@ public class ProfileViewer {
skillToSkillDisplayMap.put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing"));
skillToSkillDisplayMap.put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE+"Alchemy"));
skillToSkillDisplayMap.put("skill_runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE+"Runecrafting"));
+ skillToSkillDisplayMap.put(null, null);
skillToSkillDisplayMap.put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD+"Rev Slayer"));
skillToSkillDisplayMap.put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD+"Tara Slayer"));
skillToSkillDisplayMap.put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD+"Sven Slayer"));
}
+ private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW+"Farming");
+ private static final ItemStack CAT_MINING = Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY+"Mining");
+ private static final ItemStack CAT_COMBAT = Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED+"Combat");
+ private static final ItemStack CAT_FORAGING = Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN+"Foraging");
+ private static final ItemStack CAT_FISHING = Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing");
+
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap = new LinkedHashMap<>();
+ static {
+ collectionCatToCollectionMap.put(CAT_FARMING,
+ Utils.createList("WHEAT", "CARROT_ITEM", "POTATO_ITEM", "PUMPKIN", "MELON", "SEEDS", "MUSHROOM_COLLECTION",
+ "INK_SACK:3", "CACTUS", "SUGAR_CANE", "FEATHER", "LEATHER", "PORK", "RAW_CHICKEN", "MUTTON",
+ "RABBIT", "NETHER_STALK"));
+ collectionCatToCollectionMap.put(CAT_MINING,
+ Utils.createList("COBBLESTONE", "COAL", "IRON_INGOT", "GOLD_INGOT", "DIAMOND", "INK_SACK:4",
+ "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE_DUST", "GRAVEL", "ICE", "NETHERRACK",
+ "SAND", "ENDER_STONE"));
+ collectionCatToCollectionMap.put(CAT_COMBAT,
+ Utils.createList("ROTTEN_FLESH", "BONE", "STRING", "SPIDER_EYE", "SULPHUR", "ENDER_PEARL",
+ "GHAST_TEAR", "SLIME_BALL", "BLAZE_ROD", "MAGMA_CREAM"));
+ collectionCatToCollectionMap.put(CAT_FORAGING,
+ Utils.createList("LOG", "LOG:1", "LOG:2", "LOG_2:1", "LOG_2", "LOG:3"));
+ collectionCatToCollectionMap.put(CAT_FISHING,
+ Utils.createList("RAW_FISH", "RAW_FISH:1", "RAW_FISH:2", "RAW_FISH:3", "PRISMARINE_SHARD",
+ "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE"));
+ }
+
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap = new LinkedHashMap<>();
+ static {
+ collectionCatToMinionMap.put(CAT_FARMING,
+ Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM",
+ "COCOA", "CACTUS", "SUGAR_CANE", "CHICKEN", "COW", "PIG", null, "SHEEP",
+ "RABBIT", "NETHER_WARTS"));
+ collectionCatToMinionMap.put(CAT_MINING,
+ Utils.createList("COBBLESTONE", "COAL", "IRON", "GOLD", "DIAMOND", "LAPIS",
+ "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE", "GRAVEL", "ICE", null,
+ "SAND", "ENDER_STONE"));
+ collectionCatToMinionMap.put(CAT_COMBAT,
+ Utils.createList("ZOMBIE", "SKELETON", "SPIDER", "CAVESPIDER", "CREEPER", "ENDERMAN",
+ "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE"));
+ collectionCatToMinionMap.put(CAT_FORAGING,
+ Utils.createList("OAK", "SPRUCE", "BIRCH", "DARK_OAK", "ACACIA", "JUNGLE"));
+ collectionCatToMinionMap.put(CAT_FISHING,
+ Utils.createList("FISHING", null, null, null, null,
+ null, "CLAY", null, null, null));
+ }
+
+ private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap = new LinkedHashMap<>();
+ static {
+ /** FARMING COLLECTIONS **/
+ collectionToCollectionDisplayMap.put("WHEAT", Utils.createItemStack(Items.wheat,
+ EnumChatFormatting.YELLOW+"Wheat"));
+ collectionToCollectionDisplayMap.put("CARROT_ITEM", Utils.createItemStack(Items.carrot,
+ EnumChatFormatting.YELLOW+"Carrot"));
+ collectionToCollectionDisplayMap.put("POTATO_ITEM", Utils.createItemStack(Items.potato,
+ EnumChatFormatting.YELLOW+"Potato"));
+ collectionToCollectionDisplayMap.put("PUMPKIN", Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin),
+ EnumChatFormatting.YELLOW+"Pumpkin"));
+ collectionToCollectionDisplayMap.put("MELON", Utils.createItemStack(Items.melon,
+ EnumChatFormatting.YELLOW+"Melon"));
+ collectionToCollectionDisplayMap.put("SEEDS", Utils.createItemStack(Items.wheat_seeds,
+ EnumChatFormatting.YELLOW+"Seeds"));
+ collectionToCollectionDisplayMap.put("MUSHROOM_COLLECTION",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom)
+ , EnumChatFormatting.YELLOW+"Mushroom"));
+ collectionToCollectionDisplayMap.put("INK_SACK:3", Utils.createItemStack(Items.dye,
+ EnumChatFormatting.YELLOW+"Cocoa Beans", 3));
+ collectionToCollectionDisplayMap.put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus),
+ EnumChatFormatting.YELLOW+"Cactus"));
+ collectionToCollectionDisplayMap.put("SUGAR_CANE", Utils.createItemStack(Items.reeds,
+ EnumChatFormatting.YELLOW+"Sugar Cane"));
+ collectionToCollectionDisplayMap.put("FEATHER", Utils.createItemStack(Items.feather,
+ EnumChatFormatting.YELLOW+"Feather"));
+ collectionToCollectionDisplayMap.put("LEATHER", Utils.createItemStack(Items.leather,
+ EnumChatFormatting.YELLOW+"Leather"));
+ collectionToCollectionDisplayMap.put("PORK", Utils.createItemStack(Items.porkchop,
+ EnumChatFormatting.YELLOW+"Porkchop"));
+ collectionToCollectionDisplayMap.put("RAW_CHICKEN", Utils.createItemStack(Items.chicken,
+ EnumChatFormatting.YELLOW+"Chicken"));
+ collectionToCollectionDisplayMap.put("MUTTON", Utils.createItemStack(Items.mutton,
+ EnumChatFormatting.YELLOW+"Mutton"));
+ collectionToCollectionDisplayMap.put("RABBIT", Utils.createItemStack(Items.rabbit,
+ EnumChatFormatting.YELLOW+"Rabbit"));
+ collectionToCollectionDisplayMap.put("NETHER_STALK", Utils.createItemStack(Items.nether_wart,
+ EnumChatFormatting.YELLOW+"Nether Wart"));
+
+ /** MINING COLLECTIONS **/
+ collectionToCollectionDisplayMap.put("COBBLESTONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone),
+ EnumChatFormatting.GRAY+"Cobblestone"));
+ collectionToCollectionDisplayMap.put("COAL", Utils.createItemStack(Items.coal,
+ EnumChatFormatting.GRAY+"Coal"));
+ collectionToCollectionDisplayMap.put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot,
+ EnumChatFormatting.GRAY+"Iron Ingot"));
+ collectionToCollectionDisplayMap.put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot,
+ EnumChatFormatting.GRAY+"Gold Ingot"));
+ collectionToCollectionDisplayMap.put("DIAMOND", Utils.createItemStack(Items.diamond,
+ EnumChatFormatting.GRAY+"Diamond"));
+ collectionToCollectionDisplayMap.put("INK_SACK:4", Utils.createItemStack(Items.dye,
+ EnumChatFormatting.GRAY+"Lapis Lazuli", 4));
+ collectionToCollectionDisplayMap.put("EMERALD", Utils.createItemStack(Items.emerald,
+ EnumChatFormatting.GRAY+"Emerald"));
+ collectionToCollectionDisplayMap.put("REDSTONE", Utils.createItemStack(Items.redstone,
+ EnumChatFormatting.GRAY+"Redstone"));
+ collectionToCollectionDisplayMap.put("QUARTZ", Utils.createItemStack(Items.quartz,
+ EnumChatFormatting.GRAY+"Nether Quartz"));
+ collectionToCollectionDisplayMap.put("OBSIDIAN", Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian),
+ EnumChatFormatting.GRAY+"Obsidian"));
+ collectionToCollectionDisplayMap.put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust,
+ EnumChatFormatting.GRAY+"Glowstone"));
+ collectionToCollectionDisplayMap.put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel),
+ EnumChatFormatting.GRAY+"Gravel"));
+ collectionToCollectionDisplayMap.put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice),
+ EnumChatFormatting.GRAY+"Ice"));
+ collectionToCollectionDisplayMap.put("NETHERRACK", Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack),
+ EnumChatFormatting.GRAY+"Netherrack"));
+ collectionToCollectionDisplayMap.put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand),
+ EnumChatFormatting.GRAY+"Sand"));
+ collectionToCollectionDisplayMap.put("ENDER_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone),
+ EnumChatFormatting.GRAY+"End Stone"));
+
+ /** COMBAT COLLECTIONS **/
+ collectionToCollectionDisplayMap.put("ROTTEN_FLESH", Utils.createItemStack(Items.rotten_flesh,
+ EnumChatFormatting.RED+"Rotten Flesh"));
+ collectionToCollectionDisplayMap.put("BONE", Utils.createItemStack(Items.bone,
+ EnumChatFormatting.RED+"Bone"));
+ collectionToCollectionDisplayMap.put("STRING", Utils.createItemStack(Items.string,
+ EnumChatFormatting.RED+"String"));
+ collectionToCollectionDisplayMap.put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye,
+ EnumChatFormatting.RED+"Spider Eye"));
+ collectionToCollectionDisplayMap.put("SULPHUR", Utils.createItemStack(Items.gunpowder,
+ EnumChatFormatting.RED+"Gunpowder"));
+ collectionToCollectionDisplayMap.put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl,
+ EnumChatFormatting.RED+"Ender Pearl"));
+ collectionToCollectionDisplayMap.put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear,
+ EnumChatFormatting.RED+"Ghast Tear"));
+ collectionToCollectionDisplayMap.put("SLIME_BALL", Utils.createItemStack(Items.slime_ball,
+ EnumChatFormatting.RED+"Slimeball"));
+ collectionToCollectionDisplayMap.put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod,
+ EnumChatFormatting.RED+"Blaze Rod"));
+ collectionToCollectionDisplayMap.put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream,
+ EnumChatFormatting.RED+"Magma Cream"));
+
+ /** FORAGING COLLECTIONS **/
+ collectionToCollectionDisplayMap.put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
+ EnumChatFormatting.DARK_GREEN+"Oak"));
+ collectionToCollectionDisplayMap.put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
+ EnumChatFormatting.DARK_GREEN+"Birch", 1));
+ collectionToCollectionDisplayMap.put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
+ EnumChatFormatting.DARK_GREEN+"Spruce", 2));
+ collectionToCollectionDisplayMap.put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
+ EnumChatFormatting.DARK_GREEN+"Jungle", 1));
+ collectionToCollectionDisplayMap.put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
+ EnumChatFormatting.DARK_GREEN+"Acacia"));
+ collectionToCollectionDisplayMap.put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
+ EnumChatFormatting.DARK_GREEN+"Dark Oak", 3));
+
+ /** FISHING COLLECTIONS **/
+ collectionToCollectionDisplayMap.put("RAW_FISH", Utils.createItemStack(Items.fish,
+ EnumChatFormatting.AQUA+"Fish"));
+ collectionToCollectionDisplayMap.put("RAW_FISH:1", Utils.createItemStack(Items.fish,
+ EnumChatFormatting.AQUA+"Salmon", 1));
+ collectionToCollectionDisplayMap.put("RAW_FISH:2", Utils.createItemStack(Items.fish,
+ EnumChatFormatting.AQUA+"Clownfish", 2));
+ collectionToCollectionDisplayMap.put("RAW_FISH:3", Utils.createItemStack(Items.fish,
+ EnumChatFormatting.AQUA+"Pufferfish", 3));
+ collectionToCollectionDisplayMap.put("PRISMARINE_SHARD", Utils.createItemStack(Items.prismarine_shard,
+ EnumChatFormatting.AQUA+"Prismarine Shard"));
+ collectionToCollectionDisplayMap.put("PRISMARINE_CRYSTALS", Utils.createItemStack(Items.prismarine_crystals,
+ EnumChatFormatting.AQUA+"Prismarine Crystals"));
+ collectionToCollectionDisplayMap.put("CLAY_BALL", Utils.createItemStack(Items.clay_ball,
+ EnumChatFormatting.AQUA+"Clay"));
+ collectionToCollectionDisplayMap.put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily),
+ EnumChatFormatting.AQUA+"Lilypad"));
+ collectionToCollectionDisplayMap.put("INK_SACK", Utils.createItemStack(Items.dye,
+ EnumChatFormatting.AQUA+"Ink Sack"));
+ collectionToCollectionDisplayMap.put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge),
+ EnumChatFormatting.AQUA+"Sponge"));
+ }
+
+ public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToMinionMap() {
+ return collectionCatToMinionMap;
+ }
+
+ public static LinkedHashMap<String, ItemStack> getCollectionToCollectionDisplayMap() {
+ return collectionToCollectionDisplayMap;
+ }
+
+ public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToCollectionMap() {
+ return collectionCatToCollectionMap;
+ }
+
public static Map<String, ItemStack> getSkillToSkillDisplayMap() {
return Collections.unmodifiableMap(skillToSkillDisplayMap);
}
@@ -65,6 +256,8 @@ public class ProfileViewer {
private JsonObject basicInfo = null;
private final HashMap<String, JsonObject> profileMap = new HashMap<>();
+ private final HashMap<String, JsonObject> petsInfoMap = new HashMap<>();
+ private final HashMap<String, List<JsonObject>> coopProfileMap = new HashMap<>();
private final HashMap<String, JsonObject> skillInfoMap = new HashMap<>();
private final HashMap<String, JsonObject> inventoryInfoMap = new HashMap<>();
private final HashMap<String, JsonObject> collectionInfoMap = new HashMap<>();
@@ -102,50 +295,49 @@ public class ProfileViewer {
}
public JsonArray getPlayerInformation(Runnable runnable) {
- if(playerInformation != null) return playerInformation;
- if(updatingPlayerInfoState.get()) return null;
+ if (playerInformation != null) return playerInformation;
+ if (updatingPlayerInfoState.get()) return null;
updatingPlayerInfoState.set(true);
HashMap<String, String> args = new HashMap<>();
- args.put("uuid", ""+uuid);
+ args.put("uuid", "" + uuid);
manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/profiles",
- args, jsonObject -> {
- if(jsonObject == null) return;
-
- updatingPlayerInfoState.set(false);
- if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- playerInformation = jsonObject.get("profiles").getAsJsonArray();
- if(playerInformation == null) return;
- String backup = null;
- long backupLastSave = 0;
- for(int i=0; i<playerInformation.size(); i++) {
- JsonObject profile = playerInformation.get(i).getAsJsonObject();
- String cute_name = profile.get("cute_name").getAsString();
-
- if(backup == null) backup = cute_name;
-
- if(!profile.has("members")) continue;
- JsonObject members = profile.get("members").getAsJsonObject();
-
- if(members.has(uuid)) {
- JsonObject member = members.get(uuid).getAsJsonObject();
- if(member.has("last_save")) {
- long last_save = member.get("last_save").getAsLong();
- if(last_save > backupLastSave) {
- backupLastSave = last_save;
- backup = cute_name;
+ args, jsonObject -> {
+ if (jsonObject == null) return;
+
+ updatingPlayerInfoState.set(false);
+ if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ playerInformation = jsonObject.get("profiles").getAsJsonArray();
+ if (playerInformation == null) return;
+ String backup = null;
+ long backupLastSave = 0;
+ for (int i = 0; i < playerInformation.size(); i++) {
+ JsonObject profile = playerInformation.get(i).getAsJsonObject();
+ String cute_name = profile.get("cute_name").getAsString();
+
+ if (backup == null) backup = cute_name;
+
+ if (!profile.has("members")) continue;
+ JsonObject members = profile.get("members").getAsJsonObject();
+
+ if (members.has(uuid)) {
+ JsonObject member = members.get(uuid).getAsJsonObject();
+ if (member.has("last_save")) {
+ long last_save = member.get("last_save").getAsLong();
+ if (last_save > backupLastSave) {
+ backupLastSave = last_save;
+ backup = cute_name;
+ }
}
}
}
+ if (runnable != null) runnable.run();
+ latestProfile = backup;
}
- System.out.println("accepting runnable");
- if(runnable != null) runnable.run();
- latestProfile = backup;
+ }, () -> {
+ updatingPlayerInfoState.set(false);
}
- }, () -> {
- updatingPlayerInfoState.set(false);
- }
);
return null;
@@ -171,12 +363,41 @@ public class ProfileViewer {
if(profile.has("banking")) {
profileInfo.add("banking", profile.get("banking").getAsJsonObject());
}
- System.out.println("got profile");
profileMap.put(profileId, profileInfo);
return profileInfo;
}
}
- System.out.println("couldnt get profile");
+
+ return null;
+ }
+
+ public List<JsonObject> getCoopProfileInformation(String profileId) {
+ JsonArray playerInfo = getPlayerInformation(() -> {});
+ if(playerInfo == null) return null;
+ if(profileId == null) profileId = latestProfile;
+ if(coopProfileMap.containsKey(profileId)) return coopProfileMap.get(profileId);
+
+ for(int i=0; i<playerInformation.size(); i++) {
+ if(!playerInformation.get(i).isJsonObject()) {
+ playerInformation = null;
+ return null;
+ }
+ JsonObject profile = playerInformation.get(i).getAsJsonObject();
+ if(profile.get("cute_name").getAsString().equalsIgnoreCase(profileId)) {
+ if(!profile.has("members")) return null;
+ JsonObject members = profile.get("members").getAsJsonObject();
+ if(!members.has(uuid)) return null;
+ List<JsonObject> coopList = new ArrayList<>();
+ for(Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
+ if(!islandMember.getKey().equals(uuid)) {
+ JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject();
+ coopList.add(coopProfileInfo);
+ }
+ }
+ coopProfileMap.put(profileId, coopList);
+ return coopList;
+ }
+ }
return null;
}
@@ -185,7 +406,11 @@ public class ProfileViewer {
playerInformation = null;
basicInfo = null;
playerStatus = null;
+ stats = null;
+ passiveStats = null;
profileMap.clear();
+ coopProfileMap.clear();
+ petsInfoMap.clear();
skillInfoMap.clear();
inventoryInfoMap.clear();
collectionInfoMap.clear();
@@ -250,7 +475,6 @@ public class ProfileViewer {
+ experience_skill_runecrafting;
if(totalSkillXP <= 0) {
- System.out.println("couldnt get skill xp");
return null;
}
@@ -340,8 +564,6 @@ public class ProfileViewer {
if(profileId == null) profileId = latestProfile;
if(inventoryInfoMap.containsKey(profileId)) return inventoryInfoMap.get(profileId);
- //inv_armor, fishing_bag, quiver, ender_chest_contents, wardrobe_contents, potion_bag, inv_contents, talisman_bag, candy_inventory_contents
-
String inv_armor_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "inv_armor.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
String fishing_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "fishing_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
String quiver_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "quiver.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
@@ -378,47 +600,148 @@ public class ProfileViewer {
return inventoryInfo;
}
+ public JsonObject getPetsInfo(String profileId) {
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if(profileInfo == null) return null;
+ if(petsInfoMap.containsKey(profileId)) return petsInfoMap.get(profileId);
+
+ JsonObject petsInfo = new JsonObject();
+ JsonElement petsElement = profileInfo.get("pets");
+ if(petsElement != null && petsElement.isJsonArray()) {
+ JsonObject activePet = null;
+ JsonArray pets = petsElement.getAsJsonArray();
+ for(int i=0; i<pets.size(); i++) {
+ JsonObject pet = pets.get(i).getAsJsonObject();
+ if(pet.has("active") && pet.get("active").getAsJsonPrimitive().getAsBoolean()) {
+ activePet = pet;
+ break;
+ }
+ }
+ petsInfo.add("active_pet", activePet);
+ petsInfo.add("pets", pets);
+ petsInfoMap.put(profileId, petsInfo);
+ return petsInfo;
+ }
+ return null;
+ }
+
private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?[0-9]+)");
public JsonObject getCollectionInfo(String profileId) {
JsonObject profileInfo = getProfileInformation(profileId);
if(profileInfo == null) return null;
+ JsonObject resourceCollectionInfo = getResourceCollectionInformation();
+ if(resourceCollectionInfo == null) return null;
if(profileId == null) profileId = latestProfile;
if(collectionInfoMap.containsKey(profileId)) return collectionInfoMap.get(profileId);
-
JsonElement unlocked_coll_tiers_element = Utils.getElement(profileInfo, "unlocked_coll_tiers");
- if(unlocked_coll_tiers_element == null) {
- JsonObject collectionInfo = new JsonObject();
- collectionInfo.add("collection_tiers", new JsonObject());
- return collectionInfo;
+ JsonElement crafted_generators_element = Utils.getElement(profileInfo, "crafted_generators");
+ JsonElement collectionInfoElement = Utils.getElement(profileInfo, "collection");
+
+ JsonObject collectionInfo = new JsonObject();
+ JsonObject collectionTiers = new JsonObject();
+ JsonObject minionTiers = new JsonObject();
+ JsonObject personalAmounts = new JsonObject();
+ JsonObject totalAmounts = new JsonObject();
+
+ if(collectionInfoElement != null && collectionInfoElement.isJsonObject()) {
+ personalAmounts = collectionInfoElement.getAsJsonObject();
}
- JsonArray unlocked_coll_tiers = unlocked_coll_tiers_element.getAsJsonArray();
- JsonElement collectionInfoElement = Utils.getElement(profileInfo, "collections");
- if(collectionInfoElement == null) {
- JsonObject collectionInfo = new JsonObject();
- collectionInfo.add("collection_tiers", new JsonObject());
- return collectionInfo;
+ for(Map.Entry<String, JsonElement> entry : personalAmounts.entrySet()) {
+ totalAmounts.addProperty(entry.getKey(), entry.getValue().getAsInt());
}
- JsonObject collectionInfo = collectionInfoElement.getAsJsonObject();
- JsonObject collectionTiers = new JsonObject();
- for(int i=0; i<unlocked_coll_tiers.size(); i++) {
- String unlocked = unlocked_coll_tiers.get(i).getAsString();
+ List<JsonObject> coopProfiles = getCoopProfileInformation(profileId);
+ if(coopProfiles != null) {
+ for(JsonObject coopProfile : coopProfiles) {
+ JsonElement coopCollectionInfoElement = Utils.getElement(coopProfile, "collection");
+ if(coopCollectionInfoElement != null && coopCollectionInfoElement.isJsonObject()) {
+ for(Map.Entry<String, JsonElement> entry : coopCollectionInfoElement.getAsJsonObject().entrySet()) {
+ float existing = Utils.getElementAsFloat(totalAmounts.get(entry.getKey()), 0);
+ totalAmounts.addProperty(entry.getKey(), existing+entry.getValue().getAsInt());
+ }
+ }
+ }
+ }
+
+ if(unlocked_coll_tiers_element != null && unlocked_coll_tiers_element.isJsonArray()) {
+ JsonArray unlocked_coll_tiers = unlocked_coll_tiers_element.getAsJsonArray();
+ for(int i=0; i<unlocked_coll_tiers.size(); i++) {
+ String unlocked = unlocked_coll_tiers.get(i).getAsString();
- Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
+ Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
- if(matcher.find()) {
- String tier_str = matcher.group(1);
- int tier = Integer.parseInt(tier_str);
- String coll = unlocked.substring(0, unlocked.length()-(matcher.group().length()));
- if(!collectionTiers.has(coll) || collectionTiers.get(coll).getAsInt() < tier) {
- collectionTiers.addProperty(coll, tier);
+ if(matcher.find()) {
+ String tier_str = matcher.group(1);
+ int tier = Integer.parseInt(tier_str);
+ String coll = unlocked.substring(0, unlocked.length()-(matcher.group().length()));
+ if(!collectionTiers.has(coll) || collectionTiers.get(coll).getAsInt() < tier) {
+ collectionTiers.addProperty(coll, tier);
+ }
}
}
}
- collectionInfo.add("collection_tiers", collectionInfo);
+ if(crafted_generators_element != null && crafted_generators_element.isJsonArray()) {
+ JsonArray crafted_generators = crafted_generators_element.getAsJsonArray();
+ for(int i=0; i<crafted_generators.size(); i++) {
+ String unlocked = crafted_generators.get(i).getAsString();
+
+ Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
+
+ if(matcher.find()) {
+ String tier_str = matcher.group(1);
+ int tier = Integer.parseInt(tier_str);
+ String coll = unlocked.substring(0, unlocked.length()-(matcher.group().length()));
+ if(!minionTiers.has(coll) || minionTiers.get(coll).getAsInt() < tier) {
+ minionTiers.addProperty(coll, tier);
+ }
+ }
+ }
+ }
+
+ JsonObject maxAmount = new JsonObject();
+ JsonObject updatedCollectionTiers = new JsonObject();
+ for(Map.Entry<String, JsonElement> totalAmountsEntry : totalAmounts.entrySet()) {
+ String collName = totalAmountsEntry.getKey();
+ int collTier = (int)Utils.getElementAsFloat(collectionTiers.get(collName), 0);
+
+ int currentAmount = (int)Utils.getElementAsFloat(totalAmounts.get(collName), 0);
+ if(currentAmount > 0) {
+ for(Map.Entry<String, JsonElement> resourceEntry : resourceCollectionInfo.entrySet()) {
+ JsonElement tiersElement = Utils.getElement(resourceEntry.getValue(), "items."+collName+".tiers");
+ if(tiersElement != null && tiersElement.isJsonArray()) {
+ JsonArray tiers = tiersElement.getAsJsonArray();
+ int maxTierAcquired = -1;
+ int maxAmountRequired = -1;
+ for(int i=0; i<tiers.size(); i++) {
+ JsonObject tierInfo = tiers.get(i).getAsJsonObject();
+ int tier = tierInfo.get("tier").getAsInt();
+ int amountRequired = tierInfo.get("amountRequired").getAsInt();
+ if(currentAmount >= amountRequired) {
+ maxTierAcquired = tier;
+ }
+ maxAmountRequired = amountRequired;
+ }
+ if(maxTierAcquired >= 0 && maxTierAcquired > collTier) {
+ updatedCollectionTiers.addProperty(collName, maxTierAcquired);
+ }
+ maxAmount.addProperty(collName, maxAmountRequired);
+ }
+ }
+ }
+ }
+
+ for(Map.Entry<String, JsonElement> collectionTiersEntry : updatedCollectionTiers.entrySet()) {
+ collectionTiers.add(collectionTiersEntry.getKey(), collectionTiersEntry.getValue());
+ }
+
+ collectionInfo.add("minion_tiers", minionTiers);
+ collectionInfo.add("max_amounts", maxAmount);
+ collectionInfo.add("personal_amounts", personalAmounts);
+ collectionInfo.add("total_amounts", totalAmounts);
+ collectionInfo.add("collection_tiers", collectionTiers);
return collectionInfo;
}
@@ -492,10 +815,8 @@ public class ProfileViewer {
public Profile getProfile(String uuid, Consumer<Profile> callback) {
Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
if(profile.playerInformation != null) {
- System.out.println("getting profile with callback1");
callback.accept(profile);
} else {
- System.out.println("getting profile with callback3");
profile.getPlayerInformation(() -> callback.accept(profile));
}
return profile;
@@ -507,4 +828,27 @@ public class ProfileViewer {
return profile;
}
+ private static JsonObject resourceCollection = null;
+ private static AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
+ public static JsonObject getResourceCollectionInformation() {
+ if(resourceCollection != null) return resourceCollection;
+ if(updatingResourceCollection.get()) return null;
+
+ updatingResourceCollection.set(true);
+
+ HashMap<String, String> args = new HashMap<>();
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.manager.config.apiKey.value, "resources/skyblock/collections",
+ args, jsonObject -> {
+ updatingResourceCollection.set(false);
+ if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ resourceCollection = jsonObject.get("collections").getAsJsonObject();
+ }
+ }, () -> {
+ updatingResourceCollection.set(false);
+ }
+ );
+
+ return null;
+ }
+
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java
index 89ec44cc..4c19dd39 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java
@@ -28,7 +28,6 @@ public class SBScoreboardData {
public Date currentTimeDate = null;
-
public static SBScoreboardData getInstance() {
return INSTANCE;
}
@@ -57,7 +56,6 @@ public class SBScoreboardData {
Matcher matcher = timePattern.matcher(lines.get(3));
if(matcher.find()) {
time = Utils.cleanColour(matcher.group()).trim();
-
try {
String timeSpace = time.replace("am", " am").replace("pm", " pm");
SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
@@ -69,7 +67,9 @@ public class SBScoreboardData {
location = Utils.cleanColour(matcher.group()).trim();
}
}
- } catch(Exception e) {}
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
//System.out.println(date + ":" + time + ":" + location);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
index 05351629..f0a4853f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
@@ -45,7 +45,6 @@ public class HypixelApi {
}
public JsonObject getHypixelApiSync(String urlS) throws IOException {
-
URL url = new URL(urlS);
URLConnection connection = url.openConnection();
connection.setConnectTimeout(3000);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 5fe96aae..144db9da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -1,6 +1,7 @@
package io.github.moulberry.notenoughupdates.util;
import com.google.common.base.Splitter;
+import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
@@ -82,7 +83,7 @@ public class Utils {
RenderHelper.disableStandardItemLighting();
}
- public static void drawItemStack(ItemStack stack, int x, int y) {
+ public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) {
if(stack == null)return;
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
@@ -90,11 +91,17 @@ public class Utils {
RenderHelper.enableGUIStandardItemLighting();
itemRender.zLevel = -145; //Negates the z-offset of the below method.
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- itemRender.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, stack, x, y);
+ itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text);
itemRender.zLevel = 0;
RenderHelper.disableStandardItemLighting();
}
+ public static void drawItemStack(ItemStack stack, int x, int y) {
+ if(stack == null)return;
+
+ drawItemStackWithText(stack, x, y, null);
+ }
+
private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
EnumChatFormatting.RED,
EnumChatFormatting.GOLD,
@@ -228,6 +235,33 @@ public class Utils {
return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
}
+ private static String[] rarityArr = new String[] {
+ "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL",
+ };
+ public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
+ for(int i=lore.size()-1; i>=0; i--) {
+ String line = lore.get(i).getAsString();
+ for(String rarity : rarityArr) {
+ for(int j=0; j<typeMatches.length; j++) {
+ if(contains) {
+ if(line.trim().contains(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ } else {
+ if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
public static void playPressSound() {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
new ResourceLocation("gui.button.press"), 1.0F));
@@ -290,7 +324,11 @@ public class Utils {
}
public static ItemStack createItemStack(Item item, String displayname, String... lore) {
- ItemStack stack = new ItemStack(item);
+ return createItemStack(item, displayname, 0, lore);
+ }
+
+ public static ItemStack createItemStack(Item item, String displayname, int damage, String... lore) {
+ ItemStack stack = new ItemStack(item, 1, damage);
NBTTagCompound tag = new NBTTagCompound();
NBTTagCompound display = new NBTTagCompound();
NBTTagList Lore = new NBTTagList();
@@ -303,12 +341,18 @@ public class Utils {
display.setTag("Lore", Lore);
tag.setTag("display", display);
+ tag.setInteger("HideFlags", 254);
stack.setTagCompound(tag);
return stack;
}
+ public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ GL11.glTranslatef(x, y, 0);
+ fr.drawString(str, x, y, colour, shadow);
+ }
+
public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
int strLen = fr.getStringWidth(str);
float factor = len/(float)strLen;
@@ -345,6 +389,19 @@ public class Utils {
drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, factor);
}
+ public static Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float)width;
+ projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
public static void drawStringCenteredScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
int strLen = fr.getStringWidth(str);
float factor = len/(float)strLen;
@@ -529,6 +586,39 @@ public class Utils {
file.delete();
}
+ public static Color getPrimaryColour(String displayname) {
+ int lastColourCode = -99;
+ int currentColour = 0;
+ int[] mostCommon = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ for(int i=0; i<displayname.length(); i++) {
+ char c = displayname.charAt(i);
+ if(c == '\u00A7') {
+ lastColourCode = i;
+ } else if(lastColourCode == i-1) {
+ int colIndex = "0123456789abcdef".indexOf(c);
+ if(colIndex >= 0) {
+ currentColour = colIndex;
+ } else {
+ currentColour = 0;
+ }
+ } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){
+ if(currentColour > 0) {
+ mostCommon[currentColour]++;
+ }
+ }
+ }
+ int mostCommonCount = 0;
+ for(int index=0; index<mostCommon.length; index++) {
+ if(mostCommon[index] > mostCommonCount) {
+ mostCommonCount = mostCommon[index];
+ currentColour = index;
+ }
+ }
+
+ int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode("0123456789abcdef".charAt(currentColour));
+ return new Color(colourInt).darker();
+ }
+
public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) {
if (!textLines.isEmpty())
{
@@ -639,36 +729,7 @@ public class Utils {
if(NotEnoughUpdates.INSTANCE.manager.config.tooltipBorderColours.value && coloured) {
if(textLines.size() > 0) {
String first = textLines.get(0);
- int lastColourCode = -99;
- int currentColour = 0;
- int[] mostCommon = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- for(int i=0; i<first.length(); i++) {
- char c = first.charAt(i);
- if(c == '\u00A7') {
- lastColourCode = i;
- } else if(lastColourCode == i-1) {
- int colIndex = "0123456789abcdef".indexOf(c);
- if(colIndex >= 0) {
- currentColour = colIndex;
- } else {
- currentColour = 0;
- }
- } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){
- if(currentColour > 0) {
- mostCommon[currentColour]++;
- }
- }
- }
- int mostCommonCount = 0;
- for(int index=0; index<mostCommon.length; index++) {
- if(mostCommon[index] > mostCommonCount) {
- mostCommonCount = mostCommon[index];
- currentColour = index;
- }
- }
-
- int colourInt = font.getColorCode("0123456789abcdef".charAt(currentColour));
- borderColorStart = new Color(colourInt).darker().getRGB() & 0x00FFFFFF |
+ borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF |
((NotEnoughUpdates.INSTANCE.manager.config.tooltipBorderOpacity.value.intValue()) << 24);
}
}
diff --git a/src/main/resources/assets/notenoughupdates/button20x.png b/src/main/resources/assets/notenoughupdates/button20x.png
new file mode 100644
index 00000000..8d723798
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/button20x.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/custom_ench_colour.png b/src/main/resources/assets/notenoughupdates/custom_ench_colour.png
new file mode 100644
index 00000000..2c1c717e
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/custom_ench_colour.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/folder.png b/src/main/resources/assets/notenoughupdates/folder.png
new file mode 100644
index 00000000..f4af7353
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/folder.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_0.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_0.jpg
index 9482df80..9482df80 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_0.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_0.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_1.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_1.jpg
index 1b4235dd..1b4235dd 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_1.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_1.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_2.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_2.jpg
index 2f1fcc06..2f1fcc06 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_2.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_2.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_3.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_3.jpg
index ce20d9b5..ce20d9b5 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_3.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_3.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_4.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_4.jpg
index 3dcdac57..3dcdac57 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_4.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_4.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_5.jpg b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_5.jpg
index 45f65c7c..45f65c7c 100644
--- a/src/main/resources/assets/notenoughupdates/panoramas/missing/panorama_5.jpg
+++ b/src/main/resources/assets/notenoughupdates/panoramas/unknown/panorama_5.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_basic.png b/src/main/resources/assets/notenoughupdates/pv_basic.png
index 8e9c8d85..227bad5a 100644
--- a/src/main/resources/assets/notenoughupdates/pv_basic.png
+++ b/src/main/resources/assets/notenoughupdates/pv_basic.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_bg.png b/src/main/resources/assets/notenoughupdates/pv_bg.png
new file mode 100644
index 00000000..6c09e78d
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_bg.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_cols.png b/src/main/resources/assets/notenoughupdates/pv_cols.png
new file mode 100644
index 00000000..d0f2fa73
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_cols.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_elements.png b/src/main/resources/assets/notenoughupdates/pv_elements.png
new file mode 100644
index 00000000..c73111db
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_elements.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_invs.png b/src/main/resources/assets/notenoughupdates/pv_invs.png
new file mode 100644
index 00000000..881078d2
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_invs.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_pets.png b/src/main/resources/assets/notenoughupdates/pv_pets.png
new file mode 100644
index 00000000..d23b8e37
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_pets.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/blur.json b/src/main/resources/assets/notenoughupdates/shaders/program/blur.json
new file mode 100644
index 00000000..9da3c2e8
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/blur.json
@@ -0,0 +1,21 @@
+{
+ "blend": {
+ "func": "add",
+ "srcrgb": "srcalpha",
+ "dstrgb": "1-srcalpha"
+ },
+ "vertex": "sobel",
+ "fragment": "blur2",
+ "attributes": [ "Position" ],
+ "samplers": [
+ { "name": "DiffuseSampler" }
+ ],
+ "uniforms": [
+ { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
+ { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
+ { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
+ { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
+ { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] },
+ { "name": "AlphaMult", "type": "float", "count": 1, "values": [ 1.0 ] }
+ ]
+}
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
new file mode 100644
index 00000000..ca64470a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
@@ -0,0 +1,34 @@
+#version 120
+
+uniform sampler2D DiffuseSampler;
+
+varying vec2 texCoord;
+varying vec2 oneTexel;
+
+uniform vec2 InSize;
+
+uniform vec2 BlurDir;
+uniform float Radius;
+uniform float AlphaMult;
+
+void main() {
+ vec4 blurred = vec4(0.0);
+ float totalStrength = 0.0;
+ float totalAlpha = 0.0;
+ float totalSamples = 0.0;
+ for(float r = -Radius; r <= Radius; r += 1.0) {
+ vec4 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
+
+ // Accumulate average alpha
+ totalAlpha = totalAlpha + sample.a;
+ totalSamples = totalSamples + 1.0;
+
+ // Accumulate smoothed blur
+ //float strength = (2.0 - abs(r / Radius))*sample.a;
+ float strength = sample.a;
+ totalStrength = totalStrength + strength;
+ blurred = blurred + sample;
+ }
+ float alpha = totalAlpha/totalSamples*AlphaMult;
+ gl_FragColor = vec4(blurred.rgb / totalStrength, alpha);
+}
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh
new file mode 100644
index 00000000..324602fd
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh
@@ -0,0 +1,11 @@
+#version 120
+
+uniform sampler2D DiffuseSampler;
+
+varying vec2 texCoord;
+
+void main(){
+ vec4 diffuseColor = texture2D(DiffuseSampler, texCoord);
+
+ gl_FragColor = vec4(diffuseColor.a);
+}
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json
new file mode 100644
index 00000000..653764fb
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json
@@ -0,0 +1,17 @@
+{
+ "blend": {
+ "func": "add",
+ "srcrgb": "srcalpha",
+ "dstrgb": "1-srcalpha"
+ },
+ "vertex": "blit",
+ "fragment": "setrgbtoalpha",
+ "attributes": [ "Position" ],
+ "samplers": [
+ { "name": "DiffuseSampler" }
+ ],
+ "uniforms": [
+ { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
+ { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
+ ]
+}
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh b/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh
new file mode 100644
index 00000000..21b17369
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh
@@ -0,0 +1,20 @@
+#version 120
+
+attribute vec4 Position;
+
+uniform mat4 ProjMat;
+uniform vec2 InSize;
+uniform vec2 OutSize;
+
+varying vec2 texCoord;
+varying vec2 oneTexel;
+
+void main(){
+ vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
+ gl_Position = vec4(outPos.xy, 0.2, 1.0);
+
+ oneTexel = 1.0 / InSize;
+
+ texCoord = Position.xy / OutSize;
+ texCoord.y = 1.0 - texCoord.y;
+}
diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json
index 49e37916..8f07f5cc 100644
--- a/src/main/resources/mixins.notenoughupdates.json
+++ b/src/main/resources/mixins.notenoughupdates.json
@@ -5,6 +5,7 @@
"mixins": [
"MixinItemStack",
"MixinInventoryEffectRenderer",
- "MixinGuiIngame"
+ "MixinGuiIngame",
+ "MixinRenderItem"
]
} \ No newline at end of file