Skip to content

Commit

Permalink
Fix issues with player skins not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Dec 13, 2024
1 parent 6b3a003 commit ea54ccb
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minelittlepony.common.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
import com.minelittlepony.common.event.SkinFilterCallback;
Expand Down Expand Up @@ -28,26 +29,22 @@ private void beforeUpdate(NativeImage image,
initialHeight.set(image.getHeight());
}

@Inject(method = FILTER_IMAGE, at = @At("RETURN"), cancellable = true)
private void update(NativeImage image,
CallbackInfoReturnable<NativeImage> ci,
@ModifyReturnValue(method = FILTER_IMAGE, at = @At("RETURN"))
private NativeImage update(NativeImage image,
@Share(value = "kirinmlp_initialWidth") LocalIntRef initialWidth,
@Share(value = "kirinmlp_initialHeight") LocalIntRef initialHeight) {
// convert skins from mojang server
ci.setReturnValue(SkinFilterCallback.EVENT.invoker().processImage(ci.getReturnValue(), initialWidth.get(), initialHeight.get()));
return SkinFilterCallback.EVENT.invoker().processImage(image, initialWidth.get(), initialHeight.get());
}

// Sorry, Mahjon. Input validation is good 'n all, but this interferes with our other mods.
@Inject(method = FILTER_IMAGE, at = {
@At(value = "INVOKE", target = STRIP_ALPHA),
@At(value = "INVOKE", target = STRIP_COLOR)
}, cancellable = true)
private void cancelAlphaStrip(NativeImage image, CallbackInfoReturnable<NativeImage> ci,
@Inject(method = FILTER_IMAGE, at = @At(value = "INVOKE", target = STRIP_ALPHA))
private void cancelAlphaStrip(NativeImage image, CallbackInfoReturnable<NativeImage> info,
@Share(value = "kirinmlp_initialWidth") LocalIntRef initialWidth,
@Share(value = "kirinmlp_initialHeight") LocalIntRef initialHeight) {
if (SkinFilterCallback.EVENT.invoker().shouldAllowTransparency(image, initialWidth.get(), initialHeight.get())) {
ci.cancel();
if (!SkinFilterCallback.EVENT.invoker().shouldAllowTransparency(image, initialWidth.get(), initialHeight.get())) {
info.setReturnValue(SkinFilterCallback.EVENT.invoker().processImage(image, initialWidth.get(), initialHeight.get()));
}
}
// -
}
}

0 comments on commit ea54ccb

Please sign in to comment.