Skip to content

Commit c803392

Browse files
committed
Fix potential division by zero.
1 parent 25ebda4 commit c803392

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

common/src/main/java/li/cil/manual/client/gui/ManualScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private int getSmoothScrollPosition() {
273273
}
274274

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

401401
public void applyTooltip(final boolean fixedY) {
402402
final var screen = Minecraft.getInstance().screen;
403-
if (screen != null) {
403+
if (screen != null && canScroll()) {
404404
screen.setTooltipForNextRenderPass(getTooltipContent(), getClientTooltipPositioner(fixedY), true);
405405
}
406406
}

0 commit comments

Comments
 (0)