mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-18 13:49:16 +00:00
Support 1.20.2. (#266)
This commit is contained in:
1 parent
d5ae6226ae
commit
b8ca913848
27 files changed
+830
-446
No files matched your search
@@ -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.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
@@ -49,8 +49,7 @@ public class CustomSkinLoader {
|
||||
private static final ProfileCache profileCache = new ProfileCache();
|
||||
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
||||
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(
|
||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
public 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();
|
||||
@@ -71,26 +70,28 @@ public class CustomSkinLoader {
|
||||
THREAD_POOL.execute(runnable);
|
||||
}
|
||||
|
||||
public static void loadProfileLazily(
|
||||
GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
|
||||
public static Object loadProfileLazily(GameProfile gameProfile, Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> function) {
|
||||
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.");
|
||||
consumer.accept(Maps.newHashMap());
|
||||
return;
|
||||
return function.apply(Maps.newHashMap());
|
||||
}
|
||||
String tempName = Thread.currentThread().getName();
|
||||
Thread.currentThread().setName(username); // Change Thread Name
|
||||
if (profileCache.isLoading(credential)) {
|
||||
profileCache.putLoader(credential, consumer);
|
||||
profileCache.putLoader(credential, function);
|
||||
Thread.currentThread().setName(tempName);
|
||||
return;
|
||||
return function.apply(Maps.newHashMap());
|
||||
}
|
||||
consumer.accept(loadProfile(gameProfile));
|
||||
Object result = function.apply(loadProfile(gameProfile));
|
||||
Thread.currentThread().setName(tempName);
|
||||
profileCache.getLastLoader(credential).ifPresent(c -> loadProfileLazily(gameProfile, c));
|
||||
Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> func = profileCache.getLastLoader(credential);
|
||||
if (func != null) {
|
||||
result = loadProfileLazily(gameProfile, func);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//For User Skin
|
||||
@@ -194,8 +195,7 @@ 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,12 +230,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,20 @@ 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 final HttpTextureUtil.HttpTextureInfo info;
|
||||
private final Map<String, String> metadata;
|
||||
private ResourceLocation resourceLocation;
|
||||
|
||||
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
||||
super(url, metadata);
|
||||
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public void setResourceLocation(ResourceLocation resourceLocation) {
|
||||
@@ -30,8 +31,10 @@ public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
||||
return this.info.url;
|
||||
}
|
||||
|
||||
public String getRawUrl() {
|
||||
return super.getUrl();
|
||||
public void setModule(String module) {
|
||||
if (this.metadata != null) {
|
||||
this.metadata.put("module", module);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,39 +2,63 @@ package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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.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 com.mojang.authlib.properties.Property;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
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 static Map<ResourceLocation, MinecraftProfileTexture> MODEL_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<ResourceLocation, MinecraftProfileTexture> modelCache = new ConcurrentHashMap<>();
|
||||
|
||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||
this.textureManager = textureManagerInstance;
|
||||
/**
|
||||
* 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#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
* 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) throws Exception {
|
||||
return cacheLoader.load(cacheKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
*/
|
||||
public static ResourceLocation setResourceLocation(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
@@ -44,19 +68,19 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.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);
|
||||
public static MinecraftProfileTexture getModelCache(MinecraftProfileTexture profileTexture, ResourceLocation location) {
|
||||
return MODEL_CACHE.getOrDefault(location, profileTexture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, FakeSkinManager fakeManager, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback 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;
|
||||
@@ -66,7 +90,7 @@ public class FakeSkinManager {
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
}
|
||||
params[params.length - 1] = fakeManager.new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, fakeProfileTexture);
|
||||
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, resourcelocation, fakeProfileTexture);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
@@ -75,7 +99,7 @@ public class FakeSkinManager {
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinAvailableCallback, boolean)}
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
@@ -83,9 +107,31 @@ public class FakeSkinManager {
|
||||
// This is a hack.
|
||||
((Multimap) profile.getProperties()).put(KEY, m);
|
||||
runnable.run();
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.SkinManager$CacheKey, GameProfile)
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Object[] loadProfileTextures(ImmutableList<Object> list, GameProfile profile) {
|
||||
Object[] params = list.toArray();
|
||||
if (!profile.getProperties().containsKey(SKULL_KEY)) {
|
||||
final Supplier<?> supplier = (Supplier<?>) params[0];
|
||||
params[0] = (Supplier<?>) () -> CustomSkinLoader.loadProfileLazily(profile, m -> {
|
||||
// This is a hack.
|
||||
((Multimap) profile.getProperties()).put(KEY, m);
|
||||
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)}
|
||||
*/
|
||||
@@ -107,74 +153,80 @@ public class FakeSkinManager {
|
||||
}
|
||||
}
|
||||
|
||||
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 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"));
|
||||
}
|
||||
|
||||
private static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||
if (callback != null)
|
||||
callback.skinAvailable(type, location, texture);
|
||||
/**
|
||||
* 23w31a+
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||
}
|
||||
|
||||
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
|
||||
return texture != null && "auto".equals(texture.getMetadata("model"));
|
||||
}
|
||||
|
||||
private class BaseBuffer implements IImageBuffer {
|
||||
private static class BaseBuffer implements IImageBuffer {
|
||||
private IImageBuffer buffer;
|
||||
|
||||
private SkinManager.SkinAvailableCallback callback;
|
||||
private MinecraftProfileTexture.Type type;
|
||||
private ResourceLocation location;
|
||||
private FakeMinecraftProfileTexture texture;
|
||||
private final Runnable callback;
|
||||
private final ResourceLocation location;
|
||||
private final FakeMinecraftProfileTexture texture;
|
||||
|
||||
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, FakeMinecraftProfileTexture texture) {
|
||||
public BaseBuffer(Runnable 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;
|
||||
}
|
||||
|
||||
@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
|
||||
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);
|
||||
texture.setModule(type);
|
||||
MODEL_CACHE.put(location, texture);
|
||||
}
|
||||
}
|
||||
|
||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
||||
if (this.callback != null) {
|
||||
this.callback.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
|
||||
public interface IFakeIImageBuffer extends Runnable {
|
||||
@Override
|
||||
default void run() {
|
||||
((IImageBuffer) this).skinAvailable();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ 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;
|
||||
|
||||
@@ -111,8 +112,7 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
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
|
||||
@@ -120,10 +120,7 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||
new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft")
|
||||
.setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username)))
|
||||
);
|
||||
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;
|
||||
}
|
||||
@@ -153,23 +150,18 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
return null;
|
||||
}
|
||||
UUID id = profile.getId();
|
||||
return standard ? id.toString() : UUIDTypeAdapter.fromUUID(id);
|
||||
return standard ? id.toString() : TextureUtil.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/"
|
||||
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(profile.getId())).setCacheTime(90));
|
||||
if (StringUtils.isEmpty(responce.content)) {
|
||||
return profile;
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||
.create();
|
||||
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());
|
||||
@@ -185,23 +177,23 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
||||
if (textureProperty == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
String value = textureProperty.getValue();
|
||||
String value = TextureUtil.getPropertyValue(textureProperty);
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
MinecraftTexturesPayload result = gson.fromJson(json, MinecraftTexturesPayload.class);
|
||||
if (result == null || result.getTextures() == null) {
|
||||
|
||||
if (result == null || TextureUtil.getMinecraftTexturesPayloadTextures(result) == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
return result.getTextures();
|
||||
return TextureUtil.getMinecraftTexturesPayloadTextures(result);
|
||||
}
|
||||
|
||||
@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
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
package customskinloader.profile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
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;
|
||||
|
||||
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 static class SkullTexture {
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
||||
public String index;//Index File
|
||||
public ArrayList<String> skins;
|
||||
public int interval;
|
||||
@@ -39,121 +38,119 @@ public class DynamicSkullManager {
|
||||
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){
|
||||
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.<Type, MinecraftProfileTexture>newHashMap());
|
||||
if (textureProperty == null) {
|
||||
staticTextures.put(profile, Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
String value=textureProperty.getValue();
|
||||
if(StringUtils.isBlank(value)){
|
||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||
String value = TextureUtil.getPropertyValue(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.<Type, MinecraftProfileTexture>newHashMap());
|
||||
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(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)){
|
||||
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)
|
||||
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());
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
||||
|
||||
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)){
|
||||
|
||||
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){
|
||||
File skinFile = new File(CustomSkinLoader.DATA_DIR, skin);
|
||||
if (skinFile.isFile() && skinFile.length() > 0) {
|
||||
//Skin found
|
||||
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
|
||||
String fakeUrl = HttpTextureUtil.getLocalFakeUrl(skin);
|
||||
result.skins.set(i, fakeUrl);
|
||||
}else{
|
||||
} else {
|
||||
//Could not find skin
|
||||
result.skins.remove(i--);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//Online Skin
|
||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
||||
if(!responce.success){
|
||||
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
|
||||
|
||||
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));
|
||||
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))
|
||||
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())
|
||||
File skinFile = new File(CustomSkinLoader.DATA_DIR, skinUrl);
|
||||
if (!skinFile.isFile())
|
||||
return Maps.newHashMap();
|
||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||
textures.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||
return textures;
|
||||
}
|
||||
|
||||
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
||||
if(staticTextures.get(profile)!=null)
|
||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTexture(final GameProfile profile) {
|
||||
if (staticTextures.get(profile) != null)
|
||||
return staticTextures.get(profile);
|
||||
if(loadingList.contains(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));
|
||||
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(){
|
||||
public void run(){
|
||||
parseGameProfile(profile);//Load in thread
|
||||
loadingList.remove(profile);
|
||||
}
|
||||
};
|
||||
loadThread.setName("Skull "+profile.hashCode());
|
||||
Thread loadThread = new Thread(() -> {
|
||||
parseGameProfile(profile);//Load in thread
|
||||
loadingList.remove(profile);
|
||||
});
|
||||
loadThread.setName("Skull " + profile.hashCode());
|
||||
loadThread.start();
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@ 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.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
@@ -18,7 +17,7 @@ public class ProfileCache {
|
||||
|
||||
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
|
||||
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
|
||||
private Map<String, Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>>> profileLoaders = new ConcurrentHashMap<>();
|
||||
private Map<String, Deque<Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?>>> profileLoaders = new ConcurrentHashMap<>();
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public ProfileCache(){
|
||||
@@ -53,12 +52,12 @@ public class ProfileCache {
|
||||
return localProfiles.get(username.toLowerCase());
|
||||
return loadLocalProfile(username);
|
||||
}
|
||||
public Optional<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> getLastLoader(String username) {
|
||||
Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> deque = this.profileLoaders.get(username);
|
||||
public Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> getLastLoader(String username) {
|
||||
Deque<Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?>> deque = this.profileLoaders.get(username);
|
||||
if (deque != null) {
|
||||
return Optional.ofNullable(deque.pollLast());
|
||||
return deque.pollLast();
|
||||
}
|
||||
return Optional.empty();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLoading(String username,boolean loading){
|
||||
@@ -75,7 +74,7 @@ public class ProfileCache {
|
||||
return;
|
||||
saveLocalProfile(username,profile);
|
||||
}
|
||||
public void putLoader(String username, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> loader) {
|
||||
public void putLoader(String username, Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> loader) {
|
||||
this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>());
|
||||
this.profileLoaders.get(username).offerLast(loader);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package customskinloader.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||
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
|
||||
@@ -30,4 +36,42 @@ public class TextureUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
private final static Field VALUE_FIELD;
|
||||
private final static Field TEXTURES_FIELD;
|
||||
|
||||
static {
|
||||
try {
|
||||
VALUE_FIELD = Property.class.getDeclaredField("value");
|
||||
VALUE_FIELD.setAccessible(true);
|
||||
TEXTURES_FIELD = MinecraftTexturesPayload.class.getDeclaredField("textures");
|
||||
TEXTURES_FIELD.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPropertyValue(Property property) {
|
||||
try {
|
||||
return (String) VALUE_FIELD.get(property);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getMinecraftTexturesPayloadTextures(MinecraftTexturesPayload payload) {
|
||||
try {
|
||||
return (Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>) TEXTURES_FIELD.get(payload);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromUUID(UUID value) {
|
||||
return value.toString().replace("-", "");
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,13 @@ 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 Runnable {
|
||||
public interface IImageBuffer extends IFakeIImageBuffer {
|
||||
BufferedImage parseUserSkin(BufferedImage image);
|
||||
|
||||
NativeImage func_195786_a(NativeImage image);
|
||||
|
||||
void skinAvailable();
|
||||
|
||||
@Override
|
||||
default void run() {
|
||||
this.skinAvailable();
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -15,7 +15,6 @@ 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
|
||||
@@ -50,11 +49,12 @@ 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$3 net/minecraft/class_1071$3
|
||||
field_152801_c field_152801_c
|
||||
field_152802_d field_152802_d
|
||||
net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1
|
||||
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686
|
||||
profile ()Lcom/mojang/authlib/GameProfile; comp_1631
|
||||
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
|
||||
|
||||
@@ -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
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18
|
||||
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
|
||||
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21
|
||||
#forge gradle needs forge version
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
|
||||
+12
-12
@@ -2,22 +2,17 @@ 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
|
||||
@@ -29,20 +24,25 @@ 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_229297_b_ (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655
|
||||
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
|
||||
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$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$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
|
||||
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$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
|
||||
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
|
||||
net/minecraft/scoreboard/ScoreObjective net/minecraft/class_266
|
||||
net/minecraft/scoreboard/Scoreboard net/minecraft/class_269
|
||||
net/minecraft/util/ResourceLocation net/minecraft/class_2960
|
||||
@@ -55,12 +55,16 @@ public class MixinConfigPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
boolean result = true;
|
||||
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(".MixinSkinManager$V1")) {
|
||||
result = this.world_version >= 2205 && this.protocol_version >= 554; // 19w38a+
|
||||
if (mixinClassName.endsWith(".MixinIImageBuffer")) {
|
||||
result = this.world_version <= 2204 && this.protocol_version <= 553; // 18w43b ~ 19w37a
|
||||
} 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$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")) {
|
||||
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+
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
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 {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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 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.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.profile()));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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 net.minecraft.util.ResourceLocation;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@Mixin(SkinManager.TextureCache.class)
|
||||
public abstract class MixinSkinManager$TextureCache {
|
||||
@Shadow
|
||||
private MinecraftProfileTexture.Type type;
|
||||
|
||||
@ModifyVariable(
|
||||
method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "STORE",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 0
|
||||
)
|
||||
private ResourceLocation modifyVariable_registerTexture(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
|
||||
return FakeSkinManager.setResourceLocation(resourceLocation, profileTexture);
|
||||
}
|
||||
|
||||
@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,11 +1,14 @@
|
||||
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;
|
||||
@@ -26,157 +29,177 @@ 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;
|
||||
|
||||
@Mixin(SkinManager.class)
|
||||
@SuppressWarnings("target")
|
||||
public abstract class MixinSkinManager {
|
||||
private FakeSkinManager fakeManager;
|
||||
|
||||
@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) {
|
||||
this.fakeManager = new FakeSkinManager(textureManagerInstance, skinCacheDirectory, sessionService);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
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 = "STORE",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 0
|
||||
)
|
||||
private ResourceLocation modifyVariable_loadSkin(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
return FakeSkinManager.setResourceLocation(resourceLocation, profileTexture);
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
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/resources/SkinManager$SkinAvailableCallback;skinAvailable(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V"
|
||||
)
|
||||
)
|
||||
private MinecraftProfileTexture modifyArg_loadSkin(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
return FakeSkinManager.getModelCache(profileTexture, this.fakeManager, location);
|
||||
}
|
||||
|
||||
// 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), this.fakeManager, profileTexture, textureType, skinAvailableCallback);
|
||||
args.setAll(argsArr);
|
||||
}
|
||||
|
||||
// 19w38a+
|
||||
@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);
|
||||
}
|
||||
|
||||
// 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+
|
||||
@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(this.fakeManager.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);
|
||||
}
|
||||
|
||||
// 19w38a+
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
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 = "STORE",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 0
|
||||
)
|
||||
private ResourceLocation modifyVariable_loadSkin(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
return FakeSkinManager.setResourceLocation(resourceLocation, profileTexture);
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
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/resources/SkinManager$SkinAvailableCallback;skinAvailable(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V"
|
||||
)
|
||||
)
|
||||
private MinecraftProfileTexture modifyArg_loadSkin(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
return FakeSkinManager.getModelCache(profileTexture, location);
|
||||
}
|
||||
|
||||
// 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;func_229297_b_(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
|
||||
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;",
|
||||
@@ -187,4 +210,48 @@ public abstract class MixinSkinManager {
|
||||
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) throws Exception {
|
||||
return FakeSkinManager.loadCache(loadingCache, cacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
public class SkinManager$1 {
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,16 @@
|
||||
"package": "customskinloader.mixin",
|
||||
"client": [
|
||||
"MixinGuiPlayerTabOverlay",
|
||||
"MixinIImageBuffer",
|
||||
"MixinIResource",
|
||||
"MixinIResourceManager",
|
||||
"MixinLayerCape",
|
||||
"MixinMinecraft",
|
||||
"MixinRenderPlayer",
|
||||
"MixinSkinManager",
|
||||
"MixinSkinManager$1",
|
||||
"MixinSkinManager$TextureCache",
|
||||
"MixinSkinManager$V1",
|
||||
"MixinSkinManager$V2",
|
||||
"MixinThreadDownloadImageData$V1",
|
||||
"MixinThreadDownloadImageData$V2"
|
||||
],
|
||||
|
||||
@@ -15,7 +15,6 @@ 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
|
||||
@@ -50,11 +49,12 @@ 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$3 net/minecraft/client/resources/SkinManager$3
|
||||
field_152801_c field_152801_c
|
||||
field_152802_d field_152802_d
|
||||
net/minecraft/client/resources/SkinManager$1 net/minecraft/client/resources/SkinManager$1
|
||||
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/client/resources/SkinManager$CacheKey
|
||||
profile ()Lcom/mojang/authlib/GameProfile; profile
|
||||
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
|
||||
|
||||
@@ -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
|
||||
java_full_versions=16,17,18
|
||||
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
|
||||
java_full_versions=16,17,18,19,20,21
|
||||
#forge gradle needs forge version
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
|
||||
@@ -35,27 +35,26 @@ 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")) {
|
||||
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-
|
||||
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 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;"));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/io/File;)V", 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;")) {
|
||||
} 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+
|
||||
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));
|
||||
}
|
||||
}
|
||||
} 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.INVOKESPECIAL && node.owner.equals("net/minecraft/resources/ResourceLocation") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/lang/String;)V")) // 1.19-
|
||||
@@ -65,10 +64,8 @@ function initializeCoreMod() {
|
||||
}
|
||||
|
||||
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));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;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"))) {
|
||||
@@ -81,12 +78,9 @@ 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 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));
|
||||
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));
|
||||
@@ -102,7 +96,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")) {
|
||||
} 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-
|
||||
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||
var node = iterator.next();
|
||||
if (node.getOpcode() === Opcodes.INVOKEINTERFACE
|
||||
@@ -114,7 +108,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")) {
|
||||
} else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
|
||||
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;")) {
|
||||
@@ -122,7 +116,7 @@ function initializeCoreMod() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) {
|
||||
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
|
||||
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;")) {
|
||||
@@ -131,13 +125,64 @@ 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;")) {
|
||||
} else if (checkName(mn.name, "m_118815_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")) { // 1.20.1-
|
||||
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.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
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 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.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadCache", "(Lcom/google/common/cache/LoadingCache;Ljava/lang/Object;)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.INVOKEVIRTUAL, "net/minecraft/client/resources/SkinManager$CacheKey", mapName("f_290972_"), "()Lcom/mojang/authlib/GameProfile;", false));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/GameProfile;)[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;")) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return cn;
|
||||
@@ -197,6 +242,51 @@ 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.INVOKEVIRTUAL && node.owner.equals("net/minecraft/client/resources/SkinManager$TextureCache") && checkName(node.name, "m_293729_") && node.desc.equals("(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;")) {
|
||||
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 (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',
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
public class LaunchWrapper implements IClassTransformer {
|
||||
private static final TransformerManager.IClassTransformer[] CLASS_TRANSFORMERS = {
|
||||
new FakeInterfacesTransformer.MinecraftTransformer(),
|
||||
new FakeInterfacesTransformer.IImageBufferTransformer(),
|
||||
new FakeInterfacesTransformer.ThreadDownloadImageDataTransformer(),
|
||||
new FakeInterfacesTransformer.ClientIResourceTransformer(),
|
||||
new FakeInterfacesTransformer.ClientIResourceManagerTransformer(),
|
||||
|
||||
+11
@@ -30,6 +30,17 @@ public class FakeInterfacesTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
@TransformerManager.TransformTarget(
|
||||
className = "net.minecraft.client.renderer.IImageBuffer"
|
||||
)
|
||||
public static class IImageBufferTransformer implements TransformerManager.IClassTransformer {
|
||||
@Override
|
||||
public ClassNode transform(ClassNode cn) {
|
||||
cn.interfaces.add("customskinloader/fake/itf/IFakeIImageBuffer");
|
||||
return cn;
|
||||
}
|
||||
}
|
||||
|
||||
@TransformerManager.TransformTarget(
|
||||
className = "net.minecraft.client.renderer.ThreadDownloadImageData"
|
||||
)
|
||||
|
||||
+8
-23
@@ -18,28 +18,19 @@ import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public class SkinManagerTransformer {
|
||||
@TransformerManager.TransformTarget(
|
||||
className = "net.minecraft.client.resources.SkinManager",
|
||||
methodNameSrg = "<init>",
|
||||
desc = "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V"
|
||||
className = "net.minecraft.client.resources.SkinManager",
|
||||
methodNameSrg = "<init>",
|
||||
desc = "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V"
|
||||
)
|
||||
public static class InitTransformer implements TransformerManager.IMethodTransformer {
|
||||
@Override
|
||||
public MethodNode transform(ClassNode cn, MethodNode mn) {
|
||||
cn.fields.removeIf(fn -> fn.name.equals("fakeManager") && fn.desc.equals("Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
|
||||
|
||||
for (AbstractInsnNode ain : mn.instructions.toArray()) {
|
||||
if (ain.getOpcode() == Opcodes.RETURN) {
|
||||
InsnList il = new InsnList();
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
il.add(new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
|
||||
il.add(new InsnNode(Opcodes.DUP));
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 2));
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 3));
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "customskinloader/fake/FakeSkinManager", "<init>", "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
|
||||
il.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
mn.instructions.insert(il);
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/io/File;)V", false));
|
||||
mn.instructions.insertBefore(ain, il);
|
||||
}
|
||||
}
|
||||
return mn;
|
||||
@@ -70,10 +61,8 @@ public class SkinManagerTransformer {
|
||||
MethodInsnNode min = (MethodInsnNode) ain;
|
||||
if (TransformerManager.checkClassName(min.owner, "net/minecraft/client/resources/SkinManager$SkinAvailableCallback") && TransformerManager.checkMethodName(min.owner, min.name, min.desc, "func_180521_a") && TransformerManager.checkMethodDesc(min.desc, "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V")) {
|
||||
InsnList il = new InsnList();
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
il.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 4));
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcustomskinloader/fake/FakeSkinManager;Lnet/minecraft/util/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lnet/minecraft/util/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
|
||||
mn.instructions.insertBefore(min, il);
|
||||
}
|
||||
}
|
||||
@@ -88,13 +77,11 @@ public class SkinManagerTransformer {
|
||||
sb.append("Ljava/lang/Object;");
|
||||
}
|
||||
il0.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", sb.append(")Lcom/google/common/collect/ImmutableList;").toString(), false));
|
||||
il0.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
il0.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
il0.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
il0.add(new VarInsnNode(Opcodes.ALOAD, 2));
|
||||
il0.add(new VarInsnNode(Opcodes.ALOAD, 3));
|
||||
|
||||
il0.add(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$SkinAvailableCallback;)[Ljava/lang/Object;", false));
|
||||
il0.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)[Ljava/lang/Object;", false));
|
||||
for (int i = 0, len = args.length; i < len; i++) {
|
||||
il0.add(new InsnNode(Opcodes.DUP));
|
||||
il0.add(new IntInsnNode(Opcodes.BIPUSH, i));
|
||||
@@ -152,10 +139,8 @@ public class SkinManagerTransformer {
|
||||
@Override
|
||||
public MethodNode transform(ClassNode cn, MethodNode mn) {
|
||||
InsnList il = new InsnList();
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
il.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||
il.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
il.add(new InsnNode(Opcodes.ARETURN));
|
||||
il.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));
|
||||
mn.instructions.insert(il);
|
||||
|
||||
@@ -3,7 +3,6 @@ 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');
|
||||
@@ -44,24 +43,13 @@ 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")) {
|
||||
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 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;"));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/io/File;)V", false));
|
||||
}
|
||||
}
|
||||
} else if (checkName(mn.name, "func_152789_a")
|
||||
@@ -78,10 +66,8 @@ function initializeCoreMod() {
|
||||
&& (node.owner.equals("net/minecraft/client/resources/SkinManager$SkinAvailableCallback") // 1.13.2-
|
||||
|| node.owner.equals("net/minecraft/client/resources/SkinManager$ISkinAvailableCallback")) // 1.14.2+
|
||||
&& checkName(node.name, "onSkinTextureAvailable") && node.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/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/util/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
|
||||
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lnet/minecraft/util/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
|
||||
}
|
||||
|
||||
if (node.getOpcode() === Opcodes.INVOKESPECIAL
|
||||
@@ -101,12 +87,9 @@ function initializeCoreMod() {
|
||||
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 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$SkinAvailableCallback;)[Ljava/lang/Object;", false));
|
||||
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));
|
||||
@@ -171,10 +154,8 @@ function initializeCoreMod() {
|
||||
}
|
||||
} else if (checkName(mn.name, "func_152788_a") && 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.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||
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 InsnNode(Opcodes.ARETURN));
|
||||
}
|
||||
});
|
||||
@@ -204,6 +185,18 @@ function initializeCoreMod() {
|
||||
return cn;
|
||||
}
|
||||
},
|
||||
'IImageBufferTransformer': {
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
'name': 'net/minecraft/client/renderer/IImageBuffer'
|
||||
},
|
||||
'transformer': function (cn) {
|
||||
if (!cn.interfaces.contains("customskinloader/fake/itf/IFakeIImageBuffer")) {
|
||||
cn.interfaces.add("customskinloader/fake/itf/IFakeIImageBuffer");
|
||||
}
|
||||
return cn;
|
||||
}
|
||||
},
|
||||
|
||||
// For 1.14+
|
||||
'MinecraftTransformer': {
|
||||
|
||||
Reference in new issue
Block a user