I'm working on a custom armor model that renders very close to the player's skin. I'm trying to quickly check the image data to see if I need to adjust the size to fit the second optional layer on the skin. I have access to AbstractClientPlayer and it's getLocationSkin and getDownloadedImageSkin. So I know the location of the skin. But I haven't been able to find a method that will take either of them and give back usable image data. So far, all I found has either thrown a "file not found" or just been another way to get the resource location.
I've gathered that much. However, wouldn't the client have that data cached somewhere? I know minecraft doesn't instantly forget what the skin is if I get disconnected.
I've gathered that much. However, wouldn't the client have that data cached somewhere? I know minecraft doesn't instantly forget what the skin is if I get disconnected.
If you quit Minecraft and restart it without internet however, it will indeed forget. The skin is cached in memory.
Unless it's a private/protected field, you should be able to buffer the resource location into your own texture for use - or there may be a public buffered image already, not sure.
From what I have gathered, it keeps the skin in memory as a ResourceLocation and nothing is actually saved to disk. So once you see a player, their skin is buffered from their server http://s3.amazonaws.com/MinecraftSkins/darkhax.png and remains in memory until the game is completely closed. In 1.8 they will cache the skin, but it's weird how they do this. From what I understand they chache skins by their contents so if multiple users have the same skin it will not request data twice from the mojang skin servers, this was done to minimize the impact of skin loading on both their servers and the clients. It's kind of confusing how they do this, but in this cache the physical file is not stored. Although I believe that link I posted above may help you as you can just download your own copy of the player skin.
From what I have gathered, it keeps the skin in memory as a ResourceLocation and nothing is actually saved to disk. So once you see a player, their skin is buffered from their server http://s3.amazonaws.com/MinecraftSkins/darkhax.png and remains in memory until the game is completely closed. In 1.8 they will cache the skin, but it's weird how they do this. From what I understand they chache skins by their contents so if multiple users have the same skin it will not request data twice from the mojang skin servers, this was done to minimize the impact of skin loading on both their servers and the clients. It's kind of confusing how they do this, but in this cache the physical file is not stored. Although I believe that link I posted above may help you as you can just download your own copy of the player skin.
Bitmap as byte array, stored in NBT maybe? Skins aren't exactly high resolution But anyway that's 1.8....
I think that's the old skin server or something, I looked at mine (same username as my forum name) and it's a very old one of mine. So I don't think it'd be good to use that URL for manual download.
Bitmap as byte array, stored in NBT maybe? Skins aren't exactly high resolution But anyway that's 1.8....
I think that's the old skin server or something, I looked at mine (same username as my forum name) and it's a very old one of mine. So I don't think it'd be good to use that URL for manual download.
Perhaps, I believe they store the skin along with things like the uuids related to the skin, they're also signed, and expire. Also you're right, I didn't notice at first but that's also showing the skin I was using before Oct 1st.
It seems that 1.7.10 does download skins to a file? Or some of the code is there anyway. Or ResourceLocation is not necessarily a physical file... I think I remember someone saying that?
Unless it's a private/protected field, you should be able to buffer the resource location into your own texture for use - or there may be a public buffered image already, not sure.
The one instance I've found of buffered image is indeed marked private. It's in ThreadDownloadImageData. I did see getGlTextureId() in the same class. It sounds useful, but anything directly GL related is beyond my understanding.
It wouldn't be. I found out how to get the real url. Just found it a few min ago so my sleepy brain is currently having problems knowing what's there. See below.
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation p_110304_0_, String p_110304_1_)
{
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
Object object = texturemanager.getTexture(p_110304_0_);
if (object == null)
{
object = new ThreadDownloadImageData((File)null, String.format("http://skins.minecraft.net/MinecraftSkins/%s.png", new Object[] {StringUtils.stripControlCodes(p_110304_1_)}), locationStevePng, new ImageBufferDownload());
texturemanager.loadTexture(p_110304_0_, (ITextureObject)object);
}
return (ThreadDownloadImageData)object;
}
public static ResourceLocation getLocationSkin(String p_110311_0_)
{
return new ResourceLocation("skins/" + StringUtils.stripControlCodes(p_110311_0_));
}
Those would be where I initially started from.
Beyond getGlTextureId(), the only other lead I have is Minecraft.getMinecraft().func_152342_ad().func_152788_a(player.getGameProfile()). Rather long, but that's the "skin manager." It returns a map with SKIN and URL within. I'm not quite sure yet what SKIN is. It's too late for me to get much more out of me.
Edit: The string version of SKIN lists com.mojang.authlib.minecraft.MinecraftProfileTexture then some other stuff. com.mojang? I'm starting to wonder if I'm so deep down the rabbit hole that I've hit bedrock. As an aside, I found out that getLocationSkin() contains the file name of the skin on minecraft's texture server. I'm not sure if that means that function is meant for urls or if it's cached under the same name.
Your answer wasn't it, but the linked github had a good one. The ObfuscationReflectionHelper let's me get the image data in ThreadDownloadImageData. Sadly, it wasn't what I was expecting it to be. At the point I can call it, the bufferedimage has already been parsed from 64x64 to 64x32. In other words, I don't think I make the check I was wanting from it. The image from getDownloadImageData and from minecraft.func_152342_ad().func_152792_a() are identical.
I'm left wondering where the other layer is. Where's the hat layer stored at? I'm not sure if I want to redownload the skin or not, but it's looking more like I don't have a lot of choice.
Edit: Wait, maybe I'm just being silly.
Edit2: Yes, pretty sure I was being silly. I think I got it from here.
Any suggestions on how to get to the skin?
Farewell everyone o/
If you quit Minecraft and restart it without internet however, it will indeed forget. The skin is cached in memory.
Unless it's a private/protected field, you should be able to buffer the resource location into your own texture for use - or there may be a public buffered image already, not sure.
Farewell everyone o/
Bitmap as byte array, stored in NBT maybe? Skins aren't exactly high resolution But anyway that's 1.8....
I think that's the old skin server or something, I looked at mine (same username as my forum name) and it's a very old one of mine. So I don't think it'd be good to use that URL for manual download.
EDIT: It's http://skins.minecraft.net/MinecraftSkins/cosmicdan.png but it redirects, so if you're going to code it that way just be aware that that might be an issue.
Perhaps, I believe they store the skin along with things like the uuids related to the skin, they're also signed, and expire. Also you're right, I didn't notice at first but that's also showing the skin I was using before Oct 1st.
Farewell everyone o/
It seems that 1.7.10 does download skins to a file? Or some of the code is there anyway. Or ResourceLocation is not necessarily a physical file... I think I remember someone saying that?
Minecraft 1.7.10, net.minecraft.client.entity.AbstractClientPlayer.java:
The one instance I've found of buffered image is indeed marked private. It's in ThreadDownloadImageData. I did see getGlTextureId() in the same class. It sounds useful, but anything directly GL related is beyond my understanding.
It wouldn't be. I found out how to get the real url. Just found it a few min ago so my sleepy brain is currently having problems knowing what's there. See below.
Those would be where I initially started from.
Beyond getGlTextureId(), the only other lead I have is Minecraft.getMinecraft().func_152342_ad().func_152788_a(player.getGameProfile()). Rather long, but that's the "skin manager." It returns a map with SKIN and URL within. I'm not quite sure yet what SKIN is. It's too late for me to get much more out of me.
Edit: The string version of SKIN lists com.mojang.authlib.minecraft.MinecraftProfileTexture then some other stuff. com.mojang? I'm starting to wonder if I'm so deep down the rabbit hole that I've hit bedrock. As an aside, I found out that getLocationSkin() contains the file name of the skin on minecraft's texture server. I'm not sure if that means that function is meant for urls or if it's cached under the same name.
Sadly, it wasn't what I was expecting it to be. At the point I can call it, the bufferedimage has already been parsed from 64x64 to 64x32. In other words, I don't think I make the check I was wanting from it.The image from getDownloadImageData and from minecraft.func_152342_ad().func_152792_a() are identical.I'm left wondering where the other layer is. Where's the hat layer stored at? I'm not sure if I want to redownload the skin or not, but it's looking more like I don't have a lot of choice.Edit: Wait, maybe I'm just being silly.
Edit2: Yes, pretty sure I was being silly. I think I got it from here.