25
25
import java .io .FileInputStream ;
26
26
import java .io .IOException ;
27
27
import java .io .InputStream ;
28
+ import java .nio .file .Path ;
28
29
import java .util .HashMap ;
29
30
import java .util .Map ;
30
31
import java .util .concurrent .CompletableFuture ;
46
47
public class ServerTexture extends SimpleTexture implements Tickable {
47
48
public static final Map <String , ServerTexture > WAITING_TEXTURES = new HashMap <>();
48
49
private static final Logger LOGGER = LogUtils .getLogger ();
50
+ public static final String LOCAL_TEXTURE_SOURCE = ".local" ;
49
51
private final File file ;
50
52
private final String destPath ;
51
53
private final String fileName ;
@@ -56,15 +58,21 @@ public class ServerTexture extends SimpleTexture implements Tickable {
56
58
private boolean uploaded ;
57
59
private long timeSinceLastReference ;
58
60
private boolean isClosed ;
61
+ boolean hasLocalSource ;
59
62
60
63
public ServerTexture (String destPath , String fileName , ResourceLocation fallback , @ Nullable Runnable callback ) {
61
64
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 ();
63
69
this .destPath = destPath ;
64
70
this .fileName = fileName ;
65
71
this .onDownloaded = callback ;
66
72
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
+ }
68
76
}
69
77
70
78
private void loadCallback (NativeImage image ) {
0 commit comments