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

This commit is contained in:
embeddedt 2023-05-08 15:38:49 -04:00
commit 28bbb79e60
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 19 additions and 6 deletions

View File

@ -36,16 +36,17 @@ public abstract class TextureAtlasMixin {
private Map<ResourceLocation, Pair<Resource, NativeImage>> loadedImages;
private boolean usingFasterLoad;
private Collection<TextureAtlasSprite.Info> 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<TextureAtlasSprite.Info> loadImages(TextureAtlas atlas, ResourceManager manager, Set<ResourceLocation> imageLocations) {
@Inject(method = "getBasicSpriteInfos", at = @At("HEAD"))
private void loadImages(ResourceManager manager, Set<ResourceLocation> imageLocations, CallbackInfoReturnable<Collection<TextureAtlasSprite.Info>> cir) {
usingFasterLoad = ModernFixPlatformHooks.isLoadingNormally();
// bail if Forge is erroring to avoid AT crashes
if(!usingFasterLoad) {
return getBasicSpriteInfos(manager, imageLocations);
return;
}
List<CompletableFuture<?>> futures = new ArrayList<>();
ConcurrentLinkedQueue<TextureAtlasSprite.Info> 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<ResourceLocation> spriteLocations, CallbackInfoReturnable<Collection<TextureAtlasSprite.Info>> cir) {
if(usingFasterLoad)
cir.getReturnValue().addAll(storedResults);
}
@Inject(method = "prepareToStitch", at = @At("RETURN"))
private void clearLoadedImages(CallbackInfoReturnable<TextureAtlas.Preparations> 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;",

View File

@ -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);
}
}
}