Skip to content

Commit

Permalink
Fix the auto complete rendering under some elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Apr 23, 2024
1 parent cc569fc commit b55f408
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import org.joml.Vector2d;
Expand Down Expand Up @@ -156,19 +157,16 @@ public void renderWidget(GuiGraphics guiGraphics, int mx, int my, float partial)
return;
}
updateHoveringState(mx, my);
PoseStack pose = guiGraphics.pose();
pose.translate(0, 0, 500);
for(int i = displayOffset; i < Math.min(displayOffset + maxSuggestions, suggestions.size()); i++) {
CompletionSuggestion suggestion = suggestions.get(i);
int minX = this.getX() + 2;
int minY = this.getY() + (suggestionHeight * (i - displayOffset));
int maxY = minY + suggestionHeight;
boolean hovered = selectedIndex != -1 && displayOffset + selectedIndex == i;

guiGraphics.fill(this.getX(), minY, this.getX() + this.getWidth(), maxY, hovered ? 0xe0111111 : 0xe0000000);
guiGraphics.fill(RenderType.guiOverlay(), this.getX(), minY, this.getX() + this.getWidth(), maxY, hovered ? 0xe0111111 : 0xe0000000);
guiGraphics.drawString(Minecraft.getInstance().font, suggestion.display(), minX, minY + 1, hovered ? Objects.requireNonNull(ChatFormatting.YELLOW.getColor()) : 0xFFFFFFFF);
}
pose.translate(0, 0, -500);

this.lastMousePosition.set(mx, my);
}
Expand Down

0 comments on commit b55f408

Please sign in to comment.