1
0
mirror of https://github.com/Suiranoil/SkinRestorer.git synced 2026-01-16 04:42:12 +00:00

backport to 1.20

This commit is contained in:
2025-05-30 22:39:37 +03:00
parent 90ca995907
commit 56655bca36
2 changed files with 7 additions and 6 deletions

View File

@@ -4,10 +4,14 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(ServerLoginPacketListenerImpl.class)
public interface ServerLoginPacketListenerImplAccessorInvoker {
@Accessor
GameProfile getAuthenticatedProfile();
GameProfile getGameProfile();
@Invoker
GameProfile invokeCreateFakeProfile(GameProfile original);
}

View File

@@ -23,18 +23,15 @@ public abstract class ServerLoginPacketListenerImplMixin {
@Unique
private CompletableFuture<Void> skinrestorer$pendingSkin;
@Shadow
protected abstract GameProfile createFakeProfile(GameProfile original);
@Inject(method = "handleAcceptedLogin", at = @At(value = "HEAD"), cancellable = true)
public void waitForSkin(CallbackInfo ci) {
if (skinrestorer$pendingSkin == null) {
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
var profile = gameProfile;
var profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).getGameProfile();
assert profile != null;
if (!profile.isComplete())
profile = createFakeProfile(profile);
profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).invokeCreateFakeProfile(profile);
var originalSkin = PlayerUtils.getPlayerSkin(profile);