Skip to content

Commit 1bbc69c

Browse files
committed
Fix virtual asset mapping
1 parent 183f5e1 commit 1bbc69c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/main/java/org/mcphackers/launchwrapper/protocol/AssetRequests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,11 @@ private void mapAsset(File assetsDir, String key, JSONObject entry, boolean virt
9393
}
9494
AssetObject obj = new AssetObject(object, key, hash, size, url);
9595
mappedAssets.put(key, obj);
96+
getAssetFile(obj);
9697

9798
// Emulate launcher's handling of virtual asset index object mapping. (Copy from {assetsDir}/objects/{hash} to {assetsDir}/{name})
9899
if (virtual) {
99-
File mappedObject = getAssetFile(key);
100-
if (mappedObject == null) {
101-
return;
102-
}
100+
File mappedObject = new File(assetsDir, key);
103101
if (!mappedObject.exists() || mappedObject.length() != size || VERIFY_HASH && !hash.equals(Util.getSHA1(new FileInputStream(mappedObject)))) {
104102
mappedObject.getParentFile().mkdirs();
105103
Util.copyStream(new FileInputStream(object), new FileOutputStream(mappedObject));
@@ -115,8 +113,7 @@ public Collection<AssetObject> list() {
115113
return mappedAssets.values();
116114
}
117115

118-
public File getAssetFile(String key) throws IOException {
119-
AssetObject object = get(key);
116+
public File getAssetFile(AssetObject object) throws IOException {
120117
if (object != null) {
121118
if (object.url != null) { // url is only set when the resource is requested to be re-downloaded
122119
Launch.LOGGER.log("Downloading resource: " + object.path);

src/main/java/org/mcphackers/launchwrapper/protocol/AssetURLConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public InputStream getInputStream() throws IOException {
6060
boolean xml = url.getPath().startsWith("/MinecraftResources/");
6161
return getIndex(xml);
6262
}
63-
File file = assets.getAssetFile(key);
63+
File file = assets.getAssetFile(assets.get(key));
6464
if (file == null) {
6565
throw new FileNotFoundException();
6666
}

0 commit comments

Comments
 (0)