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 cd91ecbb..da23d7af 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 @@ -36,16 +36,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<>(); @@ -81,12 +82,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;", 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 ff434d53..3b1372ae 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 @@ -185,6 +185,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"); @@ -196,8 +198,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); } } }