mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Fix hd skins a bit more
This commit is contained in:
parent
2a37a69f60
commit
9e707e4af9
2 changed files with 47 additions and 20 deletions
|
@ -32,6 +32,7 @@ import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public final class HDSkinManager {
|
public final class HDSkinManager {
|
||||||
private static String gatewayUrl = "skinmanager.voxelmodpack.com";
|
private static String gatewayUrl = "skinmanager.voxelmodpack.com";
|
||||||
|
@ -79,33 +80,59 @@ public final class HDSkinManager {
|
||||||
if (mc.theWorld == null) {
|
if (mc.theWorld == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Collection<NetworkPlayerInfo> playersInfo = mc.getNetHandler().func_175106_d();
|
return findPlayer(mc, hash);
|
||||||
String uuid;
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String findPlayer(Minecraft mc, String hash) {
|
||||||
|
String uuid = findNetworkPlayer(mc, hash);
|
||||||
|
if (uuid == null) {
|
||||||
|
uuid = findWorldPlayers(mc.theWorld, hash);
|
||||||
|
}
|
||||||
|
if (uuid == null) {
|
||||||
|
uuid = findSkullPlayers(hash);
|
||||||
|
}
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String findNetworkPlayer(Minecraft mc, String hash) {
|
||||||
|
Collection<NetworkPlayerInfo> playersInfo = mc.getNetHandler().getPlayerInfoMap();
|
||||||
// players
|
// players
|
||||||
for (NetworkPlayerInfo player : playersInfo) {
|
for (NetworkPlayerInfo player : playersInfo) {
|
||||||
GameProfile profile = player.getGameProfile();
|
GameProfile profile = player.getGameProfile();
|
||||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(mc, profile);
|
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(profile);
|
||||||
storeTexturesForProfile(profile, textures);
|
storeTexturesForProfile(profile, textures);
|
||||||
uuid = findUUID(profile, textures, hash);
|
String uuid = findUUID(profile, textures, hash);
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String findWorldPlayers(World world, String hash) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<EntityPlayer> players = mc.theWorld.playerEntities;
|
List<EntityPlayer> players = world.playerEntities;
|
||||||
for (EntityPlayer player : players) {
|
for (EntityPlayer player : players) {
|
||||||
GameProfile profile = player.getGameProfile();
|
GameProfile profile = player.getGameProfile();
|
||||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(mc, profile);
|
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(profile);
|
||||||
storeTexturesForProfile(profile, textures);
|
storeTexturesForProfile(profile, textures);
|
||||||
uuid = findUUID(profile, textures, hash);
|
String uuid = findUUID(profile, textures, hash);
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String findSkullPlayers(String hash) {
|
||||||
// skulls
|
// skulls
|
||||||
for (Entry<GameProfile, Map<Type, MinecraftProfileTexture>> e : getSkinsCache().asMap().entrySet()) {
|
for (Entry<GameProfile, Map<Type, MinecraftProfileTexture>> e : getSkinsCache().asMap().entrySet()) {
|
||||||
GameProfile profile = e.getKey();
|
GameProfile profile = e.getKey();
|
||||||
|
// stupid plugineers..
|
||||||
|
if (profile.getId() == null)
|
||||||
|
continue;
|
||||||
Map<Type, MinecraftProfileTexture> textures = e.getValue();
|
Map<Type, MinecraftProfileTexture> textures = e.getValue();
|
||||||
storeTexturesForProfile(profile, textures);
|
storeTexturesForProfile(profile, textures);
|
||||||
uuid = findUUID(profile, textures, hash);
|
String uuid = findUUID(profile, textures, hash);
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -133,12 +160,13 @@ public final class HDSkinManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Type, MinecraftProfileTexture> getTexturesForProfile(Minecraft minecraft, GameProfile profile) {
|
private static Map<Type, MinecraftProfileTexture> getTexturesForProfile(GameProfile profile) {
|
||||||
LiteLoaderLogger.debug("Get textures for " + profile.getId(), new Object[0]);
|
LiteLoaderLogger.debug("Get textures for " + profile.getId(), new Object[0]);
|
||||||
Map<Type, MinecraftProfileTexture> cached = getCachedTexturesForId(trimUUID(profile.getId()));
|
Map<Type, MinecraftProfileTexture> cached = getCachedTexturesForId(trimUUID(profile.getId()));
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
MinecraftSessionService sessionService = minecraft.getSessionService();
|
MinecraftSessionService sessionService = minecraft.getSessionService();
|
||||||
Map<Type, MinecraftProfileTexture> textures = null;
|
Map<Type, MinecraftProfileTexture> textures = null;
|
||||||
|
|
||||||
|
@ -148,7 +176,8 @@ public final class HDSkinManager {
|
||||||
textures = sessionService.getTextures(profile, false);
|
textures = sessionService.getTextures(profile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((textures == null || textures.isEmpty()) && profile.getId().equals(minecraft.getSession().getProfile().getId())) {
|
if ((textures == null || textures.isEmpty())
|
||||||
|
&& profile.getId().equals(minecraft.getSession().getProfile().getId())) {
|
||||||
textures = sessionService.getTextures(sessionService.fillProfileProperties(profile, false), false);
|
textures = sessionService.getTextures(sessionService.fillProfileProperties(profile, false), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,19 +230,18 @@ public final class HDSkinManager {
|
||||||
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile) {
|
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile) {
|
||||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||||
Object skinTexture = textureManager.getTexture(skinResource);
|
Object skinTexture = textureManager.getTexture(skinResource);
|
||||||
|
|
||||||
if (skinTexture == null) {
|
if (skinTexture == null) {
|
||||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(Minecraft.getMinecraft(), profile);
|
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(profile);
|
||||||
MinecraftProfileTexture skin = textures.get(Type.SKIN);
|
MinecraftProfileTexture skin = textures.get(Type.SKIN);
|
||||||
if (skin == null) {
|
if (skin != null) {
|
||||||
throw new RuntimeException("Could not get player skin URL from profile");
|
String url = skin.getUrl();
|
||||||
|
skinTexture = new PreviewTexture(url, DefaultPlayerSkin.getDefaultSkin(profile.getId()), new ImageBufferDownloadHD());
|
||||||
|
textureManager.loadTexture(skinResource, (ITextureObject) skinTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = skin.getUrl();
|
|
||||||
skinTexture = new PreviewTexture(url, DefaultPlayerSkin.getDefaultSkin(profile.getId()), new ImageBufferDownloadHD());
|
|
||||||
textureManager.loadTexture(skinResource, (ITextureObject) skinTexture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PreviewTexture) skinTexture;
|
return (PreviewTexture) skinTexture;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearSkinCache() {
|
public static void clearSkinCache() {
|
||||||
|
|
|
@ -642,8 +642,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale,
|
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseX, float mouseY, float partialTick) {
|
||||||
@SuppressWarnings("unused") float mouseX, float mouseY, float partialTick) {
|
|
||||||
GL11.glEnable(GL.GL_COLOR_MATERIAL);
|
GL11.glEnable(GL.GL_COLOR_MATERIAL);
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
translate(xPosition, yPosition, 300.0F);
|
translate(xPosition, yPosition, 300.0F);
|
||||||
|
|
Loading…
Reference in a new issue