Skip to content

Commit

Permalink
Use vanilla stitcher for simple atlases
Browse files Browse the repository at this point in the history
Fixes some minor mod compatibility issues
  • Loading branch information
embeddedt committed Apr 22, 2024
1 parent 97e2a31 commit 2915a88
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -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);
Expand All @@ -69,7 +75,7 @@ private void stitchFast(CallbackInfo ci) {
*/
@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) {
Expand Down

0 comments on commit 2915a88

Please sign in to comment.