mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-20 16:59:40 +00:00
Fix Crash in Spectator Menu
This commit is contained in:
1 parent
883e7b45fc
commit
1558ec819a
6 files changed
+69
-76
No files matched your search
+2
-1
@@ -28,4 +28,5 @@ build/
|
||||
|
||||
# IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
*.iml
|
||||
out/
|
||||
@@ -55,10 +55,4 @@ public class SkinSiteProfile {
|
||||
ssp.elytra=elytra;
|
||||
return ssp;
|
||||
}
|
||||
public static SkinSiteProfile createElfSkin(String name){
|
||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
||||
ssp.name=name;
|
||||
ssp.type="ElfSkin";
|
||||
return ssp;
|
||||
}
|
||||
}
|
||||
@@ -20,67 +20,64 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
public class FakeClientPlayer {
|
||||
//For Legacy Skin
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username)
|
||||
{
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||
//For Legacy Skin
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||
|
||||
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
|
||||
//if Legacy Skin for username not loaded yet
|
||||
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
|
||||
UUID offlineUUID = EntityPlayer.getOfflineUUID(username);
|
||||
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
|
||||
|
||||
//Load Default Skin
|
||||
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
||||
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
|
||||
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
||||
|
||||
//Load Skin from SkinManager
|
||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||
}
|
||||
|
||||
if (ito instanceof ThreadDownloadImageData)
|
||||
return (ThreadDownloadImageData) ito;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkin(String username) {
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
||||
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
||||
}
|
||||
|
||||
private static class LegacyBuffer implements SkinAvailableCallback {
|
||||
ResourceLocation resourceLocationIn;
|
||||
boolean loaded = false;
|
||||
|
||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
|
||||
this.resourceLocationIn = resourceLocationIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
if (typeIn != Type.SKIN || loaded)
|
||||
return;
|
||||
|
||||
loaded = true;
|
||||
|
||||
|
||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||
ITextureObject ito = textman.getTexture(location);
|
||||
|
||||
if (ito == null || !(ito instanceof ThreadDownloadImageData))
|
||||
{
|
||||
//if Legacy Skin for username not loaded yet
|
||||
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
|
||||
UUID offlineUUID=EntityPlayer.getOfflineUUID(username);
|
||||
GameProfile offlineProfile=new GameProfile(offlineUUID,username);
|
||||
|
||||
//Load Default Skin
|
||||
ResourceLocation defaultSkin=DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
||||
ITextureObject defaultSkinObj=new SimpleTexture(defaultSkin);
|
||||
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
||||
|
||||
//Load Skin from SkinManager
|
||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||
}
|
||||
|
||||
if(ito instanceof ThreadDownloadImageData)
|
||||
return (ThreadDownloadImageData)ito;
|
||||
else
|
||||
return null;
|
||||
if (ito != null)
|
||||
textman.loadTexture(resourceLocationIn, ito);
|
||||
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
|
||||
(ito == null ? null : ito.toString()) + " (" + location + ")");
|
||||
//textman.bindTexture(resourceLocationIn);
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkin(String username)
|
||||
{
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
||||
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
||||
}
|
||||
|
||||
private static class LegacyBuffer implements SkinAvailableCallback{
|
||||
ResourceLocation resourceLocationIn;
|
||||
boolean loaded=false;
|
||||
|
||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||
CustomSkinLoader.logger.debug("Loading Legacy Texture ("+resourceLocationIn+")");
|
||||
this.resourceLocationIn=resourceLocationIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
if(typeIn!=Type.SKIN || loaded)
|
||||
return;
|
||||
|
||||
loaded=true;
|
||||
|
||||
|
||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(location);
|
||||
|
||||
if(ito!=null)
|
||||
textman.loadTexture(resourceLocationIn, ito);
|
||||
CustomSkinLoader.logger.debug("Legacy Texture ("+resourceLocationIn+") Loaded as "+
|
||||
ito==null?null:ito.toString()+" ("+location+")");
|
||||
//textman.bindTexture(resourceLocationIn);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffe
|
||||
Graphics graphics = bufferedimage.getGraphics();
|
||||
graphics.setColor(new Color(0,0,0,0));
|
||||
graphics.fillRect(0,0,64,64);
|
||||
graphics.drawImage(image,0,0,(ImageObserver)null);
|
||||
graphics.drawImage(image, 0, 0, null);
|
||||
if (image.getHeight() == 32 * ratio){//Single Layer
|
||||
//Revert to original algorithm
|
||||
//Right Leg -> Left Leg
|
||||
@@ -67,7 +67,7 @@ public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffe
|
||||
* @since 14.9
|
||||
*/
|
||||
public String judgeType(){
|
||||
if (this.imageData==null)
|
||||
if (this.imageData == null)
|
||||
return null;
|
||||
if (((this.imageData[getPosition(55, 20)] & B) >>> 24) == 0)//if (55,20) is transparent
|
||||
return "slim";
|
||||
|
||||
@@ -98,13 +98,14 @@ public class FakeSkinManager{
|
||||
return buffer==null?image:buffer.parseUserSkin(image);
|
||||
}
|
||||
public void skinAvailable(){
|
||||
if (buffer != null)
|
||||
if (buffer != null){
|
||||
buffer.skinAvailable();
|
||||
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
|
||||
//Auto judge skin type
|
||||
Map metadata = Maps.newHashMap();
|
||||
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
|
||||
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
|
||||
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
|
||||
//Auto judge skin type
|
||||
Map metadata = Maps.newHashMap();
|
||||
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
|
||||
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
|
||||
}
|
||||
}
|
||||
|
||||
FakeSkinManager.makeCallback(callback,type, location, texture);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
||||
if(skinFile.exists()&&skinFile.isFile())
|
||||
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
||||
}else{
|
||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
||||
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||
if(responce.success)
|
||||
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
||||
if(capeFile.exists()&&capeFile.isFile())
|
||||
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
||||
}else{
|
||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
||||
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||
if(responce.success)
|
||||
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user