mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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: |
|
||||
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
modtype: [Fabric,Forge-Active,Forge-Legacy]
|
||||
include:
|
||||
-
|
||||
website: ObjectStorage
|
||||
website: TencentCOS
|
||||
modtype: All
|
||||
# -
|
||||
# website: GitHub-Release
|
||||
@@ -99,10 +99,7 @@ jobs:
|
||||
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 "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
|
||||
echo "$(grep "minecraft_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/minecraft_full_versions=//" | sed "s/,/\n/g")" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
-
|
||||
if: startsWith(matrix.website, 'GitHub-')
|
||||
@@ -114,7 +111,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 }}
|
||||
@@ -133,15 +130,15 @@ jobs:
|
||||
EOF
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||
name: "[GitHub Pre-Release] Upload Tag"
|
||||
uses: richardsimko/update-tag@v1.0.7
|
||||
name: 【GitHub Pre-Release】 Upload Tag
|
||||
uses: richardsimko/update-tag@v1
|
||||
with:
|
||||
tag_name: CI-Build
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||
name: "[GitHub Pre-Release] Publish"
|
||||
name: 【GitHub Pre-Release】 Publish
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -154,7 +151,7 @@ jobs:
|
||||
-
|
||||
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 }}
|
||||
@@ -162,16 +159,12 @@ jobs:
|
||||
#generate_release_notes: true
|
||||
files: ${{ steps.cslenv-github.outputs.pathlist }}
|
||||
-
|
||||
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)
|
||||
@@ -180,7 +173,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
|
||||
@@ -192,14 +185,13 @@ jobs:
|
||||
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
|
||||
name: CustomSkinLoader_${{ steps.cslenv.outputs.edition }}_${{ steps.cslenv.outputs.version }}
|
||||
version: ${{ steps.cslenv.outputs.version }}-${{ steps.cslenv.outputs.edition }}
|
||||
version: ${{ steps.cslenv.outputs.version }}
|
||||
version-type: release
|
||||
loaders: ${{ steps.cslenv.outputs.modloader }}
|
||||
game-versions: |
|
||||
${{ steps.cslenv.outputs.minecraft_vers }}
|
||||
game-version-filter: releases
|
||||
java: |
|
||||
${{ steps.cslenv.outputs.java_vers }}
|
||||
java: 8 11 17
|
||||
|
||||
retry-attempts: 2
|
||||
retry-delay: 10000
|
||||
|
||||
+8
-8
@@ -31,7 +31,7 @@ There are the available versions in different environments below:
|
||||
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_ForgeLegacy-${version}.pom`
|
||||
```xml
|
||||
@@ -40,7 +40,7 @@ There are the available versions in different environments below:
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_ForgeLegacy</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>
|
||||
```
|
||||
@@ -51,7 +51,7 @@ There are the available versions in different environments below:
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mods</groupId>
|
||||
<artifactId>CustomSkinLoader_ForgeActive</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>
|
||||
```
|
||||
@@ -62,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>
|
||||
```
|
||||
@@ -71,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 {
|
||||
@@ -85,8 +85,8 @@ There are the available versions in different environments below:
|
||||
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 {
|
||||
@@ -104,7 +104,7 @@ 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"
|
||||
}
|
||||
|
||||
tasks.runClient {
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+21
-18
@@ -8,7 +8,7 @@ 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.Maps;
|
||||
import com.google.gson.Gson;
|
||||
@@ -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(null);
|
||||
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(null);
|
||||
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;
|
||||
return ModelManager0.fromUserProfile(profile);
|
||||
}
|
||||
|
||||
//Core
|
||||
@@ -195,7 +194,8 @@ public class CustomSkinLoader {
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
@@ -230,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;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+20
@@ -7,7 +7,9 @@ import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
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;
|
||||
|
||||
@@ -36,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;
|
||||
@@ -67,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;
|
||||
@@ -146,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) {
|
||||
File renamed without changes.
@@ -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;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -18,7 +19,11 @@ public class FakeInterfaceManager {
|
||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
||||
}
|
||||
|
||||
public static IResourceManager Minecraft_getResourceManager(Object minecraft) {
|
||||
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 {
|
||||
File renamed without changes.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+27
-16
@@ -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://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft").setCacheTime(600).setPayload(GSON.toJson(Collections.singletonList(username))));
|
||||
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 (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(profile.getId())).setCacheTime(90));
|
||||
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,22 +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 || TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(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();
|
||||
}
|
||||
return TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
|
||||
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();
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+8
-7
@@ -3,9 +3,10 @@ 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;
|
||||
@@ -17,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(){
|
||||
@@ -52,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){
|
||||
@@ -74,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);
|
||||
}
|
||||
-34
@@ -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;
|
||||
@@ -75,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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +0,0 @@
|
||||
package com.mojang.authlib;
|
||||
|
||||
public enum SignatureState {
|
||||
UNSIGNED,
|
||||
INVALID,
|
||||
SIGNED
|
||||
}
|
||||
@@ -1,9 +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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,239 +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.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.IFakeSkinManagerCacheKey;
|
||||
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.NativeImage;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
|
||||
public class FakeSkinManager {
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
|
||||
*/
|
||||
public static void setSkinCacheDir(File skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
|
||||
*/
|
||||
public static void setSkinCacheDir(Path skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
|
||||
}
|
||||
|
||||
private static CacheLoader<Object, ?> cacheLoader;
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
|
||||
*/
|
||||
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
|
||||
return cacheLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
params[0] = fakeProfileTexture.getCacheFile();
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
}
|
||||
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, fakeProfileTexture);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* 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 net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 net.minecraft.client.resources.SkinManager$1#lambda$load$0(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 net.minecraft.client.resources.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 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) {
|
||||
IFakeSkinManagerCacheKey fakeCacheKey = (IFakeSkinManagerCacheKey) cacheKey;
|
||||
if (fakeCacheKey.profile() != null) {
|
||||
return cacheKey; // 23w31a ~ 23w41a
|
||||
} else {
|
||||
TextureUtil.AuthlibField.PROPERTY_SIGNATURE.set(fakeCacheKey.packedTextures(), MojangAPILoader.GSON.toJson(profile, GameProfile.class));
|
||||
return fakeCacheKey; // 23w42a+
|
||||
}
|
||||
}
|
||||
|
||||
public static GameProfile unwrapCacheKey(Object cacheKey) {
|
||||
IFakeSkinManagerCacheKey fakeCacheKey = (IFakeSkinManagerCacheKey) cacheKey;
|
||||
if (fakeCacheKey.profile() != null) {
|
||||
return fakeCacheKey.profile(); // 23w31a ~ 23w41a
|
||||
} else {
|
||||
return unwrapProperty(fakeCacheKey.packedTextures()); // 23w42a+
|
||||
}
|
||||
}
|
||||
|
||||
public static GameProfile unwrapProperty(Property property) {
|
||||
return MojangAPILoader.GSON.fromJson((String) TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property), GameProfile.class); // 23w42a+
|
||||
}
|
||||
|
||||
public static Object createMinecraftProfileTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
|
||||
return new MinecraftProfileTextures(textures.get(MinecraftProfileTexture.Type.SKIN), textures.get(MinecraftProfileTexture.Type.CAPE), textures.get(MinecraftProfileTexture.Type.ELYTRA), SignatureState.SIGNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,12 +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,157 +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))
|
||||
return 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 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<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 Maps.newHashMap();
|
||||
}
|
||||
}
|
||||
@@ -1,101 +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.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;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
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 {
|
||||
Field theUnsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafeField.setAccessible(true);
|
||||
Unsafe theUnsafe = (Unsafe) theUnsafeField.get(null);
|
||||
Field implLookupField = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP");
|
||||
return (MethodHandles.Lookup) theUnsafe.getObject(theUnsafe.staticFieldBase(implLookupField), theUnsafe.staticFieldOffset(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("-", "");
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -7,9 +7,6 @@ customskinloader/fake/itf/IFakeIResourceManager customskinloader/fake/itf/IFakeI
|
||||
getResource (Lnet/minecraft/util/ResourceLocation;)Ljava/util/Optional; method_14486
|
||||
customskinloader/fake/itf/IFakeMinecraft customskinloader/fake/itf/IFakeMinecraft
|
||||
func_195551_G ()Lnet/minecraft/resources/IResourceManager; method_1478
|
||||
customskinloader/fake/itf/IFakeSkinManagerCacheKey customskinloader/fake/itf/IFakeSkinManagerCacheKey
|
||||
profile ()Lcom/mojang/authlib/GameProfile; comp_1631
|
||||
packedTextures ()Lcom/mojang/authlib/properties/Property; comp_2011
|
||||
net/minecraft/client/Minecraft net/minecraft/class_310
|
||||
gameDir field_1697
|
||||
getCurrentServerData ()Lnet/minecraft/client/multiplayer/ServerData; method_1558
|
||||
@@ -18,6 +15,7 @@ net/minecraft/client/Minecraft net/minecraft/class_310
|
||||
getSkinManager ()Lnet/minecraft/client/resources/SkinManager; method_1582
|
||||
getTextureManager ()Lnet/minecraft/client/renderer/texture/TextureManager; method_1531
|
||||
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
|
||||
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/class_530
|
||||
net/minecraft/client/multiplayer/ServerData net/minecraft/class_642
|
||||
serverIP field_3761
|
||||
net/minecraft/client/renderer/RenderType net/minecraft/class_1921
|
||||
@@ -52,11 +50,11 @@ net/minecraft/client/resources/IResourceManager net/minecraft/class_3300
|
||||
net/minecraft/client/resources/SkinManager net/minecraft/class_1071
|
||||
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V method_4652
|
||||
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; method_4656
|
||||
net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1
|
||||
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686
|
||||
net/minecraft/client/resources/SkinManager$3 net/minecraft/class_1071$3
|
||||
field_152801_c field_152801_c
|
||||
field_152802_d field_152802_d
|
||||
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
|
||||
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
|
||||
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071$class_8687
|
||||
net/minecraft/resources/IResource net/minecraft/class_3298
|
||||
net/minecraft/resources/IResourceManager net/minecraft/class_3300
|
||||
net/minecraft/util/ResourceLocation net/minecraft/class_2960
|
||||
|
||||
+8
-16
@@ -1,9 +1,16 @@
|
||||
|
||||
jar {
|
||||
exclude 'customskinloader/tweaker/**'
|
||||
exclude 'net/minecraft/client/renderer/RenderType.class'
|
||||
exclude 'net/minecraft/client/renderer/texture/**'
|
||||
exclude 'net/minecraft/client/resources/**'
|
||||
exclude 'net/minecraft/resources/**'
|
||||
exclude 'Profile.json'
|
||||
}
|
||||
sourceJar {
|
||||
exclude 'customskinloader/tweaker/**'
|
||||
exclude 'net/**'
|
||||
exclude 'Profile.json'
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -11,10 +18,6 @@ repositories {
|
||||
name = "fabric"
|
||||
url = "https://maven.fabricmc.net/"
|
||||
}
|
||||
maven {
|
||||
name = "sponge"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -26,18 +29,7 @@ import customskinloader.gradle.util.RemapUtil
|
||||
import customskinloader.gradle.util.SourceUtil
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
apply from: rootProject.file("buildSrc/patch.gradle")
|
||||
patchMixin()
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "mixins.customskinloader.refmap.json"
|
||||
reobfSrgFile = "build/mixin.srg"
|
||||
reobfNotchSrgFile = "build/mixin.srg"
|
||||
}
|
||||
|
||||
SourceUtil.addDependencies project, project(":Common")
|
||||
SourceUtil.addDependencies project, project(":Common"), project(":Vanilla/Common")
|
||||
RemapUtil.remapSources project
|
||||
|
||||
// Resolve snapshot versions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
minecraft_version=1.14
|
||||
minecraft_full_versions=1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21
|
||||
minecraft_full_versions=1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18
|
||||
#forge gradle needs forge version
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
|
||||
+13
-13
@@ -2,17 +2,22 @@ com/mojang/blaze3d/matrix/MatrixStack net/minecraft/class_4587
|
||||
net/minecraft/client/Minecraft net/minecraft/class_310
|
||||
isIntegratedServerRunning ()Z method_1542
|
||||
net/minecraft/client/entity/AbstractClientPlayer net/minecraft/class_742
|
||||
getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; method_3120
|
||||
getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; method_3124
|
||||
net/minecraft/client/gui/Gui net/minecraft/class_332
|
||||
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
|
||||
renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
|
||||
renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
|
||||
renderPlayerlist (Lnet/minecraft/client/gui/Gui;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
|
||||
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/class_530
|
||||
net/minecraft/client/model/ModelRenderer net/minecraft/class_630
|
||||
net/minecraft/client/renderer/IImageBuffer net/minecraft/class_760
|
||||
net/minecraft/client/renderer/IRenderTypeBuffer net/minecraft/class_4597
|
||||
net/minecraft/client/renderer/RenderType net/minecraft/class_1921
|
||||
getEntitySolid (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType; method_23572
|
||||
net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/class_1046
|
||||
bufferedImage field_110560_d
|
||||
textureUploaded field_5215
|
||||
processTask field_20843
|
||||
loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; method_22795
|
||||
processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; method_22798
|
||||
@@ -24,25 +29,20 @@ net/minecraft/client/renderer/entity/layers/LayerCape net/minecraft/class_972
|
||||
doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V method_4177
|
||||
net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011
|
||||
net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060
|
||||
net/minecraft/client/resources/PlayerSkin net/minecraft/class_8685
|
||||
net/minecraft/client/resources/SkinManager net/minecraft/class_1071
|
||||
func_210275_a (Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4653
|
||||
func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655
|
||||
getInsecureSkin (Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin; method_52862
|
||||
getOrLoad (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; method_52863
|
||||
func_229297_b_ (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655
|
||||
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V method_4652
|
||||
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; method_4651
|
||||
loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; method_4654
|
||||
net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1
|
||||
lambda$load$0 (Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo; method_52867
|
||||
lambda$load$0 (Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures; method_54647
|
||||
load (Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture; method_52868
|
||||
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686
|
||||
net/minecraft/client/resources/SkinManager$3 net/minecraft/class_1071$3
|
||||
run ()V run
|
||||
net/minecraft/client/resources/SkinManager$3$1 net/minecraft/class_1071$3$1
|
||||
field_152803_a field_152803_a
|
||||
field_152804_b field_152804_b
|
||||
run ()V run
|
||||
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
|
||||
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071$class_8687
|
||||
type field_45641
|
||||
registerTexture (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture; method_52873
|
||||
net/minecraft/client/resources/SkinManager$TextureInfo net/minecraft/class_1071$class_8688
|
||||
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
|
||||
net/minecraft/scoreboard/ScoreObjective net/minecraft/class_266
|
||||
net/minecraft/scoreboard/Scoreboard net/minecraft/class_269
|
||||
net/minecraft/util/ResourceLocation net/minecraft/class_2960
|
||||
File renamed without changes.
+3
-6
@@ -4,19 +4,16 @@
|
||||
"package": "customskinloader.mixin",
|
||||
"client": [
|
||||
"MixinGuiPlayerTabOverlay",
|
||||
"MixinIImageBuffer",
|
||||
"MixinIResource",
|
||||
"MixinIResourceManager",
|
||||
"MixinLayerCape",
|
||||
"MixinMinecraft",
|
||||
"MixinRenderPlayer",
|
||||
"MixinSkinManager$1",
|
||||
"MixinSkinManager$CacheKey",
|
||||
"MixinSkinManager$TextureCache",
|
||||
"MixinSkinManager",
|
||||
"MixinSkinManager$V1",
|
||||
"MixinSkinManager$V2",
|
||||
"MixinThreadDownloadImageData$V1",
|
||||
"MixinThreadDownloadImageData$V2"
|
||||
"MixinThreadDownloadImageDataV2",
|
||||
"MixinThreadDownloadImageDataV3"
|
||||
],
|
||||
"refmap": "mixins.customskinloader.refmap.json",
|
||||
"plugin": "customskinloader.fabric.MixinConfigPlugin",
|
||||
File renamed without changes.
+5
-9
@@ -55,17 +55,13 @@ public class MixinConfigPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
boolean result = true;
|
||||
if (mixinClassName.endsWith(".MixinIImageBuffer")) {
|
||||
result = this.world_version <= 2204 && this.protocol_version <= 553; // 18w43b ~ 19w37a
|
||||
if (mixinClassName.endsWith(".MixinThreadDownloadImageDataV2")) {
|
||||
result = (this.world_version >= 2205 && this.world_version <= 2722) && ((this.protocol_version >= 554 && this.protocol_version <= 754) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x40000022)); // 19w38a ~ 1.17-rc1
|
||||
} else if (mixinClassName.endsWith(".MixinSkinManager$V2")) {
|
||||
result = this.world_version >= 2205 && this.protocol_version >= 554; // 19w38a+
|
||||
} else if (mixinClassName.endsWith(".MixinLayerCape") || mixinClassName.endsWith(".MixinRenderPlayer")) {
|
||||
result = this.world_version >= 2210 && this.protocol_version >= 558; // 19w41a+
|
||||
} else if (mixinClassName.endsWith(".MixinSkinManager$V1")) {
|
||||
result = this.world_version <= 3465 && (this.protocol_version <= 763 || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x4000008E)); // 18w43b ~ 1.20.1
|
||||
} else if (mixinClassName.endsWith(".MixinSkinManager$V2") || mixinClassName.endsWith(".MixinSkinManager$1") || mixinClassName.endsWith(".MixinSkinManager$CacheKey") || mixinClassName.endsWith(".MixinSkinManager$TextureCache")) {
|
||||
result = this.world_version >= 3567 && ((this.protocol_version > 763 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000090); // 23w31a+
|
||||
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V1")) {
|
||||
result = (this.world_version >= 2205 && this.world_version <= 2722) && ((this.protocol_version >= 554 && this.protocol_version <= 754) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x40000022)); // 19w38a ~ 1.17-rc1
|
||||
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V2")) {
|
||||
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageDataV3")) {
|
||||
result = this.world_version >= 2723 && ((this.protocol_version >= 755 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000023); // 1.17-rc2+
|
||||
}
|
||||
logger.info("target: " + targetClassName + ", mixin: " + mixinClassName + ", result: " + result);
|
||||
@@ -1,10 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import customskinloader.fake.itf.IFakeIImageBuffer;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(IImageBuffer.class)
|
||||
public interface MixinIImageBuffer extends IFakeIImageBuffer {
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import customskinloader.fake.FakeSkinManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager$1;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Group;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@Mixin(SkinManager$1.class)
|
||||
public abstract class MixinSkinManager$1 {
|
||||
@ModifyArgs(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager$1;load(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private void modifyArgs_load(Args args, SkinManager.CacheKey cacheKey) {
|
||||
Object[] argsArr = new Object[args.size()];
|
||||
for (int i = 0; i < argsArr.length; i++) {
|
||||
argsArr[i] = args.get(i);
|
||||
}
|
||||
args.setAll(FakeSkinManager.loadProfileTextures(ImmutableList.copyOf(argsArr), cacheKey));
|
||||
}
|
||||
|
||||
// 23w31a ~ 23w41a
|
||||
@Group(
|
||||
name = "lambda$load$0",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;getTextures(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> redirect_lambda$load$0(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return FakeSkinManager.loadSkinFromCache(sessionService, profile, requireSecure);
|
||||
}
|
||||
|
||||
// 23w42a+
|
||||
@Coerce
|
||||
@Group(
|
||||
name = "lambda$load$0",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;unpackTextures(Lcom/mojang/authlib/properties/Property;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private static Object redirect_lambda$load$0(MinecraftSessionService sessionService, Property property) {
|
||||
return FakeSkinManager.loadSkinFromCache(sessionService, property);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import customskinloader.fake.itf.IFakeSkinManagerCacheKey;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(SkinManager.CacheKey.class)
|
||||
public abstract class MixinSkinManager$CacheKey implements IFakeSkinManagerCacheKey {
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.fake.FakeSkinManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@Mixin(SkinManager.TextureCache.class)
|
||||
public abstract class MixinSkinManager$TextureCache {
|
||||
@Shadow
|
||||
private MinecraftProfileTexture.Type type;
|
||||
|
||||
@ModifyArgs(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;ZLjava/lang/Runnable;)V"
|
||||
)
|
||||
)
|
||||
private void modifyArgs_registerTexture(Args args, MinecraftProfileTexture profileTexture) {
|
||||
Object[] argsArr = new Object[args.size()];
|
||||
for (int i = 0; i < argsArr.length; i++) {
|
||||
argsArr[i] = args.get(i);
|
||||
}
|
||||
argsArr = FakeSkinManager.createThreadDownloadImageData(ImmutableList.copyOf(argsArr), profileTexture, this.type);
|
||||
args.setAll(argsArr);
|
||||
}
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import customskinloader.fake.FakeSkinManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Group;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@SuppressWarnings("target")
|
||||
public abstract class MixinSkinManager {
|
||||
// 18w43b ~ 1.20.1
|
||||
@Mixin(SkinManager.class)
|
||||
public abstract static class V1 {
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void inject_init(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService, CallbackInfo callbackInfo) {
|
||||
FakeSkinManager.setSkinCacheDir(skinCacheDirectory);
|
||||
}
|
||||
|
||||
// 18w43b ~ 19w37a
|
||||
@Group(
|
||||
name = "modifyArgs_loadSkin",
|
||||
min = 1
|
||||
)
|
||||
@ModifyArgs(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/IImageBuffer;)V"
|
||||
)
|
||||
)
|
||||
private void modifyArgs_loadSkin_0(Args args, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
Object[] argsArr = new Object[args.size()];
|
||||
for (int i = 0; i < argsArr.length; i++) {
|
||||
argsArr[i] = args.get(i);
|
||||
}
|
||||
argsArr = FakeSkinManager.createThreadDownloadImageData(ImmutableList.copyOf(argsArr), profileTexture, textureType);
|
||||
args.setAll(argsArr);
|
||||
}
|
||||
|
||||
// 19w38a ~ 1.20.1
|
||||
@Group(
|
||||
name = "modifyArgs_loadSkin",
|
||||
min = 1
|
||||
)
|
||||
@ModifyArgs(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;ZLjava/lang/Runnable;)V"
|
||||
)
|
||||
)
|
||||
private void modifyArgs_loadSkin_1(Args args, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
this.modifyArgs_loadSkin_0(args, profileTexture, textureType, skinAvailableCallback);
|
||||
}
|
||||
|
||||
// 18w43b ~ 19w37a
|
||||
@Group(
|
||||
name = "redirect_loadProfileTextures",
|
||||
min = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/concurrent/ExecutorService;submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private Future<?> redirect_loadProfileTextures_0(ExecutorService executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
|
||||
FakeSkinManager.loadProfileTextures(task, profile);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 19w38a ~ 1.18-exp7
|
||||
@Group(
|
||||
name = "redirect_loadProfileTextures",
|
||||
min = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/concurrent/Executor;execute(Ljava/lang/Runnable;)V",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private void redirect_loadProfileTextures_1(Executor executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
|
||||
FakeSkinManager.loadProfileTextures(task, profile);
|
||||
}
|
||||
|
||||
// 21w37a ~ 1.20.1
|
||||
@Group(
|
||||
name = "redirect_loadProfileTextures",
|
||||
min = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/concurrent/ExecutorService;execute(Ljava/lang/Runnable;)V",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private void redirect_loadProfileTextures_2(ExecutorService executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
|
||||
FakeSkinManager.loadProfileTextures(task, profile);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;loadSkinFromCache(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void inject_loadSkinFromCache(GameProfile profile, CallbackInfoReturnable<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> callbackInfoReturnable) {
|
||||
callbackInfoReturnable.setReturnValue(FakeSkinManager.loadSkinFromCache(profile));
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;func_210275_a(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;getTextures(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> redirect_func_210275_a(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return FakeSkinManager.getUserProfile(sessionService, profile, requireSecure);
|
||||
}
|
||||
|
||||
// 18w43b ~ 19w37a
|
||||
@Group(
|
||||
name = "loadElytraTexture",
|
||||
min = 1
|
||||
)
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;func_210276_a(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Map;containsKey(Ljava/lang/Object;)Z",
|
||||
ordinal = 0,
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private void inject_func_210276_a(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback, CallbackInfo callbackInfo) {
|
||||
FakeSkinManager.loadElytraTexture((SkinManager) (Object) this, map, skinAvailableCallback);
|
||||
}
|
||||
|
||||
// 19w38a ~ 1.20.1
|
||||
@Group(
|
||||
name = "loadElytraTexture",
|
||||
min = 1
|
||||
)
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;func_210276_a(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/google/common/collect/ImmutableList;of(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private ImmutableList<MinecraftProfileTexture.Type> redirect_func_229297_b_(Object e1, Object e2) {
|
||||
return ImmutableList.copyOf(MinecraftProfileTexture.Type.values());
|
||||
}
|
||||
}
|
||||
|
||||
// 23w31a+
|
||||
@Mixin(SkinManager.class)
|
||||
public abstract static class V2 {
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void inject_init(TextureManager textureManager, Path path, MinecraftSessionService minecraftSessionService, Executor executor, CallbackInfo callbackInfo) {
|
||||
FakeSkinManager.setSkinCacheDir(path);
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/google/common/cache/CacheBuilder;build(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private CacheLoader<Object, ?> modifyArg_init(CacheLoader<Object, ?> cacheLoader) {
|
||||
return FakeSkinManager.setCacheLoader(cacheLoader);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;getInsecureSkin(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin;",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void inject_getInsecureSkin(GameProfile profile, CallbackInfoReturnable<?> callbackInfoReturnable) {
|
||||
FakeSkinManager.setSkullType(profile);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/google/common/cache/LoadingCache;getUnchecked(Ljava/lang/Object;)Ljava/lang/Object;",
|
||||
remap = false
|
||||
)
|
||||
)
|
||||
private Object redirect_getOrLoad(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
|
||||
return FakeSkinManager.loadCache(loadingCache, cacheKey, profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package customskinloader.mixin;
|
||||
|
||||
import customskinloader.fake.FakeSkinBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@SuppressWarnings("target")
|
||||
public abstract class MixinThreadDownloadImageData {
|
||||
@Mixin(ThreadDownloadImageData.class) // 19w38a ~ 1.17-rc1
|
||||
public abstract static class V1 {
|
||||
@Final
|
||||
@Shadow
|
||||
private Runnable processTask;
|
||||
|
||||
@Shadow
|
||||
private static NativeImage processLegacySkin(NativeImage nativeImageIn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;loadTexture(Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;processLegacySkin(Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;"
|
||||
)
|
||||
)
|
||||
private NativeImage redirect_loadTexture(NativeImage image) {
|
||||
return FakeSkinBuffer.processLegacySkin(image, this.processTask, MixinThreadDownloadImageData.V1::processLegacySkin);
|
||||
}
|
||||
}
|
||||
|
||||
@Mixin(ThreadDownloadImageData.class) // 1.17-rc2+
|
||||
public abstract static class V2 {
|
||||
@Final
|
||||
@Shadow
|
||||
private Runnable processTask;
|
||||
|
||||
@Shadow
|
||||
abstract NativeImage processLegacySkin(NativeImage nativeImageIn);
|
||||
|
||||
@Redirect(
|
||||
method = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;loadTexture(Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;processLegacySkin(Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;"
|
||||
)
|
||||
)
|
||||
private NativeImage redirect_loadTexture(ThreadDownloadImageData _this, NativeImage image) {
|
||||
return FakeSkinBuffer.processLegacySkin(image, this.processTask, this::processLegacySkin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
public class SkinManager$1 {
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
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) { return null; }
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final MinecraftProfileTexture.Type textureType, final SkinManager.SkinAvailableCallback skinAvailableCallback) { return null; }
|
||||
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) { }
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) { return null; }
|
||||
|
||||
public interface SkinAvailableCallback {
|
||||
void skinAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
|
||||
}
|
||||
|
||||
public static class TextureCache {
|
||||
|
||||
}
|
||||
|
||||
public static class CacheKey {
|
||||
public GameProfile profile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,6 @@ customskinloader/fake/itf/IFakeIResourceManager customskinloader/fake/itf/IFakeI
|
||||
getResource (Lnet/minecraft/util/ResourceLocation;)Ljava/util/Optional; m_213713_
|
||||
customskinloader/fake/itf/IFakeMinecraft customskinloader/fake/itf/IFakeMinecraft
|
||||
func_195551_G ()Lnet/minecraft/resources/IResourceManager; m_91098_
|
||||
customskinloader/fake/itf/IFakeSkinManagerCacheKey customskinloader/fake/itf/IFakeSkinManagerCacheKey
|
||||
profile ()Lcom/mojang/authlib/GameProfile; f_290972_
|
||||
packedTextures ()Lcom/mojang/authlib/properties/Property; f_303729_
|
||||
net/minecraft/client/Minecraft net/minecraft/client/Minecraft
|
||||
gameDir f_91069_
|
||||
getCurrentServerData ()Lnet/minecraft/client/multiplayer/ServerData; m_91089_
|
||||
@@ -18,6 +15,7 @@ net/minecraft/client/Minecraft net/minecraft/client/Minecraft
|
||||
getSkinManager ()Lnet/minecraft/client/resources/SkinManager; m_91109_
|
||||
getTextureManager ()Lnet/minecraft/client/renderer/texture/TextureManager; m_91097_
|
||||
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/client/gui/components/PlayerTabOverlay
|
||||
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/client/gui/spectator/PlayerMenuItem
|
||||
net/minecraft/client/multiplayer/ServerData net/minecraft/client/multiplayer/ServerData
|
||||
serverIP f_105363_
|
||||
net/minecraft/client/renderer/RenderType net/minecraft/client/renderer/RenderType
|
||||
@@ -52,11 +50,11 @@ net/minecraft/client/resources/IResourceManager net/minecraft/server/packs/resou
|
||||
net/minecraft/client/resources/SkinManager net/minecraft/client/resources/SkinManager
|
||||
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V m_118817_
|
||||
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; m_118825_
|
||||
net/minecraft/client/resources/SkinManager$1 net/minecraft/client/resources/SkinManager$1
|
||||
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/client/resources/SkinManager$CacheKey
|
||||
net/minecraft/client/resources/SkinManager$3 net/minecraft/client/resources/SkinManager$3
|
||||
field_152801_c field_152801_c
|
||||
field_152802_d field_152802_d
|
||||
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/client/resources/SkinManager$SkinTextureCallback
|
||||
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V m_118856_
|
||||
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/client/resources/SkinManager$TextureCache
|
||||
net/minecraft/resources/IResource net/minecraft/server/packs/resources/Resource
|
||||
net/minecraft/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager
|
||||
net/minecraft/util/ResourceLocation net/minecraft/resources/ResourceLocation
|
||||
|
||||
@@ -6,7 +6,10 @@ jar {
|
||||
])
|
||||
}
|
||||
|
||||
exclude 'net/minecraft/client/renderer/RenderType.class'
|
||||
exclude 'net/minecraft/client/renderer/texture/**'
|
||||
exclude 'net/minecraft/client/resources/**'
|
||||
exclude 'net/minecraft/resources/**'
|
||||
}
|
||||
sourceJar {
|
||||
exclude 'com/**'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
minecraft_version=1.17.1
|
||||
minecraft_full_versions=1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4
|
||||
java_full_versions=16,17,18,19,20,21
|
||||
minecraft_full_versions=1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1
|
||||
java_full_versions=16,17,18
|
||||
#forge gradle needs forge version
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+38
-131
@@ -3,6 +3,7 @@ var Handle = getJavaType('org.objectweb.asm.Handle');
|
||||
var Opcodes = getJavaType('org.objectweb.asm.Opcodes');
|
||||
var Type = getJavaType('org.objectweb.asm.Type');
|
||||
var FieldInsnNode = getJavaType('org.objectweb.asm.tree.FieldInsnNode');
|
||||
var FieldNode = getJavaType('org.objectweb.asm.tree.FieldNode');
|
||||
var InsnNode = getJavaType('org.objectweb.asm.tree.InsnNode');
|
||||
var IntInsnNode = getJavaType('org.objectweb.asm.tree.IntInsnNode');
|
||||
var InvokeDynamicInsnNode = getJavaType('org.objectweb.asm.tree.InvokeDynamicInsnNode');
|
||||
@@ -34,28 +35,42 @@ function initializeCoreMod() {
|
||||
'name': 'net/minecraft/client/resources/SkinManager'
|
||||
},
|
||||
'transformer': function (cn) {
|
||||
cn.fields.removeIf(function (fn) {
|
||||
return fn.name.equals("fakeManager") && fn.desc.equals("Lcustomskinloader/fake/FakeSkinManager;");
|
||||
});
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
|
||||
|
||||
cn.methods.forEach(function (mn) {
|
||||
if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")) { // 1.20.1-
|
||||
if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.RETURN) {
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/io/File;)V", false));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 3));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESPECIAL, "customskinloader/fake/FakeSkinManager", "<init>", "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
|
||||
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V")) { // 1.20.2+
|
||||
} else if (checkName(mn.name, "m_118828_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/ResourceLocation;")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.RETURN) {
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/nio/file/Path;)V", false));
|
||||
} else if (node.getOpcode() === Opcodes.INVOKEVIRTUAL && node.owner.equals("com/google/common/cache/CacheBuilder") && checkName(node.name, "build") && node.desc.equals("(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;")) {
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setCacheLoader", "(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/CacheLoader;", false));
|
||||
if ((node.getOpcode() === Opcodes.INVOKESPECIAL && node.owner.equals("net/minecraft/resources/ResourceLocation") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/lang/String;)V")) // 1.19-
|
||||
|| (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("net/minecraft/client/resources/SkinManager") && checkName(node.name, "m_242632_") && node.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;"))) { // 1.19.1+
|
||||
mn.instructions.insert(node, node = new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insert(node, node = new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setResourceLocation", "(Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Lnet/minecraft/resources/ResourceLocation;", false));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_118828_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/ResourceLocation;")) { // 1.20.1-
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("net/minecraft/client/resources/SkinManager$SkinTextureCallback") && checkName(node.name, "onSkinTextureAvailable") && node.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V")) {
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 5));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcustomskinloader/fake/FakeSkinManager;Lnet/minecraft/resources/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
|
||||
}
|
||||
|
||||
if (node.getOpcode() === Opcodes.INVOKESPECIAL && (node.owner.equals("net/minecraft/client/renderer/texture/HttpTexture") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/resources/ResourceLocation;ZLjava/lang/Runnable;)V"))) {
|
||||
var s = "(";
|
||||
var args = Type.getType(node.desc).getArgumentTypes();
|
||||
@@ -66,9 +81,12 @@ function initializeCoreMod() {
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)[Ljava/lang/Object;", false));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 3));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcustomskinloader/fake/FakeSkinManager;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)[Ljava/lang/Object;", false));
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
|
||||
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
|
||||
@@ -84,7 +102,7 @@ function initializeCoreMod() {
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_118817_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V")) { // 1.20.1-
|
||||
} else if (checkName(mn.name, "m_118817_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE
|
||||
@@ -96,7 +114,7 @@ function initializeCoreMod() {
|
||||
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;Lcom/mojang/authlib/GameProfile;)V", false));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
|
||||
} else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "getTextures") && node.desc.equals("(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;")) {
|
||||
@@ -104,7 +122,7 @@ function initializeCoreMod() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
|
||||
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("com/google/common/collect/ImmutableList") && checkName(node.name, "of") && node.desc.equals("(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;")) {
|
||||
@@ -113,87 +131,18 @@ function initializeCoreMod() {
|
||||
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "copyOf", "([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;"))
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_118815_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")) { // 1.20.1-
|
||||
} else if (checkName(mn.name, "m_118815_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")) {
|
||||
var first = mn.instructions.getFirst();
|
||||
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(first, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
mn.instructions.insertBefore(first, new InsnNode(Opcodes.ARETURN));
|
||||
} else if (checkName(mn.name, "m_293307_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin;")) { // 1.20.2+
|
||||
var first = mn.instructions.getFirst();
|
||||
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkullType", "(Lcom/mojang/authlib/GameProfile;)V", false));
|
||||
} else if (checkName(mn.name, "m_293351_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;")) { // 1.20.2+
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/google/common/cache/LoadingCache") && checkName(node.name, "getUnchecked") && node.desc.equals("(Ljava/lang/Object;)Ljava/lang/Object;")) {
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadCache", "(Lcom/google/common/cache/LoadingCache;Ljava/lang/Object;Lcom/mojang/authlib/GameProfile;)Ljava/lang/Object;", false));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return cn;
|
||||
}
|
||||
},
|
||||
'SkinManager$1Transformer': { // 1.20.2+
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
'name': 'net/minecraft/client/resources/SkinManager$1'
|
||||
},
|
||||
'transformer': function (cn) {
|
||||
cn.methods.forEach(function (mn) {
|
||||
if (checkName(mn.name, "load") && mn.desc.equals("(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;")) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("java/util/concurrent/CompletableFuture") && checkName(node.name, "supplyAsync") && node.desc.equals("(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) {
|
||||
var s = "(";
|
||||
var args = Type.getType(node.desc).getArgumentTypes();
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
s = s + "Ljava/lang/Object;";
|
||||
}
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Lcom/google/common/collect/ImmutableList;Ljava/lang/Object;)[Ljava/lang/Object;", false));
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
|
||||
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.AALOAD));
|
||||
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, args[i].getInternalName()));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
|
||||
}
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_293645_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;")) { // 1.20.2
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "getTextures") && node.desc.equals("(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;")) {
|
||||
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;", false));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_304063_") && mn.desc.equals("(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;")) { // 1.20.3+
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "unpackTextures") && node.desc.equals("(Lcom/mojang/authlib/properties/Property;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;")) {
|
||||
mn.instructions.insert(node, new TypeInsnNode(Opcodes.CHECKCAST, "com/mojang/authlib/minecraft/MinecraftProfileTextures"));
|
||||
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/properties/Property;)Ljava/lang/Object;", false));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return cn;
|
||||
}
|
||||
},
|
||||
'SkinManager$CacheKeyTransformer': { // 1.20.2+
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
'name': 'net/minecraft/client/resources/SkinManager$CacheKey'
|
||||
},
|
||||
'transformer': function (cn) {
|
||||
cn.interfaces.add("customskinloader/fake/itf/IFakeSkinManagerCacheKey");
|
||||
return cn;
|
||||
}
|
||||
},
|
||||
'IResourceTransformer': {
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
@@ -248,48 +197,6 @@ function initializeCoreMod() {
|
||||
}
|
||||
},
|
||||
|
||||
'SkinManager$TextureCacheTransformer': { // 1.20.2+
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'net/minecraft/client/resources/SkinManager$TextureCache',
|
||||
'methodName': 'm_294542_',
|
||||
'methodDesc': '(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;'
|
||||
},
|
||||
'transformer': function (mn) {
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKESPECIAL && (node.owner.equals("net/minecraft/client/renderer/texture/HttpTexture") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/resources/ResourceLocation;ZLjava/lang/Runnable;)V"))) {
|
||||
var s = "(";
|
||||
var args = Type.getType(node.desc).getArgumentTypes();
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
s = s + "Ljava/lang/Object;";
|
||||
}
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager$TextureCache", mapName("f_291290_"), "Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;"));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)[Ljava/lang/Object;", false));
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
|
||||
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.AALOAD));
|
||||
if (args[i].getInternalName().equals("Z")) {
|
||||
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Boolean"));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false));
|
||||
} else {
|
||||
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, args[i].getInternalName()));
|
||||
}
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
|
||||
}
|
||||
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
|
||||
}
|
||||
}
|
||||
return mn;
|
||||
}
|
||||
},
|
||||
'HttpTextureTransformer': {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,9 +6,10 @@ jar {
|
||||
"TweakOrder": -10
|
||||
])
|
||||
}
|
||||
|
||||
exclude 'net/minecraft/client/renderer/texture/**'
|
||||
exclude 'net/minecraft/client/resources/SkinManager.class'
|
||||
exclude 'net/minecraft/client/resources/SkinManager$ISkinAvailableCallback.class'
|
||||
exclude 'net/minecraft/resources/**'
|
||||
}
|
||||
sourceJar {
|
||||
exclude 'net/**'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
minecraft_version=1.12.2
|
||||
minecraft_full_versions=1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18
|
||||
#forge gradle needs forge version
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 172 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user