Properly port recipe book tree to 1.19.2
This commit is contained in:
parent
099c62672b
commit
e9c266cd16
|
|
@ -29,7 +29,7 @@ public class MinecraftMixin {
|
||||||
ModernFix.LOGGER.info("Replacing search trees with '{}' provider", provider.getName());
|
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_NAMES, list -> provider.getSearchTree(false));
|
||||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> provider.getSearchTree(true));
|
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
|
// grab components for all key mappings in order to prevent them from being loaded off-thread later
|
||||||
// this populates the LazyLoadedValues
|
// this populates the LazyLoadedValues
|
||||||
// we also need to suppress GLFW errors to prevent crashes if a key is missing
|
// we also need to suppress GLFW errors to prevent crashes if a key is missing
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,11 @@ import java.util.stream.Collectors;
|
||||||
public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
|
public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
|
||||||
private final SearchTree<ItemStack> stackCollector;
|
private final SearchTree<ItemStack> stackCollector;
|
||||||
private Map<Item, List<RecipeCollection>> collectionsByItem = null;
|
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.stackCollector = stackCollector;
|
||||||
|
this.allCollections = allCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Item, List<RecipeCollection>> populateCollectionMap() {
|
private Map<Item, List<RecipeCollection>> populateCollectionMap() {
|
||||||
|
|
@ -36,16 +37,6 @@ public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
|
||||||
return collections;
|
return collections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(RecipeCollection pObj) {
|
|
||||||
this.allCollections.add(pObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
this.allCollections.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
this.collectionsByItem = null;
|
this.collectionsByItem = null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user