aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java2
3 files changed, 13 insertions, 18 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
index 21fa64b7..ccb28dd6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
@@ -35,20 +35,22 @@ public class TooltipTextScrolling {
static int scrollOffset = 0;
static boolean didRenderTooltip = false;
- public static void handleTextLineRendering(List<String> tooltip) {
+ public static List<String> handleTextLineRendering(List<String> tooltip) {
didRenderTooltip = true;
if (!Objects.equals(tooltip, lastRenderedTooltip)) {
lastRenderedTooltip = new ArrayList<>(tooltip);
scrollOffset = 0;
- return;
+ return tooltip;
}
lastRenderedTooltip = new ArrayList<>(tooltip);
- for (int i = 0; i < scrollOffset && tooltip.size() > 1; i++) {
- tooltip.remove(0);
+ List<String> modifiableTooltip = new ArrayList<>(tooltip);
+ for (int i = 0; i < scrollOffset && modifiableTooltip.size() > 1; i++) {
+ modifiableTooltip.remove(0);
}
- for (int i = 0; i < -scrollOffset && tooltip.size() > 1; i++) {
- tooltip.remove(tooltip.size() - 1);
+ for (int i = 0; i < -scrollOffset && modifiableTooltip.size() > 1; i++) {
+ modifiableTooltip.remove(modifiableTooltip.size() - 1);
}
+ return modifiableTooltip;
}
@SubscribeEvent
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
index a3313090..a4e83a11 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
@@ -74,17 +74,10 @@ public class MixinGuiUtils {
List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font, CallbackInfo ci) {
Utils.resetGuiScale();
}
- @Inject(at = @At("HEAD"), method = "drawHoveringText")
- private static void onDrawHoveringText(
- List<String> textLines,
- int mouseX,
- int mouseY,
- int screenWidth,
- int screenHeight,
- int maxTextWidth,
- FontRenderer font,
- CallbackInfo ci
+ @ModifyVariable(at = @At("HEAD"), method = "drawHoveringText")
+ private static List<String> onDrawHoveringText(
+ List<String> textLines
) {
- TooltipTextScrolling.handleTextLineRendering(textLines);
+ return TooltipTextScrolling.handleTextLineRendering(textLines);
}
}
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 bd3693a0..90e53097 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -1571,7 +1571,7 @@ public class Utils {
((NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderOpacity) << 24);
}
}
- TooltipTextScrolling.handleTextLineRendering(textLines);
+ textLines = TooltipTextScrolling.handleTextLineRendering(textLines);
if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) {
ScaledResolution scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale);
mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;