mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 20:47:59 +01:00
Properly detect when a server's texture is in use
This commit is contained in:
parent
68fcde4c2c
commit
0ef8f810d7
1 changed files with 11 additions and 2 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue