mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-26 20:53:00 +00:00
Fix 1.14 skin load
This commit is contained in:
1 parent
3ade4867d4
commit
95ee345441
4 files changed
+99
-51
No files matched your search
@@ -495,3 +495,4 @@ MD: net/minecraft/client/resources/SkinManager/func_210275_a (Lcom/mojang/authli
|
||||
MD: net/minecraft/client/resources/SkinManager/func_152792_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; duy/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lqs;
|
||||
MD: net/minecraft/client/resources/SkinManager/func_152789_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; duy/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lduy$a;)Lqs;
|
||||
MD: net/minecraft/client/resources/SkinManager/func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V duy/a (Ljava/util/Map;Lduy$a;)V
|
||||
MD: net/minecraft/client/Minecraft/addScheduledTask (Ljava/lang/Runnable;)V cvi/execute (Ljava/lang/Runnable;)V
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.minecraft.client;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.util.Session;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Minecraft {
|
||||
public File gameDir = null;
|
||||
|
||||
public static Minecraft getMinecraft() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SkinManager getSkinManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TextureManager getTextureManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public MinecraftSessionService getSessionService() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Session getSession() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ServerData getCurrentServerData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addScheduledTask(Runnable r) {
|
||||
}
|
||||
}
|
||||
@@ -27,85 +27,100 @@ import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeSkinManager{
|
||||
public class FakeSkinManager {
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
|
||||
private final TextureManager textureManager;
|
||||
|
||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||
this.textureManager=textureManagerInstance;
|
||||
HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
|
||||
this.textureManager = textureManagerInstance;
|
||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||
}
|
||||
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType){
|
||||
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType) {
|
||||
return this.loadSkin(profileTexture, textureType, null);
|
||||
}
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback){
|
||||
HttpTextureInfo info=HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
|
||||
|
||||
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback) {
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("loadSkin");
|
||||
HttpTextureInfo info = HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
|
||||
|
||||
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash);
|
||||
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
|
||||
|
||||
if (itextureobject != null)//Have already loaded
|
||||
makeCallback(skinAvailableCallback,textureType, resourcelocation, profileTexture);
|
||||
else{
|
||||
makeCallback(skinAvailableCallback, textureType, resourcelocation, profileTexture);
|
||||
else {
|
||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
|
||||
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
|
||||
if(skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
|
||||
FakeClientPlayer.textureCache.put(resourcelocation,threaddownloadimagedata);
|
||||
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
|
||||
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
|
||||
FakeClientPlayer.textureCache.put(resourcelocation, threaddownloadimagedata);
|
||||
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
||||
}
|
||||
return resourcelocation;
|
||||
}
|
||||
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
|
||||
THREAD_POOL.submit(new Runnable(){
|
||||
public void run(){
|
||||
|
||||
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) {
|
||||
THREAD_POOL.submit(new Runnable() {
|
||||
public void run() {
|
||||
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
|
||||
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
|
||||
public void run(){
|
||||
for(Type type:Type.values())
|
||||
if(map.containsKey(type))
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("Map size: " + map.size());
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
||||
public void run() {
|
||||
for (Type type : Type.values()) {
|
||||
if (map.containsKey(type)) {
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("Loading type:" + type);
|
||||
FakeSkinManager.this.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile){
|
||||
|
||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||
}
|
||||
|
||||
private static void makeCallback(SkinAvailableCallback callback,Type type, ResourceLocation location, MinecraftProfileTexture texture){
|
||||
if(callback!=null)
|
||||
|
||||
private static void makeCallback(SkinAvailableCallback callback, Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("makeCallback");
|
||||
if (callback != null)
|
||||
callback.skinAvailable(type, location, texture);
|
||||
}
|
||||
private class BaseBuffer implements IImageBuffer{
|
||||
|
||||
private class BaseBuffer implements IImageBuffer {
|
||||
private IImageBuffer buffer;
|
||||
|
||||
|
||||
private SkinAvailableCallback callback;
|
||||
private Type type;
|
||||
private ResourceLocation location;
|
||||
private MinecraftProfileTexture texture;
|
||||
public BaseBuffer(SkinAvailableCallback callback,Type type,ResourceLocation location,MinecraftProfileTexture texture){
|
||||
this.buffer=(type==Type.SKIN?new FakeSkinBuffer():null);
|
||||
|
||||
this.callback=callback;
|
||||
this.type=type;
|
||||
this.location=location;
|
||||
this.texture=texture;
|
||||
|
||||
public BaseBuffer(SkinAvailableCallback callback, Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||
this.buffer = (type == Type.SKIN ? new FakeSkinBuffer() : null);
|
||||
|
||||
this.callback = callback;
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image){
|
||||
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("func_195786_a");
|
||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
||||
}
|
||||
public BufferedImage parseUserSkin(BufferedImage image){
|
||||
return buffer==null?image:buffer.parseUserSkin(image);
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||
return buffer == null ? image : buffer.parseUserSkin(image);
|
||||
}
|
||||
public void skinAvailable(){
|
||||
if (buffer != null){
|
||||
|
||||
public void skinAvailable() {
|
||||
org.apache.logging.log4j.LogManager.getLogger().warn("skinAvailable");
|
||||
if (buffer != null) {
|
||||
buffer.skinAvailable();
|
||||
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
|
||||
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer) {
|
||||
//Auto judge skin type
|
||||
Map<String, String> metadata = Maps.newHashMap();
|
||||
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
|
||||
@@ -113,7 +128,7 @@ public class FakeSkinManager{
|
||||
}
|
||||
}
|
||||
|
||||
FakeSkinManager.makeCallback(callback,type, location, texture);
|
||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-11
@@ -50,6 +50,7 @@ jar {
|
||||
attributes 'TweakOrder' : '-10'
|
||||
}
|
||||
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
|
||||
exclude 'net/minecraft/client/Minecraft.class'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -59,6 +60,8 @@ sourceSets {
|
||||
srcDir '../Common/source'
|
||||
//Vanilla
|
||||
srcDir '../Vanilla'
|
||||
//Special
|
||||
srcDir 'source'
|
||||
}
|
||||
resources {
|
||||
//Common
|
||||
@@ -79,17 +82,6 @@ processResources {
|
||||
buildUrl : System.getenv("CIRCLE_BUILD_URL")
|
||||
])
|
||||
}
|
||||
task copyResources {
|
||||
doLast {
|
||||
def outputFile = file("src/main/resources")
|
||||
outputFile.deleteDir()
|
||||
copy {
|
||||
from '../Common/resource'
|
||||
into 'src/main/resources'
|
||||
}
|
||||
}
|
||||
}
|
||||
processResources.dependsOn copyResources
|
||||
|
||||
apply from: rootProject.file("BuildScripts/remap.gradle")
|
||||
task afterBuild {
|
||||
|
||||
Reference in new issue
Block a user