Skip to content

Commit

Permalink
Fix potential division by zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Aug 23, 2023
1 parent 25ebda4 commit c803392
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private int getSmoothScrollPosition() {
}

private int getScrollButtonY() {
if (maxScrollPosition() > 0) {
if (canScroll()) {
final int yMax = screenStyle.getScrollBarRect().getHeight() - screenStyle.getScrollButtonRect().getHeight();
return Math.max(0, Math.min(yMax, yMax * getSmoothScrollPosition() / maxScrollPosition()));
} else {
Expand Down Expand Up @@ -400,7 +400,7 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int

public void applyTooltip(final boolean fixedY) {
final var screen = Minecraft.getInstance().screen;
if (screen != null) {
if (screen != null && canScroll()) {
screen.setTooltipForNextRenderPass(getTooltipContent(), getClientTooltipPositioner(fixedY), true);
}
}
Expand Down

0 comments on commit c803392

Please sign in to comment.