Skip to content

Commit

Permalink
Fix incompatibility with Figura mod
Browse files Browse the repository at this point in the history
  • Loading branch information
shurik204 committed Nov 21, 2023
1 parent 98505dc commit 0a4f43f
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = "<init>")
void init(ChatInputSuggestor suggestor, int x, int y, int width, List<Suggestion> suggestions, boolean narrateFirstSuggestion, CallbackInfo info) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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"))
Expand All @@ -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<Text> 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);
}
}

Expand Down

0 comments on commit 0a4f43f

Please sign in to comment.