From 0a4f43fd3ebd414713747ecd0846952be76cb1ab Mon Sep 17 00:00:00 2001 From: shurik204 Date: Tue, 21 Nov 2023 10:31:50 +0200 Subject: [PATCH] Fix incompatibility with Figura mod --- .../client/mixin/SuggestionWindowMixin.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/shurik/bettersuggestions/client/mixin/SuggestionWindowMixin.java b/src/main/java/me/shurik/bettersuggestions/client/mixin/SuggestionWindowMixin.java index 025ff98..c995393 100644 --- a/src/main/java/me/shurik/bettersuggestions/client/mixin/SuggestionWindowMixin.java +++ b/src/main/java/me/shurik/bettersuggestions/client/mixin/SuggestionWindowMixin.java @@ -41,7 +41,8 @@ * Highlight entities from suggestions * Sort suggestions */ -@Mixin(value = SuggestionWindow.class, priority = 999) +@Mixin(value = SuggestionWindow.class, priority = 1001) +// 1001 - fix incompatibility with Figura mod public class SuggestionWindowMixin { @Shadow private int inWindowIndex; @@ -60,7 +61,10 @@ public class SuggestionWindowMixin { @Shadow private boolean completed; + @Unique private TextRenderer suggestions$textRenderer; + @Unique + private boolean suggestions$renderShiftTooltip; @Inject(at = @At("TAIL"), method = "") void init(ChatInputSuggestor suggestor, int x, int y, int width, List suggestions, boolean narrateFirstSuggestion, CallbackInfo info) { @@ -126,12 +130,11 @@ else if (customSuggestion.isEntitySuggestion()) { @Nullable @Unique private CustomSuggestionAccessor customCurrentSuggestion; - - private boolean renderShiftTooltip; + // HEAD @Inject(method = "render", at = @At("HEAD")) void renderPrepare(DrawContext context, int mouseX, int mouseY, CallbackInfo info) { - renderShiftTooltip = true; + suggestions$renderShiftTooltip = true; customCurrentSuggestion = null; } @@ -171,7 +174,7 @@ void renderMouseTooltip(DrawContext context, TextRenderer textRenderer, Text tex if (tooltip != null) { context.drawTooltip(textRenderer, tooltip, x, y); } - renderShiftTooltip = false; + suggestions$renderShiftTooltip = false; } @Inject(method = "render", at = @At("TAIL")) @@ -185,11 +188,11 @@ void renderFinish(DrawContext context, int mouseX, int mouseY, CallbackInfo info // } // Render shift tooltip - if (renderShiftTooltip && Screen.hasShiftDown()) { + if (suggestions$renderShiftTooltip && Screen.hasShiftDown()) { List tooltip = customSuggestion.getMultilineTooltip(); if (tooltip != null) { // get suggestion index in for loop - context.drawTooltip(suggestions$textRenderer, tooltip, this.area.getX() - 5, Math.round(this.area.getY() + (12 * (this.selection - this.inWindowIndex)) - 10 * (tooltip.size() - 1) - 1)); + context.drawTooltip(suggestions$textRenderer, tooltip, this.area.getX() - 5, this.area.getY() + (12 * (this.selection - this.inWindowIndex)) - 10 * (tooltip.size() - 1) - 1); } }