Properly detect when a server's texture is in use

This commit is contained in:
Sollace 2018-08-23 01:35:39 +02:00
parent 68fcde4c2c
commit 0ef8f810d7

View file

@ -27,6 +27,8 @@ public class LocalTexture {
private final Type type; private final Type type;
private boolean remoteLoaded = false;
public LocalTexture(GameProfile profile, Type type, IBlankSkinSupplier blank) { public LocalTexture(GameProfile profile, Type type, IBlankSkinSupplier blank) {
this.blank = blank; this.blank = blank;
this.type = type; this.type = type;
@ -36,6 +38,7 @@ public class LocalTexture {
remoteResource = new ResourceLocation(file); remoteResource = new ResourceLocation(file);
textureManager.deleteTexture(remoteResource); textureManager.deleteTexture(remoteResource);
reset(); reset();
} }
@ -60,7 +63,7 @@ public class LocalTexture {
} }
public boolean hasRemoteTexture() { public boolean hasRemoteTexture() {
return hasRemote() && remote.isTextureUploaded(); return uploadComplete() && remoteLoaded;
} }
public boolean usingLocal() { public boolean usingLocal() {
@ -78,7 +81,12 @@ public class LocalTexture {
public void setRemote(PreviewTextureManager ptm, SkinAvailableCallback callback) { public void setRemote(PreviewTextureManager ptm, SkinAvailableCallback callback) {
clearRemote(); clearRemote();
remote = ptm.getPreviewTexture(remoteResource, type, blank.getBlankSkin(type), callback); remote = ptm.getPreviewTexture(remoteResource, type, blank.getBlankSkin(type), (type, location, profileTexture) -> {
if (callback != null) {
callback.skinAvailable(type, location, profileTexture);
}
remoteLoaded = true;
});
} }
public void setLocal(File file) { public void setLocal(File file) {
@ -100,6 +108,7 @@ public class LocalTexture {
} }
private void clearRemote() { private void clearRemote() {
remoteLoaded = false;
if (hasRemote()) { if (hasRemote()) {
remote = null; remote = null;
textureManager.deleteTexture(remoteResource); textureManager.deleteTexture(remoteResource);