diff --git a/Common/src/main/java/customskinloader/CustomSkinLoader.java b/Common/src/main/java/customskinloader/CustomSkinLoader.java index 7c7bc29..97906c0 100644 --- a/Common/src/main/java/customskinloader/CustomSkinLoader.java +++ b/Common/src/main/java/customskinloader/CustomSkinLoader.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; @@ -24,7 +25,9 @@ import customskinloader.profile.DynamicSkullManager; import customskinloader.profile.ModelManager0; import customskinloader.profile.ProfileCache; import customskinloader.profile.UserProfile; +import customskinloader.utils.LIFOBlockingQueue; import customskinloader.utils.MinecraftUtil; +import customskinloader.utils.TextureUtil; /** * Custom skin loader mod for Minecraft. @@ -49,7 +52,7 @@ public class CustomSkinLoader { private static final ProfileCache profileCache = new ProfileCache(); private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager(); - public static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>()); + public static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LIFOBlockingQueue<>(new LinkedBlockingDeque<>())); //Correct thread name in thread pool private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); @@ -70,33 +73,18 @@ public class CustomSkinLoader { THREAD_POOL.execute(runnable); } - public static Object loadProfileLazily(GameProfile gameProfile, Function function) { - String username = gameProfile.getName(); + //For User Skin + public static UserProfile loadProfile(GameProfile gameProfile) { + String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile); String credential = MinecraftUtil.getCredential(gameProfile); // Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713 if (username == null) { logger.warning("Could not load profile: username is null."); - return function.apply(new UserProfile()); + return new UserProfile(); } + String tempName = Thread.currentThread().getName(); Thread.currentThread().setName(username); // Change Thread Name - if (profileCache.isLoading(credential)) { - profileCache.putLoader(credential, function); - Thread.currentThread().setName(tempName); - return function.apply(new UserProfile()); - } - Object result = function.apply(loadProfile(gameProfile)); - Thread.currentThread().setName(tempName); - Function func = profileCache.getLastLoader(credential); - if (func != null) { - result = loadProfileLazily(gameProfile, func); - } - return result; - } - - //For User Skin - public static UserProfile loadProfile(GameProfile gameProfile) { - String credential = MinecraftUtil.getCredential(gameProfile); UserProfile profile; if (profileCache.isReady(credential)) { logger.info("Cached profile will be used."); @@ -113,12 +101,13 @@ public class CustomSkinLoader { profileCache.setLoading(credential, true); profile = loadProfile0(gameProfile, false); } + Thread.currentThread().setName(tempName); return profile == null ? new UserProfile() : profile; } //Core public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) { - String username = gameProfile.getName(); + String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile); String credential = MinecraftUtil.getCredential(gameProfile); profileCache.setLoading(credential, true); @@ -197,7 +186,7 @@ public class CustomSkinLoader { public final static Map INCOMPLETED = ImmutableMap.of(); //For Skull public static Map loadProfileFromCache(final GameProfile gameProfile) { - String username = gameProfile.getName(); + String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile); String credential = MinecraftUtil.getCredential(gameProfile); //CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used diff --git a/Common/src/main/java/customskinloader/fake/FakeMinecraftProfileTexture.java b/Common/src/main/java/customskinloader/fake/FakeMinecraftProfileTexture.java index 1423bb4..dfdee5f 100644 --- a/Common/src/main/java/customskinloader/fake/FakeMinecraftProfileTexture.java +++ b/Common/src/main/java/customskinloader/fake/FakeMinecraftProfileTexture.java @@ -3,8 +3,11 @@ package customskinloader.fake; import java.io.File; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import customskinloader.CustomSkinLoader; import customskinloader.utils.HttpTextureUtil; public class FakeMinecraftProfileTexture extends MinecraftProfileTexture { @@ -12,6 +15,7 @@ public class FakeMinecraftProfileTexture extends MinecraftProfileTexture { private final HttpTextureUtil.HttpTextureInfo info; private final Map metadata; + private final CountDownLatch latch = new CountDownLatch(1); public FakeMinecraftProfileTexture(String url, Map metadata) { super(url, metadata); @@ -25,12 +29,24 @@ public class FakeMinecraftProfileTexture extends MinecraftProfileTexture { } @Override - public String getMetadata(final String key) { + public String getMetadata(String key) { + return this.getMetadata(key, true); + } + + public String getMetadata(String key, boolean lock) { String value = super.getMetadata(key); if ("model".equals(key) && "auto".equals(value)) { String model = MODEL_CACHE.get(this.getHash()); if (model != null) { return model; + } else { + try { + if (lock && this.latch.await(60L * CustomSkinLoader.config.loadlist.size(), TimeUnit.SECONDS)) { + return this.getMetadata(key, false); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } } return value; @@ -40,6 +56,7 @@ public class FakeMinecraftProfileTexture extends MinecraftProfileTexture { if (this.metadata != null) { MODEL_CACHE.put(this.getHash(), model); this.metadata.put("model", model); + this.latch.countDown(); } } diff --git a/Common/src/main/java/customskinloader/fake/FakeSkinBuffer.java b/Common/src/main/java/customskinloader/fake/FakeSkinBuffer.java index 5282582..1c3affd 100644 --- a/Common/src/main/java/customskinloader/fake/FakeSkinBuffer.java +++ b/Common/src/main/java/customskinloader/fake/FakeSkinBuffer.java @@ -2,6 +2,7 @@ package customskinloader.fake; import java.awt.image.BufferedImage; import java.io.InputStream; +import java.nio.file.Path; import java.util.function.Function; import java.util.function.Predicate; @@ -9,22 +10,34 @@ import customskinloader.CustomSkinLoader; import customskinloader.fake.texture.FakeBufferedImage; import customskinloader.fake.texture.FakeImage; import customskinloader.fake.texture.FakeNativeImage; -import customskinloader.fake.texture.FakeThreadDownloadImageData; import net.minecraft.client.renderer.IImageBuffer; import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.renderer.texture.SkinTextureDownloader; public class FakeSkinBuffer implements IImageBuffer { - private int ratio = 1; FakeImage image = null; + /** + * 24w46a+ + * Invoked from {@link SkinTextureDownloader#lambda$downloadAndRegisterSkin$0(Path, String, boolean)} + */ + public static NativeImage processLegacySkin(NativeImage image, String url) { + if (image == null) + return null; + + FakeImage img = parseUserSkin0(new FakeNativeImage(image)); + if (img instanceof FakeNativeImage) { + return FakeNativeImage.Extended.create((FakeNativeImage) img); + } + + CustomSkinLoader.logger.warning("Failed to parseUserSkin(downloadAndRegisterSkin)."); + return null; + } + /** * 19w38a ~ 24w45a * Invoked from {@link ThreadDownloadImageData#loadTexture(InputStream)} - * - * 24w46a+ - * Invoked from {@link FakeThreadDownloadImageData#loadContents(IResourceManager)} */ public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function processLegacySkin) { if (processTask instanceof IImageBuffer) { @@ -63,8 +76,12 @@ public class FakeSkinBuffer implements IImageBuffer { } public FakeImage parseUserSkin(FakeImage image) { + return this.image = parseUserSkin0(image); + } + + public static FakeImage parseUserSkin0(FakeImage image) { if (image == null) return null; - this.ratio = image.getWidth() / 64; + int ratio = image.getWidth() / 64; if (image.getHeight() != image.getWidth()) {//Single Layer //Create a new image and copy origin image data @@ -90,27 +107,32 @@ public class FakeSkinBuffer implements IImageBuffer { image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back } - this.image = image; - setAreaDueToConfig(0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1 - setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2 - setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1 - setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2 + setAreaDueToConfig(image, 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1 + setAreaTransparent(image, 32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2 + setAreaDueToConfig(image, 16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1 + setAreaTransparent(image, 16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2 - setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1 - setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2 - setAreaDueToConfig(0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1 - setAreaTransparent(0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2 + setAreaDueToConfig(image, 40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1 + setAreaTransparent(image, 40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2 + setAreaDueToConfig(image, 0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1 + setAreaTransparent(image, 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2 - setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1 - setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2 - setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1 - setAreaTransparent(0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2 + setAreaDueToConfig(image, 32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1 + setAreaTransparent(image, 48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2 + setAreaDueToConfig(image, 16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1 + setAreaTransparent(image, 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2 + + image.setRatio(ratio); return image; } /** Judge if the color is transparent or same with background */ static final Function> EQU_BG = bgColor -> getA(bgColor) == 0 ? (c) -> getA(c) == 0 : (c) -> c.equals(bgColor); + public String judgeType() { + return judgeType0(this.image); + } + /** * Judge the type of skin * Must be called after parseUserSkin @@ -118,9 +140,10 @@ public class FakeSkinBuffer implements IImageBuffer { * @return type of skin (slim / default) * @since 14.9 */ - public String judgeType() { - if (this.image == null) + public static String judgeType0(FakeImage image) { + if (image == null) return "default"; + int ratio = image.getRatio(); int bgColor = image.getRGBA(63 * ratio, 20 * ratio); /* * If background is transparent, all the pixels in ((54, 20), (55, 31)) areas is transparent, @@ -147,7 +170,7 @@ public class FakeSkinBuffer implements IImageBuffer { private static final int WHITE = getARGB(255, 255, 255, 255); private static final int BLACK = getARGB(255, 0, 0, 0); - private boolean isFilled(int x0, int y0, int x1, int y1) { + private static boolean isFilled(FakeImage image, int x0, int y0, int x1, int y1) { int data = image.getRGBA(x0, y0); if (data != WHITE && data != BLACK) return false; @@ -158,8 +181,8 @@ public class FakeSkinBuffer implements IImageBuffer { return true; } - private void setAreaTransparent(int x0, int y0, int x1, int y1) { - if (!isFilled(x0, y0, x1, y1)) + private static void setAreaTransparent(FakeImage image, int x0, int y0, int x1, int y1) { + if (!isFilled(image, x0, y0, x1, y1)) return; for (int x = x0; x < x1; ++x) for (int y = y0; y < y1; ++y) @@ -172,17 +195,17 @@ public class FakeSkinBuffer implements IImageBuffer { * 11111111 00000000 00000000 00000000 */ private static final int B = -16777216; - private void setAreaOpaque(int x0, int y0, int x1, int y1) { + private static void setAreaOpaque(FakeImage image, int x0, int y0, int x1, int y1) { for (int x = x0; x < x1; ++x) for (int y = y0; y < y1; ++y) image.setRGBA(x, y, image.getRGBA(x, y) | B); } - private void setAreaDueToConfig(int x0, int y0, int x1, int y1) { + private static void setAreaDueToConfig(FakeImage image, int x0, int y0, int x1, int y1) { if (customskinloader.CustomSkinLoader.config.enableTransparentSkin) - setAreaTransparent(x0, y0, x1, y1); + setAreaTransparent(image, x0, y0, x1, y1); else - setAreaOpaque(x0, y0, x1, y1); + setAreaOpaque(image, x0, y0, x1, y1); } public void skinAvailable() { diff --git a/Common/src/main/java/customskinloader/fake/FakeSkinManager.java b/Common/src/main/java/customskinloader/fake/FakeSkinManager.java index 631c15e..9cbe9e0 100644 --- a/Common/src/main/java/customskinloader/fake/FakeSkinManager.java +++ b/Common/src/main/java/customskinloader/fake/FakeSkinManager.java @@ -5,12 +5,9 @@ import java.io.File; import java.nio.file.Path; import java.util.Map; import java.util.UUID; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Supplier; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import com.mojang.authlib.GameProfile; import com.mojang.authlib.SignatureState; @@ -19,26 +16,18 @@ import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.properties.Property; import customskinloader.CustomSkinLoader; -import customskinloader.fake.itf.FakeInterfaceManager; -import customskinloader.fake.texture.FakeThreadDownloadImageData; -import customskinloader.loader.GameProfileLoader; +import customskinloader.fake.texture.FakeResourceLocation; import customskinloader.profile.ModelManager0; -import customskinloader.profile.UserProfile; import customskinloader.utils.HttpTextureUtil; -import customskinloader.utils.TextureUtil; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IImageBuffer; -import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.client.renderer.texture.ReloadableTexture; -import net.minecraft.client.renderer.texture.SkinTextureDownloader; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.PlayerSkin$Model; import net.minecraft.client.resources.SkinManager; import net.minecraft.client.resources.SkinManager$1; import net.minecraft.client.resources.SkinManager$CacheKey; import net.minecraft.client.resources.SkinManager$SkinAvailableCallback; import net.minecraft.client.resources.SkinManager$TextureCache; +import net.minecraft.server.Services; import net.minecraft.util.ResourceLocation; public class FakeSkinManager { @@ -51,36 +40,28 @@ public class FakeSkinManager { } /** - * 23w31a+ + * 23w31a ~ 23w45a * Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)} + * + * 23w46a ~ 25w33a + * Invoked from {@link SkinManager(Path, MinecraftSessionService, Executor)} + * + * 25w34a+ + * Invoked from {@link SkinManager(Path, Services, Executor)} */ public static void setSkinCacheDir(Path skinCacheDirectory) { HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile(); } - private static CacheLoader cacheLoader; /** - * 23w31a+ - * Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)} - */ - public static CacheLoader setCacheLoader(CacheLoader loader) { - return cacheLoader = loader; - } - - /** - * 23w42a+ + * 23w42a ~ 25w33a * Invoked from {@link SkinManager#getOrLoad(GameProfile)} + * + * 25w34a+ + * Invoked from {@link SkinManager#get(GameProfile)} */ public static Property createProperty(Property property) { - return property == null ? new Property(null, null) : new Property(TextureUtil.AuthlibField.PROPERTY_NAME.get(property), TextureUtil.AuthlibField.PROPERTY_VALUE.get(property), TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property)); - } - - /** - * 23w31a+ - * Invoked from {@link SkinManager#getOrLoad(GameProfile)} - */ - public static Object loadCache(LoadingCache loadingCache, Object cacheKey, GameProfile profile) throws Exception { - return cacheLoader.load(FakeCacheKey.wrapCacheKey(cacheKey, profile)); + return property == null ? new Property(null, null) : property; } /** @@ -97,9 +78,10 @@ public class FakeSkinManager { File cacheFile = fakeProfileTexture.getCacheFile(); if (params.length == 4) { if (params[3] instanceof Boolean) { // 24w46a+ - FakeInterfaceManager.ResourceLocation_setTexture(params[0], FakeThreadDownloadImageData.createTexture(params[0], cacheFile.toPath(), params[2], false, new BaseBuffer(null, textureType, fakeProfileTexture))); + if ((Boolean) params[3]) { + params[0] = FakeResourceLocation.create((ResourceLocation) params[0], fakeProfileTexture); + } params[1] = cacheFile.toPath(); - params[3] = false; } else { // 19w37a- params[0] = cacheFile; params[3] = new BaseBuffer((Runnable) params[3], textureType, fakeProfileTexture); @@ -113,62 +95,21 @@ public class FakeSkinManager { return params; } - /** - * 24w46a+ - * Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)} - */ - public static CompletableFuture clearCachedFuture(CompletableFuture future) { - CompletableFuture completableFuture = new CompletableFuture<>(); - future.thenAccept(completableFuture::complete); - return completableFuture; - } - /** - * 24w46a+ - * Invoked from {@link SkinTextureDownloader#lambda$registerTextureInManager$2(Minecraft, ResourceLocation, NativeImage)} - */ - public static void registerTextureInManager(TextureManager manager, ResourceLocation location, AbstractTexture texture) { - Object texture0 = FakeInterfaceManager.ResourceLocation_getTexture(location); - if (texture0 != null) { - manager.registerAndLoad(location, (ReloadableTexture) texture0); - } else { - manager.loadTexture(location, texture); - } - } - - - private final static String KEY = "CustomSkinLoaderInfo"; /** * 1.20.1- * Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)} */ - public static void loadProfileTextures(Runnable runnable, GameProfile profile) { - CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> { - profile.getProperties().putAll(KEY, p.toProperties()); - runnable.run(); - return null; - })); + public static void loadProfileTextures(Runnable runnable) { + CustomSkinLoader.loadProfileTextures(runnable); } /** * 23w31a+ * Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)} */ - public static Object[] loadProfileTextures(ImmutableList list, Object cacheKey) { - Object[] params = list.toArray(); - GameProfile profile = FakeCacheKey.unwrapCacheKey(cacheKey); - if (!profile.getProperties().containsKey(SKULL_KEY)) { - final Supplier supplier = (Supplier) params[0]; - params[0] = (Supplier) () -> CustomSkinLoader.loadProfileLazily(profile, p -> { - profile.getProperties().putAll(KEY, p.toProperties()); - FakeCacheKey.wrapCacheKey(cacheKey, profile); - return supplier.get(); - }); - params[1] = CustomSkinLoader.THREAD_POOL; - } else { - params[1] = Minecraft.getMinecraft(); - } - return params; + public static Executor loadProfileTextures(Executor executor) { + return CustomSkinLoader.THREAD_POOL; } /** @@ -176,7 +117,7 @@ public class FakeSkinManager { * Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)} */ public static Map getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) { - return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values())); + return ModelManager0.fromUserProfile(CustomSkinLoader.loadProfile(profile)); } /** @@ -193,27 +134,9 @@ public class FakeSkinManager { } /** - * 24w46a+ - * Invoked from {@link SkinManager#lambda$registerTextures$1(CompletableFuture, String, CompletableFuture, CompletableFuture, PlayerSkin$Model, MinecraftProfileTextures, Void)} + * 1.20.1- + * Invoked from {@link SkinManager#loadSkinFromCache(GameProfile)} */ - public static PlayerSkin$Model loadSkinModel(PlayerSkin$Model model, MinecraftProfileTextures textures) { - MinecraftProfileTexture texture = textures.skin(); - if (texture != null) { - model = PlayerSkin$Model.byName(texture.getMetadata("model")); - } - return model; - } - - private final static String SKULL_KEY = "CSL$IsSkull"; - /** - * 23w31a+ - * Invoked from {@link SkinManager#getInsecureSkin(GameProfile)} - */ - public static void setSkullType(GameProfile profile) { - profile.getProperties().removeAll(SKULL_KEY); - profile.getProperties().put(SKULL_KEY, new Property(SKULL_KEY, "true")); - } - public static Map loadSkinFromCache(GameProfile profile) { return CustomSkinLoader.loadProfileFromCache(profile); } @@ -223,39 +146,24 @@ public class FakeSkinManager { * Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)} */ public static Map 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); - } + return getUserProfile(sessionService, profile, requireSecure); } /** - * 23w42a+ + * 23w42a ~ 25w33a * Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, MinecraftSessionService)} + * + * 25w34a+ + * Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, Services)} */ - public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) { - return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false)); - } - - private final static CompletableFuture INCOMPLETED = new CompletableFuture<>(); - /** - * 1.21.6-pre1+ - * Invoked from {@link SkinManager#registerTextures(UUID, MinecraftProfileTextures)} - */ - public static CompletableFuture checkIncompleted(MinecraftProfileTextures textures, CompletableFuture future) { - if (textures == FakeCacheKey.IncompletedContainer.INCOMPLETED) { - return INCOMPLETED; + public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property, SkinManager$CacheKey cacheKey) { + if (cacheKey instanceof FakeCacheKey) { + return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, ((FakeCacheKey) cacheKey).profile(), false)); } - return future; + return sessionService.unpackTextures(property); } - private static boolean shouldJudgeType(MinecraftProfileTexture texture) { - return texture != null && "auto".equals(texture.getMetadata("model")); - } - - private static class BaseBuffer implements IImageBuffer { + public static class BaseBuffer implements IImageBuffer { private IImageBuffer buffer; private final Runnable callback; @@ -273,22 +181,20 @@ public class FakeSkinManager { @Override public NativeImage func_195786_a(NativeImage image) { - return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image; + return this.buffer instanceof FakeSkinBuffer ? this.buffer.func_195786_a(image) : image; } @Override public BufferedImage parseUserSkin(BufferedImage image) { - return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image; + return this.buffer instanceof FakeSkinBuffer ? this.buffer.parseUserSkin(image) : image; } @Override public void skinAvailable() { - if (buffer != null) { - buffer.skinAvailable(); - if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) { - //Auto judge skin type - String type = ((FakeSkinBuffer) buffer).judgeType(); - texture.setModel(type); + if (this.buffer != null) { + this.buffer.skinAvailable(); + if (this.buffer instanceof FakeSkinBuffer) { + judgeType(this.texture, () -> ((FakeSkinBuffer) this.buffer).judgeType()); } } @@ -296,36 +202,43 @@ public class FakeSkinManager { this.callback.run(); } } + + public static void judgeType(FakeMinecraftProfileTexture texture, Supplier type) { + if (shouldJudgeType(texture)) { + //Auto judge skin type + texture.setModel(type.get()); + } + } + + private static boolean shouldJudgeType(FakeMinecraftProfileTexture texture) { + return texture != null && "auto".equals(texture.getMetadata("model", false)); + } } - public static class FakeCacheKey { - public static Object wrapCacheKey(Object cacheKey, GameProfile profile) { - if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) == null) { // 23w42a+ - TextureUtil.AuthlibField.PROPERTY_SIGNATURE.set(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey), GameProfileLoader.GSON.toJson(profile, GameProfile.class)); - } - return cacheKey; + public static class FakeCacheKey extends SkinManager$CacheKey { + private final GameProfile profile; + + public FakeCacheKey(UUID uuid, Property property, GameProfile profile) { + super(uuid, property); + this.profile = profile; } - public static GameProfile unwrapCacheKey(Object cacheKey) { - if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) != null) { - return FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey); // 23w31a ~ 23w41a - } else { - return unwrapProperty(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey)); // 23w42a+ - } + public GameProfile profile() { + return this.profile; } - public static GameProfile unwrapProperty(Property property) { - return GameProfileLoader.GSON.fromJson((String) TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property), GameProfile.class); // 23w42a+ - } - - public static class IncompletedContainer { - public final static Object INCOMPLETED = new MinecraftProfileTextures(null, null, null, SignatureState.SIGNED); + /** + * 23w42a ~ 25w33a + * Invoked from {@link SkinManager#getOrLoad(GameProfile)} + * + * 25w34a+ + * Invoked from {@link SkinManager#get(GameProfile)} + */ + public static SkinManager$CacheKey createFakeCacheKey(UUID uuid, Property property, GameProfile profile) { + return new FakeCacheKey(uuid, property, profile); } public static Object createMinecraftProfileTextures(Map textures) { - if (textures == CustomSkinLoader.INCOMPLETED) { - return IncompletedContainer.INCOMPLETED; - } return new MinecraftProfileTextures(textures.get(MinecraftProfileTexture.Type.SKIN), textures.get(MinecraftProfileTexture.Type.CAPE), textures.get(MinecraftProfileTexture.Type.ELYTRA), SignatureState.SIGNED); } } diff --git a/Common/src/main/java/customskinloader/fake/itf/FakeInterfaceManager.java b/Common/src/main/java/customskinloader/fake/itf/FakeInterfaceManager.java index e09b194..3cf627f 100644 --- a/Common/src/main/java/customskinloader/fake/itf/FakeInterfaceManager.java +++ b/Common/src/main/java/customskinloader/fake/itf/FakeInterfaceManager.java @@ -3,8 +3,6 @@ package customskinloader.fake.itf; import java.io.InputStream; import java.util.Optional; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; @@ -29,20 +27,4 @@ public class FakeInterfaceManager { public static void NativeImage_setPixel(Object nativeImage, int x, int y, int color) { ((IFakeNativeImage) nativeImage).setPixel(x, y, color); } - - public static Object ResourceLocation_getTexture(Object location) { - return ((IFakeResourceLocation) location).customskinloader$getTexture(); - } - - public static void ResourceLocation_setTexture(Object location, Object texture) { - ((IFakeResourceLocation) location).customskinloader$setTexture(texture); - } - - public static GameProfile SkinManagerCacheKey_profile(Object skinManagerCacheKey) { - return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).profile(); - } - - public static Property SkinManagerCacheKey_packedTextures(Object skinManagerCacheKey) { - return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).packedTextures(); - } } diff --git a/Common/src/main/java/customskinloader/fake/itf/IFakeResourceLocation.java b/Common/src/main/java/customskinloader/fake/itf/IFakeResourceLocation.java deleted file mode 100644 index 11bc126..0000000 --- a/Common/src/main/java/customskinloader/fake/itf/IFakeResourceLocation.java +++ /dev/null @@ -1,6 +0,0 @@ -package customskinloader.fake.itf; - -public interface IFakeResourceLocation { - Object customskinloader$getTexture(); - void customskinloader$setTexture(Object texture); -} diff --git a/Common/src/main/java/customskinloader/fake/itf/IFakeSkinManagerCacheKey.java b/Common/src/main/java/customskinloader/fake/itf/IFakeSkinManagerCacheKey.java deleted file mode 100644 index 9e95212..0000000 --- a/Common/src/main/java/customskinloader/fake/itf/IFakeSkinManagerCacheKey.java +++ /dev/null @@ -1,9 +0,0 @@ -package customskinloader.fake.itf; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; - -public interface IFakeSkinManagerCacheKey { - default GameProfile profile() { return null; } - Property packedTextures(); -} diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeBufferedImage.java b/Common/src/main/java/customskinloader/fake/texture/FakeBufferedImage.java index 0e96498..e0531f7 100644 --- a/Common/src/main/java/customskinloader/fake/texture/FakeBufferedImage.java +++ b/Common/src/main/java/customskinloader/fake/texture/FakeBufferedImage.java @@ -10,6 +10,7 @@ import javax.imageio.ImageIO; public class FakeBufferedImage implements FakeImage { private BufferedImage image; private Graphics graphics; + private int ratio; public FakeBufferedImage(int width, int height) { this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)); @@ -33,6 +34,16 @@ public class FakeBufferedImage implements FakeImage { return new FakeBufferedImage(ImageIO.read(is)); } + @Override + public int getRatio() { + return this.ratio; + } + + @Override + public void setRatio(int ratio) { + this.ratio = ratio; + } + public int getWidth() { return image.getWidth(); } diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeImage.java b/Common/src/main/java/customskinloader/fake/texture/FakeImage.java index 7614865..0199267 100644 --- a/Common/src/main/java/customskinloader/fake/texture/FakeImage.java +++ b/Common/src/main/java/customskinloader/fake/texture/FakeImage.java @@ -8,6 +8,10 @@ public interface FakeImage { FakeImage createImage(InputStream is) throws IOException; + int getRatio(); + + void setRatio(int ratio); + int getWidth(); int getHeight(); diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeNativeImage.java b/Common/src/main/java/customskinloader/fake/texture/FakeNativeImage.java index 4c6adc4..ab58d46 100644 --- a/Common/src/main/java/customskinloader/fake/texture/FakeNativeImage.java +++ b/Common/src/main/java/customskinloader/fake/texture/FakeNativeImage.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.NativeImage; public class FakeNativeImage implements FakeImage { private NativeImage image; + private int ratio; public FakeNativeImage(int width, int height) { this(new NativeImage(width, height, true)); @@ -28,6 +29,16 @@ public class FakeNativeImage implements FakeImage { return new FakeNativeImage(NativeImage.func_195713_a(is)); } + @Override + public int getRatio() { + return this.ratio; + } + + @Override + public void setRatio(int ratio) { + this.ratio = ratio; + } + public int getWidth() { return image.func_195702_a(); } @@ -58,5 +69,24 @@ public class FakeNativeImage implements FakeImage { } public void close() { + image.close(); + } + + public static class Extended extends NativeImage { + public static NativeImage create(FakeNativeImage fakeImage) { + return new FakeNativeImage.Extended(fakeImage); + } + + private final FakeNativeImage fakeImage; + + public Extended(FakeNativeImage fakeImage) { + super(fakeImage.getWidth(), fakeImage.getHeight(), true); + this.func_195703_a(fakeImage.getImage()); + this.fakeImage = fakeImage; + } + + public FakeNativeImage getFakeImage() { + return this.fakeImage; + } } } diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeResourceLocation.java b/Common/src/main/java/customskinloader/fake/texture/FakeResourceLocation.java new file mode 100644 index 0000000..2f25dd6 --- /dev/null +++ b/Common/src/main/java/customskinloader/fake/texture/FakeResourceLocation.java @@ -0,0 +1,22 @@ +package customskinloader.fake.texture; + +import customskinloader.fake.FakeMinecraftProfileTexture; +import net.minecraft.util.ResourceLocation; + +public class FakeResourceLocation extends ResourceLocation { + public static FakeResourceLocation create(ResourceLocation location, FakeMinecraftProfileTexture texture) { + String[] s = location.toString().split(":", 2); + return new FakeResourceLocation(s[0], s[1], texture); + } + + private final FakeMinecraftProfileTexture texture; + + public FakeResourceLocation(String domain, String path, FakeMinecraftProfileTexture texture) { + super(domain, path); + this.texture = texture; + } + + public FakeMinecraftProfileTexture getTexture() { + return this.texture; + } +} diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java b/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java index 18c8c5d..4c0ee8b 100644 --- a/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java +++ b/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java @@ -1,38 +1,46 @@ package customskinloader.fake.texture; -import java.nio.file.Path; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import customskinloader.fake.FakeCapeBuffer; import customskinloader.fake.FakeSkinBuffer; +import customskinloader.fake.FakeSkinManager; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.texture.SkinTextureDownloader; import net.minecraft.client.renderer.texture.TextureContents; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; // 24w46a+ public class FakeThreadDownloadImageData extends SimpleTexture { - private final Path cacheFile; - private final String imageUrl; - private final boolean legacySkin; - private final Runnable processTask; + private FakeCapeBuffer buffer; + private FakeNativeImage image; - public static Object createTexture(Object location, Object cacheFile, Object imageUrl, Object legacySkin, Object processTask) { - return new FakeThreadDownloadImageData((ResourceLocation) location, (Path) cacheFile, (String) imageUrl, (boolean) legacySkin, (Runnable) processTask); + public static Function> createTexture(Function> function, ResourceLocation location, boolean bl) { + return bl ? _image -> { + if (location instanceof FakeResourceLocation && _image instanceof FakeNativeImage.Extended) { + FakeSkinManager.BaseBuffer.judgeType(((FakeResourceLocation) location).getTexture(), () -> FakeSkinBuffer.judgeType0(((FakeNativeImage.Extended) _image).getFakeImage())); + } + return function.apply(_image); + } : _image -> function.apply(_image).thenApply(_location -> { + Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, _image)); + return _location; + }); } - public FakeThreadDownloadImageData(ResourceLocation location, Path cacheFile, String imageUrl, boolean legacySkin, Runnable processTask) { + public FakeThreadDownloadImageData(ResourceLocation location, NativeImage image) { super(location); - this.cacheFile = cacheFile; - this.imageUrl = imageUrl; - this.legacySkin = legacySkin; - this.processTask = processTask; + this.buffer = new FakeCapeBuffer(); + this.image = new FakeNativeImage(image); } @Override public TextureContents loadContents(IResourceManager resourceManager) { - NativeImage image = FakeSkinBuffer.processLegacySkin(SkinTextureDownloader.lambda$downloadAndRegisterSkin$0(this.cacheFile, this.imageUrl, this.legacySkin), this.processTask, i -> SkinTextureDownloader.processLegacySkin(i, this.imageUrl)); - this.processTask.run(); - return new TextureContents(image, null); + this.image = (FakeNativeImage) this.buffer.parseUserSkin(this.image); + FakeNativeImage local = (FakeNativeImage) this.image.createImage(this.image.getWidth(), this.image.getHeight()); + local.copyImageData(this.image); + return new TextureContents(local.getImage(), null); } } diff --git a/Common/src/main/java/customskinloader/loader/GameProfileLoader.java b/Common/src/main/java/customskinloader/loader/GameProfileLoader.java index b20bdbb..bfc09f9 100644 --- a/Common/src/main/java/customskinloader/loader/GameProfileLoader.java +++ b/Common/src/main/java/customskinloader/loader/GameProfileLoader.java @@ -89,7 +89,7 @@ public class GameProfileLoader implements ICustomSkinLoaderPlugin, ProfileLoader if (gameProfile == null) { return Maps.newHashMap(); } - Property textureProperty = Iterables.getFirst(gameProfile.getProperties().get("textures"), null); + Property textureProperty = Iterables.getFirst(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(gameProfile).get("textures"), null); if (textureProperty == null) { return Maps.newHashMap(); } diff --git a/Common/src/main/java/customskinloader/loader/JsonAPILoader.java b/Common/src/main/java/customskinloader/loader/JsonAPILoader.java index 6c191e9..31cee96 100644 --- a/Common/src/main/java/customskinloader/loader/JsonAPILoader.java +++ b/Common/src/main/java/customskinloader/loader/JsonAPILoader.java @@ -12,6 +12,7 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin; import customskinloader.profile.UserProfile; import customskinloader.utils.HttpRequestUtil; import customskinloader.utils.HttpUtil0; +import customskinloader.utils.TextureUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -86,7 +87,7 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr @Override public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception { - String username = gameProfile.getName(); + String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile); if (StringUtils.isEmpty(ssp.root)) { CustomSkinLoader.logger.info("Root not defined."); return null; diff --git a/Common/src/main/java/customskinloader/loader/LegacyLoader.java b/Common/src/main/java/customskinloader/loader/LegacyLoader.java index 15fb3bd..13c8a94 100644 --- a/Common/src/main/java/customskinloader/loader/LegacyLoader.java +++ b/Common/src/main/java/customskinloader/loader/LegacyLoader.java @@ -14,6 +14,7 @@ import customskinloader.profile.UserProfile; import customskinloader.utils.HttpRequestUtil; import customskinloader.utils.HttpTextureUtil; import customskinloader.utils.HttpUtil0; +import customskinloader.utils.TextureUtil; public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader { @@ -160,13 +161,12 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro return profile; } - private void getTextureUrl( - SkinSiteProfile ssp, GameProfile gameProfile, String baseUrl, Consumer onSuccess) { + private void getTextureUrl(SkinSiteProfile ssp, GameProfile gameProfile, String baseUrl, Consumer onSuccess) { //Base URL is empty if (baseUrl == null || baseUrl.isEmpty()) { return; } - String url = expandURL(baseUrl, gameProfile.getName()); + String url = expandURL(baseUrl, TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile)); //No texture can be loaded if (url == null) { return; diff --git a/Common/src/main/java/customskinloader/loader/MojangAPILoader.java b/Common/src/main/java/customskinloader/loader/MojangAPILoader.java index 3619fe6..3475d2c 100644 --- a/Common/src/main/java/customskinloader/loader/MojangAPILoader.java +++ b/Common/src/main/java/customskinloader/loader/MojangAPILoader.java @@ -9,6 +9,7 @@ import java.util.concurrent.ConcurrentHashMap; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse; import customskinloader.CustomSkinLoader; import customskinloader.config.SkinSiteProfile; @@ -78,7 +79,7 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I @Override public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) { - String username = gameProfile.getName(); + String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile); GameProfile newGameProfile = loadGameProfileCached(ssp.apiRoot, username); if (newGameProfile == null) { CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)"); @@ -87,7 +88,6 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I newGameProfile = fillGameProfile(ssp.sessionRoot, newGameProfile); Map map = GameProfileLoader.getTextures(newGameProfile); if (!map.isEmpty()) { - gameProfile.getProperties().putAll(newGameProfile.getProperties()); return ModelManager0.toUserProfile(map); } CustomSkinLoader.logger.info("Profile not found.(" + username + " doesn't have skin/cape.)"); @@ -108,16 +108,17 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I return null; } - GameProfile[] profiles = GameProfileLoader.GSON.fromJson(responce.content, GameProfile[].class); + MinecraftProfilePropertiesResponse[] profiles = GameProfileLoader.GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse[].class); if (profiles.length == 0) { return null; } - GameProfile gameProfile = profiles[0]; + GameProfile gameProfile = createGameProfile(profiles[0]); - if (gameProfile.getId() == null) { + UUID id = TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile); + if (id == null) { return null; } - return new GameProfile(gameProfile.getId(), gameProfile.getName()); + return new GameProfile(id, TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile)); } /** @@ -132,23 +133,27 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I if (profile == null) { return null; } - UUID id = profile.getId(); + UUID id = TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile); return standard ? id.toString() : TextureUtil.fromUUID(id); } //UUID -> Profile public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) { //Doc (https://minecraft.wiki/w/Mojang_API#Query_player's_skin_and_cape) - HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(profile.getId())).setCacheTime(90)); + HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile))).setCacheTime(90)); if (StringUtils.isEmpty(responce.content)) { return profile; } + return createGameProfile(GameProfileLoader.GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse.class)); + } - MinecraftProfilePropertiesResponse propertiesResponce = GameProfileLoader.GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse.class); - GameProfile newGameProfile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(propertiesResponce), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(propertiesResponce)); - newGameProfile.getProperties().putAll(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(propertiesResponce)); - - return newGameProfile; + public static GameProfile createGameProfile(MinecraftProfilePropertiesResponse response) { + GameProfile profile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(response), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(response)); + PropertyMap map = TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(response); + if (map != null) { + TextureUtil.AuthlibField.PROPERTY_MAP_PROPERTIES.set(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(profile), TextureUtil.AuthlibField.PROPERTY_MAP_PROPERTIES.get(map)); + } + return profile; } @Override diff --git a/Common/src/main/java/customskinloader/profile/DynamicSkullManager.java b/Common/src/main/java/customskinloader/profile/DynamicSkullManager.java index 0e2ec4f..b8818e0 100644 --- a/Common/src/main/java/customskinloader/profile/DynamicSkullManager.java +++ b/Common/src/main/java/customskinloader/profile/DynamicSkullManager.java @@ -15,6 +15,7 @@ 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.authlib.properties.PropertyMap; import com.mojang.util.UUIDTypeAdapter; import customskinloader.CustomSkinLoader; import customskinloader.utils.HttpRequestUtil; @@ -44,7 +45,7 @@ public class DynamicSkullManager { private List loadingList = Lists.newArrayList(); private void parseGameProfile(GameProfile profile) { - Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null); + Property textureProperty = Iterables.getFirst(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(profile).get("textures"), null); if (textureProperty == null) { staticTextures.put(profile, Maps.newHashMap()); return; diff --git a/Common/src/main/java/customskinloader/profile/UserProfile.java b/Common/src/main/java/customskinloader/profile/UserProfile.java index b183d7a..fea40f0 100644 --- a/Common/src/main/java/customskinloader/profile/UserProfile.java +++ b/Common/src/main/java/customskinloader/profile/UserProfile.java @@ -1,15 +1,7 @@ package customskinloader.profile; -import java.util.Collection; -import java.util.List; - -import com.google.common.collect.Lists; -import com.mojang.authlib.properties.Property; -import customskinloader.utils.TextureUtil; import org.apache.commons.lang3.StringUtils; -import customskinloader.profile.ModelManager0.Model; - /**The instance to storage user's profile in memory temporarily. * In this manner, it could be easier to pass profile in program. * @since 13.1 @@ -43,7 +35,7 @@ public class UserProfile { */ public String elytraUrl=null; - public void put(Model model,String url){ + public void put(ModelManager0.Model model,String url){ if(model==null||StringUtils.isEmpty(url)) return; switch(model){ @@ -77,34 +69,6 @@ public class UserProfile { (StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+ (expiry==0?"":(" , Expiry: "+expiry))+")"; } - - public List toProperties() { - return Lists.newArrayList( - new Property("skinUrl" , nullToValue(this.skinUrl )), - new Property("model" , nullToValue(this.model )), - new Property("capeUrl" , nullToValue(this.capeUrl )), - new Property("elytraUrl", nullToValue(this.elytraUrl)) - ); - } - - public static UserProfile fromProperties(Collection properties) { - UserProfile profile = new UserProfile(); - if (properties != null) { - for (Property property : properties) { - switch ((String) TextureUtil.AuthlibField.PROPERTY_NAME.get(property)) { - case "skinUrl" : profile.skinUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break; - case "model" : profile.model = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break; - case "capeUrl" : profile.capeUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break; - case "elytraUrl": profile.elytraUrl = nullToValue(TextureUtil.AuthlibField.PROPERTY_VALUE.get(property)); break; - } - } - } - return profile; - } - - private static String nullToValue(String value) { - return value == null ? "null" : value.equals("null") ? null : value; - } /** * Check if the instance is empty. diff --git a/Common/src/main/java/customskinloader/utils/LIFOBlockingQueue.java b/Common/src/main/java/customskinloader/utils/LIFOBlockingQueue.java new file mode 100644 index 0000000..d8f5be1 --- /dev/null +++ b/Common/src/main/java/customskinloader/utils/LIFOBlockingQueue.java @@ -0,0 +1,50 @@ +package customskinloader.utils; + +import java.util.concurrent.BlockingDeque; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; + +import com.google.common.util.concurrent.ForwardingBlockingQueue; + +public class LIFOBlockingQueue extends ForwardingBlockingQueue { + private final BlockingDeque deque; + + public LIFOBlockingQueue(BlockingDeque deque) { + this.deque = deque; + } + + @Override + protected BlockingQueue delegate() { + return deque; + } + + @Override + public boolean offer(E e) { + return deque.offerFirst(e); + } + + @Override + public void put(E e) throws InterruptedException { + deque.putFirst(e); + } + + @Override + public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException { + return deque.offerFirst(e, timeout, unit); + } + + @Override + public E take() throws InterruptedException { + return deque.takeFirst(); + } + + @Override + public E poll(long timeout, TimeUnit unit) throws InterruptedException { + return deque.pollFirst(timeout, unit); + } + + @Override + public E peek() { + return deque.peekFirst(); + } +} \ No newline at end of file diff --git a/Common/src/main/java/customskinloader/utils/MinecraftUtil.java b/Common/src/main/java/customskinloader/utils/MinecraftUtil.java index 2a17ebf..dfee05f 100644 --- a/Common/src/main/java/customskinloader/utils/MinecraftUtil.java +++ b/Common/src/main/java/customskinloader/utils/MinecraftUtil.java @@ -85,6 +85,6 @@ public class MinecraftUtil { } public static String getCredential(GameProfile profile) { - return profile == null ? null : String.format("%s-%s", profile.getName(), profile.getId()); + return profile == null ? null : String.format("%s-%s", TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(profile), TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile)); } } diff --git a/Common/src/main/java/customskinloader/utils/TextureUtil.java b/Common/src/main/java/customskinloader/utils/TextureUtil.java index dc976e1..000754d 100644 --- a/Common/src/main/java/customskinloader/utils/TextureUtil.java +++ b/Common/src/main/java/customskinloader/utils/TextureUtil.java @@ -1,14 +1,10 @@ package customskinloader.utils; import java.io.File; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Map; import java.util.UUID; -import java.util.function.Supplier; +import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse; @@ -42,42 +38,25 @@ public class TextureUtil { } } - private final static MethodHandles.Lookup IMPL_LOOKUP = ((Supplier) () -> { - try { - Class unsafeClass = Class.forName("sun.misc.Unsafe"); - Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe"); - theUnsafeField.setAccessible(true); - Object theUnsafe = theUnsafeField.get(null); - - Method getObjectMethod = unsafeClass.getMethod("getObject", Object.class, long.class); - Method staticFieldBaseMethod = unsafeClass.getMethod("staticFieldBase", Field.class); - Method staticFieldOffsetMethod = unsafeClass.getMethod("staticFieldOffset", Field.class); - - Field implLookupField = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP"); - return (MethodHandles.Lookup) getObjectMethod.invoke(theUnsafe, staticFieldBaseMethod.invoke(theUnsafe, implLookupField), staticFieldOffsetMethod.invoke(theUnsafe, implLookupField)); - } catch (Throwable t) { - throw new RuntimeException(t); - } - }).get(); - // Some of the classes in Authlib used after Minecraft 23w31a were changed to record classes, // resulting in changes to method names, so reflection is used here to be compatible with these changes. public enum AuthlibField { - PROPERTY_NAME(Property.class, "name", String.class), - PROPERTY_VALUE(Property.class, "value", String.class), - PROPERTY_SIGNATURE(Property.class, "signature", String.class), - MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID(MinecraftProfilePropertiesResponse.class, "id", UUID.class), - MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME(MinecraftProfilePropertiesResponse.class, "name", String.class), - MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES(MinecraftProfilePropertiesResponse.class, "properties", PropertyMap.class), - MINECRAFT_TEXTURES_PAYLOAD_TEXTURES(MinecraftTexturesPayload.class, "textures", Map.class); + GAME_PROFILE_ID(GameProfile.class, "id"), + GAME_PROFILE_NAME(GameProfile.class, "name"), + GAME_PROFILE_PROPERTIES(GameProfile.class, "properties"), + PROPERTY_VALUE(Property.class, "value"), + PROPERTY_MAP_PROPERTIES(PropertyMap.class, "properties"), + MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID(MinecraftProfilePropertiesResponse.class, "id"), + MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME(MinecraftProfilePropertiesResponse.class, "name"), + MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES(MinecraftProfilePropertiesResponse.class, "properties"), + MINECRAFT_TEXTURES_PAYLOAD_TEXTURES(MinecraftTexturesPayload.class, "textures"); - private final MethodHandle getter; - private final MethodHandle setter; + private final Field field; - AuthlibField(Class clazz, String name, Class returnType) { + AuthlibField(Class clazz, String name) { try { - this.getter = IMPL_LOOKUP.findGetter(clazz, name, returnType); - this.setter = IMPL_LOOKUP.findSetter(clazz, name, returnType); + this.field = clazz.getDeclaredField(name); + this.field.setAccessible(true); } catch (Throwable t) { throw new RuntimeException(t); } @@ -86,7 +65,7 @@ public class TextureUtil { @SuppressWarnings("unchecked") public R get(Object o) { try { - return (R) this.getter.invokeWithArguments(o); + return (R) this.field.get(o); } catch (Throwable t) { throw new RuntimeException(t); } @@ -94,7 +73,7 @@ public class TextureUtil { public void set(Object o, Object value) { try { - this.setter.invokeWithArguments(o, value); + this.field.set(o, value); } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/Dummy/src/main/java/com/google/errorprone/annotations/CanIgnoreReturnValue.java b/Dummy/src/main/java/com/google/errorprone/annotations/CanIgnoreReturnValue.java new file mode 100644 index 0000000..5c542b7 --- /dev/null +++ b/Dummy/src/main/java/com/google/errorprone/annotations/CanIgnoreReturnValue.java @@ -0,0 +1,5 @@ +package com.google.errorprone.annotations; + +public @interface CanIgnoreReturnValue { + +} diff --git a/Dummy/src/main/java/com/mojang/authlib/minecraft/MinecraftSessionService.java b/Dummy/src/main/java/com/mojang/authlib/minecraft/MinecraftSessionService.java new file mode 100644 index 0000000..02e1299 --- /dev/null +++ b/Dummy/src/main/java/com/mojang/authlib/minecraft/MinecraftSessionService.java @@ -0,0 +1,7 @@ +package com.mojang.authlib.minecraft; + +import com.mojang.authlib.properties.Property; + +public interface MinecraftSessionService { + MinecraftProfileTextures unpackTextures(Property packedTextures); +} diff --git a/Dummy/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java b/Dummy/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java index 9386a93..25f427f 100644 --- a/Dummy/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java +++ b/Dummy/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java @@ -3,7 +3,7 @@ package net.minecraft.client.renderer.texture; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; -public class SimpleTexture implements ITextureObject { +public class SimpleTexture extends ReloadableTexture implements ITextureObject { public SimpleTexture(ResourceLocation location) {} public TextureContents loadContents(IResourceManager resourceManager) { return null; } } diff --git a/Dummy/src/main/java/net/minecraft/client/renderer/texture/SkinTextureDownloader.java b/Dummy/src/main/java/net/minecraft/client/renderer/texture/SkinTextureDownloader.java index 57567f8..11dd19e 100644 --- a/Dummy/src/main/java/net/minecraft/client/renderer/texture/SkinTextureDownloader.java +++ b/Dummy/src/main/java/net/minecraft/client/renderer/texture/SkinTextureDownloader.java @@ -3,12 +3,10 @@ package net.minecraft.client.renderer.texture; import java.nio.file.Path; import java.util.concurrent.CompletableFuture; -import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; public class SkinTextureDownloader { public static CompletableFuture downloadAndRegisterSkin(ResourceLocation location, Path path, String string, boolean b) { return null; } public static NativeImage processLegacySkin(NativeImage nativeImage, String url) { return null; } public static NativeImage lambda$downloadAndRegisterSkin$0(Path path, String url, boolean b) { return null; } - public static ResourceLocation lambda$registerTextureInManager$2(Minecraft minecraft, ResourceLocation location, NativeImage image) { return null; } } diff --git a/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin$Model.java b/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin$Model.java deleted file mode 100644 index 7dad77a..0000000 --- a/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin$Model.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.client.resources; - -public class PlayerSkin$Model { - public static PlayerSkin$Model byName(String string) { return null; } -} diff --git a/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin.java b/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin.java deleted file mode 100644 index 1032dea..0000000 --- a/Dummy/src/main/java/net/minecraft/client/resources/PlayerSkin.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.client.resources; - -public class PlayerSkin { - -} diff --git a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$1.java b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$1.java index 9f3c18e..0e1971b 100644 --- a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$1.java +++ b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$1.java @@ -5,9 +5,11 @@ import java.util.concurrent.CompletableFuture; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.minecraft.MinecraftSessionService; +import net.minecraft.server.Services; public class SkinManager$1 { public CompletableFuture load(SkinManager$CacheKey cacheKey) { return null; } public static SkinManager$TextureInfo lambda$load$0(MinecraftSessionService sessionService, GameProfile profile) { return null; } public static MinecraftProfileTextures lambda$load$0(SkinManager$CacheKey cacheKey, MinecraftSessionService sessionService) { return null; } + public static MinecraftProfileTextures lambda$load$0(SkinManager$CacheKey cacheKey, Services services) { return null; } } diff --git a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$CacheKey.java b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$CacheKey.java index 6027e8d..180c22a 100644 --- a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$CacheKey.java +++ b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager$CacheKey.java @@ -1,7 +1,9 @@ package net.minecraft.client.resources; -import com.mojang.authlib.GameProfile; +import java.util.UUID; + +import com.mojang.authlib.properties.Property; public class SkinManager$CacheKey { - public GameProfile profile() { return null; } + public SkinManager$CacheKey(UUID uuid, Property property) { } } diff --git a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager.java b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager.java index c289201..e3fb7c2 100644 --- a/Dummy/src/main/java/net/minecraft/client/resources/SkinManager.java +++ b/Dummy/src/main/java/net/minecraft/client/resources/SkinManager.java @@ -2,12 +2,10 @@ package net.minecraft.client.resources; import java.io.File; import java.util.Map; -import java.util.UUID; import java.util.concurrent.CompletableFuture; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.minecraft.MinecraftSessionService; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; @@ -17,10 +15,8 @@ public class SkinManager { public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager$SkinAvailableCallback skinAvailableCallback) { return null; } public void loadProfileTextures(GameProfile profile, SkinManager$SkinAvailableCallback skinAvailableCallback, boolean requireSecure) { } public Map loadSkinFromCache(GameProfile profile) { return null; } + public CompletableFuture get(GameProfile profile) { return null; } public CompletableFuture getOrLoad(GameProfile profile) { return null; } - public PlayerSkin getInsecureSkin(GameProfile profile) { return null; } - public CompletableFuture registerTextures(UUID uuid, MinecraftProfileTextures textures) { return null; } public void /* lambda$loadProfileTextures$1 */ func_210275_a(GameProfile profile, boolean b, SkinManager$SkinAvailableCallback callback) {} public void /* lambda$null$0 */ func_210276_a(Map map, SkinManager$SkinAvailableCallback callback) {} - public static PlayerSkin lambda$registerTextures$1(CompletableFuture skin, String url, CompletableFuture cape, CompletableFuture elytra, PlayerSkin$Model model, MinecraftProfileTextures textures, Void _void) { return null; } } diff --git a/Dummy/src/main/java/net/minecraft/server/Services.java b/Dummy/src/main/java/net/minecraft/server/Services.java new file mode 100644 index 0000000..46f0b28 --- /dev/null +++ b/Dummy/src/main/java/net/minecraft/server/Services.java @@ -0,0 +1,5 @@ +package net.minecraft.server; + +public class Services { + +} diff --git a/Fabric/Fabric.tsrg b/Fabric/Fabric.tsrg index 650ec69..b6824c3 100644 --- a/Fabric/Fabric.tsrg +++ b/Fabric/Fabric.tsrg @@ -10,9 +10,6 @@ customskinloader/fake/itf/IFakeMinecraft customskinloader/fake/itf/IFakeMinecraf customskinloader/fake/itf/IFakeNativeImage customskinloader/fake/itf/IFakeNativeImage getPixel (II)I method_61940 setPixel (III)V method_61941 -customskinloader/fake/itf/IFakeSkinManagerCacheKey customskinloader/fake/itf/IFakeSkinManagerCacheKey - profile ()Lcom/mojang/authlib/GameProfile; comp_1631 - packedTextures ()Lcom/mojang/authlib/properties/Property; comp_2011 net/minecraft/client/Minecraft net/minecraft/class_310 gameDir field_1697 getCurrentServerData ()Lnet/minecraft/client/multiplayer/ServerData; method_1558 @@ -45,8 +42,6 @@ net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011 func_195715_a (IIIII)V method_4326 net/minecraft/client/renderer/texture/ReloadableTexture net/minecraft/class_10537 net/minecraft/client/renderer/texture/SkinTextureDownloader net/minecraft/class_10538 - lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage; method_65866 - processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage; method_65863 net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/class_1049 loadContents (Lnet/minecraft/client/resources/IResourceManager;)Lnet/minecraft/client/renderer/texture/TextureContents; method_65809 net/minecraft/client/renderer/texture/TextureContents net/minecraft/class_10539 @@ -61,9 +56,6 @@ net/minecraft/client/resources/IResource net/minecraft/class_3298 getInputStream ()Ljava/io/InputStream; method_14482 net/minecraft/client/resources/IResourceManager net/minecraft/class_3300 getResource (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/resources/IResource; method_14486 -net/minecraft/client/resources/PlayerSkin net/minecraft/class_8685 -net/minecraft/client/resources/PlayerSkin$Model net/minecraft/class_8685$class_7920 - byName (Ljava/lang/String;)Lnet/minecraft/client/resources/PlayerSkin$Model; method_52857 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 @@ -75,6 +67,7 @@ net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071 net/minecraft/client/resources/data/TextureMetadataSection net/minecraft/class_1084 net/minecraft/resources/IResource net/minecraft/class_3298 net/minecraft/resources/IResourceManager net/minecraft/class_3300 +net/minecraft/server/Services net/minecraft/class_7497 net/minecraft/util/ResourceLocation net/minecraft/class_2960 net/minecraft/util/StringUtils net/minecraft/class_3544 stripControlCodes (Ljava/lang/String;)Ljava/lang/String; method_15440 diff --git a/Fabric/build.properties b/Fabric/build.properties index ec6d759..d43fb18 100644 --- a/Fabric/build.properties +++ b/Fabric/build.properties @@ -1,5 +1,5 @@ -dependencies=Fabric|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8;\ - Quilt|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8 +dependencies=Fabric|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9;\ + Quilt|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9 java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 #forge gradle needs forge version forge_mc_version=1.12.2 diff --git a/Fabric/mixin.tsrg b/Fabric/mixin.tsrg index b8f751c..5703149 100644 --- a/Fabric/mixin.tsrg +++ b/Fabric/mixin.tsrg @@ -12,6 +12,7 @@ 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/SubmitNodeCollector net/minecraft/class_11659 net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/class_1046 processTask field_20843 loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; method_22795 @@ -23,31 +24,28 @@ 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;FFFFFF)V method_4177 doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V method_4177 doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V method_4177 + doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V method_4177 +net/minecraft/client/renderer/entity/state/AvatarRenderState net/minecraft/class_10055 net/minecraft/client/renderer/entity/state/PlayerRenderState net/minecraft/class_10055 -net/minecraft/client/renderer/texture/AbstractTexture net/minecraft/class_1044 net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011 net/minecraft/client/renderer/texture/SkinTextureDownloader net/minecraft/class_10538 downloadAndRegisterSkin (Lnet/minecraft/util/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture; method_65861 - lambda$registerTextureInManager$2 (Lnet/minecraft/client/Minecraft;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/util/ResourceLocation; method_65864 - lambda$registerTextureInManager$2 (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;Lnet/minecraft/client/Minecraft;)Lnet/minecraft/util/ResourceLocation; method_65864 + lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage; method_65866 + lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Lnet/minecraft/core/ClientAsset$DownloadedTexture;Z)Lnet/minecraft/client/renderer/texture/NativeImage; method_65866 + processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage; method_65863 net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060 - loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V method_4616 -net/minecraft/client/resources/PlayerSkin net/minecraft/class_8685 -net/minecraft/client/resources/PlayerSkin$Model net/minecraft/class_8685$class_7920 net/minecraft/client/resources/SkinManager net/minecraft/class_1071 func_210275_a (Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4653 func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655 - getInsecureSkin (Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin; method_52862 - getInsecureSkin (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/PlayerSkin;)Lnet/minecraft/client/resources/PlayerSkin; method_72180 + get (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; method_52863_ getOrLoad (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; method_52863 - lambda$registerTextures$1 (Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Ljava/util/concurrent/CompletableFuture;Ljava/util/concurrent/CompletableFuture;Lnet/minecraft/client/resources/PlayerSkin$Model;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;Ljava/lang/Void;)Lnet/minecraft/client/resources/PlayerSkin; method_52861 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 - registerTextures (Ljava/util/UUID;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;)Ljava/util/concurrent/CompletableFuture; method_52859 net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1 lambda$load$0 (Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo; method_52867 lambda$load$0 (Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures; method_54647 + lambda$load$0 (Lnet/minecraft/client/resources/SkinManager$CacheKey;Lnet/minecraft/server/Services;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures; method_54647 load (Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture; method_52868 net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686 net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072 @@ -55,6 +53,8 @@ net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071 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/core/ClientAsset$DownloadedTexture net/minecraft/class_12079$class_12080 net/minecraft/scoreboard/ScoreObjective net/minecraft/class_266 net/minecraft/scoreboard/Scoreboard net/minecraft/class_269 +net/minecraft/server/Services net/minecraft/class_7497 net/minecraft/util/ResourceLocation net/minecraft/class_2960 diff --git a/Fabric/src/main/java/customskinloader/fabric/DevEnvRemapper.java b/Fabric/src/main/java/customskinloader/fabric/DevEnvRemapper.java index 4d29da0..4f5f889 100644 --- a/Fabric/src/main/java/customskinloader/fabric/DevEnvRemapper.java +++ b/Fabric/src/main/java/customskinloader/fabric/DevEnvRemapper.java @@ -56,13 +56,6 @@ public class DevEnvRemapper extends SimpleRemapper { Lists.newArrayList("customskinloader.fake.itf.FakeInterfaceManager") ) ); - remappedClasses.put( - "net.minecraft.class_1071$class_8686", - new AbstractMap.SimpleEntry<>( - Lists.newArrayList("customskinloader.fake.itf.IFakeSkinManagerCacheKey"), - Lists.newArrayList("customskinloader.fake.itf.FakeInterfaceManager") - ) - ); } @SuppressWarnings("unchecked") diff --git a/Fabric/src/main/resources/customskinloader.accesswidener b/Fabric/src/main/resources/customskinloader.accesswidener index b1c2b36..e352754 100644 --- a/Fabric/src/main/resources/customskinloader.accesswidener +++ b/Fabric/src/main/resources/customskinloader.accesswidener @@ -1,4 +1,6 @@ accessWidener v2 intermediary +extendable class net/minecraft/class_1011 # 24w46a+ +extendable class net/minecraft/class_1071$class_8686 # 23w31a+ +extendable class net/minecraft/class_2960 # 24w46a+ +accessible method net/minecraft/class_1071$class_8686 (Ljava/util/UUID;Lcom/mojang/authlib/properties/Property;)V # 23w42a+ accessible method net/minecraft/class_2960 (Ljava/lang/String;Ljava/lang/String;)V # 24w18a+ -accessible method net/minecraft/class_10538 method_65863 (Lnet/minecraft/class_1011;Ljava/lang/String;)Lnet/minecraft/class_1011; # 24w46a+ -accessible method net/minecraft/class_10538 method_65866 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/class_1011; # 24w46a+ diff --git a/Fabric/src/main/resources/mixins.customskinloader.json b/Fabric/src/main/resources/mixins.customskinloader.json index 07bddf7..8abf212 100644 --- a/Fabric/src/main/resources/mixins.customskinloader.json +++ b/Fabric/src/main/resources/mixins.customskinloader.json @@ -11,17 +11,11 @@ "MixinMinecraft", "MixinNativeImage", "MixinRenderPlayer", - "MixinResourceLocation", "MixinSkinManager$1", - "MixinSkinManager$CacheKey", - "MixinSkinManager$TextureCache$V1", - "MixinSkinManager$TextureCache$V2", + "MixinSkinManager$TextureCache", "MixinSkinManager$V1", "MixinSkinManager$V2", "MixinSkinManager$V3", - "MixinSkinManager$V4", - "MixinSkinManager$V5", - "MixinSkinManager$V6", "MixinSkinTextureDownloader", "MixinThreadDownloadImageData$V1", "MixinThreadDownloadImageData$V2" diff --git a/Forge/V1/src/main/java/customskinloader/forge/transformer/SkinManagerTransformer.java b/Forge/V1/src/main/java/customskinloader/forge/transformer/SkinManagerTransformer.java index 19e4a58..5d21a21 100644 --- a/Forge/V1/src/main/java/customskinloader/forge/transformer/SkinManagerTransformer.java +++ b/Forge/V1/src/main/java/customskinloader/forge/transformer/SkinManagerTransformer.java @@ -99,8 +99,7 @@ public class SkinManagerTransformer { if (ain.getOpcode() == Opcodes.INVOKEINTERFACE) { MethodInsnNode min = (MethodInsnNode) ain; if (TransformerManager.checkClassName(min.owner, "java/util/concurrent/ExecutorService") && TransformerManager.checkMethodName(min.owner, min.name, min.desc, "submit") && TransformerManager.checkMethodDesc(min.desc, "(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;")) { - mn.instructions.insertBefore(min, new VarInsnNode(Opcodes.ALOAD, 1)); - mn.instructions.set(min, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;Lcom/mojang/authlib/GameProfile;)V", false)); + mn.instructions.set(min, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;)V", false)); } } } diff --git a/Forge/V1/src/main/resources/transformers.js b/Forge/V1/src/main/resources/transformers.js index 6dd3262..c0b7081 100644 --- a/Forge/V1/src/main/resources/transformers.js +++ b/Forge/V1/src/main/resources/transformers.js @@ -100,11 +100,10 @@ function initializeCoreMod() { if (node.getOpcode() === Opcodes.INVOKEINTERFACE && ((node.owner.equals("java/util/concurrent/ExecutorService") && checkName(node.name, "submit") && node.desc.equals("(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;")) // 1.14.4- || (node.owner.equals("java/util/concurrent/Executor") && checkName(node.name, "execute") && node.desc.equals("(Ljava/lang/Runnable;)V")))) { // 1.15+ - mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1)); if (node.desc.endsWith("V")) { mn.instructions.insert(node, new InsnNode(Opcodes.POP)); } - mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;Lcom/mojang/authlib/GameProfile;)V", false)); + mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;)V", false)); } } } else if (((checkName(mn.name, "func_210275_a") || checkName(mn.name, "lambda$loadProfileTextures$1")) // 1.14.4- diff --git a/Forge/V2/Forge.tsrg b/Forge/V2/Forge.tsrg index 7f71e69..9cdc9f7 100644 --- a/Forge/V2/Forge.tsrg +++ b/Forge/V2/Forge.tsrg @@ -10,9 +10,6 @@ customskinloader/fake/itf/IFakeMinecraft customskinloader/fake/itf/IFakeMinecraf customskinloader/fake/itf/IFakeNativeImage customskinloader/fake/itf/IFakeNativeImage getPixel (II)I getPixel setPixel (III)V setPixel -customskinloader/fake/itf/IFakeSkinManagerCacheKey customskinloader/fake/itf/IFakeSkinManagerCacheKey - profile ()Lcom/mojang/authlib/GameProfile; f_290972_ - packedTextures ()Lcom/mojang/authlib/properties/Property; f_303729_ net/minecraft/client/Minecraft net/minecraft/client/Minecraft gameDir f_91069_ getCurrentServerData ()Lnet/minecraft/client/multiplayer/ServerData; m_91089_ @@ -45,8 +42,6 @@ net/minecraft/client/renderer/texture/NativeImage com/mojang/blaze3d/platform/Na func_195715_a (IIIII)V m_84997_ net/minecraft/client/renderer/texture/ReloadableTexture net/minecraft/client/renderer/texture/ReloadableTexture net/minecraft/client/renderer/texture/SkinTextureDownloader net/minecraft/client/renderer/texture/SkinTextureDownloader - lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage; lambda$downloadAndRegisterSkin$0 - processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage; processLegacySkin net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/client/renderer/texture/SimpleTexture loadContents (Lnet/minecraft/client/resources/IResourceManager;)Lnet/minecraft/client/renderer/texture/TextureContents; loadContents net/minecraft/client/renderer/texture/TextureContents net/minecraft/client/renderer/texture/TextureContents @@ -61,9 +56,6 @@ net/minecraft/client/resources/IResource net/minecraft/server/packs/resources/Re getInputStream ()Ljava/io/InputStream; m_6679_ net/minecraft/client/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager getResource (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/resources/IResource; m_142591_ -net/minecraft/client/resources/PlayerSkin net/minecraft/client/resources/PlayerSkin -net/minecraft/client/resources/PlayerSkin$Model net/minecraft/client/resources/PlayerSkin$Model - byName (Ljava/lang/String;)Lnet/minecraft/client/resources/PlayerSkin$Model; byName 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_ @@ -75,6 +67,7 @@ net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/client/res net/minecraft/client/resources/data/TextureMetadataSection net/minecraft/client/resources/metadata/texture/TextureMetadataSection net/minecraft/resources/IResource net/minecraft/server/packs/resources/Resource net/minecraft/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager +net/minecraft/server/Services net/minecraft/server/Services net/minecraft/util/ResourceLocation net/minecraft/resources/ResourceLocation net/minecraft/util/StringUtils net/minecraft/util/StringUtil stripControlCodes (Ljava/lang/String;)Ljava/lang/String; m_14406_ diff --git a/Forge/V2/src/main/resources/META-INF/accesstransformer.cfg b/Forge/V2/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..b329ae5 --- /dev/null +++ b/Forge/V2/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,2 @@ +public-f net.minecraft.client.resources.SkinManager$CacheKey # 23w31a+ +public net.minecraft.client.resources.SkinManager$CacheKey (Ljava/util/UUID;Lcom/mojang/authlib/properties/Property;)V # 23w42a+ diff --git a/Forge/V2/src/main/resources/transformers.js b/Forge/V2/src/main/resources/transformers.js index 03e052f..bd8318d 100644 --- a/Forge/V2/src/main/resources/transformers.js +++ b/Forge/V2/src/main/resources/transformers.js @@ -91,9 +91,8 @@ function initializeCoreMod() { && (node.owner.equals("java/util/concurrent/Executor") // 1.17.1 || node.owner.equals("java/util/concurrent/ExecutorService")) // 1.18+ && checkName(node.name, "execute") && node.desc.equals("(Ljava/lang/Runnable;)V")) { - mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1)); mn.instructions.insert(node, new InsnNode(Opcodes.POP)); - mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;Lcom/mojang/authlib/GameProfile;)V", false)); + mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;)V", false)); } } } else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1- @@ -118,10 +117,6 @@ function initializeCoreMod() { mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 1)); mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false)); mn.instructions.insertBefore(first, new 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(); @@ -129,7 +124,7 @@ function initializeCoreMod() { mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createProperty", "(Lcom/mojang/authlib/properties/Property;)Lcom/mojang/authlib/properties/Property;", false)); } else if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/google/common/cache/LoadingCache") && checkName(node.name, "getUnchecked") && node.desc.equals("(Ljava/lang/Object;)Ljava/lang/Object;")) { mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1)); - mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadCache", "(Lcom/google/common/cache/LoadingCache;Ljava/lang/Object;Lcom/mojang/authlib/GameProfile;)Ljava/lang/Object;", false)); + mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadCache", "(Ljava/lang/Object;Lcom/mojang/authlib/GameProfile;)Ljava/lang/Object;", false)); } } } @@ -147,23 +142,14 @@ function initializeCoreMod() { if (checkName(mn.name, "load") && mn.desc.equals("(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;")) { for (var iterator = mn.instructions.iterator(); iterator.hasNext();) { var node = iterator.next(); - if (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("java/util/concurrent/CompletableFuture") && checkName(node.name, "supplyAsync") && node.desc.equals("(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) { - var s = "("; - var args = Type.getType(node.desc).getArgumentTypes(); - for (var i = 0; i < args.length; i++) { - s = s + "Ljava/lang/Object;"; - } - mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false)); - mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1)); - mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Lcom/google/common/collect/ImmutableList;Ljava/lang/Object;)[Ljava/lang/Object;", false)); - for (var i = 0; i < args.length; i++) { - mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP)); - mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i)); - mn.instructions.insertBefore(node, new InsnNode(Opcodes.AALOAD)); - mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, args[i].getInternalName())); - mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP)); - } - mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP)); + if ((node.getOpcode() === Opcodes.INVOKESTATIC + || node.getOpcode() === Opcodes.INVOKEVIRTUAL) + && node.owner.equals("java/util/concurrent/CompletableFuture") + && (checkName(node.name, "supplyAsync") + || checkName(node.name, "thenComposeAsync")) + && (node.desc.equals("(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;") + || node.desc.equals("(Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))) { + mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/util/concurrent/Executor;)Ljava/util/concurrent/Executor;", false)); } } } else if (checkName(mn.name, "m_293645_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;")) { // 1.20.2 @@ -177,8 +163,9 @@ function initializeCoreMod() { for (var iterator = mn.instructions.iterator(); iterator.hasNext();) { var node = iterator.next(); if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "unpackTextures") && node.desc.equals("(Lcom/mojang/authlib/properties/Property;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;")) { + mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1)); mn.instructions.insert(node, new TypeInsnNode(Opcodes.CHECKCAST, "com/mojang/authlib/minecraft/MinecraftProfileTextures")); - mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/properties/Property;)Ljava/lang/Object;", false)); + mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/properties/Property;Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/lang/Object;", false)); } } } @@ -186,16 +173,6 @@ function initializeCoreMod() { return cn; } }, - 'SkinManager$CacheKeyTransformer': { // 1.20.2+ - 'target': { - 'type': 'CLASS', - 'name': 'net/minecraft/client/resources/SkinManager$CacheKey' - }, - 'transformer': function (cn) { - cn.interfaces.add("customskinloader/fake/itf/IFakeSkinManagerCacheKey"); - return cn; - } - }, 'IResourceTransformer': { 'target': { 'type': 'CLASS', diff --git a/Forge/V3/Forge.tsrg b/Forge/V3/Forge.tsrg index 4ba176a..8acaf12 100644 --- a/Forge/V3/Forge.tsrg +++ b/Forge/V3/Forge.tsrg @@ -10,9 +10,6 @@ customskinloader/fake/itf/IFakeMinecraft customskinloader/fake/itf/IFakeMinecraf customskinloader/fake/itf/IFakeNativeImage customskinloader/fake/itf/IFakeNativeImage getPixel (II)I getPixel setPixel (III)V setPixel -customskinloader/fake/itf/IFakeSkinManagerCacheKey customskinloader/fake/itf/IFakeSkinManagerCacheKey - profile ()Lcom/mojang/authlib/GameProfile; profile - packedTextures ()Lcom/mojang/authlib/properties/Property; packedTextures net/minecraft/client/Minecraft net/minecraft/client/Minecraft gameDir gameDirectory getCurrentServerData ()Lnet/minecraft/client/multiplayer/ServerData; getCurrentServer @@ -45,8 +42,6 @@ net/minecraft/client/renderer/texture/NativeImage com/mojang/blaze3d/platform/Na func_195715_a (IIIII)V fillRect net/minecraft/client/renderer/texture/ReloadableTexture net/minecraft/client/renderer/texture/ReloadableTexture net/minecraft/client/renderer/texture/SkinTextureDownloader net/minecraft/client/renderer/texture/SkinTextureDownloader - lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage; lambda$downloadAndRegisterSkin$0 - processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage; processLegacySkin net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/client/renderer/texture/SimpleTexture loadContents (Lnet/minecraft/client/resources/IResourceManager;)Lnet/minecraft/client/renderer/texture/TextureContents; loadContents net/minecraft/client/renderer/texture/TextureContents net/minecraft/client/renderer/texture/TextureContents @@ -61,9 +56,6 @@ net/minecraft/client/resources/IResource net/minecraft/server/packs/resources/Re getInputStream ()Ljava/io/InputStream; getInputStream net/minecraft/client/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager getResource (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/resources/IResource; getResource -net/minecraft/client/resources/PlayerSkin net/minecraft/client/resources/PlayerSkin -net/minecraft/client/resources/PlayerSkin$Model net/minecraft/client/resources/PlayerSkin$Model - byName (Ljava/lang/String;)Lnet/minecraft/client/resources/PlayerSkin$Model; byName net/minecraft/client/resources/SkinManager net/minecraft/client/resources/SkinManager loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V registerSkins loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; registerTexture @@ -75,6 +67,7 @@ net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/client/res net/minecraft/client/resources/data/TextureMetadataSection net/minecraft/client/resources/metadata/texture/TextureMetadataSection net/minecraft/resources/IResource net/minecraft/server/packs/resources/Resource net/minecraft/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager +net/minecraft/server/Services net/minecraft/server/Services net/minecraft/util/ResourceLocation net/minecraft/resources/ResourceLocation net/minecraft/util/StringUtils net/minecraft/util/StringUtil stripControlCodes (Ljava/lang/String;)Ljava/lang/String; stripColor diff --git a/Forge/V3/build.properties b/Forge/V3/build.properties index 7ef4d64..621bda5 100644 --- a/Forge/V3/build.properties +++ b/Forge/V3/build.properties @@ -1,5 +1,5 @@ -dependencies=Forge|1.20.6,1.21,1.21.1,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8;\ - NeoForge|1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8 +dependencies=Forge|1.20.6,1.21,1.21.1,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9;\ + NeoForge|1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9 java_full_versions=17,18,19,20,21,22 #forge gradle needs forge version forge_mc_version=1.12.2 diff --git a/Forge/V3/mixin.tsrg b/Forge/V3/mixin.tsrg index f5d08eb..bd40137 100644 --- a/Forge/V3/mixin.tsrg +++ b/Forge/V3/mixin.tsrg @@ -12,6 +12,7 @@ net/minecraft/client/renderer/IImageBuffer net/minecraft/client/renderer/HttpTex net/minecraft/client/renderer/IRenderTypeBuffer net/minecraft/client/renderer/MultiBufferSource net/minecraft/client/renderer/RenderType net/minecraft/client/renderer/RenderType getEntitySolid (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType; entitySolid +net/minecraft/client/renderer/SubmitNodeCollector net/minecraft/client/renderer/SubmitNodeCollector net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/client/renderer/texture/HttpTexture processTask onDownloaded loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; load @@ -23,31 +24,28 @@ net/minecraft/client/renderer/entity/layers/LayerCape net/minecraft/client/rende doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFF)V render doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V render doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V render + doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V submit +net/minecraft/client/renderer/entity/state/AvatarRenderState net/minecraft/client/renderer/entity/state/AvatarRenderState net/minecraft/client/renderer/entity/state/PlayerRenderState net/minecraft/client/renderer/entity/state/PlayerRenderState -net/minecraft/client/renderer/texture/AbstractTexture net/minecraft/client/renderer/texture/AbstractTexture net/minecraft/client/renderer/texture/NativeImage com/mojang/blaze3d/platform/NativeImage net/minecraft/client/renderer/texture/SkinTextureDownloader net/minecraft/client/renderer/texture/SkinTextureDownloader downloadAndRegisterSkin (Lnet/minecraft/util/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture; downloadAndRegisterSkin - lambda$registerTextureInManager$2 (Lnet/minecraft/client/Minecraft;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/util/ResourceLocation; lambda$registerTextureInManager$2 - lambda$registerTextureInManager$2 (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;Lnet/minecraft/client/Minecraft;)Lnet/minecraft/util/ResourceLocation; lambda$registerTextureInManager$2 + lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage; lambda$downloadAndRegisterSkin$0 + lambda$downloadAndRegisterSkin$0 (Ljava/nio/file/Path;Lnet/minecraft/core/ClientAsset$DownloadedTexture;Z)Lnet/minecraft/client/renderer/texture/NativeImage; lambda$downloadAndRegisterSkin$0 + processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage; processLegacySkin net/minecraft/client/renderer/texture/TextureManager net/minecraft/client/renderer/texture/TextureManager - loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V register -net/minecraft/client/resources/PlayerSkin net/minecraft/client/resources/PlayerSkin -net/minecraft/client/resources/PlayerSkin$Model net/minecraft/client/resources/PlayerSkin$Model net/minecraft/client/resources/SkinManager net/minecraft/client/resources/SkinManager func_210275_a (Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V lambda$registerSkins$4 func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V lambda$registerSkins$2 - getInsecureSkin (Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin; getInsecureSkin - getInsecureSkin (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/PlayerSkin;)Lnet/minecraft/client/resources/PlayerSkin; getInsecureSkin + get (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; get getOrLoad (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; getOrLoad - lambda$registerTextures$1 (Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Ljava/util/concurrent/CompletableFuture;Ljava/util/concurrent/CompletableFuture;Lnet/minecraft/client/resources/PlayerSkin$Model;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;Ljava/lang/Void;)Lnet/minecraft/client/resources/PlayerSkin; lambda$registerTextures$1 loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V registerSkins loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; registerTexture loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; getInsecureSkinInformation - registerTextures (Ljava/util/UUID;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;)Ljava/util/concurrent/CompletableFuture; registerTextures net/minecraft/client/resources/SkinManager$1 net/minecraft/client/resources/SkinManager$1 lambda$load$0 (Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo; lambda$load$0 lambda$load$0 (Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures; lambda$load$0 + lambda$load$0 (Lnet/minecraft/client/resources/SkinManager$CacheKey;Lnet/minecraft/server/Services;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures; lambda$load$0 load (Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture; load net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/client/resources/SkinManager$SkinTextureCallback @@ -55,6 +53,8 @@ net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/client/res type type registerTexture (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture; registerTexture net/minecraft/client/resources/SkinManager$TextureInfo net/minecraft/client/resources/SkinManager$TextureInfo +net/minecraft/core/ClientAsset$DownloadedTexture net/minecraft/core/ClientAsset$DownloadedTexture net/minecraft/scoreboard/ScoreObjective net/minecraft/world/scores/Objective net/minecraft/scoreboard/Scoreboard net/minecraft/world/scores/Scoreboard +net/minecraft/server/Services net/minecraft/server/Services net/minecraft/util/ResourceLocation net/minecraft/resources/ResourceLocation diff --git a/Forge/V3/src/main/java/customskinloader/forge/MixinConfigPlugin.java b/Forge/V3/src/main/java/customskinloader/forge/MixinConfigPlugin.java index e3d5224..242a35b 100644 --- a/Forge/V3/src/main/java/customskinloader/forge/MixinConfigPlugin.java +++ b/Forge/V3/src/main/java/customskinloader/forge/MixinConfigPlugin.java @@ -53,7 +53,7 @@ public class MixinConfigPlugin extends customskinloader.mixin.core.MixinConfigPl private static void fixMixinModifyArgs() throws Throwable { ClassLoader loader = MixinConfigPlugin.class.getClassLoader(); Map handles = findPackageLookup(loader.getClass()); - if (handles != null) { + if (handles != null && handles.get("packageLookup") != null) { Map packageToOurModules = (Map) handles.get("packageLookup").invokeWithArguments(loader); String packageName = "org.spongepowered.asm.synthetic.args"; if (packageToOurModules.get(packageName) == null) { diff --git a/Forge/V3/src/main/resources/META-INF/accesstransformer.cfg b/Forge/V3/src/main/resources/META-INF/accesstransformer.cfg index 31a8be0..1a98473 100644 --- a/Forge/V3/src/main/resources/META-INF/accesstransformer.cfg +++ b/Forge/V3/src/main/resources/META-INF/accesstransformer.cfg @@ -1,3 +1,5 @@ +public-f com.mojang.blaze3d.platform.NativeImage # 24w46a+ +public-f net.minecraft.client.resources.SkinManager$CacheKey # 23w42a+ +public-f net.minecraft.resources.ResourceLocation # 24w46a+ +public net.minecraft.client.resources.SkinManager$CacheKey (Ljava/util/UUID;Lcom/mojang/authlib/properties/Property;)V # 23w42a+ public net.minecraft.resources.ResourceLocation (Ljava/lang/String;Ljava/lang/String;)V # 24w18a+ -public net.minecraft.client.renderer.texture.SkinTextureDownloader processLegacySkin(Lcom/mojang/blaze3d/platform/NativeImage;Ljava/lang/String;)Lcom/mojang/blaze3d/platform/NativeImage; # 24w46a+ -public net.minecraft.client.renderer.texture.SkinTextureDownloader lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Ljava/lang/String;Z)Lcom/mojang/blaze3d/platform/NativeImage; # 24w46a+ diff --git a/Forge/V3/src/main/resources/META-INF/neoforge.mods.toml b/Forge/V3/src/main/resources/META-INF/neoforge.mods.toml index e0bc8d3..f8ef3e8 100644 --- a/Forge/V3/src/main/resources/META-INF/neoforge.mods.toml +++ b/Forge/V3/src/main/resources/META-INF/neoforge.mods.toml @@ -13,8 +13,8 @@ Custom Skin Loader for Minecraft ''' # The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded. -#[[mixins]] -#config="{mod_id}.mixins.json" +[[mixins]] +config="mixins.customskinloader.json" # The [[accessTransformers]] block allows you to declare where your AT file is. # If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg diff --git a/Forge/V3/src/main/resources/mixins.customskinloader.json b/Forge/V3/src/main/resources/mixins.customskinloader.json index a5d19de..8dab911 100644 --- a/Forge/V3/src/main/resources/mixins.customskinloader.json +++ b/Forge/V3/src/main/resources/mixins.customskinloader.json @@ -10,16 +10,10 @@ "MixinMinecraft", "MixinNativeImage", "MixinRenderPlayer", - "MixinResourceLocation", "MixinSkinManager$1", - "MixinSkinManager$CacheKey", - "MixinSkinManager$TextureCache$V1", - "MixinSkinManager$TextureCache$V2", - "MixinSkinManager$V2", + "MixinSkinManager$TextureCache", + "MixinSkinManager$V1", "MixinSkinManager$V3", - "MixinSkinManager$V4", - "MixinSkinManager$V5", - "MixinSkinManager$V6", "MixinSkinTextureDownloader", "MixinThreadDownloadImageData$V2" ], diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinLayerCape.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinLayerCape.java index 4cfa161..d4ba117 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinLayerCape.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinLayerCape.java @@ -17,7 +17,8 @@ public abstract class MixinLayerCape { method = { "Lnet/minecraft/client/renderer/entity/layers/LayerCape;doRenderLayer(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V", // 19w39a ~ 19w44a "Lnet/minecraft/client/renderer/entity/layers/LayerCape;doRenderLayer(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFF)V", // 19w45a ~ 1.21.1 - "Lnet/minecraft/client/renderer/entity/layers/LayerCape;doRenderLayer(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V" // 24w33a+ + "Lnet/minecraft/client/renderer/entity/layers/LayerCape;doRenderLayer(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V", // 24w33a ~ 1.21.8 + "Lnet/minecraft/client/renderer/entity/layers/LayerCape;doRenderLayer(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V" // 25w31a+ }, at = @At( value = "INVOKE", diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinRenderPlayer.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinRenderPlayer.java index 98fbe13..0d3c378 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinRenderPlayer.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinRenderPlayer.java @@ -15,8 +15,8 @@ import org.spongepowered.asm.mixin.injection.Redirect; public abstract class MixinRenderPlayer { @Redirect( method = { - "Lnet/minecraft/client/renderer/entity/RenderPlayer;renderItem(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;Lnet/minecraft/client/entity/AbstractClientPlayer;Lnet/minecraft/client/model/ModelRenderer;Lnet/minecraft/client/model/ModelRenderer;)V", // 19w39a~19w44a - "Lnet/minecraft/client/renderer/entity/RenderPlayer;renderItem(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;Lnet/minecraft/client/model/ModelRenderer;Lnet/minecraft/client/model/ModelRenderer;)V" // 19w45a+ + "Lnet/minecraft/client/renderer/entity/RenderPlayer;renderItem(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;Lnet/minecraft/client/entity/AbstractClientPlayer;Lnet/minecraft/client/model/ModelRenderer;Lnet/minecraft/client/model/ModelRenderer;)V", // 19w39a ~ 19w44a + "Lnet/minecraft/client/renderer/entity/RenderPlayer;renderItem(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;Lnet/minecraft/client/model/ModelRenderer;Lnet/minecraft/client/model/ModelRenderer;)V" // 19w45a ~ 1.21.1 }, at = @At( value = "INVOKE", diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinResourceLocation.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinResourceLocation.java deleted file mode 100644 index 9bed8fa..0000000 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinResourceLocation.java +++ /dev/null @@ -1,22 +0,0 @@ -package customskinloader.mixin; - -import customskinloader.fake.itf.IFakeResourceLocation; -import net.minecraft.util.ResourceLocation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(ResourceLocation.class) -public abstract class MixinResourceLocation implements IFakeResourceLocation { - @Unique - private Object customskinloader$texture; - - @Override - public Object customskinloader$getTexture() { - return this.customskinloader$texture; - } - - @Override - public void customskinloader$setTexture(Object texture) { - this.customskinloader$texture = texture; - } -} diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$1.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$1.java index 4c71cc1..5e4d557 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$1.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$1.java @@ -1,8 +1,8 @@ package customskinloader.mixin; import java.util.Map; +import java.util.concurrent.Executor; -import com.google.common.collect.ImmutableList; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftSessionService; @@ -14,13 +14,12 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Group; -import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.ModifyArg; 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( + @ModifyArg( method = "Lnet/minecraft/client/resources/SkinManager$1;load(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;", at = @At( value = "INVOKE", @@ -28,12 +27,20 @@ public abstract class MixinSkinManager$1 { 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)); + private Executor modifyArg_load_0(Executor executor) { + return FakeSkinManager.loadProfileTextures(executor); + } + + @ModifyArg( + 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;thenComposeAsync(Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", + remap = false + ) + ) + private Executor modifyArg_load_1(Executor executor) { + return FakeSkinManager.loadProfileTextures(executor); } // 23w31a ~ 23w41a @@ -62,14 +69,17 @@ public abstract class MixinSkinManager$1 { max = 2 ) @Redirect( - method = "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;", + method = { + "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;", // 23w42a ~ 25w33a + "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lnet/minecraft/server/Services;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;" // 25w34a+ + }, at = @At( value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;unpackTextures(Lcom/mojang/authlib/properties/Property;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;", remap = false ) ) - private static Object redirect_lambda$load$0(MinecraftSessionService sessionService, Property property) { - return FakeSkinManager.loadSkinFromCache(sessionService, property); + private static Object redirect_lambda$load$0(MinecraftSessionService sessionService, Property property, SkinManager$CacheKey cacheKey, @Coerce Object service) { + return FakeSkinManager.loadSkinFromCache(sessionService, property, cacheKey); } } diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$CacheKey.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$CacheKey.java deleted file mode 100644 index 0b282df..0000000 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$CacheKey.java +++ /dev/null @@ -1,10 +0,0 @@ -package customskinloader.mixin; - -import customskinloader.fake.itf.IFakeSkinManagerCacheKey; -import net.minecraft.client.resources.SkinManager$CacheKey; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(SkinManager$CacheKey.class) -public abstract class MixinSkinManager$CacheKey implements IFakeSkinManagerCacheKey { - -} diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$TextureCache.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$TextureCache.java index 4ee3a8c..ea53952 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$TextureCache.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager$TextureCache.java @@ -1,7 +1,5 @@ package customskinloader.mixin; -import java.util.concurrent.CompletableFuture; - import com.google.common.collect.ImmutableList; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import customskinloader.fake.FakeSkinManager; @@ -9,64 +7,54 @@ import net.minecraft.client.resources.SkinManager$TextureCache; 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.Inject; +import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; +@Mixin(SkinManager$TextureCache.class) public abstract class MixinSkinManager$TextureCache { - // 23w31a ~ 24w45a - @Mixin(SkinManager$TextureCache.class) - public abstract static class V1 { - @Shadow - private MinecraftProfileTexture.Type type; + @Shadow + private MinecraftProfileTexture.Type type; - @ModifyArgs( - method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;ZLjava/lang/Runnable;)V" - ) + // 23w31a ~ 24w45a + @Group( + name = "modifyArgs_registerTexture", + min = 1 + ) + @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;(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); + ) + private void modifyArgs_registerTexture_0(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); } // 23w46a+ - @Mixin(SkinManager$TextureCache.class) - public abstract static class V2 { - @Shadow - private MinecraftProfileTexture.Type type; - - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;", - at = @At("RETURN"), - cancellable = true + @Group( + name = "modifyArgs_registerTexture", + min = 1 + ) + @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/texture/SkinTextureDownloader;downloadAndRegisterSkin(Lnet/minecraft/util/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture;" ) - private void inject_registerTexture(CallbackInfoReturnable> cir) { - cir.setReturnValue(FakeSkinManager.clearCachedFuture(cir.getReturnValue())); - } - - @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/texture/SkinTextureDownloader;downloadAndRegisterSkin(Lnet/minecraft/util/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture;" - ) - ) - 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); + ) + private void modifyArgs_registerTexture_1(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); } } diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager.java index b59f0b8..157131c 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinManager.java @@ -4,32 +4,26 @@ import java.io.File; import java.nio.file.Path; import java.util.Map; import java.util.UUID; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.properties.Property; import customskinloader.fake.FakeSkinManager; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.PlayerSkin; -import net.minecraft.client.resources.PlayerSkin$Model; import net.minecraft.client.resources.SkinManager; +import net.minecraft.client.resources.SkinManager$CacheKey; import net.minecraft.client.resources.SkinManager$SkinAvailableCallback; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -37,17 +31,68 @@ import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @SuppressWarnings("target") public abstract class MixinSkinManager { - // 18w43b ~ 1.20.1 + // 18w43b+ @Mixin(SkinManager.class) public abstract static class V1 { + // 18w43b ~ 1.20.1 + @Group( + name = "inject_init", + min = 1 + ) @Inject( method = "Lnet/minecraft/client/resources/SkinManager;(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) { + private void inject_init(@Coerce Object textureManager, File skinCacheDirectory, @Coerce Object service, CallbackInfo callbackInfo) { FakeSkinManager.setSkinCacheDir(skinCacheDirectory); } + // 23w31a ~ 24w45a + @Group( + name = "inject_init", + min = 1 + ) + @Inject( + method = "Lnet/minecraft/client/resources/SkinManager;(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(@Coerce Object textureManager, Path path, @Coerce Object service, @Coerce Object executor, CallbackInfo callbackInfo) { + FakeSkinManager.setSkinCacheDir(path); + } + + // 24w46a ~ 25w34b + @Group( + name = "inject_init", + min = 1 + ) + @Inject( + method = { + "Lnet/minecraft/client/resources/SkinManager;(Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V", // 24w46a ~ 25w33a + "Lnet/minecraft/client/resources/SkinManager;(Ljava/nio/file/Path;Lnet/minecraft/server/Services;Ljava/util/concurrent/Executor;)V" // 25w34a ~ 25w34b + }, + at = @At("RETURN") + ) + private void inject_init(Path path, @Coerce Object service, @Coerce Object executor, CallbackInfo callbackInfo) { + FakeSkinManager.setSkinCacheDir(path); + } + + // 25w35a+ + @Group( + name = "inject_init", + min = 1 + ) + @Inject( + method = "Lnet/minecraft/client/resources/SkinManager;(Ljava/nio/file/Path;Lnet/minecraft/server/Services;Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;Ljava/util/concurrent/Executor;)V", + at = @At("RETURN") + ) + private void inject_init(Path path, @Coerce Object service, @Coerce Object downloader, @Coerce Object executor, CallbackInfo callbackInfo) { + FakeSkinManager.setSkinCacheDir(path); + } + } + + // 18w43b ~ 1.20.1 + @Mixin(SkinManager.class) + public abstract static class V2 { // 18w43b ~ 19w37a @Group( name = "modifyArgs_loadSkin", @@ -98,8 +143,8 @@ public abstract class MixinSkinManager { remap = false ) ) - private Future redirect_loadProfileTextures_0(ExecutorService executor, Runnable task, GameProfile profile, SkinManager$SkinAvailableCallback skinAvailableCallback, boolean requireSecure) { - FakeSkinManager.loadProfileTextures(task, profile); + private Future redirect_loadProfileTextures_0(ExecutorService executor, Runnable task) { + FakeSkinManager.loadProfileTextures(task); return null; } @@ -116,8 +161,8 @@ public abstract class MixinSkinManager { remap = false ) ) - private void redirect_loadProfileTextures_1(Executor executor, Runnable task, GameProfile profile, SkinManager$SkinAvailableCallback skinAvailableCallback, boolean requireSecure) { - FakeSkinManager.loadProfileTextures(task, profile); + private void redirect_loadProfileTextures_1(Executor executor, Runnable task) { + FakeSkinManager.loadProfileTextures(task); } // 21w37a ~ 1.20.1 @@ -133,8 +178,8 @@ public abstract class MixinSkinManager { remap = false ) ) - private void redirect_loadProfileTextures_2(ExecutorService executor, Runnable task, GameProfile profile, SkinManager$SkinAvailableCallback skinAvailableCallback, boolean requireSecure) { - FakeSkinManager.loadProfileTextures(task, profile); + private void redirect_loadProfileTextures_2(ExecutorService executor, Runnable task) { + FakeSkinManager.loadProfileTextures(task); } @Inject( @@ -194,59 +239,14 @@ public abstract class MixinSkinManager { } } - // 23w31a ~ 23w45a - @Mixin(SkinManager.class) - public abstract static class V2 { - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager;(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;(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 modifyArg_init(CacheLoader cacheLoader) { - return FakeSkinManager.setCacheLoader(cacheLoader); - } - } - - // 23w31a+ - @Mixin(SkinManager.class) - public abstract static class V3 { - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager;getInsecureSkin(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin;", - at = @At("HEAD") - ) - private void inject_getInsecureSkin(GameProfile profile, CallbackInfoReturnable callbackInfoReturnable) { - FakeSkinManager.setSkullType(profile); - } - - @Redirect( - method = "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;", - at = @At( - value = "INVOKE", - target = "Lcom/google/common/cache/LoadingCache;getUnchecked(Ljava/lang/Object;)Ljava/lang/Object;", - remap = false - ) - ) - private Object redirect_getOrLoad(LoadingCache loadingCache, Object cacheKey, GameProfile profile) throws Exception { - return FakeSkinManager.loadCache(loadingCache, cacheKey, profile); - } - } - // 23w42a+ @Mixin(SkinManager.class) - public abstract static class V4 { + public abstract static class V3 { @ModifyArg( - method = "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;", + method = { + "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;", // 23w42a ~ 25w33a + "Lnet/minecraft/client/resources/SkinManager;get(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;" // 25w34a+ + }, at = @At( value = "INVOKE", target = "Lnet/minecraft/client/resources/SkinManager$CacheKey;(Ljava/util/UUID;Lcom/mojang/authlib/properties/Property;)V" @@ -255,59 +255,19 @@ public abstract class MixinSkinManager { private Property modifyArg_getOrLoad(Property property) { return FakeSkinManager.createProperty(property); } - } - // 23w46a+ - @Mixin(SkinManager.class) - public abstract static class V5 { - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager;(Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V", - at = @At("RETURN") - ) - private void inject_init(Path path, MinecraftSessionService minecraftSessionService, Executor executor, CallbackInfo callbackInfo) { - FakeSkinManager.setSkinCacheDir(path); - } - - @ModifyArg( - method = "Lnet/minecraft/client/resources/SkinManager;(Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V", + @Redirect( + method = { + "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;", // 23w42a ~ 25w33a + "Lnet/minecraft/client/resources/SkinManager;get(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;" // 25w34a+ + }, at = @At( - value = "INVOKE", - target = "Lcom/google/common/cache/CacheBuilder;build(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;", - remap = false + value = "NEW", + target = "(Ljava/util/UUID;Lcom/mojang/authlib/properties/Property;)Lnet/minecraft/client/resources/SkinManager$CacheKey;" ) ) - private CacheLoader modifyArg_init(CacheLoader cacheLoader) { - return FakeSkinManager.setCacheLoader(cacheLoader); - } - - @ModifyVariable( - method = "Lnet/minecraft/client/resources/SkinManager;lambda$registerTextures$1(Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Ljava/util/concurrent/CompletableFuture;Ljava/util/concurrent/CompletableFuture;Lnet/minecraft/client/resources/PlayerSkin$Model;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;Ljava/lang/Void;)Lnet/minecraft/client/resources/PlayerSkin;", - at = @At("HEAD"), - argsOnly = true - ) - private static PlayerSkin$Model modifyVariable_lambda$registerTextures$1(PlayerSkin$Model model, CompletableFuture skin, String url, CompletableFuture cape, CompletableFuture elytra, PlayerSkin$Model _model, MinecraftProfileTextures textures) { - return FakeSkinManager.loadSkinModel(model, textures); - } - } - - // 1.21.6-pre1+ - @Mixin(SkinManager.class) - public abstract static class V6 { - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager;getInsecureSkin(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/PlayerSkin;)Lnet/minecraft/client/resources/PlayerSkin;", - at = @At("HEAD") - ) - private void inject_getInsecureSkin(GameProfile profile, PlayerSkin skin, CallbackInfoReturnable callbackInfoReturnable) { - FakeSkinManager.setSkullType(profile); - } - - @Inject( - method = "Lnet/minecraft/client/resources/SkinManager;registerTextures(Ljava/util/UUID;Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;)Ljava/util/concurrent/CompletableFuture;", - at = @At("RETURN"), - cancellable = true - ) - private void inject_registerTextures(UUID uuid, MinecraftProfileTextures textures, CallbackInfoReturnable> callbackInfoReturnable) { - callbackInfoReturnable.setReturnValue(FakeSkinManager.checkIncompleted(textures, callbackInfoReturnable.getReturnValue())); + private SkinManager$CacheKey redirect_getOrLoad(UUID uuid, Property property, GameProfile profile) { + return FakeSkinManager.FakeCacheKey.createFakeCacheKey(uuid, property, profile); } } } diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinTextureDownloader.java b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinTextureDownloader.java index 43b691a..f96492d 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinTextureDownloader.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/MixinSkinTextureDownloader.java @@ -1,28 +1,44 @@ package customskinloader.mixin; -import customskinloader.fake.FakeSkinManager; -import net.minecraft.client.renderer.texture.AbstractTexture; +import java.nio.file.Path; + +import customskinloader.fake.FakeSkinBuffer; +import customskinloader.fake.texture.FakeThreadDownloadImageData; +import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.renderer.texture.SkinTextureDownloader; -import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; 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(SkinTextureDownloader.class) @SuppressWarnings("target") public abstract class MixinSkinTextureDownloader { + @ModifyArgs( + method = "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;downloadAndRegisterSkin(Lnet/minecraft/util/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture;", + at = @At( + value = "INVOKE", + target = "Ljava/util/concurrent/CompletableFuture;thenCompose(Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture;", + remap = false + ) + ) + private static void modifyArg_downloadAndRegisterSkin(Args args, ResourceLocation location, Path path, String url, boolean bl) { + args.set(0, FakeThreadDownloadImageData.createTexture(args.get(0), location, bl)); + } + @Redirect( method = { - "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;lambda$registerTextureInManager$2(Lnet/minecraft/client/Minecraft;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/util/ResourceLocation;", // 23w46a ~ 1.21.5 - "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;lambda$registerTextureInManager$2(Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/NativeImage;Lnet/minecraft/client/Minecraft;)Lnet/minecraft/util/ResourceLocation;" // 25w15a+ + "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Ljava/lang/String;Z)Lnet/minecraft/client/renderer/texture/NativeImage;", // 24w46a ~ 25w37a + "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Lnet/minecraft/core/ClientAsset$DownloadedTexture;Z)Lnet/minecraft/client/renderer/texture/NativeImage;" // 1.21.9-pre1+ }, at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/renderer/texture/TextureManager;loadTexture(Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V" + target = "Lnet/minecraft/client/renderer/texture/SkinTextureDownloader;processLegacySkin(Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage;" ) ) - private static void redirect_lambda$registerTextureInManager$2(TextureManager manager, ResourceLocation location, AbstractTexture texture) { - FakeSkinManager.registerTextureInManager(manager, location, texture); + private static NativeImage redirect_lambda$downloadAndRegisterSkin$0(NativeImage image, String url) { + return FakeSkinBuffer.processLegacySkin(image, url); } } diff --git a/Vanilla/Common/src/main/java/customskinloader/mixin/core/MixinConfigPlugin.java b/Vanilla/Common/src/main/java/customskinloader/mixin/core/MixinConfigPlugin.java index 1aa846e..079580a 100644 --- a/Vanilla/Common/src/main/java/customskinloader/mixin/core/MixinConfigPlugin.java +++ b/Vanilla/Common/src/main/java/customskinloader/mixin/core/MixinConfigPlugin.java @@ -53,25 +53,25 @@ public class MixinConfigPlugin implements IMixinConfigPlugin { public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { boolean result = true; if (mixinClassName.endsWith(".MixinIImageBuffer")) { - result = this.world_version <= 2204 && this.protocol_version <= 553; // 18w43b ~ 19w37a - } else if (mixinClassName.endsWith(".MixinLayerCape") || mixinClassName.endsWith(".MixinRenderPlayer")) { + result = (this.world_version >= 0 && this.world_version <= 2204) && (this.protocol_version >= 0 && this.protocol_version <= 553); // 18w43b ~ 19w37a + } else if (mixinClassName.endsWith(".MixinLayerCape")) { result = this.world_version >= 2210 && this.protocol_version >= 558; // 19w41a+ + } else if (mixinClassName.endsWith(".MixinRenderPlayer")) { + result = (this.world_version >= 2210 && this.world_version <= 3955) && ((this.protocol_version >= 558 && this.protocol_version <= 767) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x400000CC)); // 19w41a ~ 1.21.1 } 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$TextureCache$V1")) { - result = (this.world_version >= 3567 && this.world_version <= 4177) && ((this.protocol_version >= 764 && this.protocol_version <= 768) || (this.protocol_version >= 0x40000090 && this.protocol_version <= 0x400000DD)); // 23w31a ~ 23w45a - } else if (mixinClassName.endsWith(".MixinSkinManager$V3") || mixinClassName.endsWith(".MixinSkinManager$1") || mixinClassName.endsWith(".MixinSkinManager$CacheKey")) { - result = this.world_version >= 3567 && ((this.protocol_version >= 764 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000090); // 23w31a+ - } else if (mixinClassName.endsWith(".MixinSkinManager$V4")) { + result = this.world_version >= 0 && this.protocol_version >= 0; // 18w43b+ + } else if (mixinClassName.endsWith(".MixinSkinManager$V2")) { + result = (this.world_version >= 0 && this.world_version <= 3465) && ((this.protocol_version >= 0 && 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$V3")) { result = this.world_version >= 3684 && ((this.protocol_version >= 765 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x4000009D); // 23w42a+ - } else if (mixinClassName.endsWith(".MixinSkinManager$V5") || mixinClassName.endsWith(".MixinSkinManager$TextureCache$V2") || mixinClassName.endsWith(".MixinSkinTextureDownloader") || mixinClassName.endsWith(".MixinResourceLocation")) { - result = this.world_version >= 4178 && ((this.protocol_version >= 769 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x400000DE); // 23w46a+ - } else if (mixinClassName.endsWith(".MixinSkinManager$V6")) { - result = this.world_version >= 4430 && ((this.protocol_version >= 771 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x400000FC); // 1.21.6-pre1+ + } else if (mixinClassName.endsWith(".MixinSkinManager$1") || mixinClassName.endsWith(".MixinSkinManager$TextureCache")) { + result = this.world_version >= 3567 && ((this.protocol_version >= 764 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000090); // 23w31a+ + } else if (mixinClassName.endsWith(".MixinSkinTextureDownloader")) { + result = this.world_version >= 4178 && ((this.protocol_version >= 769 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x400000DE); // 24w46a+ } 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.world_version <= 4177) && ((this.protocol_version >= 755 && this.protocol_version <= 768) || (this.protocol_version >= 0x40000023 && this.protocol_version <= 0x400000DD)); // 1.17-rc2 ~ 23w45a + result = (this.world_version >= 2723 && this.world_version <= 4177) && ((this.protocol_version >= 755 && this.protocol_version <= 768) || (this.protocol_version >= 0x40000023 && this.protocol_version <= 0x400000DD)); // 1.17-rc2 ~ 24w45a } logger.info("target: " + targetClassName + ", mixin: " + mixinClassName + ", result: " + result); return result; diff --git a/build.gradle b/build.gradle index 18525e8..413df4c 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,7 @@ subprojects { archivesBaseName = "CustomSkinLoader_${-> VersionUtil.getEdition(project)}" processResources { - filesNotMatching(["**/*.js", "**/accesstransformer.cfg", "mixins.*.json"]) { + filesNotMatching(["**/*.js", "**/accesstransformer.cfg", "customskinloader.accesswidener", "mixins.*.json"]) { expand([ modVersion : rootProject.ext.config.version, modFullVersion : project.version, diff --git a/buildSrc/src/main/java/customskinloader/gradle/util/RemapUtil.java b/buildSrc/src/main/java/customskinloader/gradle/util/RemapUtil.java index 7683859..5775f84 100644 --- a/buildSrc/src/main/java/customskinloader/gradle/util/RemapUtil.java +++ b/buildSrc/src/main/java/customskinloader/gradle/util/RemapUtil.java @@ -18,7 +18,11 @@ import com.google.common.collect.Sets; import net.minecraftforge.srg2source.ast.RangeExtractor; import net.minecraftforge.srg2source.util.io.InputSupplier; import org.apache.commons.io.FileUtils; +import org.cadixdev.bombe.type.ArrayType; +import org.cadixdev.bombe.type.FieldType; +import org.cadixdev.bombe.type.ObjectType; import org.cadixdev.lorenz.MappingSet; +import org.cadixdev.lorenz.impl.MappingSetImpl; import org.cadixdev.lorenz.io.srg.SrgReader; import org.cadixdev.lorenz.io.srg.SrgWriter; import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader; @@ -39,7 +43,7 @@ public class RemapUtil { if (!tsrg.exists()) return; if (!srg.getParentFile().exists()) srg.getParentFile().mkdirs(); - MappingSet set = MappingSet.create(); + MappingSet set = new MappingSetImplWithoutInnerClass(); try ( Reader reader = Files.newBufferedReader(tsrg.toPath(), StandardCharsets.UTF_8); @@ -107,6 +111,42 @@ public class RemapUtil { return new String(chars); } + public static class MappingSetImplWithoutInnerClass extends MappingSetImpl { + @Override + public Optional> getClassMapping(String obfuscatedName) { + return this.getTopLevelClassMapping(obfuscatedName); + } + + @Override + public Optional> computeClassMapping(final String obfuscatedName) { + return this.getTopLevelClassMapping(obfuscatedName); + } + + @Override + public ClassMapping getOrCreateClassMapping(final String obfuscatedName) { + return this.getOrCreateTopLevelClassMapping(obfuscatedName); + } + + @Override + public FieldType deobfuscate(final FieldType type) { + if (type instanceof ArrayType) { + final ArrayType arr = (ArrayType) type; + final FieldType component = this.deobfuscate(arr.getComponent()); + return component == arr.getComponent() ? arr : new ArrayType(arr.getDimCount(), component); + } else if (type instanceof ObjectType) { + final ObjectType obj = (ObjectType) type; + + ClassMapping currentClass = this.getClassMapping(obj.getClassName()).orElse(null); + if (currentClass == null) { + return type; + } + + return new ObjectType(currentClass.getFullDeobfuscatedName()); + } + return type; + } + } + public static class SrgWriterWithoutFilter extends SrgWriter { private final List classes = new ArrayList<>(); private final List fields = new ArrayList<>();