Format code

This commit is contained in:
Sollace 2018-07-15 12:21:47 +02:00
parent 021f53c0da
commit 865535d49e
15 changed files with 369 additions and 357 deletions

View file

@ -10,7 +10,7 @@ public class DynamicTextureImage extends DynamicTexture {
public DynamicTextureImage(BufferedImage bufferedImage) { public DynamicTextureImage(BufferedImage bufferedImage) {
super(bufferedImage); super(bufferedImage);
this.image = bufferedImage; image = bufferedImage;
} }
public BufferedImage getImage() { public BufferedImage getImage() {
@ -20,7 +20,7 @@ public class DynamicTextureImage extends DynamicTexture {
@Override @Override
public void deleteGlTexture() { public void deleteGlTexture() {
super.deleteGlTexture(); super.deleteGlTexture();
this.image = null; image = null;
} }
} }

View file

@ -81,6 +81,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
private Map<UUID, Map<Type, ResourceLocation>> skinCache = Maps.newHashMap(); private Map<UUID, Map<Type, ResourceLocation>> skinCache = Maps.newHashMap();
// TODO: Garggling marbles
private LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skins = CacheBuilder.newBuilder() private LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skins = CacheBuilder.newBuilder()
.initialCapacity(20) .initialCapacity(20)
.maximumSize(100) .maximumSize(100)
@ -247,16 +248,16 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
} }
public Class<? extends SkinServer> getSkinServerClass(String type) { public Class<? extends SkinServer> getSkinServerClass(String type) {
return this.skinServerTypes.get(type); return skinServerTypes.get(type);
} }
public void addSkinServer(SkinServer skinServer) { public void addSkinServer(SkinServer skinServer) {
this.skinServers.add(skinServer); skinServers.add(skinServer);
} }
@Deprecated @Deprecated
public SkinServer getGatewayServer() { public SkinServer getGatewayServer() {
return this.skinServers.get(0); return skinServers.get(0);
} }
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
@ -277,9 +278,10 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
try { try {
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins")); FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "hd")); FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "hd"));
TextureManager textures = Minecraft.getMinecraft().getTextureManager(); TextureManager textures = Minecraft.getMinecraft().getTextureManager();
INSTANCE.skinCache.values().stream()
.flatMap(m -> m.values().stream()) INSTANCE.skinCache.values().stream().flatMap(m -> m.values().stream())
.forEach(textures::deleteTexture); .forEach(textures::deleteTexture);
INSTANCE.skinCache.clear(); INSTANCE.skinCache.clear();
INSTANCE.skins.invalidateAll(); INSTANCE.skins.invalidateAll();
@ -312,13 +314,11 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
} }
public void convertSkin(BufferedImage image, Graphics dest) { public void convertSkin(BufferedImage image, Graphics dest) {
for (ISkinModifier skin : skinModifiers) { skinModifiers.forEach(a -> a.convertSkin(image, dest));
skin.convertSkin(image, dest);
}
} }
@Override @Override
public void onResourceManagerReload(IResourceManager resourceManager) { public void onResourceManagerReload(IResourceManager resourceManager) {
this.resources.onResourceManagerReload(resourceManager); resources.onResourceManagerReload(resourceManager);
} }
} }

View file

