Skip to content

Commit 2915a88

Browse files
committed
Use vanilla stitcher for simple atlases
Fixes some minor mod compatibility issues
1 parent 97e2a31 commit 2915a88

File tree

1 file changed

+7
-1
lines changed
  • common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching

1 file changed

+7
-1
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/faster_texture_stitching/StitcherMixin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ public class StitcherMixin {
4141
*/
4242
@Inject(method = "stitch", at = @At("HEAD"), cancellable = true)
4343
private void stitchFast(CallbackInfo ci) {
44+
this.loadableSpriteInfos = null;
4445
if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally()) {
4546
ModernFix.LOGGER.error("Using vanilla stitcher implementation due to invalid loading state");
4647
return;
4748
}
49+
if(this.texturesToBeStitched.size() < 100) {
50+
// The vanilla implementation is fine for small atlases, and using it allows mods like JEI that depend on
51+
// precise texture alignments to avoid bugs.
52+
return;
53+
}
4854
ci.cancel();
4955
ObjectArrayList<Stitcher.Holder> holderList = new ObjectArrayList<>(this.texturesToBeStitched);
5056
holderList.sort(HOLDER_COMPARATOR);
@@ -69,7 +75,7 @@ private void stitchFast(CallbackInfo ci) {
6975
*/
7076
@Inject(method = "gatherSprites", at = @At("HEAD"), cancellable = true)
7177
private void gatherSpritesFast(Stitcher.SpriteLoader spriteLoader, CallbackInfo ci) {
72-
if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally())
78+
if(this.loadableSpriteInfos == null)
7379
return;
7480
ci.cancel();
7581
for(StbStitcher.LoadableSpriteInfo info : loadableSpriteInfos) {

0 commit comments

Comments
 (0)