From 73fad7064fb47d9d79ccdb3bab5988df1b9eea6f Mon Sep 17 00:00:00 2001 From: CraftyOldMiner <85420839+CraftyOldMiner@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:44:17 -0600 Subject: Wishing Compass Solver, Metal Detector Solver improvements, add /neudiag, other misc changes (#90) --- .../moulberry/notenoughupdates/util/Utils.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 9b5f62e3..dc88da2f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -301,6 +301,40 @@ public class Utils { return ""; } + public static String trimWhitespaceAndFormatCodes(String str) { + int startIndex = indexOfFirstNonWhitespaceNonFormatCode(str); + int endIndex = lastIndexOfNonWhitespaceNonFormatCode(str); + if (startIndex == -1 || endIndex == -1) return ""; + return str.substring(startIndex, endIndex+1); + } + + private static int indexOfFirstNonWhitespaceNonFormatCode(String str) { + int len = str.length(); + for (int i = 0; i < len; i++) { + char ch = str.charAt(i); + if (Character.isWhitespace(ch)) { + continue; + } else if (ch == '\u00a7') { + i++; + continue; + } + return i; + } + return -1; + } + + private static int lastIndexOfNonWhitespaceNonFormatCode(String str) { + for (int i = str.length() - 1; i >= 0; i--) { + char ch = str.charAt(i); + if (Character.isWhitespace(ch) || ch == '\u00a7' || (i > 0 && str.charAt(i - 1) == '\u00a7')) { + continue; + } + return i; + } + + return -1; + } + public static List getRawTooltip(ItemStack stack) { List list = Lists.newArrayList(); String s = stack.getDisplayName(); -- cgit From 6ca951d739913486e9a345be47ab467bad8e97c3 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Wed, 13 Apr 2022 07:53:52 +0200 Subject: Crimson Essence support (#110) * jani1 * update bingo more often * crimson support * move method to Utils * remove debug prints * fix single items * gray items * improvements better variable names fix behavior from 10 to 15 stars use EnumChatFormatting instead of the color code directly * fix dungeonize cost * remove master stars check --- .../moulberry/notenoughupdates/util/Utils.java | 64 ++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 dc88da2f..31499f7f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -2,7 +2,11 @@ package io.github.moulberry.notenoughupdates.util; import com.google.common.base.Splitter; import com.google.common.collect.Lists; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import net.minecraft.client.Minecraft; @@ -30,14 +34,19 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.network.play.client.C0DPacketCloseWindow; -import net.minecraft.util.*; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Matrix4f; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; import net.minecraftforge.fml.common.Loader; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; -import java.awt.Color; +import java.awt.*; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -47,7 +56,11 @@ import java.lang.reflect.Method; import java.nio.FloatBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1798,4 +1811,47 @@ public class Utils { return left <= x && x <= left + width && top <= y && y <= top + height; } + + public static int getNumberOfStars(ItemStack stack) { + if (stack != null && stack.hasTagCompound()) { + NBTTagCompound tag = stack.getTagCompound(); + + if (tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + if (ea.hasKey("upgrade_level", 99)) { + return ea.getInteger("upgrade_level"); + } else if (ea.hasKey("dungeon_item_level")) { + return ea.getInteger("dungeon_item_level"); + } + } + } + return -1; + } + + public static String getStarsString(int stars) { + EnumChatFormatting colorCode = null; + EnumChatFormatting defaultColorCode = EnumChatFormatting.GOLD; + int amount = 0; + if (stars > 5 && stars < 11) { + colorCode = EnumChatFormatting.LIGHT_PURPLE; + amount = stars - 5; + stars = 5; + } + if (stars > 10) { + colorCode = EnumChatFormatting.AQUA; + defaultColorCode = EnumChatFormatting.LIGHT_PURPLE; + amount = stars - 10; + stars = 5; + } + + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < stars; i++) { + if (i < amount) { + stringBuilder.append(colorCode).append('\u272A'); + } else { + stringBuilder.append(defaultColorCode).append('\u272A'); + } + } + return stringBuilder.toString(); + } } -- cgit From 2692193e54e4dd6c0117dcdb85368dc83bb04f1a Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Mon, 18 Apr 2022 17:33:32 +0200 Subject: Mob loot recipe PR (#81) * entity renderer (somewhat functionaL) * more modifiers and entities * Fix cookie fuckup * add neu repo as resource pack, cause why not at this point * add tabs, because i can * add extra skin parts and make less tabs * hot tall men * fix texture offsets and also parts:true * some untested changes * still broken, but better (just like me (stop being edgy nea ( no u )))) * stuff (with er skeletons * niceities * skytils interop * horseys * horseys ouch * panos * stupid tests :angery: * NPE * add drop chance * colored leather armo * finish off * move shit into hover cause items look pretty terrible * Update 2.1.md * better recipe display name * always show mobs toggle * moving parts --- .../github/moulberry/notenoughupdates/util/Utils.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 31499f7f..5fac9208 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -9,6 +9,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.entity.EntityPlayerSP; @@ -175,8 +176,13 @@ public class Utils { } public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) { - if (stack == null) return; + drawItemStackWithText(stack, x, y, text, false); + } + public static void drawItemStackWithText(ItemStack stack, int x, int y, String text, boolean skytilsRarity) { + if (stack == null) return; + if (skytilsRarity) + SkytilsCompat.renderSkytilsRarity(stack, x, y); RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); disableCustomDungColours = true; @@ -190,11 +196,13 @@ public class Utils { } public static void drawItemStack(ItemStack stack, int x, int y) { - if (stack == null) return; - drawItemStackWithText(stack, x, y, null); } + public static void drawItemStack(ItemStack stack, int x, int y, boolean skytilsRarity) { + drawItemStackWithText(stack, x, y, null, skytilsRarity); + } + private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ EnumChatFormatting.RED, EnumChatFormatting.GOLD, @@ -767,6 +775,9 @@ public class Utils { public static ItemStack createItemStack(Item item, String displayname, String... lore) { return createItemStack(item, displayname, 0, lore); } + public static ItemStack createItemStack(Block item, String displayname, String... lore) { + return createItemStack(Item.getItemFromBlock(item), displayname, lore); + } public static ItemStack createItemStack(Item item, String displayname, int damage, String... lore) { ItemStack stack = new ItemStack(item, 1, damage); -- cgit From 0418460b5ff12af5bc0b4078ec43210489d6ae99 Mon Sep 17 00:00:00 2001 From: CraftyOldMiner <85420839+CraftyOldMiner@users.noreply.github.com> Date: Sat, 30 Apr 2022 09:17:14 -0500 Subject: Crash & perf fixes (#121) - Fix crash in profile viewer when name not found - Parse numbers using exception-free methods in hot code paths - Update price graph to handle items transitioning from the bz to ah --- .../moulberry/notenoughupdates/util/Utils.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 5fac9208..7b714cd0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -653,6 +653,41 @@ public class Utils { return (float) Math.round(value * scale) / scale; } + // Parses Roman numerals, allowing for single character irregular subtractive notation (e.g. IL is 49, IIL is invalid) + public static int parseRomanNumeral(String input) { + int prevVal = 0; + int total = 0; + for (int i = input.length()-1; i >= 0; i--) { + int val; + char ch = input.charAt(i); + switch (ch) { + case 'I' : val = 1; break; + case 'V' : val = 5; break; + case 'X' : val = 10; break; + case 'L' : val = 50; break; + case 'C' : val = 100; break; + case 'D' : val = 500; break; + case 'M' : val = 1000; break; + default: throw new IllegalArgumentException("Invalid Roman Numeral Character: " + ch); + } + if (val < prevVal) val = -val; + total += val; + prevVal = val; + } + + return total; + } + + public static int parseIntOrRomanNumeral(String input) { + // 0 through 9, '-', and '+' come before 'A' in ANSI, UTF8, and UTF16 character sets + // + if (input.charAt(0) < 'A') { + return Integer.parseInt(input); + } + + return parseRomanNumeral(input); + } + public static void playPressSound() { playSound(new ResourceLocation("gui.button.press"), true); } -- cgit From 1ca41f88d7729d9279df71cd186ff86f22e7d515 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Fri, 6 May 2022 16:13:36 +0200 Subject: Item Shop Recipes (#118) * first draft of item shop PR * add teleporter navigation because i can * fix teleporter navigation because apparently i cant * navigation gui basics * :pushpin: and removed some unused shit and added myself to devtest command * track / untrack + ery texture Co-Authored-By: RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> * consoom the event * fix crash in ItemShopRecipe.java + fetch repository * i am so sorry jani * on second thought, this entire thing was a bit untested * more recipe stuff * make navigation actually good * make pins dissapear if you not a waypoint * npc parsing * save file * different file saving * remove message * Warping... (to deez nuts) * move shit around Co-authored-by: jani270 Co-authored-by: RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Co-authored-by: Lulonaut --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 7b714cd0..e572a391 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1854,8 +1854,8 @@ public class Utils { } public static boolean isWithinRect(int x, int y, int left, int top, int width, int height) { - return left <= x && x <= left + width && - top <= y && y <= top + height; + return left <= x && x < left + width && + top <= y && y < top + height; } public static int getNumberOfStars(ItemStack stack) { -- cgit From 9f372b3f8b5f07b3dbc6c010e064924d5b4820a4 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Sun, 15 May 2022 11:55:11 +0200 Subject: More Keyboard fixes (#130) * Allow holding down keys in StorageOverlay and Item list searchbar * don't sleep on the render thread * Remove most calls to Keyboard#enableRepeatEvents Also remove my flawless implementation in the render methods since it's not needed anymore * remove autoclicker --- .../moulberry/notenoughupdates/util/Utils.java | 154 +++++++++++---------- 1 file changed, 81 insertions(+), 73 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 e572a391..4f420de1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -66,13 +66,65 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Utils { - public static boolean hasEffectOverride = false; - public static boolean disableCustomDungColours = false; private static final LinkedList guiScales = new LinkedList<>(); - private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); //Labymod compatibility private static final FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16); private static final FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16); + private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ + EnumChatFormatting.RED, + EnumChatFormatting.GOLD, + EnumChatFormatting.YELLOW, + EnumChatFormatting.GREEN, + EnumChatFormatting.AQUA, + EnumChatFormatting.LIGHT_PURPLE, + EnumChatFormatting.DARK_PURPLE + }; + private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)"); + private static final char[] c = new char[]{'k', 'm', 'b', 't'}; + private static final LerpingFloat scrollY = new LerpingFloat(0, 100); + public static boolean hasEffectOverride = false; + public static boolean disableCustomDungColours = false; + public static String[] rarityArr = new String[]{ + "COMMON", + "UNCOMMON", + "RARE", + "EPIC", + "LEGENDARY", + "MYTHIC", + "SPECIAL", + "VERY SPECIAL", + "SUPREME", + "^^ THAT ONE IS DIVINE ^^" +//, "DIVINE" + }; + public static String[] rarityArrC = new String[]{ + EnumChatFormatting.WHITE + EnumChatFormatting.BOLD.toString() + "COMMON", + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD.toString() + "UNCOMMON", + EnumChatFormatting.BLUE + EnumChatFormatting.BOLD.toString() + "RARE", + EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD.toString() + "EPIC", + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD.toString() + "LEGENDARY", + EnumChatFormatting.LIGHT_PURPLE + EnumChatFormatting.BOLD.toString() + "MYTHIC", + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "SPECIAL", + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "VERY SPECIAL", + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE", + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE", + //EnumChatFormatting.AQUA+EnumChatFormatting.BOLD.toString()+"DIVINE", + }; + public static final HashMap rarityArrMap = new HashMap() {{ + put("COMMON", rarityArrC[0]); + put("UNCOMMON", rarityArrC[1]); + put("RARE", rarityArrC[2]); + put("EPIC", rarityArrC[3]); + put("LEGENDARY", rarityArrC[4]); + put("MYTHIC", rarityArrC[5]); + put("SPECIAL", rarityArrC[6]); + put("VERY SPECIAL", rarityArrC[7]); + put("DIVINE", rarityArrC[8]); + // put("DIVINE", rarityArrC[9]); + }}; + public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2); + private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); + private static long startTime = 0; public static ArrayList createList(T... values) { ArrayList list = new ArrayList<>(); @@ -203,22 +255,10 @@ public class Utils { drawItemStackWithText(stack, x, y, null, skytilsRarity); } - private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ - EnumChatFormatting.RED, - EnumChatFormatting.GOLD, - EnumChatFormatting.YELLOW, - EnumChatFormatting.GREEN, - EnumChatFormatting.AQUA, - EnumChatFormatting.LIGHT_PURPLE, - EnumChatFormatting.DARK_PURPLE - }; - public static String chromaString(String str) { return chromaString(str, 0, false); } - private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)"); - public static String chromaStringByColourCode(String str) { if (str.contains("\u00a7z")) { Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str); @@ -240,8 +280,6 @@ public class Utils { return str; } - private static long startTime = 0; - public static String chromaString(String str, float offset, boolean bold) { str = cleanColour(str); @@ -268,8 +306,6 @@ public class Utils { return rainbowText.toString(); } - private static final char[] c = new char[]{'k', 'm', 'b', 't'}; - public static String shortNumberFormat(double n, int iteration) { double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) % 10 == 0; @@ -326,7 +362,7 @@ public class Utils { int startIndex = indexOfFirstNonWhitespaceNonFormatCode(str); int endIndex = lastIndexOfNonWhitespaceNonFormatCode(str); if (startIndex == -1 || endIndex == -1) return ""; - return str.substring(startIndex, endIndex+1); + return str.substring(startIndex, endIndex + 1); } private static int indexOfFirstNonWhitespaceNonFormatCode(String str) { @@ -532,46 +568,6 @@ public class Utils { return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); } - public static String[] rarityArr = new String[]{ - "COMMON", - "UNCOMMON", - "RARE", - "EPIC", - "LEGENDARY", - "MYTHIC", - "SPECIAL", - "VERY SPECIAL", - "SUPREME", - "^^ THAT ONE IS DIVINE ^^" -//, "DIVINE" - }; - - public static String[] rarityArrC = new String[]{ - EnumChatFormatting.WHITE + EnumChatFormatting.BOLD.toString() + "COMMON", - EnumChatFormatting.GREEN + EnumChatFormatting.BOLD.toString() + "UNCOMMON", - EnumChatFormatting.BLUE + EnumChatFormatting.BOLD.toString() + "RARE", - EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD.toString() + "EPIC", - EnumChatFormatting.GOLD + EnumChatFormatting.BOLD.toString() + "LEGENDARY", - EnumChatFormatting.LIGHT_PURPLE + EnumChatFormatting.BOLD.toString() + "MYTHIC", - EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "SPECIAL", - EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "VERY SPECIAL", - EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE", - EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE", - //EnumChatFormatting.AQUA+EnumChatFormatting.BOLD.toString()+"DIVINE", - }; - public static final HashMap rarityArrMap = new HashMap() {{ - put("COMMON", rarityArrC[0]); - put("UNCOMMON", rarityArrC[1]); - put("RARE", rarityArrC[2]); - put("EPIC", rarityArrC[3]); - put("LEGENDARY", rarityArrC[4]); - put("MYTHIC", rarityArrC[5]); - put("SPECIAL", rarityArrC[6]); - put("VERY SPECIAL", rarityArrC[7]); - put("DIVINE", rarityArrC[8]); - // put("DIVINE", rarityArrC[9]); - }}; - public static String getRarityFromInt(int rarity) { if (rarity < 0 || rarity >= rarityArr.length) { return rarityArr[0]; @@ -657,18 +653,33 @@ public class Utils { public static int parseRomanNumeral(String input) { int prevVal = 0; int total = 0; - for (int i = input.length()-1; i >= 0; i--) { + for (int i = input.length() - 1; i >= 0; i--) { int val; char ch = input.charAt(i); switch (ch) { - case 'I' : val = 1; break; - case 'V' : val = 5; break; - case 'X' : val = 10; break; - case 'L' : val = 50; break; - case 'C' : val = 100; break; - case 'D' : val = 500; break; - case 'M' : val = 1000; break; - default: throw new IllegalArgumentException("Invalid Roman Numeral Character: " + ch); + case 'I': + val = 1; + break; + case 'V': + val = 5; + break; + case 'X': + val = 10; + break; + case 'L': + val = 50; + break; + case 'C': + val = 100; + break; + case 'D': + val = 500; + break; + case 'M': + val = 1000; + break; + default: + throw new IllegalArgumentException("Invalid Roman Numeral Character: " + ch); } if (val < prevVal) val = -val; total += val; @@ -810,6 +821,7 @@ public class Utils { public static ItemStack createItemStack(Item item, String displayname, String... lore) { return createItemStack(item, displayname, 0, lore); } + public static ItemStack createItemStack(Block item, String displayname, String... lore) { return createItemStack(Item.getItemFromBlock(item), displayname, lore); } @@ -1346,8 +1358,6 @@ public class Utils { return prim.getAsString(); } - public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2); - public static JsonElement getElement(JsonElement element, String path) { List path_split = PATH_SPLITTER.splitToList(path); if (element instanceof JsonObject) { @@ -1429,8 +1439,6 @@ public class Utils { scrollY.resetTimer(); } - private static final LerpingFloat scrollY = new LerpingFloat(0, 100); - public static void drawHoveringText( List textLines, final int mouseX, -- cgit From 50dc2122462642a0c3a00b3a3ae6389825dc04df Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 9 Jun 2022 18:04:22 -0400 Subject: Re-license project as LGPL (#157) * add licence files & a few misc chores * add license notices & run auto formatter --- .../github/moulberry/notenoughupdates/util/Utils.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 4f420de1..b6447706 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see . + */ + package io.github.moulberry.notenoughupdates.util; import com.google.common.base.Splitter; -- cgit From f34220a92af85a33d979edb24ac5c3e698498fe3 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Wed, 22 Jun 2022 14:41:15 +0200 Subject: bug fixes (#172) * yikes * cookie warning * better wording in docs * edit items in parent that are the bounds of the item list * totalCount not updating when not present * unplayable * comment? * outdated repo notification * more notification * crash * more crash * cookie bug --- .../moulberry/notenoughupdates/util/Utils.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 b6447706..ce0ecc4a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1391,6 +1391,11 @@ public class Utils { } } + public static JsonElement getElementOrDefault(JsonElement element, String path, JsonElement def) { + JsonElement result = getElement(element, path); + return result != null ? result : def; + } + public static ChatStyle createClickStyle(ClickEvent.Action action, String value) { ChatStyle style = new ChatStyle(); style.setChatClickEvent(new ClickEvent(action, value)); @@ -1927,4 +1932,19 @@ public class Utils { } return stringBuilder.toString(); } + + public static void showOutdatedRepoNotification() { + NotificationHandler.displayNotification(Lists.newArrayList( + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", + EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" + ), + true, true + ); + } } -- cgit From 1ed053c9a8bbbbbe9b34c61fcdcc1a43d78118fd Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Tue, 5 Jul 2022 08:13:22 +0200 Subject: Merge pull request #179 * magical power * major flaw * rarity --- .../moulberry/notenoughupdates/util/Utils.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 ce0ecc4a..3745d72e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1947,4 +1947,29 @@ public class Utils { true, true ); } + + /** + * Finds the rarity from the lore of an item. + * -1 = UNKNOWN + * 0 = COMMON + * 1 = UNCOMMON + * 2 = RARE + * 3 = EPIC + * 4 = LEGENDARY + * 5 = MYTHIC + * 6 = SPECIAL + * 7 = VERY SPECIAL + */ + public static int getRarityFromLore(JsonArray lore) { + for (int i = lore.size() - 1; i >= 0; i--) { + String line = lore.get(i).getAsString(); + + for (int j = 0; j < rarityArrC.length; j++) { + if (line.startsWith(rarityArrC[j])) { + return j; + } + } + } + return -1; + } } -- cgit From 04d6f54c067a5cdab61186eb37f67fef11affa57 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Sun, 10 Jul 2022 16:04:00 +0200 Subject: ah profit cool gui display (#178) Co-authored-by: Lulonaut Co-authored-by: nopo --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 3745d72e..f45b840c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1937,10 +1937,8 @@ public class Utils { NotificationHandler.displayNotification(Lists.newArrayList( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + - EnumChatFormatting.RED + " to see if that fixes the issue.", - EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + - "discord.gg/moulberry" + + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + EnumChatFormatting.RED +" and restart your game" + + " to see if that fixes the issue.", EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + "discord.gg/moulberry" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" ), -- cgit From 6d2c47744663309c4297a93ff9311e9074251fa1 Mon Sep 17 00:00:00 2001 From: kr45732 <52721908+kr45732@users.noreply.github.com> Date: Fri, 5 Aug 2022 14:53:17 -0400 Subject: Add weight to pv (#201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Finished senither weight * Fixed lily weight * move file and add senither weight * Impl weight * Remove unnecessary stuff * undo nw change * fix stuff * Update 2.1.md * why on earth would you do this 🙂 Co-authored-by: nopo --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 f45b840c..4d546505 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -668,6 +668,10 @@ public class Utils { return (float) Math.round(value * scale) / scale; } + public static int roundToNearestInt(double value) { + return (int) Math.round(value); + } + // Parses Roman numerals, allowing for single character irregular subtractive notation (e.g. IL is 49, IIL is invalid) public static int parseRomanNumeral(String input) { int prevVal = 0; -- cgit From ba69e034794b7a5dc8d950ab4ba2d12370aa509f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:03:30 +0200 Subject: display name (#219) --- .../moulberry/notenoughupdates/util/Utils.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 4d546505..a99e4e7a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -841,15 +841,15 @@ public class Utils { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } - public static ItemStack createItemStack(Item item, String displayname, String... lore) { - return createItemStack(item, displayname, 0, lore); + public static ItemStack createItemStack(Item item, String displayName, String... lore) { + return createItemStack(item, displayName, 0, lore); } - public static ItemStack createItemStack(Block item, String displayname, String... lore) { - return createItemStack(Item.getItemFromBlock(item), displayname, lore); + public static ItemStack createItemStack(Block item, String displayName, String... lore) { + return createItemStack(Item.getItemFromBlock(item), displayName, lore); } - public static ItemStack createItemStack(Item item, String displayname, int damage, String... 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(); @@ -859,7 +859,7 @@ public class Utils { Lore.appendTag(new NBTTagString(line)); } - display.setString("Name", displayname); + display.setString("Name", displayName); display.setTag("Lore", Lore); tag.setTag("display", display); @@ -1425,12 +1425,12 @@ public class Utils { file.delete(); } - public static char getPrimaryColourCode(String displayname) { + public static char getPrimaryColourCode(String displayName) { int lastColourCode = -99; int currentColour = 0; int[] mostCommon = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - for (int i = 0; i < displayname.length(); i++) { - char c = displayname.charAt(i); + for (int i = 0; i < displayName.length(); i++) { + char c = displayName.charAt(i); if (c == '\u00A7') { lastColourCode = i; } else if (lastColourCode == i - 1) { @@ -1457,8 +1457,8 @@ public class Utils { return "0123456789abcdef".charAt(currentColour); } - public static Color getPrimaryColour(String displayname) { - int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(getPrimaryColourCode(displayname)); + public static Color getPrimaryColour(String displayName) { + int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(getPrimaryColourCode(displayName)); return new Color(colourInt).darker(); } -- cgit From 4d48d36976dae85fcd46a605408b006857f1f9fd Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Thu, 11 Aug 2022 13:18:16 +0200 Subject: Autoupdate (#191) Co-authored-by: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> --- .../io/github/moulberry/notenoughupdates/util/Utils.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 a99e4e7a..9713b69a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -877,6 +877,8 @@ public class Utils { String... lore ) { NBTTagCompound tag = itemStack.getTagCompound(); + if (tag == null) + tag = new NBTTagCompound(); NBTTagCompound display = tag.getCompoundTag("display"); NBTTagList Lore = new NBTTagList(); @@ -1940,9 +1942,13 @@ public class Utils { public static void showOutdatedRepoNotification() { NotificationHandler.displayNotification(Lists.newArrayList( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", - EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + EnumChatFormatting.RED +" and restart your game" + - " to see if that fixes the issue.", EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + "discord.gg/moulberry" + + EnumChatFormatting.RED + + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " and restart your game" + + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" ), -- cgit From 3571d2bba813a0f260f0d0356da0dd0c19660b00 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 13 Aug 2022 07:15:16 +0000 Subject: i forgot to make a pr :skull: (#220) * https://cdn.discordapp.com/attachments/832652653292027904/998120255245262848/unknown.png * added repo warning toggle --- .../moulberry/notenoughupdates/util/Utils.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 9713b69a..5d6af2aa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1940,20 +1940,18 @@ public class Utils { } public static void showOutdatedRepoNotification() { - NotificationHandler.displayNotification(Lists.newArrayList( - EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", - EnumChatFormatting.RED + - "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + - EnumChatFormatting.RED + " and restart your game" + - " to see if that fixes the issue.", - EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + - "discord.gg/moulberry" + - EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + - "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" - ), - true, true - ); + if (NotEnoughUpdates.INSTANCE.config.notifications.outdatedRepo) { + NotificationHandler.displayNotification(Lists.newArrayList( + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", + EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + EnumChatFormatting.RED +" and restart your game" + + " to see if that fixes the issue.", EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + "discord.gg/moulberry" + + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" + ), + true, true + ); + } } /** -- cgit From 5d2aa40fdee044c0579f426bff279b9d631e306f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 17 Aug 2022 09:38:24 +0200 Subject: Probably fixing Lag spikes (#229) * using method getOpenChestName instead of field lastOpenContainerName * probably fixing lag spikes in power stone stats display * using new getOpenChestName in EnchantingSolvers --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 5d6af2aa..d7b80a0e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1978,4 +1978,8 @@ public class Utils { } return -1; } + + public static String getOpenChestName() { + return SBInfo.getInstance().currentlyOpenChestName; + } } -- cgit From b2d35428ac089ac104a2ea8212d8332c27a6cbee Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 19 Aug 2022 13:05:33 +0200 Subject: Dumb bugs (#232) * fixing experimentation solver * fixing neu buttons not resetting properly after disabling trophy reward overlay or accessory bag overlay * fixed ah overlay --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 d7b80a0e..5b3ea853 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1982,4 +1982,8 @@ public class Utils { public static String getOpenChestName() { return SBInfo.getInstance().currentlyOpenChestName; } + + public static String getLastOpenChestName() { + return SBInfo.getInstance().lastOpenChestName; + } } -- cgit From dfd2f6b05bce74d7feb5d28e7a388dbb871ecf6a Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 26 Aug 2022 13:24:35 +0200 Subject: Of course you have pronouns in pv (#234) --- .../github/moulberry/notenoughupdates/util/Utils.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 5b3ea853..2267cbea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -73,6 +73,7 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.math.BigInteger; import java.nio.FloatBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -81,6 +82,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1943,9 +1945,13 @@ public class Utils { if (NotEnoughUpdates.INSTANCE.config.notifications.outdatedRepo) { NotificationHandler.displayNotification(Lists.newArrayList( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", - EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + EnumChatFormatting.RED +" and restart your game" + - " to see if that fixes the issue.", EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + "discord.gg/moulberry" + + EnumChatFormatting.RED + + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " and restart your game" + + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" ), @@ -1979,6 +1985,13 @@ public class Utils { return -1; } + public static UUID parseDashlessUUID(String dashlessUuid) { + // From: https://stackoverflow.com/a/30760478/ + BigInteger most = new BigInteger(dashlessUuid.substring(0, 16), 16); + BigInteger least = new BigInteger(dashlessUuid.substring(16, 32), 16); + return new UUID(most.longValue(), least.longValue()); + } + public static String getOpenChestName() { return SBInfo.getInstance().currentlyOpenChestName; } -- cgit