mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
28
Commits
v14.24
..
14-develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
299c8f53cf | ||
|
|
13fb0a4f92 | ||
|
|
921374f24f | ||
|
|
d2d244c70e | ||
|
|
f201f344a2 | ||
|
|
76d6ed9a41 | ||
|
|
b807aa1fb1 | ||
|
|
d797ed378a | ||
|
|
c3f8f1eb8f | ||
|
|
226d953012 | ||
|
|
d1ab2fbf43 | ||
|
|
00a14010c6 | ||
|
|
a198e40fc7 | ||
|
|
5b820c537d | ||
|
|
6e1be02cf0 | ||
|
|
9abf9eb779 | ||
|
|
fbc95314ad | ||
|
|
d4576249ac | ||
|
|
dfe47f7c64 | ||
|
|
1199e10ca4 | ||
|
|
61287cf64c | ||
|
|
b16058340c | ||
|
|
ac09a51f48 | ||
|
|
3e5bd83b5c | ||
|
|
4ce00d07b5 | ||
|
|
6e9380be49 | ||
|
|
53050a63f5 | ||
|
|
34ac3ac4f2 |
No files matched your search
@@ -41,8 +41,6 @@ body:
|
||||
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: csl-log
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Link to CustomSkinLoader.log if applicable
|
||||
description: |
|
||||
|
||||
@@ -41,8 +41,6 @@ body:
|
||||
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: csl-log
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: CustomSkinLoader.log 查看地址
|
||||
description: |
|
||||
|
||||
@@ -21,10 +21,10 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '8'
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
|
||||
./gradlew clean build --stacktrace
|
||||
-
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
name: Publish to Github Artifact
|
||||
with:
|
||||
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
|
||||
@@ -53,10 +53,10 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
website: [CurseForge_Modrinth]
|
||||
modtype: [Fabric,ForgeV1,ForgeV2,ForgeV3]
|
||||
modtype: [Fabric,Forge-Active,Forge-Legacy]
|
||||
include:
|
||||
-
|
||||
website: ObjectStorage
|
||||
website: TencentCOS
|
||||
modtype: All
|
||||
# -
|
||||
# website: GitHub-Release
|
||||
@@ -69,9 +69,9 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout Git Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
name: Download Artifact Zips
|
||||
with:
|
||||
path: build
|
||||
@@ -86,41 +86,20 @@ jobs:
|
||||
id: cslenv
|
||||
run: |
|
||||
output="$(ls build/libs | grep -v "sources")"
|
||||
|
||||
case "${{ matrix.modtype }}" in
|
||||
"ForgeV1")
|
||||
modloader="Forge"
|
||||
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
|
||||
;;
|
||||
"ForgeV2" | "ForgeV3")
|
||||
modloader=$(cat <<EOF
|
||||
Forge
|
||||
NeoForge
|
||||
EOF
|
||||
)
|
||||
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
|
||||
;;
|
||||
"Fabric")
|
||||
modloader=$(cat <<EOF
|
||||
Fabric
|
||||
Quilt
|
||||
EOF
|
||||
)
|
||||
path="${{ matrix.modtype }}"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported modtype: ${{ matrix.modtype }}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${{ matrix.modtype }}" == "Forge"* ]]; then
|
||||
modloader="Forge"
|
||||
path=$(echo ${{ matrix.modtype }} | sed "s#-#/#")
|
||||
else
|
||||
modloader=${{ matrix.modtype }}
|
||||
path=${{ matrix.modtype }}
|
||||
fi
|
||||
echo "path=$path" >> $GITHUB_OUTPUT
|
||||
echo "modloader="$modloader"" >> $GITHUB_OUTPUT
|
||||
echo "modloader=$modloader" >> $GITHUB_OUTPUT
|
||||
echo "filename=$(echo "$output"|grep $(echo ${{ matrix.modtype }}|sed "s#-##") )" >> $GITHUB_OUTPUT
|
||||
echo "version=$(grep "version=" build.properties | grep -v "#" | sed "s/version=//")" >> $GITHUB_OUTPUT
|
||||
echo "edition=$(echo ${{ matrix.modtype }} | sed "s/-//")" >> $GITHUB_OUTPUT
|
||||
echo "minecraft_vers<<EOF" >> $GITHUB_OUTPUT
|
||||
grep "dependencies=" "$path"/build.properties | grep -v "#" | awk -F '|' '{print $2}' | sed 's#\;\\##' | sed "s/,/\n/g" >> $GITHUB_OUTPUT
|
||||
grep "minecraft_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/minecraft_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
echo "java_vers<<EOF" >> $GITHUB_OUTPUT
|
||||
grep "java_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/java_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
|
||||
@@ -135,7 +114,7 @@ jobs:
|
||||
echo "pathlist="$(find build/libs -type f|grep -v "sources"|grep -v "json")"" >> $GITHUB_OUTPUT
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||
name: "[GitHub Pre-Release] Delete"
|
||||
name: 【GitHub Pre-Release】 Delete
|
||||
uses: 8Mi-Tech/delete-release-assets-action@main
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -154,7 +133,7 @@ jobs:
|
||||
EOF
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||
name: "[GitHub Pre-Release] Upload Tag"
|
||||
name: 【GitHub Pre-Release】 Upload Tag
|
||||
uses: richardsimko/update-tag@v1
|
||||
with:
|
||||
tag_name: CI-Build
|
||||
@@ -162,8 +141,8 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||
name: "[GitHub Pre-Release] Publish"
|
||||
uses: softprops/action-gh-release@v2
|
||||
name: 【GitHub Pre-Release】 Publish
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: CustomSkinLoader CI-Build
|
||||
@@ -171,11 +150,11 @@ jobs:
|
||||
prerelease: true
|
||||
body_path: build/ci-build.md
|
||||
files: build/libs/*
|
||||
#files: "${{ steps.cslenv-github.outputs.pathlist }}"
|
||||
#iles: "${{ steps.cslenv-github.outputs.pathlist }}"
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-Release' && inputs.type == 'Release' }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
name: "[GitHub Release] Publish"
|
||||
name: 【GitHub Release】 Publish
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: CustomSkinLoader ${{ github.ref }}
|
||||
@@ -183,24 +162,12 @@ jobs:
|
||||
#generate_release_notes: true
|
||||
files: ${{ steps.cslenv-github.outputs.pathlist }}
|
||||
-
|
||||
if: ${{ matrix.website == 'ObjectStorage' }}
|
||||
name: "[ObjectStorage] Force JDK 8"
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '8'
|
||||
cache: 'gradle'
|
||||
-
|
||||
if: ${{ matrix.website == 'ObjectStorage' }}
|
||||
name: "[ObjectStorage] Publish"
|
||||
if: ${{ matrix.website == 'TencentCOS' }}
|
||||
name: 【TencentCOS】 Publish
|
||||
env:
|
||||
COS_BUCKET: ${{ secrets.COS_BUCKET }}
|
||||
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
|
||||
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
|
||||
R2_BASE_URL: ${{ secrets.R2_BASE_URL }}
|
||||
R2_BUCKET: ${{ secrets.R2_BUCKET }}
|
||||
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
|
||||
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
|
||||
run: |
|
||||
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
|
||||
@@ -209,7 +176,7 @@ jobs:
|
||||
|
||||
-
|
||||
if: ${{ matrix.website == 'CurseForge_Modrinth' && inputs.type == 'Release' }}
|
||||
name: "[CurseForge & Modrinth] Publish"
|
||||
name: 【CurseForge & Modrinth】 Publish
|
||||
uses: Kir-Antipov/[email protected]
|
||||
with:
|
||||
modrinth-id: idMHQ4n2
|
||||
|
||||
+22
-30
@@ -27,43 +27,31 @@ There are the available versions in different environments below:
|
||||
```
|
||||
1. Create these folders in the new project directory, then copy the built jar and source jar into it:
|
||||
```
|
||||
Forge 1.8 ~ 1.16.5: ./local-repo/mods/CustomSkinLoader_ForgeV1/${version}
|
||||
Forge 1.17.1 ~ 1.20.4 / NeoForge 1.20.1: ./local-repo/mods/CustomSkinLoader_ForgeV2/${version}
|
||||
Forge 1.20.6 ~ latest / NeoForge 1.20.2 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeV3/${version}
|
||||
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
|
||||
Forge 1.8 ~ 1.16.5: ./local-repo/mods/CustomSkinLoader_ForgeLegacy/${version}
|
||||
Forge 1.17.1 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeActive/${version}
|
||||
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
|
||||
```
|
||||
*`${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually*
|
||||
*`${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually*
|
||||
1. Create a pom file in the same folder:
|
||||
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeV1-${version}.pom`
|
||||
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeLegacy-${version}.pom`
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_ForgeV1</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||
<artifactId>CustomSkinLoader_ForgeLegacy</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
- Forge 1.17.1 ~ 1.20.4 / NeoForge 1.20.1: `CustomSkinLoader_ForgeV2-${version}.pom`
|
||||
- Forge 1.17.1 ~ latest: `CustomSkinLoader_ForgeActive-${version}.pom`
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_ForgeV2</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
- Forge 1.20.6 ~ latest / NeoForge 1.20.2 ~ latest: `CustomSkinLoader_ForgeV3-${version}.pom`
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_ForgeV3</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||
<artifactId>CustomSkinLoader_ForgeActive</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
@@ -74,7 +62,7 @@ There are the available versions in different environments below:
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_Fabric</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
@@ -83,7 +71,7 @@ There are the available versions in different environments below:
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00"
|
||||
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
@@ -93,12 +81,12 @@ There are the available versions in different environments below:
|
||||
1. Run `./gradlew setupDecompWorkspace` command.
|
||||
1. Then you can debug the mod in IDE or through `./gradlew runClient` command.
|
||||
|
||||
### For ForgeGradle 3.x ~ latest ( forge-1.12.2-14.23.5.2851 ~ latest )
|
||||
### For ForgeGradle 3.x ~ 5.x ( forge-1.12.2-14.23.5.2851 ~ latest )
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
|
||||
}
|
||||
|
||||
minecraft {
|
||||
@@ -116,12 +104,15 @@ There are the available versions in different environments below:
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
modImplementation "mods:CustomSkinLoader_Fabric:15.0-SNAPSHOT-00"
|
||||
modImplementation "mods:CustomSkinLoader_Fabric:14.15-SNAPSHOT-00"
|
||||
}
|
||||
|
||||
loom.runs.client.programArgs "--username", "<Your username>"
|
||||
tasks.runClient {
|
||||
args += ["--username", "<Your username>"]
|
||||
}
|
||||
```
|
||||
1. Setup the development environment and run the game as usual.
|
||||
1. Add `--username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
|
||||
1. Run the game in IDE or through `./gradlew runClient` command..
|
||||
|
||||
## Depend on release builds
|
||||
1. Check the latest version in https://littlesk.in/csl-latest .
|
||||
@@ -154,4 +145,5 @@ There are the available versions in different environments below:
|
||||
|
||||
## Developing
|
||||
- CustomSkinLoader is based on forge-1.12.2-14.23.5.2768 currently, including Fabric edition. We use custom reobfuscation mappings such as [Fabric.tsrg](Fabric/Fabric.tsrg) and [mixin.tsrg](Fabric/mixin.tsrg) to generate different editions jar and Mixin reference jsons.
|
||||
- The source codes are all in `${projectDir}/sources` and resource files are in `${projectDir}/resources` instead of `src/main/java` and `src/main/resources`.
|
||||
- Do not add other required mods.
|
||||
@@ -1,5 +0,0 @@
|
||||
// This subproject is only to provide dependency for other subprojects.
|
||||
|
||||
dependencies {
|
||||
implementation project(':Dummy')
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
"name": "CustomSkinLoader",
|
||||
"version": "${modVersion}",
|
||||
"fullVersion": "${modFullVersion}",
|
||||
"dependencies": {
|
||||
"${dependencies}"
|
||||
},
|
||||
"mcVersion": "${mcVersion}",
|
||||
"mcFullVersions": "${mcFullVersions}",
|
||||
"forgeVersion": "${forgeVersion}",
|
||||
"gitVersion": "${gitVersion}",
|
||||
"buildUrl": "${buildUrl}",
|
||||
"buildTime": "${releaseTime}"
|
||||
File renamed without changes.
+24
-22
@@ -8,9 +8,9 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -49,7 +49,8 @@ public class CustomSkinLoader {
|
||||
private static final ProfileCache profileCache = new ProfileCache();
|
||||
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
||||
|
||||
public static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(
|
||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
|
||||
//Correct thread name in thread pool
|
||||
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
||||
@@ -70,32 +71,30 @@ public class CustomSkinLoader {
|
||||
THREAD_POOL.execute(runnable);
|
||||
}
|
||||
|
||||
public static Object loadProfileLazily(GameProfile gameProfile, Function<UserProfile, ?> function) {
|
||||
public static void loadProfileLazily(
|
||||
GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
|
||||
String username = gameProfile.getName();
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||
if (username == null) {
|
||||
logger.warning("Could not load profile: username is null.");
|
||||
return function.apply(new UserProfile());
|
||||
consumer.accept(Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
String tempName = Thread.currentThread().getName();
|
||||
Thread.currentThread().setName(username); // Change Thread Name
|
||||
if (profileCache.isLoading(credential)) {
|
||||
profileCache.putLoader(credential, function);
|
||||
profileCache.putLoader(credential, consumer);
|
||||
Thread.currentThread().setName(tempName);
|
||||
return function.apply(new UserProfile());
|
||||
return;
|
||||
}
|
||||
Object result = function.apply(loadProfile(gameProfile));
|
||||
consumer.accept(loadProfile(gameProfile));
|
||||
Thread.currentThread().setName(tempName);
|
||||
Function<UserProfile, ?> func = profileCache.getLastLoader(credential);
|
||||
if (func != null) {
|
||||
result = loadProfileLazily(gameProfile, func);
|
||||
}
|
||||
return result;
|
||||
profileCache.getLastLoader(credential).ifPresent(c -> loadProfileLazily(gameProfile, c));
|
||||
}
|
||||
|
||||
//For User Skin
|
||||
public static UserProfile loadProfile(GameProfile gameProfile) {
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile) {
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
UserProfile profile;
|
||||
if (profileCache.isReady(credential)) {
|
||||
@@ -113,7 +112,7 @@ public class CustomSkinLoader {
|
||||
profileCache.setLoading(credential, true);
|
||||
profile = loadProfile0(gameProfile, false);
|
||||
}
|
||||
return profile == null ? new UserProfile() : profile;
|
||||
return ModelManager0.fromUserProfile(profile);
|
||||
}
|
||||
|
||||
//Core
|
||||
@@ -180,7 +179,7 @@ public class CustomSkinLoader {
|
||||
|
||||
if (config.enableLocalProfileCache) {
|
||||
UserProfile profile = profileCache.getLocalProfile(credential);
|
||||
if (profile == null || profile.equals(UserProfile.NULL)) {
|
||||
if (profile == null) {
|
||||
logger.info(username + "'s LocalProfile not found.");
|
||||
} else {
|
||||
profileCache.updateCache(credential, profile, false);
|
||||
@@ -194,9 +193,9 @@ public class CustomSkinLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> INCOMPLETED = ImmutableMap.of();
|
||||
//For Skull
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(
|
||||
final GameProfile gameProfile) {
|
||||
String username = gameProfile.getName();
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
|
||||
@@ -223,7 +222,7 @@ public class CustomSkinLoader {
|
||||
threadPool.execute(loadThread);
|
||||
}
|
||||
}
|
||||
return INCOMPLETED;
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
private static Logger initLogger() {
|
||||
@@ -231,9 +230,12 @@ public class CustomSkinLoader {
|
||||
Logger logger = LogManager.getLogger("Core");
|
||||
logger.info("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
|
||||
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
|
||||
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
||||
logger.info("Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
|
||||
logger.info("Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
|
||||
logger.info("Operating System: " + System.getProperty("os.name") +
|
||||
" (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
||||
logger.info("Java Version: " + System.getProperty("java.version") +
|
||||
", " + System.getProperty("java.vendor"));
|
||||
logger.info("Java VM Version: " + System.getProperty("java.vm.name") +
|
||||
" (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
|
||||
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
|
||||
return logger;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package customskinloader;
|
||||
|
||||
/**
|
||||
* @deprecated From 14.16, use <code>customskinloader.log.Logger</code> instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class Logger extends customskinloader.log.Logger {
|
||||
}
|
||||
+5
-5
@@ -2,11 +2,7 @@ package customskinloader.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.loader.ProfileLoader;
|
||||
@@ -14,6 +10,7 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.plugin.PluginLoader;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
import customskinloader.utils.Version;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -27,6 +24,7 @@ public class Config {
|
||||
//Function
|
||||
public boolean enableDynamicSkull = true;
|
||||
public boolean enableTransparentSkin = true;
|
||||
public boolean forceIgnoreHttpsCertificate = false;
|
||||
public boolean forceLoadAllTextures = true;
|
||||
public boolean enableCape = true;
|
||||
public int threadPoolSize = 8;
|
||||
@@ -78,6 +76,8 @@ public class Config {
|
||||
config.updateLoadlist();
|
||||
config.initLocalFolder();
|
||||
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
||||
if (config.forceIgnoreHttpsCertificate)
|
||||
HttpUtil0.ignoreHttpsCertificate();
|
||||
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
||||
File renamed without changes.
+24
-8
@@ -2,27 +2,26 @@ package customskinloader.fake;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeBufferedImage;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
private static final ResourceLocation TEXTURE_ELYTRA_V1 = new ResourceLocation("minecraft", "textures/entity/elytra.png");
|
||||
private static final ResourceLocation TEXTURE_ELYTRA_V2 = new ResourceLocation("minecraft", "textures/entity/equipment/wings/elytra.png");
|
||||
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
||||
private static int loadedGlobal = 0;
|
||||
private static FakeImage elytraImage;
|
||||
|
||||
private static FakeImage loadElytra(FakeImage originalImage) {
|
||||
loadedGlobal++;
|
||||
try {
|
||||
Object resourceManager = FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft());
|
||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V1)
|
||||
.orElseGet(() -> FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V2).orElse(null)));
|
||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
|
||||
if (is != null) {
|
||||
FakeImage image = originalImage.createImage(is);
|
||||
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
||||
@@ -31,8 +30,7 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
image = resetImageFormat(image, 22, 0, 46, 22);
|
||||
return image;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
CustomSkinLoader.logger.warning(e);
|
||||
} catch (IOException | NoSuchElementException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -40,8 +38,13 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
private int loaded = 0;
|
||||
private double ratioX = -1;
|
||||
private double ratioY = -1;
|
||||
private final ResourceLocation location;
|
||||
private String type = null;
|
||||
|
||||
public FakeCapeBuffer(ResourceLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FakeImage parseUserSkin(FakeImage image) {
|
||||
if (image == null) return null;
|
||||
@@ -71,6 +74,9 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
if ("cape".equals(this.type)) {
|
||||
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
||||
this.attachElytra(elytraImage);
|
||||
if (this.image instanceof FakeBufferedImage) { // before 1.12.2
|
||||
this.refreshTexture((FakeBufferedImage) this.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.image;
|
||||
@@ -150,6 +156,16 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
return defaultReturnValue;
|
||||
}
|
||||
|
||||
// TextureID won't be regenerated when changing resource packs before 1.12.2
|
||||
private void refreshTexture(FakeBufferedImage image) {
|
||||
Object textureObj = MinecraftUtil.getTextureManager().getTexture(this.location);
|
||||
if (textureObj != null) {
|
||||
// NOTICE: OptiFine modified the upload process of the texture from ThreadDownloadImageData
|
||||
// Therefore, it may not be correct to simply copy the vanilla behavior
|
||||
FakeInterfaceManager.ThreadDownloadImageData_resetNewBufferedImage(textureObj, image.getImage());
|
||||
}
|
||||
}
|
||||
|
||||
// Some cape image doesn't support alpha channel, so reset image format to ARGB
|
||||
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
||||
if (image != null) {
|
||||
+5
-4
@@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
@@ -15,15 +16,15 @@ import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
public class FakeClientPlayer {
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
*/
|
||||
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager$SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
||||
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager.SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
||||
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer) {//Cache for client player
|
||||
textureCache.put(resourcelocation, threaddownloadimagedata);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class FakeClientPlayer {
|
||||
|
||||
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||
|
||||
public static class LegacyBuffer implements SkinManager$SkinAvailableCallback {
|
||||
public static class LegacyBuffer implements SkinAvailableCallback {
|
||||
ResourceLocation resourceLocationIn;
|
||||
boolean loaded = false;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
||||
private HttpTextureUtil.HttpTextureInfo info;
|
||||
private ResourceLocation resourceLocation;
|
||||
|
||||
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
||||
super(url, metadata);
|
||||
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
||||
}
|
||||
|
||||
public void setResourceLocation(ResourceLocation resourceLocation) {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation() {
|
||||
return this.resourceLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return this.info.url;
|
||||
}
|
||||
|
||||
public String getRawUrl() {
|
||||
return super.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash() {
|
||||
return this.info.hash == null ? super.getHash() : this.info.hash;
|
||||
}
|
||||
|
||||
public File getCacheFile() {
|
||||
return this.info.cacheFile;
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -1,7 +1,6 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -9,31 +8,19 @@ import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.texture.FakeBufferedImage;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import customskinloader.fake.texture.FakeNativeImage;
|
||||
import customskinloader.fake.texture.FakeThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
|
||||
public class FakeSkinBuffer implements IImageBuffer {
|
||||
private int ratio = 1;
|
||||
FakeImage image = null;
|
||||
|
||||
/**
|
||||
* 19w38a ~ 24w45a
|
||||
* Invoked from {@link ThreadDownloadImageData#loadTexture(InputStream)}
|
||||
*
|
||||
* 24w46a+
|
||||
* Invoked from {@link FakeThreadDownloadImageData#loadContents(IResourceManager)}
|
||||
*/
|
||||
//parseUserSkin for 1.15+
|
||||
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
|
||||
if (processTask instanceof IImageBuffer) {
|
||||
return ((IImageBuffer) processTask).func_195786_a(image);
|
||||
} else if (processLegacySkin != null) {
|
||||
return processLegacySkin.apply(image);
|
||||
} else {
|
||||
return image;
|
||||
}
|
||||
return processLegacySkin.apply(image);
|
||||
}
|
||||
|
||||
//parseUserSkin for 1.13+
|
||||
@@ -0,0 +1,179 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeSkinManager {
|
||||
private final TextureManager textureManager;
|
||||
|
||||
private final Map<ResourceLocation, MinecraftProfileTexture> modelCache = new ConcurrentHashMap<>();
|
||||
|
||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||
this.textureManager = textureManagerInstance;
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
*/
|
||||
public static ResourceLocation setResourceLocation(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
((FakeMinecraftProfileTexture) profileTexture).setResourceLocation(resourceLocation);
|
||||
}
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
* <p>
|
||||
* {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture);} -> {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, this.fakeManager.getModelCache(profileTexture, resourcelocation));}
|
||||
* <p>
|
||||
*/
|
||||
public static MinecraftProfileTexture getModelCache(MinecraftProfileTexture profileTexture, FakeSkinManager fakeManager, ResourceLocation location) {
|
||||
return fakeManager.modelCache.getOrDefault(location, profileTexture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, FakeSkinManager fakeManager, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
ResourceLocation resourcelocation = fakeProfileTexture.getResourceLocation();
|
||||
if (fakeProfileTexture.getResourceLocation() != null) {
|
||||
params[0] = fakeProfileTexture.getCacheFile();
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
}
|
||||
params[params.length - 1] = fakeManager.new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, fakeProfileTexture);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, m -> {
|
||||
// This is a hack.
|
||||
((Multimap) profile.getProperties()).put(KEY, m);
|
||||
runnable.run();
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
// This is a hack.
|
||||
return (Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>) ((Optional) profile.getProperties().removeAll(KEY).stream().findFirst()).orElse(Maps.newHashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$null$0(Map, SkinAvailableCallback)}
|
||||
*/
|
||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
|
||||
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
|
||||
if (map.containsKey(type)) {
|
||||
skinManager.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = CustomSkinLoader.loadProfileFromCache(profile);
|
||||
for (Iterator<Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture>> it = map.entrySet().iterator(); it.hasNext(); ) {
|
||||
Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture> entry = it.next();
|
||||
MinecraftProfileTexture texture = entry.getValue();
|
||||
if (shouldJudgeType(texture)) {
|
||||
texture = this.modelCache.get(MinecraftUtil.getSkinManager().loadSkin(texture, entry.getKey()));
|
||||
if (texture == null) { // remove texture if was not loaded before
|
||||
it.remove();
|
||||
} else {
|
||||
map.put(entry.getKey(), texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||
if (callback != null)
|
||||
callback.skinAvailable(type, location, texture);
|
||||
}
|
||||
|
||||
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
|
||||
return texture != null && "auto".equals(texture.getMetadata("model"));
|
||||
}
|
||||
|
||||
private class BaseBuffer implements IImageBuffer {
|
||||
private IImageBuffer buffer;
|
||||
|
||||
private SkinManager.SkinAvailableCallback callback;
|
||||
private MinecraftProfileTexture.Type type;
|
||||
private ResourceLocation location;
|
||||
private FakeMinecraftProfileTexture texture;
|
||||
|
||||
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, FakeMinecraftProfileTexture texture) {
|
||||
switch (type) {
|
||||
case SKIN: this.buffer = new FakeSkinBuffer(); break;
|
||||
case CAPE: this.buffer = new FakeCapeBuffer(location); break;
|
||||
}
|
||||
|
||||
this.callback = callback;
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
|
||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
||||
}
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
|
||||
}
|
||||
|
||||
public void skinAvailable() {
|
||||
if (buffer != null) {
|
||||
buffer.skinAvailable();
|
||||
if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) {
|
||||
//Auto judge skin type
|
||||
Map<String, String> metadata = Maps.newHashMap();
|
||||
String type = ((FakeSkinBuffer) buffer).judgeType();
|
||||
metadata.put("model", type);
|
||||
texture = new FakeMinecraftProfileTexture(texture.getRawUrl(), metadata);
|
||||
FakeSkinManager.this.modelCache.put(location, texture);
|
||||
}
|
||||
}
|
||||
|
||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeInterfaceManager {
|
||||
public static InputStream IResource_getInputStream(Object resource) {
|
||||
return ((IFakeIResource.V2) resource).open();
|
||||
}
|
||||
|
||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) throws IOException {
|
||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
||||
}
|
||||
|
||||
public static IResourceManager Minecraft_getResourceManager(Minecraft minecraft) {
|
||||
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
|
||||
}
|
||||
|
||||
public static void ThreadDownloadImageData_resetNewBufferedImage(Object threadDownloadImageData, BufferedImage image) {
|
||||
((IFakeThreadDownloadImageData) threadDownloadImageData).resetNewBufferedImage(image);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.io.InputStream;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
|
||||
/** {@link IResource} is no longer an interface since 22w14a */
|
||||
/** {@link net.minecraft.client.resources.IResource} is no longer an interface since 22w14a */
|
||||
public interface IFakeIResource {
|
||||
// 1.13.2 ~ 22w13a
|
||||
interface V1 {
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -8,12 +9,12 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IFakeIResourceManager {
|
||||
// 1.13.2 ~ 22w13a
|
||||
default IResource func_199002_a(ResourceLocation location) {
|
||||
default IResource func_199002_a(ResourceLocation location) throws IOException {
|
||||
return (IResource) ((IResourceManager) this).getResource(location);
|
||||
}
|
||||
|
||||
// 22w14a+
|
||||
default Optional getResource(ResourceLocation location) {
|
||||
default Optional getResource(ResourceLocation location) throws IOException {
|
||||
return Optional.ofNullable(this.func_199002_a(location));
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,12 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
// This interface is only available before 1.12.2
|
||||
public interface IFakeThreadDownloadImageData {
|
||||
/**
|
||||
* Reset {@link net.minecraft.client.renderer.ThreadDownloadImageData#bufferedImage} and
|
||||
* {@link net.minecraft.client.renderer.ThreadDownloadImageData#textureUploaded} to false to refresh texture.
|
||||
*/
|
||||
void resetNewBufferedImage(BufferedImage image);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+2
-3
@@ -2,7 +2,6 @@ package customskinloader.fake.texture;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public class FakeNativeImage implements FakeImage {
|
||||
@@ -37,11 +36,11 @@ public class FakeNativeImage implements FakeImage {
|
||||
}
|
||||
|
||||
public int getRGBA(int x, int y) {
|
||||
return FakeInterfaceManager.NativeImage_getPixel(image, x, y);
|
||||
return image.func_195709_a(x, y);
|
||||
}
|
||||
|
||||
public void setRGBA(int x, int y, int rgba) {
|
||||
FakeInterfaceManager.NativeImage_setPixel(image, x, y, rgba);
|
||||
image.func_195700_a(x, y, rgba);
|
||||
}
|
||||
|
||||
public void copyImageData(FakeImage image) {
|
||||
File renamed without changes.
+1
-1
@@ -27,7 +27,7 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
||||
return Lists.newArrayList(new LocalSkin(this),
|
||||
getCapeProfile(this, "OptiFine", "https://optifine.net/capes/{USERNAME}.png", 810),
|
||||
getCapeProfile(this, "CloakPlus", "http://161.35.130.99/capes/{USERNAME}.png", 840),
|
||||
//getCapeProfile(this, "LabyMod", "https://dl.labymod.net/capes/{STANDARD_UUID}", 850),
|
||||
getCapeProfile(this, "LabyMod", "https://dl.labymod.net/capes/{STANDARD_UUID}", 850),
|
||||
getCapeProfile(this, "Cosmetica", "https://api.cosmetica.cc/get/cloak?username={USERNAME}&uuid={STANDARD_UUID}¬hirdparty", 860)
|
||||
);
|
||||
}
|
||||
+29
-22
@@ -25,7 +25,6 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.TextureUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -109,22 +108,27 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final Gson GSON = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create();
|
||||
private static final Map<String, GameProfile> gameProfileCache = new ConcurrentHashMap<>();
|
||||
|
||||
public static GameProfile loadGameProfileCached(String apiRoot, String username) {
|
||||
return gameProfileCache.computeIfAbsent(apiRoot + " " + username, ignored -> loadGameProfile(apiRoot, username));
|
||||
return gameProfileCache.computeIfAbsent(apiRoot + " " + username,
|
||||
ignored -> loadGameProfile(apiRoot, username));
|
||||
}
|
||||
|
||||
//Username -> UUID
|
||||
public static GameProfile loadGameProfile(String apiRoot, String username) {
|
||||
//Doc (https://minecraft.wiki/w/Mojang_API#Query_player_UUIDs_in_batch)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft").setCacheTime(600).setPayload(GSON.toJson(Collections.singletonList(username))));
|
||||
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||
new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft")
|
||||
.setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username)))
|
||||
);
|
||||
if (StringUtils.isEmpty(responce.content)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameProfile[] profiles = GSON.fromJson(responce.content, GameProfile[].class);
|
||||
GameProfile[] profiles = gson.fromJson(responce.content, GameProfile[].class);
|
||||
if (profiles.length == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -149,20 +153,26 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
return null;
|
||||
}
|
||||
UUID id = profile.getId();
|
||||
return standard ? id.toString() : TextureUtil.fromUUID(id);
|
||||
return standard ? id.toString() : UUIDTypeAdapter.fromUUID(id);
|
||||
}
|
||||
|
||||
//UUID -> Profile
|
||||
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
|
||||
//Doc (https://minecraft.wiki/w/Mojang_API#Query_player's_skin_and_cape)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(profile.getId())).setCacheTime(90));
|
||||
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||
new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/"
|
||||
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
||||
if (StringUtils.isEmpty(responce.content)) {
|
||||
return profile;
|
||||
}
|
||||
|
||||
MinecraftProfilePropertiesResponse propertiesResponce = GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
|
||||
GameProfile newGameProfile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(propertiesResponce), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(propertiesResponce));
|
||||
newGameProfile.getProperties().putAll(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(propertiesResponce));
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||
.create();
|
||||
MinecraftProfilePropertiesResponse propertiesResponce = gson.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
|
||||
GameProfile newGameProfile = new GameProfile(propertiesResponce.getId(), propertiesResponce.getName());
|
||||
newGameProfile.getProperties().putAll(propertiesResponce.getProperties());
|
||||
|
||||
return newGameProfile;
|
||||
}
|
||||
@@ -175,26 +185,23 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
if (textureProperty == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
String value = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
|
||||
String value = textureProperty.getValue();
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
|
||||
MinecraftTexturesPayload result = GSON.fromJson(json, MinecraftTexturesPayload.class);
|
||||
|
||||
if (result == null) {
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
MinecraftTexturesPayload result = gson.fromJson(json, MinecraftTexturesPayload.class);
|
||||
if (result == null || result.getTextures() == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
|
||||
if (textures == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
return textures;
|
||||
return result.getTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) || (!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
|
||||
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) ||
|
||||
(!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
|
||||
}
|
||||
|
||||
@Override
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+7
-1
@@ -3,6 +3,7 @@ package customskinloader.loader.jsonapi;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.loader.MojangAPILoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
@@ -30,7 +31,7 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
@Override
|
||||
public String getRoot() {
|
||||
return "https://api.minecraftcapes.net/profile/";
|
||||
return "https://minecraftcapes.net/profile/";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +64,11 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayload(SkinSiteProfile ssp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MinecraftCapesAPI";
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -29,7 +29,7 @@ public class LogManager {
|
||||
}
|
||||
//Set new writer
|
||||
Files.createDirectories(logFile.getParent());
|
||||
logWriter = Files.newBufferedWriter(logFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
logWriter = Files.newBufferedWriter(logFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE);
|
||||
loggers.forEach((k, v) -> v.setWriter(logWriter));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,160 @@
|
||||
package customskinloader.profile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
|
||||
public class DynamicSkullManager {
|
||||
public static class SkullTexture{
|
||||
public Map<Type,MinecraftProfileTexture> textures;
|
||||
public String index;//Index File
|
||||
public ArrayList<String> skins;
|
||||
public int interval;
|
||||
public boolean fromZero;
|
||||
//For program
|
||||
public long startTime;
|
||||
public int period;
|
||||
}
|
||||
private Map<GameProfile, SkullTexture> dynamicTextures = new ConcurrentHashMap<>();
|
||||
private Map<GameProfile, Map<Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
|
||||
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
||||
|
||||
private void parseGameProfile(GameProfile profile){
|
||||
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
|
||||
if (textureProperty==null){
|
||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||
return;
|
||||
}
|
||||
String value=textureProperty.getValue();
|
||||
if(StringUtils.isBlank(value)){
|
||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
||||
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
||||
if(result==null){
|
||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||
return;
|
||||
}
|
||||
staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
|
||||
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
|
||||
|
||||
if(StringUtils.isNotEmpty(result.index)){
|
||||
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
||||
try{
|
||||
String index=FileUtils.readFileToString(indexFile, "UTF-8");
|
||||
if(StringUtils.isNotEmpty(index)){
|
||||
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
||||
if(skins != null && skins.length != 0)
|
||||
result.skins = Lists.newArrayList(skins);
|
||||
}
|
||||
}catch(Exception e){
|
||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
||||
return;
|
||||
|
||||
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
|
||||
|
||||
for(int i=0;i<result.skins.size();i++){//check and cache skins
|
||||
String skin=result.skins.get(i);
|
||||
if(HttpUtil0.isLocal(skin)){
|
||||
//Local Skin
|
||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
||||
if(skinFile.isFile()&&skinFile.length()>0){
|
||||
//Skin found
|
||||
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
|
||||
result.skins.set(i, fakeUrl);
|
||||
}else{
|
||||
//Could not find skin
|
||||
result.skins.remove(i--);
|
||||
}
|
||||
}else{
|
||||
//Online Skin
|
||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
||||
if(!responce.success){
|
||||
//Could not load skin
|
||||
result.skins.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(result.skins.isEmpty()){//Nothing loaded
|
||||
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
||||
return;
|
||||
}
|
||||
result.interval=Math.max(result.interval, 50);
|
||||
if(result.fromZero)
|
||||
result.startTime=System.currentTimeMillis();
|
||||
result.period=result.interval*result.skins.size();
|
||||
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
|
||||
dynamicTextures.put(profile, result);
|
||||
staticTextures.remove(profile);
|
||||
}
|
||||
|
||||
//Support local skin for skull
|
||||
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
|
||||
MinecraftProfileTexture skin=textures.get(Type.SKIN);
|
||||
String skinUrl=skin.getUrl();
|
||||
if(!HttpUtil0.isLocal(skinUrl))
|
||||
return textures;
|
||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
||||
if(!skinFile.isFile())
|
||||
return Maps.newHashMap();
|
||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||
return textures;
|
||||
}
|
||||
|
||||
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
||||
if(staticTextures.get(profile)!=null)
|
||||
return staticTextures.get(profile);
|
||||
if(loadingList.contains(profile))
|
||||
return Maps.newHashMap();
|
||||
if(dynamicTextures.containsKey(profile)){
|
||||
SkullTexture texture=dynamicTextures.get(profile);
|
||||
long time=System.currentTimeMillis()-texture.startTime;
|
||||
int index=(int)Math.floor((time%texture.period)/texture.interval);
|
||||
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
|
||||
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
||||
return map;
|
||||
}
|
||||
|
||||
loadingList.add(profile);
|
||||
Thread loadThread=new Thread(){
|
||||
public void run(){
|
||||
parseGameProfile(profile);//Load in thread
|
||||
loadingList.remove(profile);
|
||||
}
|
||||
};
|
||||
loadThread.setName("Skull "+profile.hashCode());
|
||||
loadThread.start();
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -5,7 +5,6 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.FakeMinecraftProfileTexture;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -99,9 +98,9 @@ public class ModelManager0 {
|
||||
* @since 13.1
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile) {
|
||||
if (profile == null)
|
||||
return CustomSkinLoader.INCOMPLETED;
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||
if (profile == null)
|
||||
return map;
|
||||
if (profile.skinUrl != null) {
|
||||
Map<String, String> metadata = null;
|
||||
if ("slim".equals(profile.model) || "auto".equals(profile.model)) {
|
||||
+12
-10
@@ -3,10 +3,12 @@ package customskinloader.profile;
|
||||
import java.io.File;
|
||||
import java.util.Deque;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.TimeUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -16,7 +18,7 @@ public class ProfileCache {
|
||||
|
||||
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
|
||||
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
|
||||
private Map<String, Deque<Function<UserProfile, ?>>> profileLoaders = new ConcurrentHashMap<>();
|
||||
private Map<String, Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>>> profileLoaders = new ConcurrentHashMap<>();
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public ProfileCache(){
|
||||
@@ -51,12 +53,12 @@ public class ProfileCache {
|
||||
return localProfiles.get(username.toLowerCase());
|
||||
return loadLocalProfile(username);
|
||||
}
|
||||
public Function<UserProfile, ?> getLastLoader(String username) {
|
||||
Deque<Function<UserProfile, ?>> deque = this.profileLoaders.get(username);
|
||||
public Optional<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> getLastLoader(String username) {
|
||||
Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> deque = this.profileLoaders.get(username);
|
||||
if (deque != null) {
|
||||
return deque.pollLast();
|
||||
return Optional.ofNullable(deque.pollLast());
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void setLoading(String username,boolean loading){
|
||||
@@ -73,7 +75,7 @@ public class ProfileCache {
|
||||
return;
|
||||
saveLocalProfile(username,profile);
|
||||
}
|
||||
public void putLoader(String username, Function<UserProfile, ?> loader) {
|
||||
public void putLoader(String username, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> loader) {
|
||||
this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>());
|
||||
this.profileLoaders.get(username).offerLast(loader);
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class ProfileCache {
|
||||
private UserProfile loadLocalProfile(String username){
|
||||
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
|
||||
if(!localProfile.exists()){
|
||||
localProfiles.put(username.toLowerCase(), UserProfile.NULL);
|
||||
localProfiles.put(username.toLowerCase(), null);
|
||||
}
|
||||
try{
|
||||
String json = FileUtils.readFileToString(localProfile, "UTF-8");
|
||||
@@ -99,9 +101,9 @@ public class ProfileCache {
|
||||
return profile;
|
||||
}catch(Exception e){
|
||||
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
|
||||
localProfiles.put(username.toLowerCase(), UserProfile.NULL);
|
||||
localProfiles.put(username.toLowerCase(), null);
|
||||
}
|
||||
return UserProfile.NULL;
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void saveLocalProfile(String username, UserProfile profile){
|
||||
-36
@@ -1,11 +1,5 @@
|
||||
package customskinloader.profile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import customskinloader.utils.TextureUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import customskinloader.profile.ModelManager0.Model;
|
||||
@@ -15,8 +9,6 @@ import customskinloader.profile.ModelManager0.Model;
|
||||
* @since 13.1
|
||||
*/
|
||||
public class UserProfile {
|
||||
|
||||
public final static UserProfile NULL = new UserProfile();
|
||||
|
||||
/**
|
||||
* Direct url for skin.
|
||||
@@ -77,34 +69,6 @@ public class UserProfile {
|
||||
(StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+
|
||||
(expiry==0?"":(" , Expiry: "+expiry))+")";
|
||||
}
|
||||
|
||||
public List<Property> toProperties() {
|
||||
return Lists.newArrayList(
|
||||
new Property("skinUrl" , nullToValue(this.skinUrl )),
|
||||
new Property("model" , nullToValue(this.model )),
|
||||
new Property("capeUrl" , nullToValue(this.capeUrl )),
|
||||
new Property("elytraUrl", nullToValue(this.elytraUrl))
|
||||
);
|
||||
}
|
||||
|
||||
public static UserProfile fromProperties(Collection<Property> properties) {
|
||||
UserProfile profile = new UserProfile();
|
||||
if (properties != null) {
|
||||
for (Property property : properties) {
|
||||
switch ((String) TextureUtil.AuthlibField.PROPERTY_NAME.get(property)) {
|
||||
case "skinUrl" : profile.skinUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break;
|
||||
case "model" : profile.model = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break;
|
||||
case "capeUrl" : profile.capeUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break;
|
||||
case "elytraUrl": profile.elytraUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static String nullToValue(String value) {
|
||||
return value == null ? "null" : value.equals("null") ? null : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instance is empty.
|
||||
File renamed without changes.
File renamed without changes.
+34
@@ -4,7 +4,14 @@ import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -13,6 +20,33 @@ public class HttpUtil0 {
|
||||
return url != null && !url.startsWith("http://") && !url.startsWith("https://");
|
||||
}
|
||||
|
||||
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
||||
public static void ignoreHttpsCertificate(){
|
||||
HostnameVerifier doNotVerify = new HostnameVerifier() {
|
||||
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[] {};
|
||||
}
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType){}
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType){}
|
||||
}};
|
||||
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
//HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(new SSLSocketFactoryFacade());
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String parseAddress(String address) {
|
||||
if(StringUtils.isEmpty(address))
|
||||
return null;
|
||||
File renamed without changes.
+3
-2
@@ -40,7 +40,7 @@ public class MinecraftUtil {
|
||||
}
|
||||
|
||||
//version.json can be found in 1.14+
|
||||
URL versionFile = ClassLoader.getSystemClassLoader().getResource("version.json");
|
||||
URL versionFile = MinecraftUtil.class.getResource("/version.json");
|
||||
if (versionFile != null) {
|
||||
try (
|
||||
InputStream is = versionFile.openStream();
|
||||
@@ -85,6 +85,7 @@ public class MinecraftUtil {
|
||||
}
|
||||
|
||||
public static String getCredential(GameProfile profile) {
|
||||
return profile == null ? null : String.format("%s-%s", profile.getName(), profile.getId());
|
||||
return (profile == null || profile.hashCode() == 0) ? null :
|
||||
(profile.getId() == null ? profile.getName() : String.format("%s-%s", profile.getName(), profile.getId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package customskinloader.utils;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TextureUtil {
|
||||
/**
|
||||
* Save and get fake url of base64 texture
|
||||
*
|
||||
* @param base64 texture in base64 string
|
||||
* @return base64 fake url
|
||||
* @since 14.16
|
||||
*/
|
||||
public static String parseBase64Texture(String base64) {
|
||||
byte[] capeBytes = Base64.decodeBase64(base64);
|
||||
String hash = HttpTextureUtil.getHash(capeBytes);
|
||||
File cacheFile = HttpTextureUtil.getCacheFile(hash);
|
||||
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
|
||||
|
||||
//Save base64 image to cache file
|
||||
try {
|
||||
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
|
||||
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
|
||||
return fakeUrl;
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Error parsing base64 image: " + base64);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+6
-2
@@ -2,13 +2,17 @@ package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import customskinloader.fake.itf.IFakeIImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public interface IImageBuffer extends IFakeIImageBuffer {
|
||||
public interface IImageBuffer extends Runnable {
|
||||
BufferedImage parseUserSkin(BufferedImage image);
|
||||
|
||||
NativeImage func_195786_a(NativeImage image);
|
||||
|
||||
void skinAvailable();
|
||||
|
||||
@Override
|
||||
default void run() {
|
||||
this.skinAvailable();
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-1
@@ -1,8 +1,10 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// this class shouldn't be created by ASM because of modlauncher issue.
|
||||
public interface IResourceManager {
|
||||
IResource getResource(ResourceLocation location);
|
||||
IResource getResource(ResourceLocation location) throws IOException;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,54 +0,0 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
|
||||
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
||||
private final static Map<String, String> MODEL_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
private final HttpTextureUtil.HttpTextureInfo info;
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
||||
super(url, metadata);
|
||||
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return this.info.url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMetadata(final String key) {
|
||||
String value = super.getMetadata(key);
|
||||
if ("model".equals(key) && "auto".equals(value)) {
|
||||
String model = MODEL_CACHE.get(this.getHash());
|
||||
if (model != null) {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
if (this.metadata != null) {
|
||||
MODEL_CACHE.put(this.getHash(), model);
|
||||
this.metadata.put("model", model);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash() {
|
||||
return this.info.hash == null ? super.getHash() : this.info.hash;
|
||||
}
|
||||
|
||||
public File getCacheFile() {
|
||||
return this.info.cacheFile;
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.SignatureState;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeThreadDownloadImageData;
|
||||
import customskinloader.loader.MojangAPILoader;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.TextureUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.ReloadableTexture;
|
||||
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.PlayerSkin$Model;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager$1;
|
||||
import net.minecraft.client.resources.SkinManager$CacheKey;
|
||||
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||
import net.minecraft.client.resources.SkinManager$TextureCache;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeSkinManager {
|
||||
/**
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager(TextureManager, File, MinecraftSessionService)}
|
||||
*/
|
||||
public static void setSkinCacheDir(File skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static void setSkinCacheDir(Path skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
|
||||
}
|
||||
|
||||
private static CacheLoader<Object, ?> cacheLoader;
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
|
||||
return cacheLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Property createProperty(Property property) {
|
||||
return property == null ? new Property(null, null) : new Property(TextureUtil.AuthlibField.PROPERTY_NAME.get(property), TextureUtil.AuthlibField.PROPERTY_VALUE.get(property), TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property));
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
|
||||
return cacheLoader.load(FakeCacheKey.wrapCacheKey(cacheKey, profile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||
*
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
File cacheFile = fakeProfileTexture.getCacheFile();
|
||||
if (params.length == 4) {
|
||||
if (params[3] instanceof Boolean) { // 24w46a+
|
||||
FakeInterfaceManager.ResourceLocation_setTexture(params[0], FakeThreadDownloadImageData.createTexture(params[0], cacheFile.toPath(), params[2], false, new BaseBuffer(null, textureType, fakeProfileTexture)));
|
||||
params[1] = cacheFile.toPath();
|
||||
params[3] = false;
|
||||
} else { // 19w37a-
|
||||
params[0] = cacheFile;
|
||||
params[3] = new BaseBuffer((Runnable) params[3], textureType, fakeProfileTexture);
|
||||
}
|
||||
} else if (params.length == 5) { // 19w38a ~ 24w45a
|
||||
params[0] = cacheFile;
|
||||
params[3] = true;
|
||||
params[4] = new BaseBuffer((Runnable) params[4], textureType, fakeProfileTexture);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 24w46a+
|
||||
* Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
|
||||
*/
|
||||
public static CompletableFuture<?> clearCachedFuture(CompletableFuture<?> future) {
|
||||
CompletableFuture<Object> completableFuture = new CompletableFuture<>();
|
||||
future.thenAccept(completableFuture::complete);
|
||||
return completableFuture;
|
||||
}
|
||||
|
||||
/**
|
||||
* 24w46a+
|
||||
* Invoked from {@link SkinTextureDownloader#lambda$registerTextureInManager$2(Minecraft, ResourceLocation, NativeImage)}
|
||||
*/
|
||||
public static void registerTextureInManager(TextureManager manager, ResourceLocation location, AbstractTexture texture) {
|
||||
Object texture0 = FakeInterfaceManager.ResourceLocation_getTexture(location);
|
||||
if (texture0 != null) {
|
||||
manager.registerAndLoad(location, (ReloadableTexture) texture0);
|
||||
} else {
|
||||
manager.loadTexture(location, texture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> {
|
||||
profile.getProperties().putAll(KEY, p.toProperties());
|
||||
runnable.run();
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)}
|
||||
*/
|
||||
public static Object[] loadProfileTextures(ImmutableList<Object> list, Object cacheKey) {
|
||||
Object[] params = list.toArray();
|
||||
GameProfile profile = FakeCacheKey.unwrapCacheKey(cacheKey);
|
||||
if (!profile.getProperties().containsKey(SKULL_KEY)) {
|
||||
final Supplier<?> supplier = (Supplier<?>) params[0];
|
||||
params[0] = (Supplier<?>) () -> CustomSkinLoader.loadProfileLazily(profile, p -> {
|
||||
profile.getProperties().putAll(KEY, p.toProperties());
|
||||
FakeCacheKey.wrapCacheKey(cacheKey, profile);
|
||||
return supplier.get();
|
||||
});
|
||||
params[1] = CustomSkinLoader.THREAD_POOL;
|
||||
} else {
|
||||
params[1] = Minecraft.getMinecraft();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210276_a(Map, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager$SkinAvailableCallback skinAvailableCallback) {
|
||||
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
|
||||
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
|
||||
if (map.containsKey(type)) {
|
||||
skinManager.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 24w46a+
|
||||
* Invoked from {@link SkinManager#lambda$registerTextures$1(CompletableFuture, String, CompletableFuture, CompletableFuture, PlayerSkin$Model, MinecraftProfileTextures, Void)}
|
||||
*/
|
||||
public static PlayerSkin$Model loadSkinModel(PlayerSkin$Model model, MinecraftProfileTextures textures) {
|
||||
MinecraftProfileTexture texture = textures.skin();
|
||||
if (texture != null) {
|
||||
model = PlayerSkin$Model.byName(texture.getMetadata("model"));
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private final static String SKULL_KEY = "CSL$IsSkull";
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager#getInsecureSkin(GameProfile)}
|
||||
*/
|
||||
public static void setSkullType(GameProfile profile) {
|
||||
profile.getProperties().removeAll(SKULL_KEY);
|
||||
profile.getProperties().put(SKULL_KEY, new Property(SKULL_KEY, "true"));
|
||||
}
|
||||
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a ~ 23w41a
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
if (profile.getProperties().containsKey(SKULL_KEY)) {
|
||||
profile.getProperties().removeAll(SKULL_KEY);
|
||||
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||
} else {
|
||||
return getUserProfile(sessionService, profile, requireSecure);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, MinecraftSessionService)}
|
||||
*/
|
||||
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) {
|
||||
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false));
|
||||
}
|
||||
|
||||
private final static CompletableFuture<?> INCOMPLETED = new CompletableFuture<>();
|
||||
/**
|
||||
* 1.21.6-pre1+
|
||||
* Invoked from {@link SkinManager#registerTextures(UUID, MinecraftProfileTextures)}
|
||||
*/
|
||||
public static CompletableFuture<?> checkIncompleted(MinecraftProfileTextures textures, CompletableFuture<?> future) {
|
||||
if (textures == FakeCacheKey.IncompletedContainer.INCOMPLETED) {
|
||||
return INCOMPLETED;
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
|
||||
return texture != null && "auto".equals(texture.getMetadata("model"));
|
||||
}
|
||||
|
||||
private static class BaseBuffer implements IImageBuffer {
|
||||
private IImageBuffer buffer;
|
||||
|
||||
private final Runnable callback;
|
||||
private final FakeMinecraftProfileTexture texture;
|
||||
|
||||
public BaseBuffer(Runnable callback, MinecraftProfileTexture.Type type, FakeMinecraftProfileTexture texture) {
|
||||
this.callback = callback;
|
||||
this.texture = texture;
|
||||
|
||||
switch (type) {
|
||||
case SKIN: this.buffer = new FakeSkinBuffer(); break;
|
||||
case CAPE: this.buffer = new FakeCapeBuffer(); break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NativeImage func_195786_a(NativeImage image) {
|
||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable() {
|
||||
if (buffer != null) {
|
||||
buffer.skinAvailable();
|
||||
if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) {
|
||||
//Auto judge skin type
|
||||
String type = ((FakeSkinBuffer) buffer).judgeType();
|
||||
texture.setModel(type);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.callback != null) {
|
||||
this.callback.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FakeCacheKey {
|
||||
public static Object wrapCacheKey(Object cacheKey, GameProfile profile) {
|
||||
if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) == null) { // 23w42a+
|
||||
TextureUtil.AuthlibField.PROPERTY_SIGNATURE.set(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey), MojangAPILoader.GSON.toJson(profile, GameProfile.class));
|
||||
}
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
public static GameProfile unwrapCacheKey(Object cacheKey) {
|
||||
if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) != null) {
|
||||
return FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey); // 23w31a ~ 23w41a
|
||||
} else {
|
||||
return unwrapProperty(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey)); // 23w42a+
|
||||
}
|
||||
}
|
||||
|
||||
public static GameProfile unwrapProperty(Property property) {
|
||||
return MojangAPILoader.GSON.fromJson((String) TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property), GameProfile.class); // 23w42a+
|
||||
}
|
||||
|
||||
public static class IncompletedContainer {
|
||||
public final static Object INCOMPLETED = new MinecraftProfileTextures(null, null, null, SignatureState.SIGNED);
|
||||
}
|
||||
|
||||
public static Object createMinecraftProfileTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
|
||||
if (textures == CustomSkinLoader.INCOMPLETED) {
|
||||
return IncompletedContainer.INCOMPLETED;
|
||||
}
|
||||
return new MinecraftProfileTextures(textures.get(MinecraftProfileTexture.Type.SKIN), textures.get(MinecraftProfileTexture.Type.CAPE), textures.get(MinecraftProfileTexture.Type.ELYTRA), SignatureState.SIGNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeInterfaceManager {
|
||||
public static InputStream IResource_getInputStream(Object resource) {
|
||||
return ((IFakeIResource.V2) resource).open();
|
||||
}
|
||||
|
||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) {
|
||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
||||
}
|
||||
|
||||
public static IResourceManager Minecraft_getResourceManager(Object minecraft) {
|
||||
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
|
||||
}
|
||||
|
||||
public static int NativeImage_getPixel(Object nativeImage, int x, int y) {
|
||||
return ((IFakeNativeImage) nativeImage).getPixel(x, y);
|
||||
}
|
||||
|
||||
public static void NativeImage_setPixel(Object nativeImage, int x, int y, int color) {
|
||||
((IFakeNativeImage) nativeImage).setPixel(x, y, color);
|
||||
}
|
||||
|
||||
public static Object ResourceLocation_getTexture(Object location) {
|
||||
return ((IFakeResourceLocation) location).customskinloader$getTexture();
|
||||
}
|
||||
|
||||
public static void ResourceLocation_setTexture(Object location, Object texture) {
|
||||
((IFakeResourceLocation) location).customskinloader$setTexture(texture);
|
||||
}
|
||||
|
||||
public static GameProfile SkinManagerCacheKey_profile(Object skinManagerCacheKey) {
|
||||
return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).profile();
|
||||
}
|
||||
|
||||
public static Property SkinManagerCacheKey_packedTextures(Object skinManagerCacheKey) {
|
||||
return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).packedTextures();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
|
||||
public interface IFakeIImageBuffer extends Runnable {
|
||||
@Override
|
||||
default void run() {
|
||||
((IImageBuffer) this).skinAvailable();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public interface IFakeNativeImage {
|
||||
default int getPixel(int x, int y) {
|
||||
return ((NativeImage) this).func_195709_a(x, y);
|
||||
}
|
||||
|
||||
default void setPixel(int x, int y, int color) {
|
||||
((NativeImage) this).func_195700_a(x, y, color);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
public interface IFakeResourceLocation {
|
||||
Object customskinloader$getTexture();
|
||||
void customskinloader$setTexture(Object texture);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public interface IFakeSkinManagerCacheKey {
|
||||
default GameProfile profile() { return null; }
|
||||
Property packedTextures();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package customskinloader.fake.texture;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import customskinloader.fake.FakeSkinBuffer;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||
import net.minecraft.client.renderer.texture.TextureContents;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// 24w46a+
|
||||
public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||
private final Path cacheFile;
|
||||
private final String imageUrl;
|
||||
private final boolean legacySkin;
|
||||
private final Runnable processTask;
|
||||
|
||||
public static Object createTexture(Object location, Object cacheFile, Object imageUrl, Object legacySkin, Object processTask) {
|
||||
return new FakeThreadDownloadImageData((ResourceLocation) location, (Path) cacheFile, (String) imageUrl, (boolean) legacySkin, (Runnable) processTask);
|
||||
}
|
||||
|
||||
public FakeThreadDownloadImageData(ResourceLocation location, Path cacheFile, String imageUrl, boolean legacySkin, Runnable processTask) {
|
||||
super(location);
|
||||
this.cacheFile = cacheFile;
|
||||
this.imageUrl = imageUrl;
|
||||
this.legacySkin = legacySkin;
|
||||
this.processTask = processTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureContents loadContents(IResourceManager resourceManager) {
|
||||
NativeImage image = FakeSkinBuffer.processLegacySkin(SkinTextureDownloader.lambda$downloadAndRegisterSkin$0(this.cacheFile, this.imageUrl, this.legacySkin), this.processTask, i -> SkinTextureDownloader.processLegacySkin(i, this.imageUrl));
|
||||
this.processTask.run();
|
||||
return new TextureContents(image, null);
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package customskinloader.profile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
import customskinloader.utils.TextureUtil;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class DynamicSkullManager {
|
||||
public static class SkullTexture {
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
||||
public String index;//Index File
|
||||
public ArrayList<String> skins;
|
||||
public int interval;
|
||||
public boolean fromZero;
|
||||
//For program
|
||||
public long startTime;
|
||||
public int period;
|
||||
}
|
||||
|
||||
private Map<GameProfile, SkullTexture> dynamicTextures = new ConcurrentHashMap<>();
|
||||
private Map<GameProfile, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
|
||||
private List<GameProfile> loadingList = Lists.newArrayList();
|
||||
|
||||
private void parseGameProfile(GameProfile profile) {
|
||||
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
|
||||
if (textureProperty == null) {
|
||||
staticTextures.put(profile, Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
String value = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
|
||||
if (StringUtils.isBlank(value)) {
|
||||
staticTextures.put(profile, Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
SkullTexture result = gson.fromJson(json, SkullTexture.class);
|
||||
if (result == null) {
|
||||
staticTextures.put(profile, Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
staticTextures.put(profile, (result.textures == null || !result.textures.containsKey(MinecraftProfileTexture.Type.SKIN)) ? Maps.newHashMap() : parseTextures(result.textures));
|
||||
|
||||
if (StringUtils.isNotEmpty(result.index)) {
|
||||
File indexFile = new File(CustomSkinLoader.DATA_DIR, result.index);
|
||||
try {
|
||||
String index = FileUtils.readFileToString(indexFile, "UTF-8");
|
||||
if (StringUtils.isNotEmpty(index)) {
|
||||
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
||||
if (skins != null && skins.length != 0)
|
||||
result.skins = Lists.newArrayList(skins);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!CustomSkinLoader.config.enableDynamicSkull || result.skins == null || result.skins.isEmpty())
|
||||
return;
|
||||
|
||||
CustomSkinLoader.logger.info("Try to load Dynamic Skull: " + json);
|
||||
|
||||
for (int i = 0; i < result.skins.size(); i++) {//check and cache skins
|
||||
String skin = result.skins.get(i);
|
||||
if (HttpUtil0.isLocal(skin)) {
|
||||
//Local Skin
|
||||
File skinFile = new File(CustomSkinLoader.DATA_DIR, skin);
|
||||
if (skinFile.isFile() && skinFile.length() > 0) {
|
||||
//Skin found
|
||||
String fakeUrl = HttpTextureUtil.getLocalFakeUrl(skin);
|
||||
result.skins.set(i, fakeUrl);
|
||||
} else {
|
||||
//Could not find skin
|
||||
result.skins.remove(i--);
|
||||
}
|
||||
} else {
|
||||
//Online Skin
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
||||
if (!responce.success) {
|
||||
//Could not load skin
|
||||
result.skins.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.skins.isEmpty()) {//Nothing loaded
|
||||
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
||||
return;
|
||||
}
|
||||
result.interval = Math.max(result.interval, 50);
|
||||
if (result.fromZero)
|
||||
result.startTime = System.currentTimeMillis();
|
||||
result.period = result.interval * result.skins.size();
|
||||
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: " + new Gson().toJson(result));
|
||||
dynamicTextures.put(profile, result);
|
||||
staticTextures.remove(profile);
|
||||
}
|
||||
|
||||
//Support local skin for skull
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> parseTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
|
||||
MinecraftProfileTexture skin = textures.get(MinecraftProfileTexture.Type.SKIN);
|
||||
String skinUrl = skin.getUrl();
|
||||
if (!HttpUtil0.isLocal(skinUrl))
|
||||
// Wrap MinecraftProfileTexture to FakeMinecraftProfileTexture
|
||||
return ModelManager0.fromUserProfile(ModelManager0.toUserProfile(textures));
|
||||
File skinFile = new File(CustomSkinLoader.DATA_DIR, skinUrl);
|
||||
if (!skinFile.isFile())
|
||||
return Maps.newHashMap();
|
||||
textures.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||
return textures;
|
||||
}
|
||||
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTexture(final GameProfile profile) {
|
||||
if (staticTextures.get(profile) != null)
|
||||
return staticTextures.get(profile);
|
||||
if (loadingList.contains(profile))
|
||||
return CustomSkinLoader.INCOMPLETED;
|
||||
if (dynamicTextures.containsKey(profile)) {
|
||||
SkullTexture texture = dynamicTextures.get(profile);
|
||||
long time = System.currentTimeMillis() - texture.startTime;
|
||||
int index = (int) Math.floor((time % texture.period) / texture.interval);
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||
map.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
||||
return map;
|
||||
}
|
||||
|
||||
loadingList.add(profile);
|
||||
Thread loadThread = new Thread(() -> {
|
||||
parseGameProfile(profile);//Load in thread
|
||||
loadingList.remove(profile);
|
||||
});
|
||||
loadThread.setName("Skull " + profile.hashCode());
|
||||
loadThread.start();
|
||||
return CustomSkinLoader.INCOMPLETED;
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package customskinloader.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
public class TextureUtil {
|
||||
/**
|
||||
* Save and get fake url of base64 texture
|
||||
*
|
||||
* @param base64 texture in base64 string
|
||||
* @return base64 fake url
|
||||
* @since 14.16
|
||||
*/
|
||||
public static String parseBase64Texture(String base64) {
|
||||
byte[] capeBytes = Base64.decodeBase64(base64);
|
||||
String hash = HttpTextureUtil.getHash(capeBytes);
|
||||
File cacheFile = HttpTextureUtil.getCacheFile(hash);
|
||||
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
|
||||
|
||||
//Save base64 image to cache file
|
||||
try {
|
||||
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
|
||||
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
|
||||
return fakeUrl;
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Error parsing base64 image: " + base64);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final static MethodHandles.Lookup IMPL_LOOKUP = ((Supplier<MethodHandles.Lookup>) () -> {
|
||||
try {
|
||||
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
|
||||
Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
||||
theUnsafeField.setAccessible(true);
|
||||
Object theUnsafe = theUnsafeField.get(null);
|
||||
|
||||
Method getObjectMethod = unsafeClass.getMethod("getObject", Object.class, long.class);
|
||||
Method staticFieldBaseMethod = unsafeClass.getMethod("staticFieldBase", Field.class);
|
||||
Method staticFieldOffsetMethod = unsafeClass.getMethod("staticFieldOffset", Field.class);
|
||||
|
||||
Field implLookupField = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP");
|
||||
return (MethodHandles.Lookup) getObjectMethod.invoke(theUnsafe, staticFieldBaseMethod.invoke(theUnsafe, implLookupField), staticFieldOffsetMethod.invoke(theUnsafe, implLookupField));
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}).get();
|
||||
|
||||
// Some of the classes in Authlib used after Minecraft 23w31a were changed to record classes,
|
||||
// resulting in changes to method names, so reflection is used here to be compatible with these changes.
|
||||
public enum AuthlibField {
|
||||
PROPERTY_NAME(Property.class, "name", String.class),
|
||||
PROPERTY_VALUE(Property.class, "value", String.class),
|
||||
PROPERTY_SIGNATURE(Property.class, "signature", String.class),
|
||||
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID(MinecraftProfilePropertiesResponse.class, "id", UUID.class),
|
||||
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME(MinecraftProfilePropertiesResponse.class, "name", String.class),
|
||||
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES(MinecraftProfilePropertiesResponse.class, "properties", PropertyMap.class),
|
||||
MINECRAFT_TEXTURES_PAYLOAD_TEXTURES(MinecraftTexturesPayload.class, "textures", Map.class);
|
||||
|
||||
private final MethodHandle getter;
|
||||
private final MethodHandle setter;
|
||||
|
||||
AuthlibField(Class<?> clazz, String name, Class<?> returnType) {
|
||||
try {
|
||||
this.getter = IMPL_LOOKUP.findGetter(clazz, name, returnType);
|
||||
this.setter = IMPL_LOOKUP.findSetter(clazz, name, returnType);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R> R get(Object o) {
|
||||
try {
|
||||
return (R) this.getter.invokeWithArguments(o);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(Object o, Object value) {
|
||||
try {
|
||||
this.setter.invokeWithArguments(o, value);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromUUID(UUID value) {
|
||||
return value.toString().replace("-", "");
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,7 +0,0 @@
|
||||
// This subproject is only to provide dependency for other subprojects.
|
||||
|
||||
reobf {
|
||||
jar {
|
||||
mappings = file("Dummy.srg")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
mappings_version=stable_39
|
||||
# this subproject is only to provide dependency for other subprojects.
|
||||
is_real_project=false
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.mojang.authlib;
|
||||
|
||||
public enum SignatureState {
|
||||
SIGNED
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.mojang.authlib.minecraft;
|
||||
|
||||
import com.mojang.authlib.SignatureState;
|
||||
|
||||
public class MinecraftProfileTextures {
|
||||
public MinecraftProfileTextures(MinecraftProfileTexture skin, MinecraftProfileTexture cape, MinecraftProfileTexture elytra, SignatureState signatureState) {}
|
||||
public MinecraftProfileTexture skin() { return null; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package net.minecraft.client;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
|
||||
public class Minecraft {
|
||||
public File gameDir;
|
||||
public static Minecraft getMinecraft() { return null; }
|
||||
public ServerData getCurrentServerData() { return null; }
|
||||
public IResourceManager getResourceManager() { return null; }
|
||||
public SkinManager getSkinManager() { return null; }
|
||||
public TextureManager getTextureManager() { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.gui;
|
||||
|
||||
public class GuiPlayerTabOverlay {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.multiplayer;
|
||||
|
||||
public class ServerData {
|
||||
public String serverIP;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public class ThreadDownloadImageData implements ITextureObject {
|
||||
public NativeImage loadTexture(InputStream stream) { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.entity;
|
||||
|
||||
public class RenderPlayer {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.entity.layers;
|
||||
|
||||
public class LayerCape {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
public abstract class AbstractTexture {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
public interface ITextureObject {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
public abstract class ReloadableTexture extends AbstractTexture {
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SimpleTexture implements ITextureObject {
|
||||
public SimpleTexture(ResourceLocation location) {}
|
||||
public TextureContents loadContents(IResourceManager resourceManager) { return null; }
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinTextureDownloader {
|
||||
public static CompletableFuture<?> downloadAndRegisterSkin(ResourceLocation location, Path path, String string, boolean b) { return null; }
|
||||
public static NativeImage processLegacySkin(NativeImage nativeImage, String url) { return null; }
|
||||
public static NativeImage lambda$downloadAndRegisterSkin$0(Path path, String url, boolean b) { return null; }
|
||||
public static ResourceLocation lambda$registerTextureInManager$2(Minecraft minecraft, ResourceLocation location, NativeImage image) { return null; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import net.minecraft.client.resources.data.TextureMetadataSection;
|
||||
|
||||
public class TextureContents {
|
||||
public TextureContents(NativeImage image, TextureMetadataSection metadata) {}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TextureManager {
|
||||
public ITextureObject getTexture(ResourceLocation location) { return null; }
|
||||
public void loadTexture(ResourceLocation location, AbstractTexture texture) {}
|
||||
public boolean loadTexture(ResourceLocation location, ITextureObject texture) { return false; }
|
||||
public void registerAndLoad(ResourceLocation resourceLocation, ReloadableTexture reloadableTexture) {}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class DefaultPlayerSkin {
|
||||
public static ResourceLocation getDefaultSkin(UUID uuid) { return null; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface IResource {
|
||||
InputStream getInputStream();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IResourceManager {
|
||||
IResource getResource(ResourceLocation location);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
public class PlayerSkin$Model {
|
||||
public static PlayerSkin$Model byName(String string) { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
public class PlayerSkin {
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
|
||||
public class SkinManager$1 {
|
||||
public CompletableFuture<?> load(SkinManager$CacheKey cacheKey) { return null; }
|
||||
public static SkinManager$TextureInfo lambda$load$0(MinecraftSessionService sessionService, GameProfile profile) { return null; }
|
||||
public static MinecraftProfileTextures lambda$load$0(SkinManager$CacheKey cacheKey, MinecraftSessionService sessionService) { return null; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class SkinManager$CacheKey {
|
||||
public GameProfile profile() { return null; }
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface SkinManager$ISkinAvailableCallback {
|
||||
void onSkinTextureAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// put into mod jar to prevent https://github.com/cpw/modlauncher/issues/39
|
||||
public interface SkinManager$SkinAvailableCallback {
|
||||
default void skinAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
this.onSkinTextureAvailable(typeIn, location, profileTexture);
|
||||
}
|
||||
|
||||
default void onSkinTextureAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
((SkinManager$ISkinAvailableCallback) this).onSkinTextureAvailable(typeIn, location, profileTexture);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
|
||||
public class SkinManager$TextureCache {
|
||||
private MinecraftProfileTexture.Type type;
|
||||
public CompletableFuture<?> registerTexture(MinecraftProfileTexture texture) { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
public class SkinManager$TextureInfo {
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager {
|
||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) { }
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager$SkinAvailableCallback skinAvailableCallback) { return null; }
|
||||
public void loadProfileTextures(GameProfile profile, SkinManager$SkinAvailableCallback skinAvailableCallback, boolean requireSecure) { }
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) { return null; }
|
||||
public CompletableFuture<?> getOrLoad(GameProfile profile) { return null; }
|
||||
public PlayerSkin getInsecureSkin(GameProfile profile) { return null; }
|
||||
public CompletableFuture<?> registerTextures(UUID uuid, MinecraftProfileTextures textures) { return null; }
|
||||
public void /* lambda$loadProfileTextures$1 */ func_210275_a(GameProfile profile, boolean b, SkinManager$SkinAvailableCallback callback) {}
|
||||
public void /* lambda$null$0 */ func_210276_a(Map<?, ?> map, SkinManager$SkinAvailableCallback callback) {}
|
||||
public static PlayerSkin lambda$registerTextures$1(CompletableFuture<?> skin, String url, CompletableFuture<?> cape, CompletableFuture<?> elytra, PlayerSkin$Model model, MinecraftProfileTextures textures, Void _void) { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.resources.data;
|
||||
|
||||
public class TextureMetadataSection {
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public class ResourceLocation {
|
||||
public ResourceLocation(String path) {}
|
||||
public ResourceLocation(String domain, String path) {}
|
||||
}
|
||||
Loaded 100 of 245 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user