From 22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Fri, 25 Feb 2022 23:05:42 +0100 Subject: Hide Hypixel reforge stats in Reforge Stone lore (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hide Hypixel reforge stats * unused import? * better comments * 2.1.md 🙂 * 2.1.md 🙂 --- .../notenoughupdates/NEUEventListener.java | 38 +++++++++++++++++++--- .../notenoughupdates/NotEnoughUpdates.java | 1 - .../options/seperateSections/TooltipTweaks.java | 8 +++++ 3 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 10755305..6af0d057 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -53,15 +53,14 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import javax.swing.JOptionPane; -import javax.swing.JTextField; -import java.awt.Color; -import java.awt.Toolkit; +import javax.swing.*; +import java.awt.*; import java.awt.datatransfer.StringSelection; import java.io.File; import java.io.IOException; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.util.List; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -2575,16 +2574,45 @@ public class NEUEventListener { DecimalFormat myFormatter = new DecimalFormat("###,###.###"); /** - * This makes it so that holding LCONTROL while hovering over an item with NBT will show the NBT of the item. + * This method does the following: + * Move the pet inventory display tooltip to the left to avoid conflicts + * Remove reforge stats for Legendary items from Hypixel if enabled + * Show NBT data when holding LCONTROL */ @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { if (!neu.isOnSkyblock()) return; + if (event.toolTip == null) return; //Render the pet inventory display tooltip to the left to avoid things from other mods rendering over the tooltip if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUPETINVDISPLAY")) { GlStateManager.translate(-200, 0, 0); } + if (event.toolTip.size() > 2 && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.hideDefaultReforgeStats) { + String secondLine = StringUtils.stripControlCodes(event.toolTip.get(1)); + if (secondLine.equals("Reforge Stone")) { + Integer startIndex = null; + Integer cutoffIndex = null; + //loop from the back of the List to find the wanted index sooner + for (int i = event.toolTip.size() - 1; i >= 0; i--) { + //rarity or mining level requirement + String line = StringUtils.stripControlCodes(event.toolTip.get(i)); + if (line.contains("REFORGE STONE") || line.contains("Requires Mining Skill Level")) { + cutoffIndex = i; + } + + //The line where the Hypixel stats start + if (line.contains("(Legendary):")) { + startIndex = i; + break; + } + } + if (startIndex != null && cutoffIndex != null && startIndex < cutoffIndex) { + event.toolTip.subList(startIndex, cutoffIndex).clear(); + } + } + } + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && NotEnoughUpdates.INSTANCE.config.hidden.dev && event.toolTip.size() > 0 && event.toolTip.get(event.toolTip.size() - 1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) { event.toolTip.remove(event.toolTip.size() - 1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 0cff5de1..e6cfd7c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -39,7 +39,6 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import scala.collection.parallel.ParIterableLike; import java.awt.*; import java.io.*; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index 78dc1995..fcbc5ea4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -94,6 +94,14 @@ public class TooltipTweaks { @ConfigEditorBoolean public boolean showReforgeStats = true; + @Expose + @ConfigOption( + name = "Hide default reforge stats", + desc = "Hides the reforge stats only for Legendary items that Hypixel adds to the Reforge stones" + ) + @ConfigEditorBoolean + public boolean hideDefaultReforgeStats = true; + @Expose @ConfigOption( name = "Missing Enchant List", -- cgit