mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-08 12:34:46 +00:00
Fix crash when recipe search results change mid-rebuild (#1012)
This commit is contained in:
1 parent
6ced1e0604
commit
4c74a01930
2 files changed
+19
-2
No files matched your search
@@ -50,12 +50,13 @@ public class RecipePageManager {
|
||||
|
||||
final int heightAvailable = this.container.getVisibleHeight();
|
||||
final int width = Math.max(166, this.handlerInfo.getWidth());
|
||||
final int numRecipes = getNumRecipes();
|
||||
final List<Integer> searchRecipes = this.handler.getFilteredRecipes();
|
||||
final int numRecipes = searchRecipes.size();
|
||||
List<Widget> widgets = new ArrayList<>();
|
||||
int shiftY = 0;
|
||||
|
||||
for (int i = 0; i < numRecipes; i++) {
|
||||
final int recipeIndex = this.handler.ref(i);
|
||||
final int recipeIndex = searchRecipes.get(i);
|
||||
final NEIRecipeWidget widget = RecipeHandlerRef.of(this.handler.original, recipeIndex).getRecipeWidget();
|
||||
widget.w = width;
|
||||
|
||||
|
||||
@@ -97,6 +97,22 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
this.searchRecipes = searchRecipes;
|
||||
}
|
||||
|
||||
public List<Integer> getFilteredRecipes() {
|
||||
|
||||
if (this.searchRecipes == null) {
|
||||
return this.filteredRecipes;
|
||||
}
|
||||
|
||||
final List<Integer> search = this.searchRecipes;
|
||||
final List<Integer> resolved = new ArrayList<>(search.size());
|
||||
|
||||
for (int idx : search) {
|
||||
resolved.add(this.filteredRecipes.get(idx));
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
public int ref(int index) {
|
||||
|
||||
if (searchRecipes != null) {
|
||||
|
||||
Reference in new issue
Block a user