Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions Common/src/main/java/customskinloader/CustomSkinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.properties.Property;
import customskinloader.config.Config;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.ProfileLoader;
Expand Down Expand Up @@ -76,7 +77,7 @@ public static void loadProfileTextures(Runnable runnable) {
//For User Skin
public static UserProfile loadProfile(GameProfile gameProfile) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
String credential = getUniqueCredential(gameProfile);
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
if (username == null) {
logger.warning("Could not load profile: username is null.");
Expand Down Expand Up @@ -108,7 +109,7 @@ public static UserProfile loadProfile(GameProfile gameProfile) {
//Core
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
String credential = getUniqueCredential(gameProfile);

profileCache.setLoading(credential, true);
logger.info("Loading " + username + "'s profile.");
Expand Down Expand Up @@ -187,7 +188,7 @@ public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull)
//For Skull
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
String credential = getUniqueCredential(gameProfile);

//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
//Authlib 3.11.50 makes empty username to " "
Expand Down Expand Up @@ -238,4 +239,26 @@ private static Config initConfig() {
logger.enableLogStdOut = config.enableLogStdOut;
return config;
}

private static String getUniqueCredential(GameProfile gameProfile) {
String credential = MinecraftUtil.getCredential(gameProfile);
if (credential != null) {
try {
Property textureProperty = null;
for (Property property : gameProfile.getProperties().get("textures")) {
textureProperty = property;
break;
}
if (textureProperty != null) {
String textureValue = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
if (textureValue != null && !textureValue.isEmpty()) {
credential = credential + "-" + Integer.toHexString(textureValue.hashCode());
}
}
} catch (Exception ignored) {
// If texture extraction fails, just use standard credential
}
}
return credential;
}
}