mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 03:52:15 +00:00
1 parent
a9b2484b3e
commit
1cb4cf40b0
93 files changed
+762
-181
No files matched your search
@@ -4,6 +4,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.cache.CacheLoader;
|
||||
@@ -17,6 +19,7 @@ import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeThreadDownloadImageData;
|
||||
import customskinloader.loader.MojangAPILoader;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
@@ -25,18 +28,26 @@ 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.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.PlayerSkin$Model;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager$1;
|
||||
import net.minecraft.client.resources.SkinManager$CacheKey;
|
||||
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||
import net.minecraft.client.resources.SkinManager$TextureCache;
|
||||
|
||||
public class FakeSkinManager {
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager(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)}
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static void setSkinCacheDir(Path skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
|
||||
@@ -44,13 +55,15 @@ public class FakeSkinManager {
|
||||
|
||||
private static CacheLoader<Object, ?> cacheLoader;
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
|
||||
return cacheLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Property createProperty(Property property) {
|
||||
@@ -58,6 +71,7 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
|
||||
@@ -65,17 +79,31 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||
*
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
params[0] = fakeProfileTexture.getCacheFile();
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
File cacheFile = fakeProfileTexture.getCacheFile();
|
||||
if (params.length == 4) {
|
||||
if (params[3] instanceof Boolean) { // 24w46a+
|
||||
FakeInterfaceManager.ResourceLocation_setTexture(params[0], FakeThreadDownloadImageData.createTexture(params[0], cacheFile.toPath(), params[2], false, new BaseBuffer(null, textureType, fakeProfileTexture)));
|
||||
params[1] = cacheFile.toPath();
|
||||
params[3] = false;
|
||||
} else { // 19w37a-
|
||||
params[0] = cacheFile;
|
||||
params[3] = new BaseBuffer((Runnable) params[3], textureType, fakeProfileTexture);
|
||||
}
|
||||
} else if (params.length == 5) { // 19w38a ~ 24w45a
|
||||
params[0] = cacheFile;
|
||||
params[3] = true;
|
||||
params[4] = new BaseBuffer((Runnable) params[4], textureType, fakeProfileTexture);
|
||||
}
|
||||
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, fakeProfileTexture);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
@@ -83,7 +111,8 @@ public class FakeSkinManager {
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> {
|
||||
@@ -95,7 +124,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.SkinManager$CacheKey)
|
||||
* Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)}
|
||||
*/
|
||||
public static Object[] loadProfileTextures(ImmutableList<Object> list, Object cacheKey) {
|
||||
Object[] params = list.toArray();
|
||||
@@ -115,16 +144,18 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$null$0(Map, SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210276_a(Map, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
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)) {
|
||||
@@ -133,6 +164,18 @@ public class FakeSkinManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 24w46a+
|
||||
* Invoked from {@link SkinManager#lambda$registerTextures$1(CompletableFuture, String, CompletableFuture, CompletableFuture, PlayerSkin$Model, MinecraftProfileTextures, Void)}
|
||||
*/
|
||||
public static PlayerSkin$Model loadSkinModel(PlayerSkin$Model model, MinecraftProfileTextures textures) {
|
||||
MinecraftProfileTexture texture = textures.skin();
|
||||
if (texture != null) {
|
||||
model = PlayerSkin$Model.byName(texture.getMetadata("model"));
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private final static String SKULL_KEY = "CSL$IsSkull";
|
||||
/**
|
||||
* 23w31a+
|
||||
@@ -149,7 +192,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w31a ~ 23w41a
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(GameProfile)
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
if (profile.getProperties().containsKey(SKULL_KEY)) {
|
||||
@@ -162,7 +205,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(SkinManager.CacheKey, MinecraftSessionService)
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, MinecraftSessionService)}
|
||||
*/
|
||||
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) {
|
||||
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false));
|
||||
|
||||
Reference in new issue
Block a user