From 85740f83af04aa2059cf721ec8dcb39be9b60ec6 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:20:06 -0400 Subject: [PATCH] Remove blast_search_trees --- common/build.gradle | 12 -- .../embeddedt/modernfix/ModernFixClient.java | 5 - .../SessionSearchTreesMixin.java | 94 ----------- .../core/config/ModernFixEarlyConfig.java | 1 - .../modernfix/searchtree/DummySearchTree.java | 39 ----- .../searchtree/JEIBackedSearchTree.java | 109 ------------- .../searchtree/JEIRuntimeCapturer.java | 34 ---- .../searchtree/REIBackedSearchTree.java | 150 ------------------ .../searchtree/RecipeBookSearchTree.java | 50 ------ .../SearchTreeProviderRegistry.java | 34 ---- gradle.properties | 4 +- .../resources/META-INF/neoforge.mods.toml | 2 +- 12 files changed, 3 insertions(+), 531 deletions(-) delete mode 100644 common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/blast_search_trees/SessionSearchTreesMixin.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/DummySearchTree.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/JEIBackedSearchTree.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/JEIRuntimeCapturer.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/REIBackedSearchTree.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/RecipeBookSearchTree.java delete mode 100644 common/src/main/java/org/embeddedt/modernfix/searchtree/SearchTreeProviderRegistry.java diff --git a/common/build.gradle b/common/build.gradle index ad3bd0be9..38bc6a854 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -6,8 +6,6 @@ architectury { common(rootProject.enabled_platforms.split(",")) } -ext.jei_minecraft_version = "1.20.2" /* temporary, till 1.20 releases */ - dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader @@ -20,18 +18,8 @@ dependencies { modApi("dev.latvian.mods:rhino:${rhino_version}") { transitive = false } - modApi("me.shedaniel:RoughlyEnoughItems-api:${rei_version}") { - transitive = false - } - modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}") { - transitive = false - } modCompileOnly "curse.maven:spark-361579:${rootProject.spark_version}" - // compile against the JEI API but do not include it at runtime - modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-common:${jei_version}") - modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-gui:${jei_version}") - modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-lib:${jei_version}") // Remove the next line if you don't want to depend on the API // modApi "me.shedaniel:architectury:${rootProject.architectury_version}" } diff --git a/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java b/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java index 7d973fb6d..ef9af07ee 100644 --- a/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java +++ b/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java @@ -9,9 +9,6 @@ import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration; import org.embeddedt.modernfix.core.ModernFixMixinPlugin; import org.embeddedt.modernfix.platform.ModernFixPlatformHooks; -import org.embeddedt.modernfix.searchtree.JEIBackedSearchTree; -import org.embeddedt.modernfix.searchtree.REIBackedSearchTree; -import org.embeddedt.modernfix.searchtree.SearchTreeProviderRegistry; import org.embeddedt.modernfix.util.ClassInfoManager; import org.embeddedt.modernfix.world.IntegratedWatchdog; @@ -42,8 +39,6 @@ public ModernFixClient() { if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.branding.F3Screen")) { brandingString = ModernFix.NAME + " " + ModernFixPlatformHooks.INSTANCE.getVersionString(); } - SearchTreeProviderRegistry.register(JEIBackedSearchTree.PROVIDER); - SearchTreeProviderRegistry.register(REIBackedSearchTree.PROVIDER); for(String className : ModernFixPlatformHooks.INSTANCE.getCustomModOptions().get(IntegrationConstants.CLIENT_INTEGRATION_CLASS)) { try { CLIENT_INTEGRATIONS.add((ModernFixClientIntegration)Class.forName(className).getDeclaredConstructor().newInstance()); diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/blast_search_trees/SessionSearchTreesMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/blast_search_trees/SessionSearchTreesMixin.java deleted file mode 100644 index 74900135c..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/blast_search_trees/SessionSearchTreesMixin.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.embeddedt.modernfix.common.mixin.perf.blast_search_trees; - -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.ClientRecipeBook; -import net.minecraft.client.KeyMapping; -import net.minecraft.client.gui.screens.recipebook.RecipeCollection; -import net.minecraft.client.multiplayer.SessionSearchTrees; -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.ItemStack; -import org.embeddedt.modernfix.ModernFix; -import org.embeddedt.modernfix.annotation.ClientOnlyMixin; -import org.embeddedt.modernfix.searchtree.RecipeBookSearchTree; -import org.embeddedt.modernfix.searchtree.SearchTreeProviderRegistry; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.glfw.GLFWErrorCallback; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -@Mixin(SessionSearchTrees.class) -@ClientOnlyMixin -public abstract class SessionSearchTreesMixin { - @Shadow private CompletableFuture> recipeSearch; - @Shadow private CompletableFuture> creativeByNameSearch; - @Shadow @Final private static SessionSearchTrees.Key CREATIVE_NAMES; - @Shadow @Final private static SessionSearchTrees.Key CREATIVE_TAGS; - private SearchTreeProviderRegistry.Provider mfix$provider; - - @Inject(method = "", at = @At("RETURN")) - private void onInit(CallbackInfo ci) { - mfix$provider = SearchTreeProviderRegistry.getSearchTreeProvider(); - if(mfix$provider != null) { - ModernFix.LOGGER.info("Replacing search trees with '{}' provider", mfix$provider.getName()); - } - - // 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 - GLFWErrorCallback oldCb = GLFW.glfwSetErrorCallback(null); - for(KeyMapping mapping : KeyMapping.ALL.values()) { - mapping.getTranslatedKeyMessage(); - } - GLFW.glfwSetErrorCallback(oldCb); - } - - @ModifyArg(method = "updateRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/SessionSearchTrees;register(Lnet/minecraft/client/multiplayer/SessionSearchTrees$Key;Ljava/lang/Runnable;)V"), index = 1) - private Runnable useModernFixRecipeTree(Runnable r, @Local(ordinal = 0, argsOnly = true) ClientRecipeBook clientRecipeBook) { - if(mfix$provider == null) { - return r; - } else { - return () -> { - List list = clientRecipeBook.getCollections(); - CompletableFuture old = this.recipeSearch; - this.recipeSearch = CompletableFuture.supplyAsync(() -> { - return new RecipeBookSearchTree(mfix$provider.getSearchTree(false), list); - }); - old.cancel(true); - }; - } - } - - @ModifyArg(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/SessionSearchTrees;register(Lnet/minecraft/client/multiplayer/SessionSearchTrees$Key;Ljava/lang/Runnable;)V"), index = 1) - private Runnable useOverridenSearchTreeLogic(SessionSearchTrees.Key key, Runnable r) { - if(mfix$provider == null) { - return r; - } - if(key == CREATIVE_NAMES) { - return () -> { - CompletableFuture old = this.creativeByNameSearch; - this.creativeByNameSearch = CompletableFuture.supplyAsync(() -> { - return mfix$provider.getSearchTree(false); - }); - old.cancel(true); - }; - } - if(key == CREATIVE_TAGS) { - return () -> { - CompletableFuture old = this.creativeByNameSearch; - this.creativeByNameSearch = CompletableFuture.supplyAsync(() -> { - return mfix$provider.getSearchTree(true); - }); - old.cancel(true); - }; - } - return r; - } -} diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java index 80810af4f..8d7b00ae3 100644 --- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java +++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java @@ -163,7 +163,6 @@ public DefaultSettingMapBuilder put(String key, Boolean value) { .put("mixin.perf.dynamic_resources", false) .put("mixin.feature.direct_stack_trace", false) .put("mixin.feature.stalled_chunk_load_detection", false) - .put("mixin.perf.blast_search_trees.force", false) .put("mixin.bugfix.restore_old_dragon_movement", false) .put("mixin.perf.worldgen_allocation", false) // experimental .put("mixin.feature.cause_lag_by_disabling_threads", false) diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/DummySearchTree.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/DummySearchTree.java deleted file mode 100644 index 49af04de2..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/DummySearchTree.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.ItemStack; - -import java.util.Collections; -import java.util.List; - -/** - * Dummy search tree that stores nothing and returns nothing on searches. - */ -public class DummySearchTree implements SearchTree { - public DummySearchTree() { - super(); - } - - @Override - public List search(String pSearchText) { - return Collections.emptyList(); - } - - static final SearchTreeProviderRegistry.Provider PROVIDER = new SearchTreeProviderRegistry.Provider() { - - @Override - public SearchTree getSearchTree(boolean tag) { - return new DummySearchTree<>(); - } - - @Override - public boolean canUse() { - return true; - } - - @Override - public String getName() { - return "Dummy"; - } - }; -} diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIBackedSearchTree.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIBackedSearchTree.java deleted file mode 100644 index 6c92df937..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIBackedSearchTree.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.gui.ingredients.IngredientFilter; -import mezz.jei.gui.ingredients.IngredientFilterApi; -import mezz.jei.library.runtime.JeiRuntime; -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.ItemStack; -import org.embeddedt.modernfix.ModernFix; -import org.embeddedt.modernfix.platform.ModernFixPlatformHooks; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Uses JEI to handle search tree lookups. - */ -public class JEIBackedSearchTree extends DummySearchTree { - private final boolean filteringByTag; - private String lastSearchText = ""; - private final List listCache = new ArrayList<>(); - - private static final Field filterField; - private static final MethodHandle getIngredientListUncached; - - static { - MethodHandle m; - Field f; - try { - Method jeiMethod = IngredientFilter.class.getDeclaredMethod("getIngredientListUncached", String.class); - jeiMethod.setAccessible(true); - m = MethodHandles.lookup().unreflect(jeiMethod); - f = IngredientFilterApi.class.getDeclaredField("ingredientFilter"); - f.setAccessible(true); - } catch(ReflectiveOperationException | RuntimeException | NoClassDefFoundError e) { - m = null; - f = null; - } - getIngredientListUncached = m; - filterField = f; - } - - public JEIBackedSearchTree(boolean filteringByTag) { - this.filteringByTag = filteringByTag; - } - @Override - public List search(String pSearchText) { - Optional runtime = JEIRuntimeCapturer.runtime(); - if(runtime.isPresent()) { - IngredientFilterApi iFilterApi = (IngredientFilterApi)runtime.get().getIngredientFilter(); - IngredientFilter filter; - try { - filter = (IngredientFilter)filterField.get(iFilterApi); - } catch(ReflectiveOperationException e) { - ModernFix.LOGGER.error(e); - return Collections.emptyList(); - } - return this.searchJEI(filter, pSearchText); - } else { - /* Use the default, dummy implementation */ - return super.search(pSearchText); - } - } - - private List searchJEI(IngredientFilter filter, String pSearchText) { - if(!pSearchText.equals(lastSearchText)) { - listCache.clear(); - List> ingredients; - String finalSearchTerm = filteringByTag ? ("$" + pSearchText) : pSearchText; - try { - ingredients = (List>)getIngredientListUncached.invokeExact(filter, finalSearchTerm); - } catch(Throwable e) { - ModernFix.LOGGER.error("Error searching", e); - ingredients = ImmutableList.of(); - } - for(ITypedIngredient ingredient : ingredients) { - if(ingredient.getIngredient() instanceof ItemStack) { - listCache.add((ItemStack)ingredient.getIngredient()); - } - } - lastSearchText = pSearchText; - } - return listCache; - } - - public static final SearchTreeProviderRegistry.Provider PROVIDER = new SearchTreeProviderRegistry.Provider() { - @Override - public SearchTree getSearchTree(boolean tag) { - return new JEIBackedSearchTree(tag); - } - - @Override - public boolean canUse() { - return ModernFixPlatformHooks.INSTANCE.modPresent("jei") && !ModernFixPlatformHooks.INSTANCE.modPresent("emi") && getIngredientListUncached != null && filterField != null; - } - - @Override - public String getName() { - return "JEI"; - } - }; -} diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIRuntimeCapturer.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIRuntimeCapturer.java deleted file mode 100644 index 40bfceefa..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/JEIRuntimeCapturer.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import mezz.jei.api.IModPlugin; -import mezz.jei.api.JeiPlugin; -import mezz.jei.api.runtime.IJeiRuntime; -import mezz.jei.library.runtime.JeiRuntime; -import net.minecraft.resources.ResourceLocation; -import org.embeddedt.modernfix.ModernFix; - -import java.util.Optional; - -@JeiPlugin -public class JEIRuntimeCapturer implements IModPlugin { - private static JeiRuntime runtimeHandle = null; - - public static Optional runtime() { - return Optional.ofNullable(runtimeHandle); - } - - @Override - public ResourceLocation getPluginUid() { - return ResourceLocation.fromNamespaceAndPath(ModernFix.MODID, "capturer"); - } - - @Override - public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { - runtimeHandle = (JeiRuntime)jeiRuntime; - } - - @Override - public void onRuntimeUnavailable() { - runtimeHandle = null; - } -} diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/REIBackedSearchTree.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/REIBackedSearchTree.java deleted file mode 100644 index 63db675a9..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/REIBackedSearchTree.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import com.google.common.base.Predicates; -import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; -import me.shedaniel.rei.impl.client.search.AsyncSearchManager; -import me.shedaniel.rei.impl.common.entry.type.EntryRegistryImpl; -import me.shedaniel.rei.impl.common.util.HashedEntryStackWrapper; -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.ItemStack; -import org.embeddedt.modernfix.ModernFix; -import org.embeddedt.modernfix.platform.ModernFixPlatformHooks; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.function.UnaryOperator; - -public class REIBackedSearchTree extends DummySearchTree { - private final AsyncSearchManager searchManager = createSearchManager(); - - private final boolean filteringByTag; - private String lastSearchText = ""; - private final List listCache = new ArrayList<>(); - - public REIBackedSearchTree(boolean filteringByTag) { - this.filteringByTag = filteringByTag; - } - @Override - public List search(String pSearchText) { - if(true) { - return this.searchREI(pSearchText); - } else { - /* Use the default, dummy implementation */ - return super.search(pSearchText); - } - } - - private List searchREI(String pSearchText) { - if(!pSearchText.equals(lastSearchText)) { - listCache.clear(); - this.searchManager.updateFilter(pSearchText); - List stacks; - try { - stacks = this.searchManager.getNow(); - } catch(RuntimeException e) { - ModernFix.LOGGER.error("Couldn't search for '" + pSearchText + "'", e); - stacks = Collections.emptyList(); - } - for(Object o : stacks) { - EntryStack stack; - if(o instanceof EntryStack) - stack = (EntryStack)o; - else if(o instanceof HashedEntryStackWrapper) { - stack = ((HashedEntryStackWrapper)o).unwrap(); - } else { - ModernFix.LOGGER.error("Don't know how to handle {}", o.getClass().getName()); - continue; - } - if(stack.getType() == VanillaEntryTypes.ITEM) { - listCache.add(stack.cheatsAs().getValue()); - } - } - lastSearchText = pSearchText; - } - return listCache; - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - private static AsyncSearchManager createSearchManager() { - Method m, normalizeMethod; - try { - try { - m = EntryRegistryImpl.class.getDeclaredMethod("getPreFilteredComplexList"); - m.setAccessible(true); - normalizeMethod = HashedEntryStackWrapper.class.getDeclaredMethod("normalize"); - normalizeMethod.setAccessible(true); - } catch(NoSuchMethodException e) { - m = EntryRegistryImpl.class.getDeclaredMethod("getPreFilteredList"); - m.setAccessible(true); - normalizeMethod = EntryStack.class.getDeclaredMethod("normalize"); - normalizeMethod.setAccessible(true); - } - final MethodHandle getListMethod = MethodHandles.publicLookup().unreflect(m); - final MethodHandle normalize = MethodHandles.publicLookup().unreflect(normalizeMethod); - final EntryRegistryImpl registry = (EntryRegistryImpl)EntryRegistry.getInstance(); - Supplier stackListSupplier = () -> { - try { - return (List)getListMethod.invokeExact(registry); - } catch(Throwable e) { - if(e instanceof RuntimeException) - throw (RuntimeException)e; - throw new RuntimeException(e); - } - }; - UnaryOperator normalizeOperator = o -> { - try { - return normalize.invoke(o); - } catch(Throwable e) { - if(e instanceof RuntimeException) - throw (RuntimeException)e; - throw new RuntimeException(e); - } - }; - Supplier> shouldShowStack = () -> { - return Predicates.alwaysTrue(); - }; - try { - try { - // Old constructor taking Supplier as first arg - MethodHandle cn = MethodHandles.publicLookup().findConstructor(AsyncSearchManager.class, MethodType.methodType(void.class, Supplier.class, Supplier.class, UnaryOperator.class)); - return (AsyncSearchManager)cn.invoke(stackListSupplier, shouldShowStack, normalizeOperator); - } catch(NoSuchMethodException e) { - // New constructor taking Function as first arg - MethodHandle cn = MethodHandles.publicLookup().findConstructor(AsyncSearchManager.class, MethodType.methodType(void.class, Function.class, Supplier.class, UnaryOperator.class)); - return (AsyncSearchManager)cn.invoke((Function)o -> stackListSupplier.get(), shouldShowStack, normalizeOperator); - } - } catch(Throwable mhThrowable) { - throw new ReflectiveOperationException(mhThrowable); - } - } catch(ReflectiveOperationException e) { - throw new RuntimeException(e); - } - } - - public static final SearchTreeProviderRegistry.Provider PROVIDER = new SearchTreeProviderRegistry.Provider() { - @Override - public SearchTree getSearchTree(boolean tag) { - return new REIBackedSearchTree(tag); - } - - @Override - public boolean canUse() { - return ModernFixPlatformHooks.INSTANCE.modPresent("roughlyenoughitems"); - } - - @Override - public String getName() { - return "REI"; - } - }; -} diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/RecipeBookSearchTree.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/RecipeBookSearchTree.java deleted file mode 100644 index 0bf239c49..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/RecipeBookSearchTree.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.client.gui.screens.recipebook.RecipeCollection; -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class RecipeBookSearchTree extends DummySearchTree { - private final SearchTree stackCollector; - private Map> collectionsByItem = null; - private final List allCollections; - - public RecipeBookSearchTree(SearchTree stackCollector, List allCollections) { - this.stackCollector = stackCollector; - this.allCollections = allCollections; - } - - private Map> populateCollectionMap() { - Map> collections = this.collectionsByItem; - if(collections == null) { - collections = new Object2ObjectOpenHashMap<>(); - Map> finalCollection = collections; - for(RecipeCollection collection : allCollections) { - collection.getRecipes().stream().map(recipe -> recipe.value().getResultItem(collection.registryAccess()).getItem()).distinct().forEach(item -> { - finalCollection.computeIfAbsent(item, k -> new ArrayList<>()).add(collection); - }); - } - this.collectionsByItem = collections; - } - return collections; - } - - @Override - public List search(String pSearchText) { - // Avoid constructing the recipe collection map until the first real search - if(pSearchText.trim().length() == 0) { - return this.allCollections; - } - List stacks = stackCollector.search(pSearchText); - Map> collections = this.populateCollectionMap(); - return stacks.stream().map(ItemStack::getItem).distinct().flatMap(item -> collections.getOrDefault(item, Collections.emptyList()).stream()).collect(Collectors.toList()); - } -} diff --git a/common/src/main/java/org/embeddedt/modernfix/searchtree/SearchTreeProviderRegistry.java b/common/src/main/java/org/embeddedt/modernfix/searchtree/SearchTreeProviderRegistry.java deleted file mode 100644 index c16cf0acf..000000000 --- a/common/src/main/java/org/embeddedt/modernfix/searchtree/SearchTreeProviderRegistry.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.embeddedt.modernfix.searchtree; - -import net.minecraft.client.searchtree.SearchTree; -import net.minecraft.world.item.ItemStack; -import org.embeddedt.modernfix.core.ModernFixMixinPlugin; - -import java.util.ArrayList; -import java.util.List; - -public class SearchTreeProviderRegistry { - private static final List searchTreeProviders = new ArrayList<>(); - - public static synchronized Provider getSearchTreeProvider() { - for(Provider p : searchTreeProviders) { - if(p.canUse()) - return p; - } - if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.blast_search_trees.force.Registry")) - return DummySearchTree.PROVIDER; - else - return null; - } - - public static synchronized void register(Provider p) { - if(p.canUse()) - searchTreeProviders.add(p); - } - - public interface Provider { - SearchTree getSearchTree(boolean tag); - boolean canUse(); - String getName(); - } -} diff --git a/gradle.properties b/gradle.properties index d84ef1814..9307eb0bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,10 +7,10 @@ mixinextras_version=0.3.2 mod_id=modernfix minecraft_version=1.21 enabled_platforms=fabric,neoforge -forge_version=21.0.18-beta +forge_version=21.0.42-beta # parchment_version=2023.07.09 refined_storage_version=4392788 -jei_version=16.0.0.28 +jei_version=19.0.0.9 rei_version=13.0.678 ctm_version=1.20.1-1.1.8+4 kubejs_version=1902.6.0-build.142 diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 68a7138b5..6dca1b818 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -47,7 +47,7 @@ modId = "neoforge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified type = "required" #mandatory # The version range of the dependency -versionRange = "[21.0.17-beta,)" #mandatory +versionRange = "[21.0.42-beta,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering = "NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER