prep for skin metadata

Other cleanup
This commit is contained in:
Matthew Messinger 2016-02-29 23:41:02 -05:00
parent 73af68dce5
commit daa00a044b
5 changed files with 167 additions and 124 deletions

View file

@ -6,18 +6,24 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.InsecureTextureException; import com.mojang.authlib.minecraft.InsecureTextureException;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property;
import com.mojang.util.UUIDTypeAdapter; import com.mojang.util.UUIDTypeAdapter;
import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
@ -36,42 +42,51 @@ public final class HDSkinManager {
public static final HDSkinManager INSTANCE = new HDSkinManager(); public static final HDSkinManager INSTANCE = new HDSkinManager();
private static final ResourceLocation LOADING = new ResourceLocation("LOADING"); private static final ResourceLocation LOADING = new ResourceLocation("LOADING");
private static final File skinCacheDir = new File("assets/skins");
private String gatewayUrl = "skinmanager.voxelmodpack.com"; private String gatewayUrl = "skinmanager.voxelmodpack.com";
private String skinUrl = "skins.voxelmodpack.com"; private String skinUrl = "skins.voxelmodpack.com";
private boolean enabled = true; private boolean enabled = true;
private Map<GameProfile, Map<Type, MinecraftProfileTexture>> profileTextures = Maps.newHashMap(); private Map<UUID, Map<Type, MinecraftProfileTexture>> profileTextures = Maps.newHashMap();
private Map<GameProfile, Map<Type, ResourceLocation>> skinCache = Maps.newHashMap(); private Map<UUID, Map<Type, ResourceLocation>> skinCache = Maps.newHashMap();
private List<ISkinModifier> skinModifiers = Lists.newArrayList(); private List<ISkinModifier> skinModifiers = Lists.newArrayList();
private HDSkinManager() {} private HDSkinManager() {}
public Optional<ResourceLocation> getSkinLocation(final GameProfile profile, Type type, boolean loadIfAbsent) { public Optional<ResourceLocation> getSkinLocation(GameProfile profile1, Type type, boolean loadIfAbsent) {
if (!enabled) if (!enabled)
return Optional.absent(); return Optional.absent();
if (!this.skinCache.containsKey(profile)) { // try to recreate a broken gameprofile
this.skinCache.put(profile, Maps.<Type, ResourceLocation> newHashMap()); // happens when server sends a random profile with skin and displayname
Property prop = Iterables.getFirst(profile1.getProperties().get("textures"), null);
if (prop != null) {
JsonObject obj = new Gson().fromJson(new String(Base64.decodeBase64(prop.getValue())), JsonObject.class);
String name = obj.get("profileName").getAsString();
UUID uuid = UUIDTypeAdapter.fromString(obj.get("profileId").getAsString());
profile1 = new GameProfile(uuid, name);
} }
ResourceLocation skin = this.skinCache.get(profile).get(type); final GameProfile profile = profile1;
if (!this.skinCache.containsKey(profile.getId())) {
this.skinCache.put(profile.getId(), Maps.<Type, ResourceLocation> newHashMap());
}
ResourceLocation skin = this.skinCache.get(profile.getId()).get(type);
if (skin == null) { if (skin == null) {
if (loadIfAbsent) { if (loadIfAbsent) {
skinCache.get(profile).put(type, LOADING); skinCache.get(profile.getId()).put(type, LOADING);
loadTexture(profile, type, new SkinAvailableCallback() { loadTexture(profile, type, new SkinAvailableCallback() {
@Override @Override
public void skinAvailable(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { public void skinAvailable(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
skinCache.get(profile).put(type, location); skinCache.get(profile.getId()).put(type, location);
if (!profileTextures.containsKey(profile)) {
profileTextures.put(profile, Maps.<Type, MinecraftProfileTexture> newHashMap());
}
profileTextures.get(profile).put(type, profileTexture);
} }
}); });
} }
return Optional.absent(); return Optional.absent();
} }
return skin == LOADING ? Optional.<ResourceLocation> absent() : Optional.of(skin); return skin == LOADING ? Optional.<ResourceLocation> absent() : Optional.of(skin);
} }
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) { private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
@ -81,12 +96,12 @@ public final class HDSkinManager {
if (texture == null) { if (texture == null) {
return; return;
} }
final ResourceLocation skin = new ResourceLocation("skins/" + texture.getHash()); String dir = type.toString().toLowerCase() + "s/";
File file1 = new File(skinCacheDir, texture.getHash().substring(0, 2)); final ResourceLocation skin = new ResourceLocation(dir + texture.getHash());
@SuppressWarnings("unused") File file1 = new File(new File("assets/" + dir), texture.getHash().substring(0, 2));
File file2 = new File(file1, texture.getHash()); File file2 = new File(file1, texture.getHash());
final IImageBuffer imagebufferdownload = new ImageBufferDownloadHD(); final IImageBuffer imagebufferdownload = new ImageBufferDownloadHD();
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(null, texture.getUrl(), ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(),
DefaultPlayerSkin.getDefaultSkinLegacy(), DefaultPlayerSkin.getDefaultSkinLegacy(),
new IImageBuffer() { new IImageBuffer() {
public BufferedImage parseUserSkin(BufferedImage image) { public BufferedImage parseUserSkin(BufferedImage image) {
@ -108,8 +123,9 @@ public final class HDSkinManager {
public Map<Type, MinecraftProfileTexture> getProfileData(GameProfile profile) { public Map<Type, MinecraftProfileTexture> getProfileData(GameProfile profile) {
if (!enabled) if (!enabled)
return ImmutableMap.of(); return ImmutableMap.of();
Map<Type, MinecraftProfileTexture> textures = this.profileTextures.get(profile); Map<Type, MinecraftProfileTexture> textures = this.profileTextures.get(profile.getId());
if (textures == null) { if (textures == null) {
String uuid = UUIDTypeAdapter.fromUUID(profile.getId()); String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
String skinUrl = getCustomSkinURLForId(uuid, false); String skinUrl = getCustomSkinURLForId(uuid, false);
String capeUrl = getCustomCloakURLForId(uuid); String capeUrl = getCustomCloakURLForId(uuid);
@ -118,7 +134,7 @@ public final class HDSkinManager {
textures = ImmutableMap.of( textures = ImmutableMap.of(
Type.SKIN, new MinecraftProfileTexture(skinUrl, null), Type.SKIN, new MinecraftProfileTexture(skinUrl, null),
Type.CAPE, new MinecraftProfileTexture(capeUrl, null)); Type.CAPE, new MinecraftProfileTexture(capeUrl, null));
// this.profileTextures.put(profile, textures); this.profileTextures.put(profile.getId(), textures);
} }
return textures; return textures;
} }

View file

@ -1,6 +1,31 @@
package com.voxelmodpack.hdskins.gui; package com.voxelmodpack.hdskins.gui;
import static net.minecraft.client.renderer.GlStateManager.*; import static net.minecraft.client.renderer.GlStateManager.blendFunc;
import static net.minecraft.client.renderer.GlStateManager.color;
import static net.minecraft.client.renderer.GlStateManager.colorMask;
import static net.minecraft.client.renderer.GlStateManager.depthMask;
import static net.minecraft.client.renderer.GlStateManager.disableAlpha;
import static net.minecraft.client.renderer.GlStateManager.disableBlend;
import static net.minecraft.client.renderer.GlStateManager.disableColorMaterial;
import static net.minecraft.client.renderer.GlStateManager.disableCull;
import static net.minecraft.client.renderer.GlStateManager.disableDepth;
import static net.minecraft.client.renderer.GlStateManager.disableFog;
import static net.minecraft.client.renderer.GlStateManager.disableTexture2D;
import static net.minecraft.client.renderer.GlStateManager.enableAlpha;
import static net.minecraft.client.renderer.GlStateManager.enableBlend;
import static net.minecraft.client.renderer.GlStateManager.enableColorMaterial;
import static net.minecraft.client.renderer.GlStateManager.enableCull;
import static net.minecraft.client.renderer.GlStateManager.enableDepth;
import static net.minecraft.client.renderer.GlStateManager.enableTexture2D;
import static net.minecraft.client.renderer.GlStateManager.loadIdentity;
import static net.minecraft.client.renderer.GlStateManager.matrixMode;
import static net.minecraft.client.renderer.GlStateManager.popAttrib;
import static net.minecraft.client.renderer.GlStateManager.popMatrix;
import static net.minecraft.client.renderer.GlStateManager.pushMatrix;
import static net.minecraft.client.renderer.GlStateManager.rotate;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import static net.minecraft.client.renderer.GlStateManager.viewport;
import java.awt.Color; import java.awt.Color;
import java.awt.Window.Type; import java.awt.Window.Type;
@ -11,7 +36,6 @@ import java.io.IOException;
import java.nio.DoubleBuffer; import java.nio.DoubleBuffer;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -31,13 +55,12 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU; import org.lwjgl.util.glu.GLU;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mumfrey.liteloader.gl.GL;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.mod.LiteModHDSkinsMod; import com.voxelmodpack.hdskins.mod.LiteModHDSkinsMod;
import com.voxelmodpack.hdskins.upload.IUploadCompleteCallback; import com.voxelmodpack.hdskins.upload.IUploadCompleteCallback;
import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload; import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload;
@ -182,9 +205,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
protected void onSetRemoteSkin() {} protected void onSetRemoteSkin() {}
/**
* @param skin The skin
*/
protected void onSetLocalSkin(BufferedImage skin) {} protected void onSetLocalSkin(BufferedImage skin) {}
private void reloadRemoteSkin() { private void reloadRemoteSkin() {
@ -224,11 +244,9 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.panoramaRenderer.initPanoramaRenderer(); this.panoramaRenderer.initPanoramaRenderer();
this.getControlList().clear(); this.getControlList().clear();
this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse...")); this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
this.getControlList() this.getControlList().add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>"));
.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>"));
this.getControlList().add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear")); this.getControlList().add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear"));
this.getControlList() this.getControlList().add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close"));
.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close"));
this.btnUpload.enabled = false; this.btnUpload.enabled = false;
this.btnBrowse.enabled = !this.mc.isFullScreen(); this.btnBrowse.enabled = !this.mc.isFullScreen();
} }
@ -280,8 +298,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
@Override @Override
public void initPanoramaRenderer() { public void initPanoramaRenderer() {
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama", this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama", new DynamicTexture(256, 256));
new DynamicTexture(256, 256));
} }
@Override @Override
@ -385,8 +402,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
byte top = 30; byte top = 30;
int bottom = this.height - 40; int bottom = this.height - 40;
int mid = this.width / 2; int mid = this.width / 2;
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top && mouseY < bottom) {
&& mouseY < bottom) {
this.localPlayer.swingArm(); this.localPlayer.swingArm();
this.remotePlayer.swingArm(); this.remotePlayer.swingArm();
} }
@ -402,19 +418,19 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
} }
public void setupCubemapCamera() { public void setupCubemapCamera() {
matrixMode(5889); matrixMode(GL11.GL_PROJECTION);
pushMatrix(); pushMatrix();
loadIdentity(); loadIdentity();
GLU.gluPerspective(150.0F, 1.0F, 0.05F, 10.0F); GLU.gluPerspective(150.0F, 1.0F, 0.05F, 10.0F);
matrixMode(5888); matrixMode(GL11.GL_MODELVIEW);
pushMatrix(); pushMatrix();
loadIdentity(); loadIdentity();
} }
public void revertPanoramaMatrix() { public void revertPanoramaMatrix() {
matrixMode(5889); matrixMode(GL11.GL_PROJECTION);
popMatrix(); popMatrix();
matrixMode(5888); matrixMode(GL11.GL_MODELVIEW);
popMatrix(); popMatrix();
} }
@ -422,11 +438,11 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.setupCubemapCamera(); this.setupCubemapCamera();
color(1.0F, 1.0F, 1.0F, 1.0F); color(1.0F, 1.0F, 1.0F, 1.0F);
rotate(180.0F, 1.0F, 0.0F, 0.0F); rotate(180.0F, 1.0F, 0.0F, 0.0F);
GL11.glEnable(3042); enableBlend();
GL11.glDisable(3008); disableAlpha();
GL11.glDisable(2884); disableCull();
depthMask(false); depthMask(false);
blendFunc(770, 771); blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
byte blendIterations = 8; byte blendIterations = 8;
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer(); WorldRenderer wr = tessellator.getWorldRenderer();
@ -437,8 +453,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
float offsetY = ((float) (blendPass / blendIterations) / (float) blendIterations - 0.5F) / 64.0F; float offsetY = ((float) (blendPass / blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
float offsetZ = 0.0F; float offsetZ = 0.0F;
translate(offsetX, offsetY, offsetZ); translate(offsetX, offsetY, offsetZ);
rotate(MathHelper.sin((this.updateCounter + 200 + partialTick) / 400.0F) * 25.0F + 20.0F, 1.0F, rotate(MathHelper.sin((this.updateCounter + 200 + partialTick) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
0.0F, 0.0F);
rotate(-(this.updateCounter + 200 + partialTick) * 0.1F, 0.0F, 1.0F, 0.0F); rotate(-(this.updateCounter + 200 + partialTick) * 0.1F, 0.0F, 1.0F, 0.0F);
for (int cubeSide = 0; cubeSide < 6; ++cubeSide) { for (int cubeSide = 0; cubeSide < 6; ++cubeSide) {
@ -465,7 +480,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]); this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]);
wr.startDrawingQuads(); wr.startDrawingQuads();
wr.setColorRGBA_I(16777215, 255 / (blendPass + 1)); wr.setColorRGBA_I(0xffffff, 255 / (blendPass + 1));
wr.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0D, 0.0D); wr.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0D, 0.0D);
wr.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0D, 0.0D); wr.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0D, 0.0D);
wr.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0D, 1.0D); wr.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0D, 1.0D);
@ -481,17 +496,17 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
wr.setTranslation(0.0D, 0.0D, 0.0D); wr.setTranslation(0.0D, 0.0D, 0.0D);
colorMask(true, true, true, true); colorMask(true, true, true, true);
depthMask(true); depthMask(true);
GL11.glEnable(2884); enableCull();
GL11.glEnable(3008); enableAlpha();
GL11.glEnable(2929); enableDepth();
this.revertPanoramaMatrix(); this.revertPanoramaMatrix();
} }
private void rotateAndBlurCubemap() { private void rotateAndBlurCubemap() {
this.mc.getTextureManager().bindTexture(this.viewportTexture); this.mc.getTextureManager().bindTexture(this.viewportTexture);
GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, 256, 256); GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
GL11.glEnable(3042); enableBlend();
blendFunc(770, 771); blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
colorMask(true, true, true, false); colorMask(true, true, true, false);
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer(); WorldRenderer wr = tessellator.getWorldRenderer();
@ -509,29 +524,29 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
tessellator.draw(); tessellator.draw();
colorMask(true, true, true, true); colorMask(true, true, true, true);
GL11.glDisable(3042); disableBlend();
} }
@Override @Override
public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) { public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) {
GL11.glViewport(0, 0, 256, 256); viewport(0, 0, 256, 256);
this.renderCubeMapTexture(partialTicks); this.renderCubeMapTexture(partialTicks);
GL11.glDisable(3553); disableTexture2D();
GL11.glEnable(3553); enableTexture2D();
for (int tessellator = 0; tessellator < 8; ++tessellator) { for (int tessellator = 0; tessellator < 8; ++tessellator) {
this.rotateAndBlurCubemap(); this.rotateAndBlurCubemap();
} }
GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer(); WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads(); wr.startDrawingQuads();
float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height; float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height;
float uSample = this.height * aspect / 256.0F; float uSample = this.height * aspect / 256.0F;
float vSample = this.width * aspect / 256.0F; float vSample = this.width * aspect / 256.0F;
GL11.glTexParameteri(3553, 10241, 9729); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(3553, 10240, 9729); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.5F - uSample, 0.5F + vSample); wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.5F - uSample, 0.5F + vSample);
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.5F - uSample, 0.5F - vSample); wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.5F - uSample, 0.5F - vSample);
@ -545,45 +560,58 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
public void drawScreen(int mouseX, int mouseY, float partialTick) { public void drawScreen(int mouseX, int mouseY, float partialTick) {
float deltaTime = this.updateCounter + partialTick - this.lastPartialTick; float deltaTime = this.updateCounter + partialTick - this.lastPartialTick;
this.lastPartialTick = this.updateCounter + partialTick; this.lastPartialTick = this.updateCounter + partialTick;
GL11.glDisable(GL11.GL_FOG);
disableFog();
this.mc.entityRenderer.disableLightmap(); this.mc.entityRenderer.disableLightmap();
this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick); this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick);
byte top = 30;
int top = 30;
int bottom = this.height - 40; int bottom = this.height - 40;
int mid = this.width / 2; int mid = this.width / 2;
int horizon = this.height / 2 + this.height / 5; int horizon = this.height / 2 + this.height / 5;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE); Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE); Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE);
this.drawGradientRect(30, horizon, mid - 30, bottom, -2130706433, 16777215);
this.drawGradientRect(mid + 30, horizon, this.width - 30, bottom, -2130706433, 16777215); this.drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
this.drawGradientRect(mid + 30, horizon, this.width - 30, bottom, 0x80FFFFFF, 0xffffff);
super.drawScreen(mouseX, mouseY, partialTick); super.drawScreen(mouseX, mouseY, partialTick);
popAttrib(); popAttrib();
this.enableClipping(30, bottom); this.enableClipping(30, bottom);
float yPos = this.height * 0.75F; float yPos = this.height * 0.75F;
float xPos1 = this.width * 0.25F; float xPos1 = this.width * 0.25F;
float xPos2 = this.width * 0.75F; float xPos2 = this.width * 0.75F;
float scale = this.height * 0.25F; float scale = this.height * 0.25F;
this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY,
partialTick); this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY, partialTick);
this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY, this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY, partialTick);
partialTick);
this.disableClipping(); this.disableClipping();
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 16777215);
this.fontRendererObj.drawStringWithShadow(localSkin, 34, 34, 16777215); this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 0xffffff);
this.fontRendererObj.drawStringWithShadow(serverSkin, this.width / 2 + 34, 34, 16777215);
GL11.glDisable(GL11.GL_DEPTH_TEST); this.fontRendererObj.drawStringWithShadow(localSkin, 34, 34, 0xffffff);
GL11.glEnable(GL11.GL_BLEND); this.fontRendererObj.drawStringWithShadow(serverSkin, this.width / 2 + 34, 34, 0xffffff);
disableDepth();
enableBlend();
depthMask(false); depthMask(false);
// this is here so the next few things get blended properly
Gui.drawRect(0, 0, 1, 1, 0);
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff); this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff);
this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, -520093697); this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, 0xE0FFFFFF);
int labelwidth = (this.width / 2 - 80) / 2; int labelwidth = (this.width / 2 - 80) / 2;
int opacity;
if (!this.localPlayer.isUsingLocalTexture()) { if (!this.localPlayer.isUsingLocalTexture()) {
opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2; int opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2;
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, -1342177280); Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000);
this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff);
16777215);
} }
if (this.fetchingSkin) { if (this.fetchingSkin) {
@ -593,19 +621,16 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
String stringWidth = wait; String stringWidth = wait;
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2; int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2; int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16,
-1342177280); Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16, 0xB0000000);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10,
16777215); this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10, 0xffffff);
this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.height / 2 + 2, 0xffffff);
this.height / 2 + 2, 16777215);
} else { } else {
opacity1 = fetch; opacity1 = fetch;
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2; int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12, Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12, 0xB0000000);
-1342177280); this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4, 0xffffff);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4,
16777215);
} }
} }
@ -620,47 +645,49 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.uploadOpacity = 1.0F; this.uploadOpacity = 1.0F;
} }
opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255; int opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255;
if (this.uploadOpacity > 0.0F) { if (this.uploadOpacity > 0.0F) {
Gui.drawRect(0, 0, this.width, this.height, opacity << 24 | 0); Gui.drawRect(0, 0, this.width, this.height, opacity << 24 | 0);
if (this.uploadingSkin) { if (this.uploadingSkin) {
this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2, this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff);
this.height / 2, opacity << 24 | 16777215);
} }
} }
} }
if (this.uploadError != null) { if (this.uploadError != null) {
Gui.drawRect(0, 0, this.width, this.height, -1342177280); Gui.drawRect(0, 0, this.width, this.height, 0xB0000000);
this.drawCenteredString(this.fontRendererObj, failed, this.width / 2, this.height / 2 - 10, this.drawCenteredString(this.fontRendererObj, failed, this.width / 2, this.height / 2 - 10, 0xFFFFFF55);
-171); this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555);
this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2,
-43691);
} }
depthMask(true); depthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST); enableDepth();
} }
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseX, float mouseY, float partialTick) { public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseX, float mouseY, float partialTick) {
GL11.glEnable(GL.GL_COLOR_MATERIAL); enableColorMaterial();
pushMatrix(); pushMatrix();
translate(xPosition, yPosition, 300.0F); translate(xPosition, yPosition, 300.0F);
scale(-scale, scale, scale); scale(-scale, scale, scale);
rotate(180.0F, 0.0F, 0.0F, 1.0F); rotate(180.0F, 0.0F, 0.0F, 1.0F);
rotate(135.0F, 0.0F, 1.0F, 0.0F); rotate(135.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
rotate(-135.0F, 0.0F, 1.0F, 0.0F); rotate(-135.0F, 0.0F, 1.0F, 0.0F);
rotate(15.0F, 1.0F, 0.0F, 0.0F); rotate(15.0F, 1.0F, 0.0F, 0.0F);
rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F); rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F);
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F; thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
translate(0.0D, thePlayer.getYOffset(), 0.0D); translate(0.0D, thePlayer.getYOffset(), 0.0D);
RenderManager rm = Minecraft.getMinecraft().getRenderManager(); RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.playerViewY = 180.0F; rm.playerViewY = 180.0F;
rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F); rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F);
popMatrix(); popMatrix();
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_COLOR_MATERIAL); disableColorMaterial();
} }
protected final void enableClipping(int yTop, int yBottom) { protected final void enableClipping(int yTop, int yBottom) {
@ -670,17 +697,19 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.doubleBuffer.clear(); this.doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip(); this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip();
GL11.glClipPlane(12288, this.doubleBuffer);
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, this.doubleBuffer);
this.doubleBuffer.clear(); this.doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip(); this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip();
GL11.glClipPlane(12289, this.doubleBuffer);
GL11.glEnable(12288); GL11.glClipPlane(GL11.GL_CLIP_PLANE1, this.doubleBuffer);
GL11.glEnable(12289); GL11.glEnable(GL11.GL_CLIP_PLANE0);
GL11.glEnable(GL11.GL_CLIP_PLANE1);
} }
protected final void disableClipping() { protected final void disableClipping() {
GL11.glDisable(12289); GL11.glDisable(GL11.GL_CLIP_PLANE1);
GL11.glDisable(12288); GL11.glDisable(GL11.GL_CLIP_PLANE0);
} }
public static boolean isPowerOfTwo(int number) { public static boolean isPowerOfTwo(int number) {
@ -691,15 +720,14 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
if (!this.registerServerConnection(session, skinServerId)) { if (!this.registerServerConnection(session, skinServerId)) {
return false; return false;
} }
HashMap<String, Object> sourceData = new HashMap<String, Object>(); HashMap<String, Object> sourceData = Maps.newHashMap();
sourceData.put("user", session.getUsername()); sourceData.put("user", session.getUsername());
sourceData.put("uuid", session.getPlayerID()); sourceData.put("uuid", session.getPlayerID());
sourceData.put("clear", "1"); sourceData.put("clear", "1");
this.uploadError = null; this.uploadError = null;
this.uploadingSkin = true; this.uploadingSkin = true;
this.skinUploadMessage = request; this.skinUploadMessage = request;
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/", this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this);
sourceData, this);
this.threadSkinUpload.start(); this.threadSkinUpload.start();
return true; return true;
} }
@ -715,8 +743,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.uploadError = null; this.uploadError = null;
this.uploadingSkin = true; this.uploadingSkin = true;
this.skinUploadMessage = upload; this.skinUploadMessage = upload;
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/", this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this);
sourceData, this);
this.threadSkinUpload.start(); this.threadSkinUpload.start();
return true; return true;
} }
@ -740,9 +767,8 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
private boolean registerServerConnection(Session session, String serverId) { private boolean registerServerConnection(Session session, String serverId) {
try { try {
MinecraftSessionService e = (new YggdrasilAuthenticationService(this.mc.getProxy(), MinecraftSessionService service = Minecraft.getMinecraft().getSessionService();
UUID.randomUUID().toString())).createMinecraftSessionService(); service.joinServer(session.getProfile(), session.getToken(), serverId);
e.joinServer(session.getProfile(), session.getToken(), serverId);
return true; return true;
} catch (AuthenticationException var4) { } catch (AuthenticationException var4) {
this.setUploadError(var4.toString()); this.setUploadError(var4.toString());

View file

@ -1,5 +1,6 @@
package com.voxelmodpack.hdskins.mixin; package com.voxelmodpack.hdskins.mixin;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -18,13 +19,12 @@ import net.minecraft.util.ResourceLocation;
@Mixin(NetworkPlayerInfo.class) @Mixin(NetworkPlayerInfo.class)
public abstract class MixinPlayerInfo { public abstract class MixinPlayerInfo {
@Final
@Shadow @Shadow
private GameProfile gameProfile; private GameProfile gameProfile;
@Shadow @Shadow
private ResourceLocation locationSkin; private ResourceLocation locationSkin;
@Shadow @Shadow
private ResourceLocation locationCape;
@Shadow
public String skinType; public String skinType;
@Inject(method = "hasLocationSkin", @Inject(method = "hasLocationSkin",
@ -67,8 +67,12 @@ public abstract class MixinPlayerInfo {
MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(gameProfile).get(Type.SKIN); MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(gameProfile).get(Type.SKIN);
if (data != null) { if (data != null) {
String type = data.getMetadata("model"); String type = data.getMetadata("model");
if (type != null) boolean hasSkin = HDSkinManager.INSTANCE.getSkinLocation(gameProfile, Type.SKIN, false).isPresent();
if (hasSkin) {
if (type == null)
type = "default";
ci.setReturnValue(type); ci.setReturnValue(type);
} }
} }
} }
}

View file

@ -52,7 +52,6 @@ public class Pony {
if (!this.skinChecked) { if (!this.skinChecked) {
this.checkSkin(this.textureResourceLocation); this.checkSkin(this.textureResourceLocation);
} }
} }
public void checkSkin(ResourceLocation textureResourceLocation) { public void checkSkin(ResourceLocation textureResourceLocation) {
@ -60,12 +59,10 @@ public class Pony {
if (skinImage != null) { if (skinImage != null) {
this.checkSkin(skinImage); this.checkSkin(skinImage);
} }
} }
public BufferedImage getBufferedImage(ResourceLocation textureResourceLocation) { public BufferedImage getBufferedImage(ResourceLocation textureResourceLocation) {
BufferedImage skinImage = null; BufferedImage skinImage = null;
try { try {
skinImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager() skinImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager()
.getResource(textureResourceLocation).getInputStream()); .getResource(textureResourceLocation).getInputStream());

View file

@ -75,10 +75,10 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
this.playerModel.getModel().heldItemRight = currentItemStack == null ? 0 : 1; this.playerModel.getModel().heldItemRight = currentItemStack == null ? 0 : 1;
if (currentItemStack != null && player.getItemInUseCount() > 0) { if (currentItemStack != null && player.getItemInUseCount() > 0) {
EnumAction yOrigin = currentItemStack.getItemUseAction(); EnumAction action = currentItemStack.getItemUseAction();
if (yOrigin == EnumAction.BLOCK) { if (action == EnumAction.BLOCK) {
this.playerModel.getModel().heldItemRight = 3; this.playerModel.getModel().heldItemRight = 3;
} else if (yOrigin == EnumAction.BOW) { } else if (action == EnumAction.BOW) {
this.playerModel.getModel().aimedBow = true; this.playerModel.getModel().aimedBow = true;
} }
} }