mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-27 21:23:03 +00:00
Try to fix SpectatorMenu
Forge only
This commit is contained in:
1 parent
9698d4098a
commit
eee978fc83
4 files changed
+96
-1
No files matched your search
@@ -0,0 +1,60 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeClientPlayer {
|
||||
//For Legacy Skin
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username)
|
||||
{
|
||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||
|
||||
if (ito == null)
|
||||
{
|
||||
//if Legacy Skin for username not loaded yet
|
||||
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
|
||||
UUID offlineUUID=EntityPlayer.getOfflineUUID(username);
|
||||
GameProfile offlineProfile=new GameProfile(offlineUUID,username);
|
||||
|
||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||
}
|
||||
|
||||
return (ThreadDownloadImageData)ito;
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkin(String username)
|
||||
{
|
||||
return new ResourceLocation("skins/" + username);
|
||||
}
|
||||
|
||||
private static class LegacyBuffer implements SkinAvailableCallback{
|
||||
ResourceLocation resourceLocationIn;
|
||||
|
||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||
this.resourceLocationIn=resourceLocationIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
if(typeIn!=Type.SKIN)
|
||||
return;
|
||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(location);
|
||||
textman.loadTexture(resourceLocationIn, ito);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user