Skip to content

Commit

Permalink
Fix #238 tooltips from getTooltipStrings are drawn below other assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Apr 6, 2016
1 parent ee9fb67 commit 090aaf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/java/mezz/jei/gui/RecipeLayout.java
Expand Up @@ -91,7 +91,7 @@ public void draw(@Nonnull Minecraft minecraft, int mouseX, int mouseY) {
RenderHelper.disableStandardItemLighting();
} else if (hoveredFluidStack != null) {
hoveredFluidStack.drawHovered(minecraft, posX, posY, recipeMouseX, recipeMouseY);
} else if (recipeMouseX >= 0 && recipeMouseX < background.getWidth() && recipeMouseY >= 0 && recipeMouseY < background.getHeight()) {
} else if (isMouseOver(mouseX, mouseY)) {
List<String> tooltipStrings = recipeWrapper.getTooltipStrings(recipeMouseX, recipeMouseY);
if (tooltipStrings != null && !tooltipStrings.isEmpty()) {
TooltipRenderer.drawHoveringText(minecraft, tooltipStrings, mouseX, mouseY);
Expand All @@ -101,6 +101,13 @@ public void draw(@Nonnull Minecraft minecraft, int mouseX, int mouseY) {
GlStateManager.disableAlpha();
}

public boolean isMouseOver(int mouseX, int mouseY) {
final int recipeMouseX = mouseX - posX;
final int recipeMouseY = mouseY - posY;
final IDrawable background = recipeCategory.getBackground();
return recipeMouseX >= 0 && recipeMouseX < background.getWidth() && recipeMouseY >= 0 && recipeMouseY < background.getHeight();
}

public Focus getFocusUnderMouse(int mouseX, int mouseY) {
Focus focus = guiItemStackGroup.getFocusUnderMouse(posX, posY, mouseX, mouseY);
if (focus == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/gui/RecipesGui.java
Expand Up @@ -150,7 +150,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {

RecipeLayout hovered = null;
for (RecipeLayout recipeWidget : recipeLayouts) {
if (recipeWidget.getFocusUnderMouse(mouseX, mouseY) != null) {
if (recipeWidget.isMouseOver(mouseX, mouseY)) {
hovered = recipeWidget;
} else {
recipeWidget.draw(mc, mouseX, mouseY);
Expand Down

0 comments on commit 090aaf9

Please sign in to comment.