mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 11:59:45 +00:00
1 parent
a9b2484b3e
commit
1cb4cf40b0
93 files changed
+762
-181
No files matched your search
@@ -1,7 +0,0 @@
|
||||
package com.mojang.authlib;
|
||||
|
||||
public enum SignatureState {
|
||||
UNSIGNED,
|
||||
INVALID,
|
||||
SIGNED
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mojang.authlib.minecraft;
|
||||
|
||||
import com.mojang.authlib.SignatureState;
|
||||
|
||||
public class MinecraftProfileTextures {
|
||||
public MinecraftProfileTextures(MinecraftProfileTexture skin, MinecraftProfileTexture cape, MinecraftProfileTexture elytra, SignatureState signatureState) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,27 @@ package customskinloader.fake;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("minecraft", "textures/entity/elytra.png");
|
||||
private static final ResourceLocation TEXTURE_ELYTRA_V1 = new ResourceLocation("minecraft", "textures/entity/elytra.png");
|
||||
private static final ResourceLocation TEXTURE_ELYTRA_V2 = new ResourceLocation("minecraft", "textures/entity/equipment/wings/elytra.png");
|
||||
private static int loadedGlobal = 0;
|
||||
private static FakeImage elytraImage;
|
||||
|
||||
private static FakeImage loadElytra(FakeImage originalImage) {
|
||||
loadedGlobal++;
|
||||
try {
|
||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
|
||||
Object resourceManager = FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft());
|
||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V1)
|
||||
.orElseGet(() -> FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V2).orElse(null)));
|
||||
if (is != null) {
|
||||
FakeImage image = originalImage.createImage(is);
|
||||
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
||||
@@ -28,7 +31,8 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
image = resetImageFormat(image, 22, 0, 46, 22);
|
||||
return image;
|
||||
}
|
||||
} catch (IOException | NoSuchElementException ignored) {
|
||||
} catch (IOException e) {
|
||||
CustomSkinLoader.logger.warning(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
@@ -16,15 +15,15 @@ import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
public class FakeClientPlayer {
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager.SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
||||
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager$SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
||||
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer) {//Cache for client player
|
||||
textureCache.put(resourcelocation, threaddownloadimagedata);
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class FakeClientPlayer {
|
||||
|
||||
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||
|
||||
public static class LegacyBuffer implements SkinAvailableCallback {
|
||||
public static class LegacyBuffer implements SkinManager$SkinAvailableCallback {
|
||||
ResourceLocation resourceLocationIn;
|
||||
boolean loaded = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -8,19 +9,31 @@ import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.texture.FakeBufferedImage;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import customskinloader.fake.texture.FakeNativeImage;
|
||||
import customskinloader.fake.texture.FakeThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
|
||||
public class FakeSkinBuffer implements IImageBuffer {
|
||||
private int ratio = 1;
|
||||
FakeImage image = null;
|
||||
|
||||
//parseUserSkin for 1.15+
|
||||
/**
|
||||
* 19w38a ~ 24w45a
|
||||
* Invoked from {@link ThreadDownloadImageData#loadTexture(InputStream)}
|
||||
*
|
||||
* 24w46a+
|
||||
* Invoked from {@link FakeThreadDownloadImageData#loadContents(IResourceManager)}
|
||||
*/
|
||||
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
|
||||
if (processTask instanceof IImageBuffer) {
|
||||
return ((IImageBuffer) processTask).func_195786_a(image);
|
||||
} else if (processLegacySkin != null) {
|
||||
return processLegacySkin.apply(image);
|
||||
} else {
|
||||
return image;
|
||||
}
|
||||
return processLegacySkin.apply(image);
|
||||
}
|
||||
|
||||
//parseUserSkin for 1.13+
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.cache.CacheLoader;
|
||||
@@ -17,6 +19,7 @@ import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeThreadDownloadImageData;
|
||||
import customskinloader.loader.MojangAPILoader;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
@@ -25,18 +28,26 @@ import customskinloader.utils.TextureUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.PlayerSkin$Model;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager$1;
|
||||
import net.minecraft.client.resources.SkinManager$CacheKey;
|
||||
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||
import net.minecraft.client.resources.SkinManager$TextureCache;
|
||||
|
||||
public class FakeSkinManager {
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager(TextureManager , File, MinecraftSessionService)}
|
||||
*/
|
||||
public static void setSkinCacheDir(File skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static void setSkinCacheDir(Path skinCacheDirectory) {
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
|
||||
@@ -44,13 +55,15 @@ public class FakeSkinManager {
|
||||
|
||||
private static CacheLoader<Object, ?> cacheLoader;
|
||||
/**
|
||||
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||
*/
|
||||
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
|
||||
return cacheLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Property createProperty(Property property) {
|
||||
@@ -58,6 +71,7 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||
*/
|
||||
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
|
||||
@@ -65,17 +79,31 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||
*
|
||||
* 23w31a+
|
||||
* Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
params[0] = fakeProfileTexture.getCacheFile();
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
File cacheFile = fakeProfileTexture.getCacheFile();
|
||||
if (params.length == 4) {
|
||||
if (params[3] instanceof Boolean) { // 24w46a+
|
||||
FakeInterfaceManager.ResourceLocation_setTexture(params[0], FakeThreadDownloadImageData.createTexture(params[0], cacheFile.toPath(), params[2], false, new BaseBuffer(null, textureType, fakeProfileTexture)));
|
||||
params[1] = cacheFile.toPath();
|
||||
params[3] = false;
|
||||
} else { // 19w37a-
|
||||
params[0] = cacheFile;
|
||||
params[3] = new BaseBuffer((Runnable) params[3], textureType, fakeProfileTexture);
|
||||
}
|
||||
} else if (params.length == 5) { // 19w38a ~ 24w45a
|
||||
params[0] = cacheFile;
|
||||
params[3] = true;
|
||||
params[4] = new BaseBuffer((Runnable) params[4], textureType, fakeProfileTexture);
|
||||
}
|
||||
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, fakeProfileTexture);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
@@ -83,7 +111,8 @@ public class FakeSkinManager {
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> {
|
||||
@@ -95,7 +124,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w31a+
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.SkinManager$CacheKey)
|
||||
* Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)}
|
||||
*/
|
||||
public static Object[] loadProfileTextures(ImmutableList<Object> list, Object cacheKey) {
|
||||
Object[] params = list.toArray();
|
||||
@@ -115,16 +144,18 @@ public class FakeSkinManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$null$0(Map, SkinAvailableCallback)}
|
||||
* 1.20.1-
|
||||
* Invoked from {@link SkinManager#func_210276_a(Map, SkinManager$SkinAvailableCallback)}
|
||||
*/
|
||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager$SkinAvailableCallback skinAvailableCallback) {
|
||||
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
|
||||
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
|
||||
if (map.containsKey(type)) {
|
||||
@@ -133,6 +164,18 @@ public class FakeSkinManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 24w46a+
|
||||
* Invoked from {@link SkinManager#lambda$registerTextures$1(CompletableFuture, String, CompletableFuture, CompletableFuture, PlayerSkin$Model, MinecraftProfileTextures, Void)}
|
||||
*/
|
||||
public static PlayerSkin$Model loadSkinModel(PlayerSkin$Model model, MinecraftProfileTextures textures) {
|
||||
MinecraftProfileTexture texture = textures.skin();
|
||||
if (texture != null) {
|
||||
model = PlayerSkin$Model.byName(texture.getMetadata("model"));
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private final static String SKULL_KEY = "CSL$IsSkull";
|
||||
/**
|
||||
* 23w31a+
|
||||
@@ -149,7 +192,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w31a ~ 23w41a
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(GameProfile)
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)}
|
||||
*/
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
if (profile.getProperties().containsKey(SKULL_KEY)) {
|
||||
@@ -162,7 +205,7 @@ public class FakeSkinManager {
|
||||
|
||||
/**
|
||||
* 23w42a+
|
||||
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(SkinManager.CacheKey, MinecraftSessionService)
|
||||
* Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, MinecraftSessionService)}
|
||||
*/
|
||||
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) {
|
||||
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false));
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FakeInterfaceManager {
|
||||
return ((IFakeIResource.V2) resource).open();
|
||||
}
|
||||
|
||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) throws IOException {
|
||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) {
|
||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@ public class FakeInterfaceManager {
|
||||
((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();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -9,12 +8,12 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IFakeIResourceManager {
|
||||
// 1.13.2 ~ 22w13a
|
||||
default IResource func_199002_a(ResourceLocation location) throws IOException {
|
||||
default IResource func_199002_a(ResourceLocation location) {
|
||||
return (IResource) ((IResourceManager) this).getResource(location);
|
||||
}
|
||||
|
||||
// 22w14a+
|
||||
default Optional getResource(ResourceLocation location) throws IOException {
|
||||
default Optional getResource(ResourceLocation location) {
|
||||
return Optional.ofNullable(this.func_199002_a(location));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
public interface IFakeResourceLocation {
|
||||
Object customskinloader$getTexture();
|
||||
void customskinloader$setTexture(Object texture);
|
||||
}
|
||||
@@ -4,9 +4,6 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public interface IFakeSkinManagerCacheKey {
|
||||
default GameProfile profile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default GameProfile profile() { return null; }
|
||||
Property packedTextures();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package customskinloader.fake.texture;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import customskinloader.fake.FakeSkinBuffer;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||
import net.minecraft.client.renderer.texture.TextureContents;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// 24w46a+
|
||||
public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||
private final Path cacheFile;
|
||||
private final String imageUrl;
|
||||
private final boolean legacySkin;
|
||||
private final Runnable processTask;
|
||||
|
||||
public static Object createTexture(Object location, Object cacheFile, Object imageUrl, Object legacySkin, Object processTask) {
|
||||
return new FakeThreadDownloadImageData((ResourceLocation) location, (Path) cacheFile, (String) imageUrl, (boolean) legacySkin, (Runnable) processTask);
|
||||
}
|
||||
|
||||
public FakeThreadDownloadImageData(ResourceLocation location, Path cacheFile, String imageUrl, boolean legacySkin, Runnable processTask) {
|
||||
super(location);
|
||||
this.cacheFile = cacheFile;
|
||||
this.imageUrl = imageUrl;
|
||||
this.legacySkin = legacySkin;
|
||||
this.processTask = processTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureContents loadContents(IResourceManager resourceManager) {
|
||||
NativeImage image = FakeSkinBuffer.processLegacySkin(SkinTextureDownloader.lambda$downloadAndRegisterSkin$0(this.cacheFile, this.imageUrl, this.legacySkin), this.processTask, i -> SkinTextureDownloader.processLegacySkin(i, this.imageUrl));
|
||||
this.processTask.run();
|
||||
return new TextureContents(image, null);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -15,7 +16,6 @@ import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class TextureUtil {
|
||||
/**
|
||||
@@ -44,11 +44,17 @@ public class TextureUtil {
|
||||
|
||||
private final static MethodHandles.Lookup IMPL_LOOKUP = ((Supplier<MethodHandles.Lookup>) () -> {
|
||||
try {
|
||||
Field theUnsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
|
||||
Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
||||
theUnsafeField.setAccessible(true);
|
||||
Unsafe theUnsafe = (Unsafe) theUnsafeField.get(null);
|
||||
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) theUnsafe.getObject(theUnsafe.staticFieldBase(implLookupField), theUnsafe.staticFieldOffset(implLookupField));
|
||||
return (MethodHandles.Lookup) getObjectMethod.invoke(theUnsafe, staticFieldBaseMethod.invoke(theUnsafe, implLookupField), staticFieldOffsetMethod.invoke(theUnsafe, implLookupField));
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderType {
|
||||
// getEntityTranslucent
|
||||
public static RenderType func_228644_e_(ResourceLocation locationIn) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Empty stack for NativeImage
|
||||
*/
|
||||
public class NativeImage {
|
||||
public static NativeImage func_195713_a(InputStream inputStreamIn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
|
||||
}
|
||||
|
||||
/**
|
||||
* getWidth
|
||||
*/
|
||||
public int func_195702_a() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* getHeight
|
||||
*/
|
||||
public int func_195714_b() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* copyImage image
|
||||
*/
|
||||
public void func_195703_a(NativeImage p_195703_1_) {
|
||||
}
|
||||
|
||||
/**
|
||||
* fillAreaRGBA x0 y0 weight height rgba
|
||||
*/
|
||||
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
|
||||
}
|
||||
|
||||
/**
|
||||
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
|
||||
*/
|
||||
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
|
||||
}
|
||||
|
||||
/**
|
||||
* getPixelRGBA x y
|
||||
*/
|
||||
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* setPixelRGBA x y rgba
|
||||
*/
|
||||
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
// exclude
|
||||
public interface Texture {
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
// this class shouldn't be created by ASM because of modlauncher issue.
|
||||
public interface IResource {
|
||||
InputStream getInputStream();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// this class shouldn't be created by ASM because of modlauncher issue.
|
||||
public interface IResourceManager {
|
||||
IResource getResource(ResourceLocation location) throws IOException;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package net.minecraft.resources;
|
||||
|
||||
// exclude
|
||||
public interface IResource {
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package net.minecraft.resources;
|
||||
|
||||
// exclude
|
||||
public interface IResourceManager {
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user