Skip to content

Commit e898639

Browse files
Update ServerTexture.java
1 parent 1a2e73b commit e898639

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/net/frozenblock/lib/image_transfer/client/ServerTexture.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.FileInputStream;
2626
import java.io.IOException;
2727
import java.io.InputStream;
28+
import java.nio.file.Path;
2829
import java.util.HashMap;
2930
import java.util.Map;
3031
import java.util.concurrent.CompletableFuture;
@@ -46,6 +47,7 @@
4647
public class ServerTexture extends SimpleTexture implements Tickable {
4748
public static final Map<String, ServerTexture> WAITING_TEXTURES = new HashMap<>();
4849
private static final Logger LOGGER = LogUtils.getLogger();
50+
public static final String LOCAL_TEXTURE_SOURCE = ".local";
4951
private final File file;
5052
private final String destPath;
5153
private final String fileName;
@@ -56,15 +58,21 @@ public class ServerTexture extends SimpleTexture implements Tickable {
5658
private boolean uploaded;
5759
private long timeSinceLastReference;
5860
private boolean isClosed;
61+
boolean hasLocalSource;
5962

6063
public ServerTexture(String destPath, String fileName, ResourceLocation fallback, @Nullable Runnable callback) {
6164
super(fallback);
62-
this.file = Minecraft.getInstance().gameDirectory.toPath().resolve(destPath).resolve(fileName).toFile();
65+
Path path = Minecraft.getInstance().gameDirectory.toPath().resolve(destPath);
66+
File possibleLocalFile = path.resolve(LOCAL_TEXTURE_SOURCE).resolve(fileName).toFile();
67+
this.hasLocalSource = possibleLocalFile.exists();
68+
this.file = this.hasLocalSource ? possibleLocalFile : path.resolve(fileName).toFile();
6369
this.destPath = destPath;
6470
this.fileName = fileName;
6571
this.onDownloaded = callback;
6672
this.timeSinceLastReference = System.currentTimeMillis();
67-
WAITING_TEXTURES.put(this.destPath + "/" + this.fileName, this);
73+
if (!this.hasLocalSource) {
74+
WAITING_TEXTURES.put(this.destPath + "/" + this.fileName, this);
75+
}
6876
}
6977

7078
private void loadCallback(NativeImage image) {

0 commit comments

Comments
 (0)