From 0ef8f810d7390f0460e08686b6804f001b9b9d5d Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 23 Aug 2018 01:35:39 +0200 Subject: [PATCH] Properly detect when a server's texture is in use --- .../java/com/voxelmodpack/hdskins/LocalTexture.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java b/src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java index 4bbb69ee..83d72b00 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java @@ -27,6 +27,8 @@ public class LocalTexture { private final Type type; + private boolean remoteLoaded = false; + public LocalTexture(GameProfile profile, Type type, IBlankSkinSupplier blank) { this.blank = blank; this.type = type; @@ -36,6 +38,7 @@ public class LocalTexture { remoteResource = new ResourceLocation(file); textureManager.deleteTexture(remoteResource); + reset(); } @@ -60,7 +63,7 @@ public class LocalTexture { } public boolean hasRemoteTexture() { - return hasRemote() && remote.isTextureUploaded(); + return uploadComplete() && remoteLoaded; } public boolean usingLocal() { @@ -78,7 +81,12 @@ public class LocalTexture { public void setRemote(PreviewTextureManager ptm, SkinAvailableCallback callback) { 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) { @@ -100,6 +108,7 @@ public class LocalTexture { } private void clearRemote() { + remoteLoaded = false; if (hasRemote()) { remote = null; textureManager.deleteTexture(remoteResource);