@ -6,16 +6,21 @@ import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
public class PreviewTexture extends ThreadDownloadImageData { public class PreviewTexture extends ThreadDownloadImageData {
private boolean uploaded; private boolean uploaded;
private String model; private String model;
public PreviewTexture(@Nullable String model, String url, ResourceLocation fallbackTexture, @Nullable IImageBuffer imageBuffer) { public PreviewTexture(MinecraftProfileTexture texture, ResourceLocation fallbackTexture, @Nullable IImageBuffer imageBuffer) {
super(null, url, fallbackTexture, imageBuffer); super(null, texture.getUrl(), fallbackTexture, imageBuffer);
this.model = model == null ? "default" : model; model = texture.getMetadata("model");
if (model == null) {
model = "default";
}
} }
public boolean isTextureUploaded() { public boolean isTextureUploaded() {
@ -25,7 +30,7 @@ public class PreviewTexture extends ThreadDownloadImageData {
@Override @Override
public void deleteGlTexture() { public void deleteGlTexture() {
super.deleteGlTexture(); super.deleteGlTexture();
this.uploaded = true; uploaded = true;
} }
public boolean hasModel() { public boolean hasModel() {
@ -35,4 +40,8 @@ public class PreviewTexture extends ThreadDownloadImageData {
public boolean usesThinArms() { public boolean usesThinArms() {
return "thin".equals(model); return "thin".equals(model);
} }
public String getModel() {
return model;
}
} }

View file

@ -2,6 +2,8 @@ package com.voxelmodpack.hdskins;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer; import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.resources.SkinManager; import net.minecraft.client.resources.SkinManager;
@ -18,22 +20,20 @@ import javax.annotation.Nullable;
*/ */
public class PreviewTextureManager { public class PreviewTextureManager {
private final Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures; private final Map<Type, MinecraftProfileTexture> textures;
PreviewTextureManager(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) { PreviewTextureManager(Map<Type, MinecraftProfileTexture> textures) {
this.textures = textures; this.textures = textures;
} }
@Nullable private IImageBuffer getPreviewImageBuffer(MinecraftProfileTexture texture, ResourceLocation location, Type type, SkinManager.SkinAvailableCallback callback) {
public PreviewTexture getPreviewTexture(ResourceLocation location, MinecraftProfileTexture.Type type, ResourceLocation def, if (type != Type.SKIN) {
@Nullable SkinManager.SkinAvailableCallback callback) {
if (!textures.containsKey(type)) {
return null; return null;
} }
MinecraftProfileTexture texture = textures.get(type);
IImageBuffer buffer = new ImageBufferDownloadHD(); IImageBuffer buffer = new ImageBufferDownloadHD();
PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), texture.getUrl(), def,
type == MinecraftProfileTexture.Type.SKIN ? new IImageBuffer() { return new IImageBuffer() {
@Override @Override
@Nullable @Nullable
public BufferedImage parseUserSkin(BufferedImage image) { public BufferedImage parseUserSkin(BufferedImage image) {
@ -46,7 +46,18 @@ public class PreviewTextureManager {
callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap())); callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap()));
} }
} }
} : null); };
}
@Nullable
public PreviewTexture getPreviewTexture(ResourceLocation location, Type type, ResourceLocation def, @Nullable SkinManager.SkinAvailableCallback callback) {
if (!textures.containsKey(type)) {
return null;
}
MinecraftProfileTexture texture = textures.get(type);
PreviewTexture skinTexture = new PreviewTexture(texture, def, getPreviewImageBuffer(texture, location, type, callback));
Minecraft.getMinecraft().getTextureManager().loadTexture(location, skinTexture); Minecraft.getMinecraft().getTextureManager().loadTexture(location, skinTexture);
return skinTexture; return skinTexture;

View file

@ -6,9 +6,11 @@ import net.minecraft.util.ResourceLocation;
public class TextureLoader { public class TextureLoader {
private static Minecraft mc = Minecraft.getMinecraft(); private static final Minecraft mc = Minecraft.getMinecraft();
public static void loadTexture(final ResourceLocation textureLocation, final ITextureObject textureObj) { public static void loadTexture(ResourceLocation textureLocation, ITextureObject textureObj) {
mc.addScheduledTask((Runnable) () -> mc.getTextureManager().loadTexture(textureLocation, textureObj)); mc.addScheduledTask(() -> {
mc.getTextureManager().loadTexture(textureLocation, textureObj);
});
} }
} }

View file

@ -12,7 +12,6 @@ import org.apache.http.Header;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
@ -36,6 +35,7 @@ public class ThreadDownloadImageETag extends SimpleTexture {
private final File cacheFile; private final File cacheFile;
private final File eTagFile; private final File eTagFile;
private final String imageUrl; private final String imageUrl;
@Nullable @Nullable
private final IImageBuffer imageBuffer; private final IImageBuffer imageBuffer;
@ -47,35 +47,32 @@ public class ThreadDownloadImageETag extends SimpleTexture {
public ThreadDownloadImageETag(@Nonnull File cacheFileIn, String imageUrlIn, ResourceLocation defLocation, @Nullable IImageBuffer imageBufferIn) { public ThreadDownloadImageETag(@Nonnull File cacheFileIn, String imageUrlIn, ResourceLocation defLocation, @Nullable IImageBuffer imageBufferIn) {
super(defLocation); super(defLocation);
this.cacheFile = cacheFileIn; cacheFile = cacheFileIn;
this.eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag"); eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag");
this.imageUrl = imageUrlIn; imageUrl = imageUrlIn;
this.imageBuffer = imageBufferIn; imageBuffer = imageBufferIn;
}
private void checkTextureUploaded() {
if (!this.textureUploaded) {
if (this.bufferedImage != null) {
if (this.textureLocation != null) {
this.deleteGlTexture();
}
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
this.textureUploaded = true;
}
}
} }
public int getGlTextureId() { public int getGlTextureId() {
this.checkTextureUploaded(); if (!textureUploaded) {
if (bufferedImage != null) {
if (textureLocation != null) {
deleteGlTexture();
}
TextureUtil.uploadTextureImage(super.getGlTextureId(), bufferedImage);
textureUploaded = true;
}
}
return super.getGlTextureId(); return super.getGlTextureId();
} }
private void setBufferedImage(@Nonnull BufferedImage bufferedImageIn) { private void setBufferedImage(@Nonnull BufferedImage bufferedImageIn) {
this.bufferedImage = bufferedImageIn; bufferedImage = bufferedImageIn;
if (this.imageBuffer != null) { if (imageBuffer != null) {
this.imageBuffer.skinAvailable(); imageBuffer.skinAvailable();
} }
} }
@ -85,22 +82,22 @@ public class ThreadDownloadImageETag extends SimpleTexture {
} }
public void loadTexture(IResourceManager resourceManager) throws IOException { public void loadTexture(IResourceManager resourceManager) throws IOException {
if (this.bufferedImage == null && this.textureLocation != null) { if (bufferedImage == null && textureLocation != null) {
super.loadTexture(resourceManager); super.loadTexture(resourceManager);
} }
if (this.imageThread == null) { if (imageThread == null) {
this.imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet()); imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet());
this.imageThread.setDaemon(true); imageThread.setDaemon(true);
this.imageThread.start(); imageThread.start();
} }
} }
private void loadTexture() { private void loadTexture() {
HttpResponse response = null; HttpResponse response = null;
try { try {
HttpClient client = HttpClientBuilder.create().build(); response = HttpClientBuilder.create().build().execute(new HttpGet(imageUrl));
response = client.execute(new HttpGet(imageUrl));
int status = response.getStatusLine().getStatusCode(); int status = response.getStatusLine().getStatusCode();
if (status == HttpStatus.SC_NOT_FOUND) { if (status == HttpStatus.SC_NOT_FOUND) {
// delete the cache files in case we can't connect in the future // delete the cache files in case we can't connect in the future
@ -133,10 +130,11 @@ public class ThreadDownloadImageETag extends SimpleTexture {
} }
LOGGER.error("Couldn't load skin {} ", imageUrl, e); LOGGER.error("Couldn't load skin {} ", imageUrl, e);
} finally { } finally {
if (response != null) if (response != null) {
EntityUtils.consumeQuietly(response.getEntity()); EntityUtils.consumeQuietly(response.getEntity());
} }
} }
}
private void setLocalCache() throws IOException { private void setLocalCache() throws IOException {
if (cacheFile.isFile()) { if (cacheFile.isFile()) {
@ -149,8 +147,8 @@ public class ThreadDownloadImageETag extends SimpleTexture {
} }
private void clearCache() { private void clearCache() {
FileUtils.deleteQuietly(this.cacheFile); FileUtils.deleteQuietly(cacheFile);
FileUtils.deleteQuietly(this.eTagFile); FileUtils.deleteQuietly(eTagFile);
} }
private boolean checkETag(HttpResponse response) { private boolean checkETag(HttpResponse response) {
@ -158,14 +156,15 @@ public class ThreadDownloadImageETag extends SimpleTexture {
if (cacheFile.isFile()) { if (cacheFile.isFile()) {
String localETag = Files.readFirstLine(eTagFile, Charsets.UTF_8); String localETag = Files.readFirstLine(eTagFile, Charsets.UTF_8);
Header remoteETag = response.getFirstHeader(HttpHeaders.ETAG); Header remoteETag = response.getFirstHeader(HttpHeaders.ETAG);
// true if no remote etag or does match // true if no remote etag or does match
return remoteETag == null || localETag.equals(remoteETag.getValue()); return remoteETag == null || localETag.equals(remoteETag.getValue());
} }
return false;
} catch (IOException e) { } catch (IOException e) {
// it failed, so re-fetch.
return false;
} }
return false; // it failed, so re-fetch.
} }
private void loadTextureFromServer(HttpResponse response) { private void loadTextureFromServer(HttpResponse response) {

View file

@ -33,7 +33,7 @@ public class EntityPlayerModel extends EntityLivingBase {
public static final ResourceLocation NO_SKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png"); public static final ResourceLocation NO_SKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png");
public static final ResourceLocation NO_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); public static final ResourceLocation NO_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
private Map<EntityEquipmentSlot, ItemStack> armors = Maps.newEnumMap(ImmutableMap.of( private Map<EntityEquipmentSlot, ItemStack> armour = Maps.newEnumMap(ImmutableMap.of(
EntityEquipmentSlot.HEAD, ItemStack.EMPTY, EntityEquipmentSlot.HEAD, ItemStack.EMPTY,
EntityEquipmentSlot.CHEST, ItemStack.EMPTY, EntityEquipmentSlot.CHEST, ItemStack.EMPTY,
EntityEquipmentSlot.LEGS, ItemStack.EMPTY, EntityEquipmentSlot.LEGS, ItemStack.EMPTY,
@ -56,41 +56,41 @@ public class EntityPlayerModel extends EntityLivingBase {
protected boolean hasLocalTexture = false; protected boolean hasLocalTexture = false;
protected boolean previewThinArms = false; protected boolean previewThinArms = false;
public EntityPlayerModel(GameProfile profile) { public EntityPlayerModel(GameProfile gameprofile) {
super(new DummyWorld()); super(new DummyWorld());
this.profile = profile; profile = gameprofile;
this.textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager = Minecraft.getMinecraft().getTextureManager();
this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png"); remoteSkinResource = new ResourceLocation("skins/preview_" + profile.getName() + ".png");
this.remoteElytraResource = new ResourceLocation("elytras/preview_" + this.profile.getName() + ".png"); remoteElytraResource = new ResourceLocation("elytras/preview_" + profile.getName() + ".png");
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
this.textureManager.deleteTexture(this.remoteSkinResource); textureManager.deleteTexture(remoteSkinResource);
this.textureManager.deleteTexture(this.remoteElytraResource); textureManager.deleteTexture(remoteElytraResource);
} }
public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) { public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) {
this.remoteSkin = true; remoteSkin = true;
if (this.remoteSkinTexture != null) { if (remoteSkinTexture != null) {
this.textureManager.deleteTexture(this.remoteSkinResource); textureManager.deleteTexture(remoteSkinResource);
} }
if (this.remoteElytraTexture != null) { if (remoteElytraTexture != null) {
this.textureManager.deleteTexture(this.remoteElytraResource); textureManager.deleteTexture(remoteElytraResource);
} }
PreviewTextureManager ptm = HDSkinManager.getPreviewTextureManager(this.profile); PreviewTextureManager ptm = HDSkinManager.getPreviewTextureManager(profile);
this.remoteSkinTexture = ptm.getPreviewTexture(this.remoteSkinResource, Type.SKIN, getBlankSkin(), listener); remoteSkinTexture = ptm.getPreviewTexture(remoteSkinResource, Type.SKIN, getBlankSkin(), listener);
this.remoteElytraTexture = ptm.getPreviewTexture(this.remoteElytraResource, Type.ELYTRA, getBlankElytra(), null); remoteElytraTexture = ptm.getPreviewTexture(remoteElytraResource, Type.ELYTRA, getBlankElytra(), null);
} }
public void setLocalTexture(File skinTextureFile, Type type) { public void setLocalTexture(File skinTextureFile, Type type) {
if (skinTextureFile.exists()) { if (skinTextureFile.exists()) {
if (type == Type.SKIN) { if (type == Type.SKIN) {
this.remoteSkin = false; remoteSkin = false;
if (this.localSkinTexture != null) { if (localSkinTexture != null) {
this.textureManager.deleteTexture(this.localSkinResource); textureManager.deleteTexture(localSkinResource);
this.localSkinTexture = null; localSkinTexture = null;
} }
BufferedImage bufferedImage; BufferedImage bufferedImage;
@ -99,33 +99,33 @@ public class EntityPlayerModel extends EntityLivingBase {
bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image); bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image);
assert bufferedImage != null; assert bufferedImage != null;
} catch (IOException var4) { } catch (IOException var4) {
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
var4.printStackTrace(); var4.printStackTrace();
return; return;
} }
this.localSkinTexture = new DynamicTextureImage(bufferedImage); localSkinTexture = new DynamicTextureImage(bufferedImage);
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture); localSkinResource = textureManager.getDynamicTextureLocation("localSkinPreview", localSkinTexture);
this.hasLocalTexture = true; hasLocalTexture = true;
} else if (type == Type.ELYTRA) { } else if (type == Type.ELYTRA) {
this.remoteSkin = false; remoteSkin = false;
if (this.localElytraTexture != null) { if (localElytraTexture != null) {
this.textureManager.deleteTexture(this.localElytraResource); textureManager.deleteTexture(localElytraResource);
this.localElytraTexture = null; localElytraTexture = null;
} }
BufferedImage bufferedImage; BufferedImage bufferedImage;
try { try {
bufferedImage = ImageIO.read(skinTextureFile); bufferedImage = ImageIO.read(skinTextureFile);
} catch (IOException var4) { } catch (IOException var4) {
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
var4.printStackTrace(); var4.printStackTrace();
return; return;
} }
this.localElytraTexture = new DynamicTextureImage(bufferedImage); localElytraTexture = new DynamicTextureImage(bufferedImage);
this.localElytraResource = this.textureManager.getDynamicTextureLocation("localElytraPreview", this.localElytraTexture); localElytraResource = textureManager.getDynamicTextureLocation("localElytraPreview", localElytraTexture);
this.hasLocalTexture = true; hasLocalTexture = true;
} }
} }
} }
@ -139,35 +139,35 @@ public class EntityPlayerModel extends EntityLivingBase {
} }
public boolean isUsingLocalTexture() { public boolean isUsingLocalTexture() {
return !this.remoteSkin && this.hasLocalTexture; return !remoteSkin && hasLocalTexture;
} }
public boolean isTextureSetupComplete() { public boolean isTextureSetupComplete() {
return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded(); return (remoteSkin && remoteSkinTexture != null) && remoteSkinTexture.isTextureUploaded();
} }
public void releaseTextures() { public void releaseTextures() {
if (this.localSkinTexture != null) { if (localSkinTexture != null) {
this.textureManager.deleteTexture(this.localSkinResource); textureManager.deleteTexture(localSkinResource);
this.localSkinTexture = null; localSkinTexture = null;
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
this.hasLocalTexture = false; hasLocalTexture = false;
} }
if (this.localElytraTexture != null) { if (localElytraTexture != null) {
this.textureManager.deleteTexture(this.localElytraResource); textureManager.deleteTexture(localElytraResource);
this.localElytraTexture = null; localElytraTexture = null;
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
this.hasLocalTexture = false; hasLocalTexture = false;
} }
} }
public ResourceLocation getSkinTexture() { public ResourceLocation getSkinTexture() {
return this.remoteSkin ? (this.remoteSkinTexture != null ? this.remoteSkinResource return remoteSkin ? (remoteSkinTexture != null ? remoteSkinResource
: DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource; : DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : localSkinResource;
} }
public ResourceLocation getElytraTexture() { public ResourceLocation getElytraTexture() {
return this.remoteSkin && this.remoteElytraTexture != null ? this.remoteElytraResource : localElytraResource; return remoteSkin && remoteElytraTexture != null ? remoteElytraResource : localElytraResource;
} }
public void setPreviewThinArms(boolean thinArms) { public void setPreviewThinArms(boolean thinArms) {
@ -185,27 +185,27 @@ public class EntityPlayerModel extends EntityLivingBase {
@Override @Override
public void swingArm(EnumHand hand) { public void swingArm(EnumHand hand) {
super.swingArm(hand); super.swingArm(hand);
if (!this.isSwingInProgress || this.swingProgressInt >= 4 || this.swingProgressInt < 0) { if (!isSwingInProgress || swingProgressInt >= 4 || swingProgressInt < 0) {
this.swingProgressInt = -1; swingProgressInt = -1;
this.isSwingInProgress = true; isSwingInProgress = true;
this.swingingHand = hand; swingingHand = hand;
} }
} }
public void updateModel() { public void updateModel() {
this.prevSwingProgress = this.swingProgress; prevSwingProgress = swingProgress;
if (this.isSwingInProgress) { if (isSwingInProgress) {
++this.swingProgressInt; ++swingProgressInt;
if (this.swingProgressInt >= 8) { if (swingProgressInt >= 8) {
this.swingProgressInt = 0; swingProgressInt = 0;
this.isSwingInProgress = false; isSwingInProgress = false;
} }
} else { } else {
this.swingProgressInt = 0; swingProgressInt = 0;
} }
this.swingProgress = this.swingProgressInt / 8.0F; swingProgress = swingProgressInt / 8;
} }
@Override @Override
@ -215,17 +215,17 @@ public class EntityPlayerModel extends EntityLivingBase {
@Override @Override
public Iterable<ItemStack> getArmorInventoryList() { public Iterable<ItemStack> getArmorInventoryList() {
return armors.values(); return armour.values();
} }
@Override @Override
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) { public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
return armors.get(slotIn); return armour.get(slotIn);
} }
@Override @Override
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) { public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
armors.put(slotIn, stack); armour.put(slotIn, stack);
} }
} }

View file

@ -17,6 +17,6 @@ public class GuiItemStackButton extends GuiButton {
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
super.drawButton(mc, mouseX, mouseY, partialTicks); super.drawButton(mc, mouseX, mouseY, partialTicks);
mc.getRenderItem().renderItemIntoGUI(itemStack, this.x + 2, this.y + 2); mc.getRenderItem().renderItemIntoGUI(itemStack, x + 2, y + 2);
} }
} }

View file

@ -27,8 +27,6 @@ import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Session;
import net.minecraft.util.text.TextFormatting;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
@ -80,7 +78,7 @@ public class GuiSkins extends GuiScreen {
private final Object skinLock = new Object(); private final Object skinLock = new Object();
private File pendingSkinFile; private File pendingSkinFile;
private File selectedSkin; private File selectedSkin;
private float uploadOpacity = 0.0F; private float uploadOpacity = 0;
private int lastMouseX = 0; private int lastMouseX = 0;
@ -93,17 +91,17 @@ public class GuiSkins extends GuiScreen {
public GuiSkins() { public GuiSkins() {
Minecraft minecraft = Minecraft.getMinecraft(); Minecraft minecraft = Minecraft.getMinecraft();
// this.screenTitle = manager;
GameProfile profile = minecraft.getSession().getProfile(); GameProfile profile = minecraft.getSession().getProfile();
this.localPlayer = getModel(profile); localPlayer = getModel(profile);
this.remotePlayer = getModel(profile); remotePlayer = getModel(profile);
RenderManager rm = Minecraft.getMinecraft().getRenderManager(); RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.renderEngine = minecraft.getTextureManager(); rm.renderEngine = minecraft.getTextureManager();
rm.options = minecraft.gameSettings; rm.options = minecraft.gameSettings;
rm.renderViewEntity = this.localPlayer; rm.renderViewEntity = localPlayer;
this.reloadRemoteSkin(); reloadRemoteSkin();
this.fetchingSkin = true; fetchingSkin = true;
instance = this; instance = this;
@ -127,40 +125,40 @@ public class GuiSkins extends GuiScreen {
} }
panorama.update(); panorama.update();
this.localPlayer.updateModel(); localPlayer.updateModel();
this.remotePlayer.updateModel(); remotePlayer.updateModel();
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) { if (fetchingSkin && remotePlayer.isTextureSetupComplete()) {
this.fetchingSkin = false; fetchingSkin = false;
this.btnClear.enabled = true; btnClear.enabled = true;
} }
synchronized (this.skinLock) { synchronized (skinLock) {
if (this.pendingSkinFile != null) { if (pendingSkinFile != null) {
System.out.println("Set " + textureType + " " + this.pendingSkinFile); System.out.println("Set " + textureType + " " + pendingSkinFile);
this.localPlayer.setLocalTexture(this.pendingSkinFile, textureType); localPlayer.setLocalTexture(pendingSkinFile, textureType);
this.selectedSkin = this.pendingSkinFile; selectedSkin = pendingSkinFile;
this.pendingSkinFile = null; pendingSkinFile = null;
this.onSetLocalSkin(textureType); onSetLocalSkin(textureType);
this.btnUpload.enabled = true; btnUpload.enabled = true;
} }
} }
if (this.pendingRemoteSkinRefresh) { if (pendingRemoteSkinRefresh) {
this.pendingRemoteSkinRefresh = false; pendingRemoteSkinRefresh = false;
this.fetchingSkin = true; fetchingSkin = true;
this.btnClear.enabled = false; btnClear.enabled = false;
this.reloadRemoteSkin(); reloadRemoteSkin();
} }
if (this.throttledByMojang) { if (throttledByMojang) {
if (this.refreshCounter == -1) { if (refreshCounter == -1) {
this.refreshCounter = 200; refreshCounter = 200;
} else if (this.refreshCounter > 0) { } else if (refreshCounter > 0) {
--this.refreshCounter; --refreshCounter;
} else { } else {
this.refreshCounter = -1; refreshCounter = -1;
this.throttledByMojang = false; throttledByMojang = false;
this.reloadRemoteSkin(); reloadRemoteSkin();
} }
} }
@ -174,10 +172,10 @@ public class GuiSkins extends GuiScreen {
private void reloadRemoteSkin() { private void reloadRemoteSkin() {
try { try {
this.remotePlayer.reloadRemoteSkin(this::onSetRemoteSkin); remotePlayer.reloadRemoteSkin(this::onSetRemoteSkin);
} catch (Exception var2) { } catch (Exception var2) {
var2.printStackTrace(); var2.printStackTrace();
this.throttledByMojang = true; throttledByMojang = true;
} }
} }
@ -188,28 +186,28 @@ public class GuiSkins extends GuiScreen {
panorama.init(); panorama.init();
this.buttonList.clear(); buttonList.clear();
this.buttonList.add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse...")); buttonList.add(btnBrowse = new GuiButton(0, 30, height - 36, 60, 20, "Browse..."));
this.buttonList.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>")); buttonList.add(btnUpload = new GuiButton(1, width / 2 - 24, height / 2 - 10, 48, 20, ">>"));
this.buttonList.add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear")); buttonList.add(btnClear = new GuiButton(2, width - 90, height - 36, 60, 20, "Clear"));
this.buttonList.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close")); buttonList.add(btnBack = new GuiButton(3, width / 2 - 50, height - 36, 100, 20, "Close"));
ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS); ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS);
Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb); Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb);
this.buttonList.add(this.btnModeSkin = new GuiItemStackButton(4, 2, 2, skin)); buttonList.add(btnModeSkin = new GuiItemStackButton(4, 2, 2, skin));
skin = new ItemStack(Items.LEATHER_LEGGINGS); skin = new ItemStack(Items.LEATHER_LEGGINGS);
Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500); Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500);
this.buttonList.add(this.btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA))); buttonList.add(btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA)));
this.buttonList.add(this.btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin)); buttonList.add(btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin));
this.buttonList.add(this.btnAbout = new GuiButton(-1, this.width - 25, this.height - 25, 20, 20, "?")); buttonList.add(btnAbout = new GuiButton(-1, width - 25, height - 25, 20, 20, "?"));
this.btnUpload.enabled = false; btnUpload.enabled = false;
this.btnBrowse.enabled = !this.mc.isFullScreen(); btnBrowse.enabled = !mc.isFullScreen();
this.btnModeSkin.enabled = this.thinArmType; btnModeSkin.enabled = thinArmType;
this.btnModeSkinnySkin.enabled = !this.thinArmType; btnModeSkinnySkin.enabled = !thinArmType;
this.btnModeElytra.enabled = this.textureType == SKIN; btnModeElytra.enabled = textureType == SKIN;
} }
@ -230,107 +228,107 @@ public class GuiSkins extends GuiScreen {
} }
private void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) { private void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
this.openFileThread = null; openFileThread = null;
this.btnBrowse.enabled = true; btnBrowse.enabled = true;
if (dialogResult == 0) { if (dialogResult == 0) {
this.loadLocalFile(fileDialog.getSelectedFile()); loadLocalFile(fileDialog.getSelectedFile());
} }
} }
private void loadLocalFile(File skinFile) { private void loadLocalFile(File skinFile) {
Minecraft.getMinecraft().addScheduledTask(localPlayer::releaseTextures); Minecraft.getMinecraft().addScheduledTask(localPlayer::releaseTextures);
if (!skinFile.exists()) { if (!skinFile.exists()) {
this.skinMessage = I18n.format("hdskins.error.unreadable"); skinMessage = I18n.format("hdskins.error.unreadable");
} else if (!FilenameUtils.isExtension(skinFile.getName(), new String[]{"png", "PNG"})) { } else if (!FilenameUtils.isExtension(skinFile.getName(), new String[]{"png", "PNG"})) {
this.skinMessage = I18n.format("hdskins.error.ext"); skinMessage = I18n.format("hdskins.error.ext");
} else { } else {
BufferedImage chosenImage; BufferedImage chosenImage;
try { try {
chosenImage = ImageIO.read(skinFile); chosenImage = ImageIO.read(skinFile);
} catch (IOException var6) { } catch (IOException var6) {
this.skinMessage = I18n.format("hdskins.error.open"); skinMessage = I18n.format("hdskins.error.open");
var6.printStackTrace(); var6.printStackTrace();
return; return;
} }
if (chosenImage == null) { if (chosenImage == null) {
this.skinMessage = I18n.format("hdskins.error.open"); skinMessage = I18n.format("hdskins.error.open");
} else if (isPowerOfTwo(chosenImage.getWidth()) } else if (isPowerOfTwo(chosenImage.getWidth())
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2 && (chosenImage.getWidth() == chosenImage.getHeight() * 2
|| chosenImage.getWidth() == chosenImage.getHeight()) || chosenImage.getWidth() == chosenImage.getHeight())
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION && chosenImage.getWidth() <= MAX_SKIN_DIMENSION
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) { && chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
synchronized (this.skinLock) { synchronized (skinLock) {
this.pendingSkinFile = skinFile; pendingSkinFile = skinFile;
} }
} else { } else {
this.skinMessage = I18n.format("hdskins.error.invalid"); skinMessage = I18n.format("hdskins.error.invalid");
} }
} }
} }
@Override @Override
protected void actionPerformed(GuiButton guiButton) { protected void actionPerformed(GuiButton guiButton) {
if (this.openFileThread == null && !this.uploadingSkin) { if (openFileThread == null && !uploadingSkin) {
if (this.uploadError != null) { if (uploadError != null) {
this.uploadError = null; uploadError = null;
} else { } else {
if (guiButton.id == this.btnBrowse.id) { if (guiButton.id == btnBrowse.id) {
this.selectedSkin = null; selectedSkin = null;
this.localPlayer.releaseTextures(); localPlayer.releaseTextures();
this.openFileThread = new ThreadOpenFilePNG(this.mc, I18n.format("hdskins.open.title"), this::onFileOpenDialogClosed); openFileThread = new ThreadOpenFilePNG(mc, I18n.format("hdskins.open.title"), this::onFileOpenDialogClosed);
this.openFileThread.start(); openFileThread.start();
guiButton.enabled = false; guiButton.enabled = false;
} }
if (guiButton.id == this.btnUpload.id) { if (guiButton.id == btnUpload.id) {
if (this.selectedSkin != null) { if (selectedSkin != null) {
punchServer("hdskins.upload", selectedSkin.toURI()); punchServer("hdskins.upload", selectedSkin.toURI());
this.btnUpload.enabled = false; btnUpload.enabled = false;
} else { } else {
this.setUploadError(I18n.format("hdskins.error.select")); setUploadError(I18n.format("hdskins.error.select"));
} }
} }
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) { if (guiButton.id == btnClear.id && remotePlayer.isTextureSetupComplete()) {
punchServer("hdskins.request", null); punchServer("hdskins.request", null);
this.btnUpload.enabled = this.selectedSkin != null; btnUpload.enabled = selectedSkin != null;
} }
if (guiButton.id == this.btnBack.id) { if (guiButton.id == btnBack.id) {
this.mc.displayGuiScreen(new GuiMainMenu()); mc.displayGuiScreen(new GuiMainMenu());
} }
if (guiButton.id == this.btnModeSkin.id || guiButton.id == this.btnModeElytra.id || guiButton.id == this.btnModeSkinnySkin.id) { if (guiButton.id == btnModeSkin.id || guiButton.id == btnModeElytra.id || guiButton.id == btnModeSkinnySkin.id) {
ItemStack stack; ItemStack stack;
if (guiButton.id == this.btnModeSkin.id) { if (guiButton.id == btnModeSkin.id) {
this.thinArmType = false; thinArmType = false;
this.textureType = SKIN; textureType = SKIN;
stack = ItemStack.EMPTY; stack = ItemStack.EMPTY;
} else if (guiButton.id == this.btnModeSkinnySkin.id) { } else if (guiButton.id == btnModeSkinnySkin.id) {
this.thinArmType = true; thinArmType = true;
this.textureType = SKIN; textureType = SKIN;
stack = ItemStack.EMPTY; stack = ItemStack.EMPTY;
} else { } else {
this.textureType = ELYTRA; textureType = ELYTRA;
stack = new ItemStack(Items.ELYTRA); stack = new ItemStack(Items.ELYTRA);
} }
this.btnModeSkin.enabled = thinArmType; btnModeSkin.enabled = thinArmType;
this.btnModeSkinnySkin.enabled = !thinArmType; btnModeSkinnySkin.enabled = !thinArmType;
this.btnModeElytra.enabled = this.textureType == SKIN; btnModeElytra.enabled = textureType == SKIN;
guiButton.enabled = false; guiButton.enabled = false;
// clear currently selected skin // clear currently selected skin
this.selectedSkin = null; selectedSkin = null;
this.localPlayer.releaseTextures(); localPlayer.releaseTextures();
// put on or take off the elytra // put on or take off the elytra
this.localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack); localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
this.remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack); remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
this.localPlayer.setPreviewThinArms(thinArmType); localPlayer.setPreviewThinArms(thinArmType);
this.remotePlayer.setPreviewThinArms(thinArmType); remotePlayer.setPreviewThinArms(thinArmType);
} }
} }
@ -339,17 +337,17 @@ public class GuiSkins extends GuiScreen {
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
if (this.uploadError != null) { if (uploadError != null) {
this.uploadError = null; uploadError = null;
} else { } else {
super.mouseClicked(mouseX, mouseY, button); super.mouseClicked(mouseX, mouseY, button);
int bottom = this.height - 40; int bottom = height - 40;
int mid = this.width / 2; int mid = width / 2;
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > 30 && mouseY < bottom) { if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < width - 30) && mouseY > 30 && mouseY < bottom) {
this.localPlayer.swingArm(EnumHand.MAIN_HAND); localPlayer.swingArm(EnumHand.MAIN_HAND);
this.remotePlayer.swingArm(EnumHand.MAIN_HAND); remotePlayer.swingArm(EnumHand.MAIN_HAND);
} }
} }
@ -364,7 +362,7 @@ public class GuiSkins extends GuiScreen {
@Override @Override
protected void keyTyped(char keyChar, int keyCode) throws IOException { protected void keyTyped(char keyChar, int keyCode) throws IOException {
if (this.openFileThread == null && !this.uploadingSkin) { if (openFileThread == null && !uploadingSkin) {
if (keyCode == Keyboard.KEY_LEFT) { if (keyCode == Keyboard.KEY_LEFT) {
updateCounter -= 5; updateCounter -= 5;
@ -391,7 +389,7 @@ public class GuiSkins extends GuiScreen {
Gui.drawRect(mid + 30, 30, width - 30, bottom, Integer.MIN_VALUE); Gui.drawRect(mid + 30, 30, width - 30, bottom, Integer.MIN_VALUE);
drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff); drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
drawGradientRect(mid + 30, horizon, this.width - 30, bottom, 0x80FFFFFF, 0xffffff); drawGradientRect(mid + 30, horizon, width - 30, bottom, 0x80FFFFFF, 0xffffff);
super.drawScreen(mouseX, mouseY, partialTick); super.drawScreen(mouseX, mouseY, partialTick);
@ -399,9 +397,9 @@ public class GuiSkins extends GuiScreen {
enableClipping(bottom); enableClipping(bottom);
float yPos = height * 0.75F; float yPos = height * 0.75F;
float xPos1 = width * 0.25F; float xPos1 = width / 4;
float xPos2 = width * 0.75F; float xPos2 = width * 0.75F;
float scale = height * 0.25F; float scale = height / 4;
float lookX = mid - mouseX; float lookX = mid - mouseX;
mc.getTextureManager().bindTexture(localPlayer.getSkinTexture()); mc.getTextureManager().bindTexture(localPlayer.getSkinTexture());
@ -414,7 +412,7 @@ public class GuiSkins extends GuiScreen {
disableClipping(); disableClipping();
drawCenteredString(this.fontRenderer, I18n.format("hdskins.manager"), width / 2, 10, 0xffffff); drawCenteredString(fontRenderer, I18n.format("hdskins.manager"), width / 2, 10, 0xffffff);
fontRenderer.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff); fontRenderer.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff);
fontRenderer.drawStringWithShadow(I18n.format("hdskins.server"), width / 2 + 34, 34, 0xffffff); fontRenderer.drawStringWithShadow(I18n.format("hdskins.server"), width / 2 + 34, 34, 0xffffff);
@ -423,67 +421,67 @@ public class GuiSkins extends GuiScreen {
enableBlend(); enableBlend();
depthMask(false); depthMask(false);
int labelwidth = (this.width / 2 - 80) / 2; int labelwidth = (width / 2 - 80) / 2;
if (!this.localPlayer.isUsingLocalTexture()) { if (!localPlayer.isUsingLocalTexture()) {
int opacity = this.fontRenderer.getStringWidth(this.skinMessage) / 2; int opacity = fontRenderer.getStringWidth(skinMessage) / 2;
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000); Gui.drawRect(40, height / 2 - 12, width / 2 - 40, height / 2 + 12, 0xB0000000);
this.fontRenderer.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff); fontRenderer.drawStringWithShadow(skinMessage, (int) (xPos1 - opacity), height / 2 - 4, 0xffffff);
} }
if (this.btnModeSkin.isMouseOver() || this.btnModeElytra.isMouseOver() || this.btnModeSkinnySkin.isMouseOver()) { if (btnModeSkin.isMouseOver() || btnModeElytra.isMouseOver() || btnModeSkinnySkin.isMouseOver()) {
int y = Math.max(mouseY, 16); int y = Math.max(mouseY, 16);
String text; String text;
if (this.btnModeSkin.isMouseOver()) { if (btnModeSkin.isMouseOver()) {
text = "hdskins.mode.skin"; text = "hdskins.mode.skin";
} else if (this.btnModeSkinnySkin.isMouseOver()) { } else if (btnModeSkinnySkin.isMouseOver()) {
text = "hdskins.mode.skinny"; text = "hdskins.mode.skinny";
} else { } else {
text = "hdskins.mode.elytra"; text = "hdskins.mode.elytra";
} }
this.drawHoveringText(I18n.format(text), mouseX, y); drawHoveringText(I18n.format(text), mouseX, y);
} }
if (this.btnAbout.isMouseOver()) { if (btnAbout.isMouseOver()) {
SkinServer gateway = HDSkinManager.INSTANCE.getGatewayServer(); SkinServer gateway = HDSkinManager.INSTANCE.getGatewayServer();
this.drawHoveringText(Splitter.on("\r\n").splitToList(gateway.toString()), mouseX, mouseY); drawHoveringText(Splitter.on("\r\n").splitToList(gateway.toString()), mouseX, mouseY);
} }
if (this.fetchingSkin) { if (fetchingSkin) {
int lineHeight = throttledByMojang ? 16 : 12; int lineHeight = throttledByMojang ? 16 : 12;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - lineHeight, this.width - 40, this.height / 2 + lineHeight, 0xB0000000); Gui.drawRect((int) (xPos2 - labelwidth), height / 2 - lineHeight, width - 40, height / 2 + lineHeight, 0xB0000000);
if (this.throttledByMojang) { if (throttledByMojang) {
this.drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang"), (int)xPos2, height / 2 - 10, 0xffffff); drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang"), (int)xPos2, height / 2 - 10, 0xffffff);
this.drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang.wait"), (int)xPos2, height / 2 + 2, 0xffffff); drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang.wait"), (int)xPos2, height / 2 + 2, 0xffffff);
} else { } else {
this.drawCenteredString(fontRenderer, I18n.format("hdskins.fetch"), (int)xPos2, height / 2 - 4, 0xffffff); drawCenteredString(fontRenderer, I18n.format("hdskins.fetch"), (int)xPos2, height / 2 - 4, 0xffffff);
} }
} }
if (this.uploadingSkin || this.uploadOpacity > 0.0F) { if (uploadingSkin || uploadOpacity > 0) {
if (!this.uploadingSkin) { if (!uploadingSkin) {
this.uploadOpacity -= deltaTime * 0.05F; uploadOpacity -= deltaTime * 0.05F;
} else if (this.uploadOpacity < 1.0F) { } else if (uploadOpacity < 1) {
this.uploadOpacity += deltaTime * 0.1F; uploadOpacity += deltaTime * 0.1F;
} }
if (this.uploadOpacity > 1.0F) { if (uploadOpacity > 1) {
this.uploadOpacity = 1.0F; uploadOpacity = 1;
} }
int opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255; int opacity = Math.min(180, (int) (uploadOpacity * 180)) & 255;
if (this.uploadOpacity > 0.0F) { if (uploadOpacity > 0) {
Gui.drawRect(0, 0, this.width, this.height, opacity << 24); Gui.drawRect(0, 0, width, height, opacity << 24);
if (this.uploadingSkin) { if (uploadingSkin) {
this.drawCenteredString(this.fontRenderer, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff); drawCenteredString(fontRenderer, skinUploadMessage, width / 2, height / 2, opacity << 24 | 0xffffff);
} }
} }
} }
if (this.uploadError != null) { if (uploadError != null) {
Gui.drawRect(0, 0, this.width, this.height, 0xB0000000); Gui.drawRect(0, 0, width, height, 0xB0000000);
this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55); drawCenteredString(fontRenderer, I18n.format("hdskins.failed"), width / 2, height / 2 - 10, 0xFFFFFF55);
this.drawCenteredString(this.fontRenderer, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555); drawCenteredString(fontRenderer, uploadError, width / 2, height / 2 + 2, 0xFFFF5555);
} }
depthMask(true); depthMask(true);
@ -494,28 +492,26 @@ public class GuiSkins extends GuiScreen {
float partialTick) { float partialTick) {
enableColorMaterial(); enableColorMaterial();
pushMatrix(); pushMatrix();
translate(xPosition, yPosition, 300.0F); translate(xPosition, yPosition, 300);
scale(-scale, scale, scale); scale(-scale, scale, scale);
rotate(180.0F, 0.0F, 0.0F, 1.0F); rotate(180, 0, 0, 1);
rotate(135.0F, 0.0F, 1.0F, 0.0F); rotate(135, 0, 1, 0);
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
rotate(-135.0F, 0.0F, 1.0F, 0.0F); rotate(-135, 0, 1, 0);
rotate(15.0F, 1.0F, 0.0F, 0.0F); rotate(15, 1, 0, 0);
float rot = ((updateCounter + partialTick) * 2.5F) % 360; rotate(((updateCounter + partialTick) * 2.5F) % 360, 0, 1, 0);
rotate(rot, 0, 1, 0);
thePlayer.rotationYawHead = ((float) Math.atan(mouseX / 20)) * 30; thePlayer.rotationYawHead = ((float) Math.atan(mouseX / 20)) * 30;
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40)) * 20; thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40)) * 20;
translate(0.0D, thePlayer.getYOffset(), 0.0D); translate(0, thePlayer.getYOffset(), 0);
RenderManager rm = Minecraft.getMinecraft().getRenderManager(); RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.playerViewY = 180.0F; rm.playerViewY = 180;
rm.renderEntity(thePlayer, 0, 0, 0, 0, 1, false); rm.renderEntity(thePlayer, 0, 0, 0, 0, 1, false);
popMatrix(); popMatrix();
@ -524,18 +520,18 @@ public class GuiSkins extends GuiScreen {
} }
private void enableClipping(int yBottom) { private void enableClipping(int yBottom) {
if (this.doubleBuffer == null) { if (doubleBuffer == null) {
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer(); doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
} }
this.doubleBuffer.clear(); doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-30)).flip(); doubleBuffer.put(0).put(1).put(0).put(-30).flip();
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, this.doubleBuffer); GL11.glClipPlane(GL11.GL_CLIP_PLANE0, doubleBuffer);
this.doubleBuffer.clear(); doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip(); doubleBuffer.put(0).put(-1).put(0).put(yBottom).flip();
GL11.glClipPlane(GL11.GL_CLIP_PLANE1, this.doubleBuffer); GL11.glClipPlane(GL11.GL_CLIP_PLANE1, doubleBuffer);
GL11.glEnable(GL11.GL_CLIP_PLANE0); GL11.glEnable(GL11.GL_CLIP_PLANE0);
GL11.glEnable(GL11.GL_CLIP_PLANE1); GL11.glEnable(GL11.GL_CLIP_PLANE1);
} }
@ -560,28 +556,28 @@ public class GuiSkins extends GuiScreen {
} }
private Map<String, String> getMetadata() { private Map<String, String> getMetadata() {
return ImmutableMap.of("model", this.thinArmType ? "slim" : "default"); return ImmutableMap.of("model", thinArmType ? "slim" : "default");
} }
private void setUploadError(@Nullable String error) { private void setUploadError(@Nullable String error) {
this.uploadError = error; uploadError = error;
this.btnUpload.enabled = true; btnUpload.enabled = true;
} }
private Void onFailure(Throwable t) { private Void onFailure(Throwable t) {
t = Throwables.getRootCause(t); t = Throwables.getRootCause(t);
LogManager.getLogger().warn("Upload failed", t); LogManager.getLogger().warn("Upload failed", t);
this.setUploadError(t.toString()); setUploadError(t.toString());
this.uploadingSkin = false; uploadingSkin = false;
return null; return null;
} }
private void onUploadComplete(SkinUploadResponse response) { private void onUploadComplete(SkinUploadResponse response) {
LiteLoaderLogger.info("Upload completed with: %s", response); LiteLoaderLogger.info("Upload completed with: %s", response);
this.uploadingSkin = false; uploadingSkin = false;
this.pendingRemoteSkinRefresh = true; pendingRemoteSkinRefresh = true;
} }
static { static {

View file

@ -31,7 +31,7 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
private static final ModelPlayer THIN = new ModelPlayer(0, true); private static final ModelPlayer THIN = new ModelPlayer(0, true);
public RenderPlayerModel(RenderManager renderer) { public RenderPlayerModel(RenderManager renderer) {
super(renderer, FAT, 0.0F); super(renderer, FAT, 0);
this.addLayer(this.getElytraLayer()); this.addLayer(this.getElytraLayer());
} }
@ -44,14 +44,14 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA) { if (itemstack.getItem() == Items.ELYTRA) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1, 1, 1, 1);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
bindTexture(entity.getElytraTexture()); bindTexture(entity.getElytraTexture());
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.125F); GlStateManager.translate(0, 0, 0.125F);
modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
modelElytra.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); modelElytra.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
@ -69,18 +69,18 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
} }
@Override @Override
protected ResourceLocation getEntityTexture(M var1) { protected ResourceLocation getEntityTexture(M entity) {
return var1.getSkinTexture(); return entity.getSkinTexture();
} }
@Override @Override
protected boolean canRenderName(M targetEntity) { protected boolean canRenderName(M entity) {
return Minecraft.getMinecraft().player != null && super.canRenderName(targetEntity); return Minecraft.getMinecraft().player != null && super.canRenderName(entity);
} }
@Override @Override
protected boolean setBrightness(M entitylivingbaseIn, float partialTicks, boolean p_177092_3_) { protected boolean setBrightness(M entity, float partialTicks, boolean combineTextures) {
return Minecraft.getMinecraft().world != null && super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_); return Minecraft.getMinecraft().world != null && super.setBrightness(entity, partialTicks, combineTextures);
} }
public ModelPlayer getEntityModel(M entity) { public ModelPlayer getEntityModel(M entity) {
@ -88,8 +88,8 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
} }
@Override @Override
public void doRender(M par1Entity, double par2, double par4, double par6, float par8, float par9) { public void doRender(M entity, double x, double y, double z, float entityYaw, float partialTicks) {
ModelPlayer player = this.getEntityModel(par1Entity); ModelPlayer player = this.getEntityModel(entity);
this.mainModel = player; this.mainModel = player;
Set<EnumPlayerModelParts> parts = Minecraft.getMinecraft().gameSettings.getModelParts(); Set<EnumPlayerModelParts> parts = Minecraft.getMinecraft().gameSettings.getModelParts();
@ -104,22 +104,22 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
player.rightArmPose = ArmPose.EMPTY; player.rightArmPose = ArmPose.EMPTY;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
super.doRender(par1Entity, par2, par4, par6, par8, par9); super.doRender(entity, x, y, z, entityYaw, partialTicks);
popAttrib(); popAttrib();
pushMatrix(); pushMatrix();
scale(1.0F, -1.0F, 1.0F); scale(1, -1, 1);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
super.doRender(par1Entity, par2, par4, par6, par8, par9); super.doRender(entity, x, y, z, entityYaw, partialTicks);
popAttrib(); popAttrib();
popMatrix(); popMatrix();
} }
@Override @Override
protected void preRenderCallback(M par1EntityLiving, float par2) { protected void preRenderCallback(M entity, float partialTicks) {
this.renderCloak(par1EntityLiving, par2); renderCloak(entity, partialTicks);
} }
protected void renderCloak(M entity, float par2) { protected void renderCloak(M entity, float partialTicks) {
super.preRenderCallback(entity, par2); super.preRenderCallback(entity, partialTicks);
} }
} }

View file

@ -14,15 +14,13 @@ import java.awt.image.BufferedImage;
@Mixin(ImageBufferDownload.class) @Mixin(ImageBufferDownload.class)
public abstract class MixinImageBufferDownload implements IImageBuffer { public abstract class MixinImageBufferDownload implements IImageBuffer {
@Inject( @Inject(method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
at = @At("RETURN"), at = @At("RETURN"),
cancellable = true) cancellable = true)
private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) { private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) {
// convert skins from mojang server // convert skins from mojang server
if (image.getHeight() == 32) {
BufferedImage image2 = ci.getReturnValue(); BufferedImage image2 = ci.getReturnValue();
boolean isLegacy = image.getHeight() == 32;
if (isLegacy) {
Graphics graphics = image2.getGraphics(); Graphics graphics = image2.getGraphics();
HDSkinManager.INSTANCE.convertSkin(image2, graphics); HDSkinManager.INSTANCE.convertSkin(image2, graphics);
graphics.dispose(); graphics.dispose();

View file

@ -20,24 +20,21 @@ public abstract class MixinPlayerInfo {
@Shadow @Shadow
public abstract GameProfile getGameProfile(); public abstract GameProfile getGameProfile();
@Inject( @Inject(method = "getLocationSkin",
method = "getLocationSkin",
cancellable = true, cancellable = true,
at = @At("RETURN")) at = @At("RETURN"))
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) { private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
getTextureLocation(ci, Type.SKIN); getTextureLocation(ci, Type.SKIN);
} }
@Inject( @Inject(method = "getLocationCape",
method = "getLocationCape",
cancellable = true, cancellable = true,
at = @At("RETURN")) at = @At("RETURN"))
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> ci) { private void getLocationCape(CallbackInfoReturnable<ResourceLocation> ci) {
getTextureLocation(ci, Type.CAPE); getTextureLocation(ci, Type.CAPE);
} }
@Inject( @Inject(method = "getLocationElytra",
method = "getLocationElytra",
cancellable = true, cancellable = true,
at = @At("RETURN")) at = @At("RETURN"))
private void getLocationElytra(CallbackInfoReturnable<ResourceLocation> ci) { private void getLocationElytra(CallbackInfoReturnable<ResourceLocation> ci) {
@ -49,8 +46,7 @@ public abstract class MixinPlayerInfo {
texture.ifPresent(ci::setReturnValue); texture.ifPresent(ci::setReturnValue);
} }
@Inject( @Inject(method = "getSkinType",
method = "getSkinType",
cancellable = true, cancellable = true,
at = @At("RETURN")) at = @At("RETURN"))
private void getSkinType(CallbackInfoReturnable<String> ci) { private void getSkinType(CallbackInfoReturnable<String> ci) {

View file

@ -46,7 +46,7 @@ public class LegacySkinServer implements SkinServer {
@Override @Override
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) { public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) {
if (Strings.isNullOrEmpty(this.gateway)) { if (Strings.isNullOrEmpty(gateway)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = new EnumMap<>(MinecraftProfileTexture.Type.class); Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = new EnumMap<>(MinecraftProfileTexture.Type.class);
@ -61,7 +61,7 @@ public class LegacySkinServer implements SkinServer {
ImmutableMap.Builder<MinecraftProfileTexture.Type, MinecraftProfileTexture> builder = ImmutableMap.builder(); ImmutableMap.Builder<MinecraftProfileTexture.Type, MinecraftProfileTexture> builder = ImmutableMap.builder();
for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) { for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) {
String url = getPath(this.address, type, profile); String url = getPath(address, type, profile);
try { try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
if (urlConnection.getResponseCode() / 100 != 2) { if (urlConnection.getResponseCode() / 100 != 2) {
@ -76,7 +76,7 @@ public class LegacySkinServer implements SkinServer {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = builder.build(); Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = builder.build();
if (map.isEmpty()) { if (map.isEmpty()) {
logger.debug("No textures found for {} at {}", profile, this.address); logger.debug("No textures found for {} at {}", profile, address);
return Optional.empty(); return Optional.empty();
} }
@ -86,7 +86,7 @@ public class LegacySkinServer implements SkinServer {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata) { public CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata) {
if (Strings.isNullOrEmpty(this.gateway)) { if (Strings.isNullOrEmpty(gateway)) {
return CallableFutures.failedFuture(new NullPointerException("gateway url is blank")); return CallableFutures.failedFuture(new NullPointerException("gateway url is blank"));
} }
@ -94,7 +94,7 @@ public class LegacySkinServer implements SkinServer {
SkinServer.verifyServerConnection(session, SERVER_ID); SkinServer.verifyServerConnection(session, SERVER_ID);
String model = metadata.getOrDefault("model", "default"); String model = metadata.getOrDefault("model", "default");
Map<String, ?> data = image == null ? getClearData(session, type) : getUploadData(session, type, model, image); Map<String, ?> data = image == null ? getClearData(session, type) : getUploadData(session, type, model, image);
ThreadMultipartPostUpload upload = new ThreadMultipartPostUpload(this.gateway, data); ThreadMultipartPostUpload upload = new ThreadMultipartPostUpload(gateway, data);
String response = upload.uploadMultipart(); String response = upload.uploadMultipart();
if (response.startsWith("ERROR: ")) { if (response.startsWith("ERROR: ")) {
response = response.substring(7); response = response.substring(7);
@ -132,8 +132,8 @@ public class LegacySkinServer implements SkinServer {
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address) .append("address", address)
.append("gateway", this.gateway) .append("gateway", gateway)
.build(); .build();
} }
} }

View file

@ -54,7 +54,6 @@ public class ValhallaSkinServer implements SkinServer {
@Override @Override
public Optional<MinecraftTexturesPayload> loadProfileData(GameProfile profile) { public Optional<MinecraftTexturesPayload> loadProfileData(GameProfile profile) {
try (CloseableHttpClient client = HttpClients.createSystem(); try (CloseableHttpClient client = HttpClients.createSystem();
CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) { CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) {
@ -65,6 +64,7 @@ public class ValhallaSkinServer implements SkinServer {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return Optional.empty(); return Optional.empty();
} }
@ -128,7 +128,6 @@ public class ValhallaSkinServer implements SkinServer {
} }
private SkinUploadResponse uploadUrl(CloseableHttpClient client, URI uri, GameProfile profile, MinecraftProfileTexture.Type type, Map<String, String> metadata) throws IOException { private SkinUploadResponse uploadUrl(CloseableHttpClient client, URI uri, GameProfile profile, MinecraftProfileTexture.Type type, Map<String, String> metadata) throws IOException {
return upload(client, RequestBuilder.post() return upload(client, RequestBuilder.post()
.setUri(buildUserTextureUri(profile, type)) .setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken) .addHeader(HttpHeaders.AUTHORIZATION, this.accessToken)
@ -147,9 +146,10 @@ public class ValhallaSkinServer implements SkinServer {
private void authorize(CloseableHttpClient client, Session session) throws IOException, AuthenticationException { private void authorize(CloseableHttpClient client, Session session) throws IOException, AuthenticationException {
if (this.accessToken != null) { if (accessToken != null) {
return; return;
} }
GameProfile profile = session.getProfile(); GameProfile profile = session.getProfile();
String token = session.getToken(); String token = session.getToken();
AuthHandshake handshake = authHandshake(client, profile.getName()); AuthHandshake handshake = authHandshake(client, profile.getName());
@ -165,11 +165,13 @@ public class ValhallaSkinServer implements SkinServer {
if (!response.userId.equals(profile.getId())) { if (!response.userId.equals(profile.getId())) {
throw new IOException("UUID mismatch!"); // probably won't ever throw throw new IOException("UUID mismatch!"); // probably won't ever throw
} }
this.accessToken = response.accessToken;
accessToken = response.accessToken;
} }
private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException { private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException {
String type = resp.getEntity().getContentType().getValue(); String type = resp.getEntity().getContentType().getValue();
if (!"application/json".equals(type)) { if (!"application/json".equals(type)) {
try { try {
throw new IOException("Server returned a non-json response!"); throw new IOException("Server returned a non-json response!");
@ -177,11 +179,13 @@ public class ValhallaSkinServer implements SkinServer {
EntityUtils.consumeQuietly(resp.getEntity()); EntityUtils.consumeQuietly(resp.getEntity());
} }
} }
try (Reader r = new InputStreamReader(resp.getEntity().getContent())) { try (Reader r = new InputStreamReader(resp.getEntity().getContent())) {
if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
// TODO specific error handling // TODO specific error handling
throw new IOException(gson.fromJson(r, JsonObject.class).get("message").getAsString()); throw new IOException(gson.fromJson(r, JsonObject.class).get("message").getAsString());
} }
return gson.fromJson(r, cl); return gson.fromJson(r, cl);
} }
} }
@ -208,26 +212,26 @@ public class ValhallaSkinServer implements SkinServer {
private URI buildUserTextureUri(GameProfile profile, MinecraftProfileTexture.Type textureType) { private URI buildUserTextureUri(GameProfile profile, MinecraftProfileTexture.Type textureType) {
String user = UUIDTypeAdapter.fromUUID(profile.getId()); String user = UUIDTypeAdapter.fromUUID(profile.getId());
String skinType = textureType.name().toLowerCase(Locale.US); String skinType = textureType.name().toLowerCase(Locale.US);
return URI.create(String.format("%s/user/%s/%s", this.address, user, skinType)); return URI.create(String.format("%s/user/%s/%s", address, user, skinType));
} }
private URI getTexturesURI(GameProfile profile) { private URI getTexturesURI(GameProfile profile) {
Preconditions.checkNotNull(profile.getId(), "profile id required for skins"); Preconditions.checkNotNull(profile.getId(), "profile id required for skins");
return URI.create(String.format("%s/user/%s", this.address, UUIDTypeAdapter.fromUUID(profile.getId()))); return URI.create(String.format("%s/user/%s", address, UUIDTypeAdapter.fromUUID(profile.getId())));
} }
private URI getHandshakeURI() { private URI getHandshakeURI() {
return URI.create(String.format("%s/auth/handshake", this.address)); return URI.create(String.format("%s/auth/handshake", address));
} }
private URI getResponseURI() { private URI getResponseURI() {
return URI.create(String.format("%s/auth/response", this.address)); return URI.create(String.format("%s/auth/response", address));
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address) .append("address", address)
.toString(); .toString();
} }

View file

@ -21,12 +21,9 @@ public abstract class ThreadOpenFile extends Thread {
*/ */
protected final IOpenFileCallback parentScreen; protected final IOpenFileCallback parentScreen;
private JFileChooser fileDialog;
private static String lastChosenFile = null; private static String lastChosenFile = null;
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException {
throws IllegalStateException {
if (minecraft.isFullScreen()) { if (minecraft.isFullScreen()) {
throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!"); throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!");
} }
@ -37,13 +34,13 @@ public abstract class ThreadOpenFile extends Thread {
@Override @Override
public void run() { public void run() {
fileDialog = new JFileChooser(); JFileChooser fileDialog = new JFileChooser();
fileDialog.setDialogTitle(this.dialogTitle); fileDialog.setDialogTitle(dialogTitle);
if (lastChosenFile != null) { if (lastChosenFile != null) {
fileDialog.setSelectedFile(new File(lastChosenFile)); fileDialog.setSelectedFile(new File(lastChosenFile));
} }
fileDialog.setFileFilter(this.getFileFilter()); fileDialog.setFileFilter(getFileFilter());
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext()); int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
@ -53,7 +50,7 @@ public abstract class ThreadOpenFile extends Thread {
lastChosenFile = f.getAbsolutePath(); lastChosenFile = f.getAbsolutePath();
} }
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult); parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
} }
/** /**