diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching/StitcherMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching/StitcherMixin.java index 120e67f3..228647f6 100644 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching/StitcherMixin.java +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching/StitcherMixin.java @@ -41,10 +41,16 @@ public class StitcherMixin { */ @Inject(method = "stitch", at = @At("HEAD"), cancellable = true) private void stitchFast(CallbackInfo ci) { + this.loadableSpriteInfos = null; if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally()) { ModernFix.LOGGER.error("Using vanilla stitcher implementation due to invalid loading state"); return; } + if(this.texturesToBeStitched.size() < 100) { + // The vanilla implementation is fine for small atlases, and using it allows mods like JEI that depend on + // precise texture alignments to avoid bugs. + return; + } ci.cancel(); ObjectArrayList> holderList = new ObjectArrayList<>(this.texturesToBeStitched); holderList.sort(HOLDER_COMPARATOR); @@ -69,7 +75,7 @@ public class StitcherMixin { */ @Inject(method = "gatherSprites", at = @At("HEAD"), cancellable = true) private void gatherSpritesFast(Stitcher.SpriteLoader spriteLoader, CallbackInfo ci) { - if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally()) + if(this.loadableSpriteInfos == null) return; ci.cancel(); for(StbStitcher.LoadableSpriteInfo info : loadableSpriteInfos) {