Merge remote-tracking branch 'origin/1.19.2' into 1.20

This commit is contained in:
embeddedt 2024-03-30 17:42:09 -04:00
commit 4ddac48f1e
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 5 additions and 14 deletions

View File

@ -37,7 +37,7 @@ public abstract class MinecraftMixin {
SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier = list -> provider.getSearchTree(true);
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, nameSupplier);
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, tagSupplier);
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));
ModernFixPlatformHooks.INSTANCE.registerCreativeSearchTrees(this.searchRegistry, nameSupplier, tagSupplier, this::populateSearchTree);
// grab components for all key mappings in order to prevent them from being loaded off-thread later
// this populates the LazyLoadedValues

View File

@ -15,10 +15,11 @@ import java.util.stream.Collectors;
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() {
@ -27,7 +28,7 @@ public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
collections = new Object2ObjectOpenHashMap<>();
Map<Item, List<RecipeCollection>> finalCollection = collections;
for(RecipeCollection collection : allCollections) {
collection.getRecipes().stream().map(recipe -> recipe.getResultItem().getItem()).distinct().forEach(item -> {
collection.getRecipes().stream().map(recipe -> recipe.getResultItem(collection.registryAccess()).getItem()).distinct().forEach(item -> {
finalCollection.computeIfAbsent(item, k -> new ArrayList<>()).add(collection);
});
}
@ -36,16 +37,6 @@ public class RecipeBookSearchTree extends DummySearchTree<RecipeCollection> {
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;