From c4ee1dd5221ad18cffb374295787b3d35aa19a39 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 8 May 2023 15:06:15 -0400 Subject: [PATCH 1/2] Update incompatible mod disabling list --- .../embeddedt/modernfix/core/config/ModernFixEarlyConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b0372155..d46f0ffa 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 @@ -184,6 +184,8 @@ public class ModernFixEarlyConfig { disableIfModPresent("mixin.perf.async_jei", "modernui"); disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge"); disableIfModPresent("mixin.bugfix.mc218112", "performant"); + disableIfModPresent("mixin.bugfix.remove_block_chunkloading", "performant"); + disableIfModPresent("mixin.bugfix.paper_chunk_patches", "c2me"); disableIfModPresent("mixin.perf.reuse_datapacks", "tac"); disableIfModPresent("mixin.launch.class_search_cache", "optifine"); disableIfModPresent("mixin.perf.datapack_reload_exceptions", "cyanide"); @@ -195,8 +197,6 @@ public class ModernFixEarlyConfig { Option option = this.options.get(configName); if(option != null) option.addModOverride(false, id); - else - LOGGER.warn("Can't disable missing option {}", configName); } } } From 5ee4c636e79f32117d0d9dab476a3312ba9cc2a1 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 8 May 2023 15:38:16 -0400 Subject: [PATCH 2/2] Adjust faster texture loading for FAPI compat --- .../TextureAtlasMixin.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_loading/TextureAtlasMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_loading/TextureAtlasMixin.java index 0c9e7199..2a749f5c 100644 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_loading/TextureAtlasMixin.java +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_loading/TextureAtlasMixin.java @@ -34,16 +34,17 @@ public abstract class TextureAtlasMixin { private Map> loadedImages; private boolean usingFasterLoad; + private Collection storedResults; /** * @author embeddedt * @reason simplify texture loading by loading whole image once, avoid slow PngInfo code */ - @Redirect(method = "prepareToStitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureAtlas;getBasicSpriteInfos(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;")) - private Collection loadImages(TextureAtlas atlas, ResourceManager manager, Set imageLocations) { + @Inject(method = "getBasicSpriteInfos", at = @At("HEAD")) + private void loadImages(ResourceManager manager, Set imageLocations, CallbackInfoReturnable> cir) { usingFasterLoad = ModernFixPlatformHooks.isLoadingNormally(); // bail if Forge is erroring to avoid AT crashes if(!usingFasterLoad) { - return getBasicSpriteInfos(manager, imageLocations); + return; } List> futures = new ArrayList<>(); ConcurrentLinkedQueue results = new ConcurrentLinkedQueue<>(); @@ -71,12 +72,24 @@ public abstract class TextureAtlasMixin { }, ModernFix.resourceReloadExecutor())); } CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); - return results; + storedResults = results; + } + + @Redirect(method = "getBasicSpriteInfos", at = @At(value = "INVOKE", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;", ordinal = 0)) + private Iterator skipIteration(Set instance) { + return usingFasterLoad ? Collections.emptyIterator() : instance.iterator(); + } + + @Inject(method = "getBasicSpriteInfos", at = @At("RETURN")) + private void injectFastSprites(ResourceManager resourceManager, Set spriteLocations, CallbackInfoReturnable> cir) { + if(usingFasterLoad) + cir.getReturnValue().addAll(storedResults); } @Inject(method = "prepareToStitch", at = @At("RETURN")) private void clearLoadedImages(CallbackInfoReturnable cir) { loadedImages = Collections.emptyMap(); + storedResults = null; } @Inject(method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;",