Skip to content

Commit

Permalink
Fix skin not applying in single-player
Browse files Browse the repository at this point in the history
  • Loading branch information
Kneelawk committed Jun 8, 2024
1 parent 7baf60e commit 78a65e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.client.session.ProfileKeys;
import net.minecraft.client.session.Session;
import net.minecraft.client.session.report.AbuseReportContext;
import net.minecraft.util.Util;

import me.axieum.mcmod.authme.mixin.AbuseReportContextAccessor;
import me.axieum.mcmod.authme.mixin.MinecraftClientAccessor;
Expand Down Expand Up @@ -62,6 +63,11 @@ public static void setSession(Session session)
((MinecraftClientAccessor) client).setSession(session);
((SplashTextResourceSupplierAccessor) client.getSplashTextLoader()).setSession(session);

// Re-create the game profile future
((MinecraftClientAccessor) client).setGameProfileFuture(
CompletableFuture.supplyAsync(() -> client.getSessionService().fetchProfile(session.getUuidOrNull(), true),
Util.getDownloadWorkerExecutor()));

// Re-create the user API service (ignore offline session)
UserApiService userApiService = UserApiService.OFFLINE;
if (!OFFLINE_TOKEN.equals(session.getAccessToken())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package me.axieum.mcmod.authme.mixin;

import java.util.concurrent.CompletableFuture;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

import com.mojang.authlib.minecraft.UserApiService;
import com.mojang.authlib.yggdrasil.ProfileResult;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;

import net.minecraft.client.MinecraftClient;
Expand All @@ -29,6 +32,15 @@ public interface MinecraftClientAccessor
@Mutable
void setSession(Session session);

/**
* Sets the game profile.
*
* @param future the future of the new game profile
*/
@Accessor
@Mutable
void setGameProfileFuture(CompletableFuture<ProfileResult> future);

/**
* Returns the Minecraft authentication service.
*
Expand Down

0 comments on commit 78a65e3

Please sign in to comment.