Skip to content

Commit

Permalink
Properly port recipe book tree to 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Mar 30, 2024
1 parent 099c626 commit e9c266c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void replaceSearchTrees(CallbackInfo ci) {
ModernFix.LOGGER.info("Replacing search trees with '{}' provider", provider.getName());
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> provider.getSearchTree(false));
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> provider.getSearchTree(true));
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, list -> new RecipeBookSearchTree(provider.getSearchTree(false)));
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, list -> new RecipeBookSearchTree(provider.getSearchTree(false), list));
// grab components for all key mappings in order to prevent them from being loaded off-thread later
// this populates the LazyLoadedValues
// we also need to suppress GLFW errors to prevent crashes if a key is missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
private final SearchTree<ItemStack> stackCollector;
private Map<Item, List<RecipeCollection>> collectionsByItem = null;
private final List<RecipeCollection> allCollections = new ArrayList<>();
private final List<RecipeCollection> allCollections;

public RecipeBookSearchTree(SearchTree<ItemStack> stackCollector) {
public RecipeBookSearchTree(SearchTree<ItemStack> stackCollector, List<RecipeCollection> allCollections) {
this.stackCollector = stackCollector;
this.allCollections = allCollections;
}

private Map<Item, List<RecipeCollection>> populateCollectionMap() {
Expand All @@ -36,16 +37,6 @@ private Map<Item, List<RecipeCollection>> populateCollectionMap() {
return collections;
}

@Override
public void add(RecipeCollection pObj) {
this.allCollections.add(pObj);
}

@Override
public void clear() {
this.allCollections.clear();
}

@Override
public void refresh() {
this.collectionsByItem = null;
Expand Down

0 comments on commit e9c266c

Please sign in to comment.