Skip to content

Commit

Permalink
Fix #1611 Rare crash when cycling items
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jun 30, 2019
1 parent b674e0d commit 25d0502
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mezz/jei/gui/ingredients/CycleTimer.java
Expand Up @@ -23,8 +23,8 @@ public <T> T getCycledItem(List<T> list) {
if (list.isEmpty()) {
return null;
}
Long index = ((drawTime - startTime) / cycleTime) % list.size();
return list.get(index.intValue());
long index = ((drawTime - startTime) / cycleTime) % list.size();
return list.get(Math.toIntExact(index));
}

public void onDraw() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/gui/recipes/RecipeLayout.java
Expand Up @@ -42,7 +42,7 @@ public class RecipeLayout implements IRecipeLayoutDrawable {
private static final int RECIPE_BORDER_PADDING = 4;
public static final int recipeTransferButtonIndex = 100;

private final int ingredientCycleOffset = (int) (Math.random() * 10000);
private final int ingredientCycleOffset = (int) ((Math.random() * 10000) % Integer.MAX_VALUE);
private final IRecipeCategory recipeCategory;
private final GuiItemStackGroup guiItemStackGroup;
private final GuiFluidStackGroup guiFluidStackGroup;
Expand Down

0 comments on commit 25d0502

Please sign in to comment.