Fix JEI search tree replacement on 1.19

This commit is contained in:
embeddedt 2023-04-01 20:13:23 -04:00
parent ba82be7a89
commit b988715c2c
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 6 additions and 7 deletions

View File

@ -49,8 +49,7 @@ public class ModernFixEarlyConfig {
/* off by default in 1.18 because it doesn't work as well */ /* off by default in 1.18 because it doesn't work as well */
this.addMixinRule("perf.faster_singleplayer_load", false); this.addMixinRule("perf.faster_singleplayer_load", false);
/* Keep this off if JEI/REI isn't installed to prevent breaking vanilla gameplay */ /* Keep this off if JEI/REI isn't installed to prevent breaking vanilla gameplay */
Optional<ModInfo> jeiMod = FMLLoader.getLoadingModList().getMods().stream().filter(mod -> mod.getModId().equals("jei")).findFirst(); this.addMixinRule("perf.blast_search_trees", FMLLoader.getLoadingModList().getModFileById("jei") != null || FMLLoader.getLoadingModList().getModFileById("roughlyenoughitems") != null);
this.addMixinRule("perf.blast_search_trees", (jeiMod.isPresent() && jeiMod.get().getVersion().getMajorVersion() >= 10) || FMLLoader.getLoadingModList().getModFileById("roughlyenoughitems") != null);
this.addMixinRule("safety", true); this.addMixinRule("safety", true);
this.addMixinRule("launch.transformer_cache", false); this.addMixinRule("launch.transformer_cache", false);
this.addMixinRule("launch.class_search_cache", true); this.addMixinRule("launch.class_search_cache", true);

View File

@ -30,7 +30,7 @@ public class MinecraftMixin {
ModernFix.LOGGER.info("Replaced creative search logic with REI"); ModernFix.LOGGER.info("Replaced creative search logic with REI");
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new REIBackedSearchTree(false)); this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new REIBackedSearchTree(false));
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new REIBackedSearchTree(true)); this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new REIBackedSearchTree(true));
} else if(jeiContainer.isPresent() && jeiContainer.get().getModInfo().getVersion().getMajorVersion() >= 10) { } else if(jeiContainer.isPresent()) {
ModernFix.LOGGER.info("Replaced creative search logic with JEI"); ModernFix.LOGGER.info("Replaced creative search logic with JEI");
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new JEIBackedSearchTree(false)); this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new JEIBackedSearchTree(false));
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new JEIBackedSearchTree(true)); this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new JEIBackedSearchTree(true));

View File

@ -12,10 +12,10 @@ import java.util.Optional;
@JeiPlugin @JeiPlugin
public class JEIRuntimeCapturer implements IModPlugin { public class JEIRuntimeCapturer implements IModPlugin {
private static WeakReference<JeiRuntime> runtimeHandle = new WeakReference<>(null); private static JeiRuntime runtimeHandle = null;
public static Optional<JeiRuntime> runtime() { public static Optional<JeiRuntime> runtime() {
return Optional.ofNullable(runtimeHandle.get()); return Optional.ofNullable(runtimeHandle);
} }
@Override @Override
@ -25,11 +25,11 @@ public class JEIRuntimeCapturer implements IModPlugin {
@Override @Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
runtimeHandle = new WeakReference<>((JeiRuntime)jeiRuntime); runtimeHandle = (JeiRuntime)jeiRuntime;
} }
@Override @Override
public void onRuntimeUnavailable() { public void onRuntimeUnavailable() {
runtimeHandle = new WeakReference<>(null); runtimeHandle = null;
} }
} }