Use vanilla stitcher for simple atlases

Fixes some minor mod compatibility issues
This commit is contained in:
embeddedt 2024-04-21 21:26:13 -04:00
parent 97e2a318f3
commit 2915a88465
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -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<Stitcher.Holder> 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) {