Skip to content

Commit

Permalink
Prevent crash when scrolling in Identity screen without any unlocks
Browse files Browse the repository at this point in the history
Fixes #210
  • Loading branch information
Draylar committed Oct 10, 2021
1 parent a3df357 commit 70d09c6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/java/draylar/identity/screen/IdentityScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,20 @@ public void renderEntityWidgets(MatrixStack matrices, int mouseX, int mouseY, fl

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
float firstPos = entityWidgets.get(0).y;
if(entityWidgets.size() > 0) {
float firstPos = entityWidgets.get(0).y;

// Top section should always have mobs, prevent scrolling the entire list down the screen
if(amount == 1 && firstPos >= 35) {
return false;
}

((ScreenAccessor) this).getSelectables().forEach(button -> {
if(button instanceof EntityWidget widget) {
widget.y = (int) (widget.y + amount * 10);
// Top section should always have mobs, prevent scrolling the entire list down the screen
if(amount == 1 && firstPos >= 35) {
return false;
}
});

((ScreenAccessor) this).getSelectables().forEach(button -> {
if(button instanceof EntityWidget widget) {
widget.y = (int) (widget.y + amount * 10);
}
});
}

return false;
}
Expand Down

0 comments on commit 70d09c6

Please sign in to comment.