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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user