diff options
author | nea <nea@nea.moe> | 2023-02-15 10:50:06 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-02-15 10:50:06 +0100 |
commit | 0960bc9aa9faeb558124ee62b1c1e65983bbff69 (patch) | |
tree | 5d1e15a010d82dce17f2ad678c83cccbd8a6357c /src/main/java | |
parent | 21e8f5833176828e31a57e0a9c428867a6a1c1fd (diff) | |
download | NotEnoughUpdates-0960bc9aa9faeb558124ee62b1c1e65983bbff69.tar.gz NotEnoughUpdates-0960bc9aa9faeb558124ee62b1c1e65983bbff69.tar.bz2 NotEnoughUpdates-0960bc9aa9faeb558124ee62b1c1e65983bbff69.zip |
Use a new arraylist instead of modifying the old one (achievments)
Diffstat (limited to 'src/main/java')
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; |