use one asset directory
parent
10f134fcc2
commit
1691c8c2d8
|
@ -78,25 +78,12 @@ public class MinecraftLibraryProvider {
|
||||||
MinecraftVersionInfo.AssetIndex assetIndex = versionInfo.assetIndex;
|
MinecraftVersionInfo.AssetIndex assetIndex = versionInfo.assetIndex;
|
||||||
|
|
||||||
// get existing cache files
|
// get existing cache files
|
||||||
project.getLogger().lifecycle(":checking for existing asset files");
|
File assets = new File(extension.getUserCache(), "assets");
|
||||||
Multimap<String, File> assetFilenameToFile = HashMultimap.create();
|
|
||||||
for (File assetDir : Objects.requireNonNull(extension.getUserCache().listFiles((f) -> f.isDirectory() && f.getName().startsWith("assets-")))) {
|
|
||||||
File objectsDir = new File(assetDir, "objects");
|
|
||||||
if (objectsDir.exists() && objectsDir.isDirectory()) {
|
|
||||||
for (File subDir : Objects.requireNonNull(objectsDir.listFiles(File::isDirectory))) {
|
|
||||||
for (File subFile : Objects.requireNonNull(subDir.listFiles(File::isFile))) {
|
|
||||||
assetFilenameToFile.put("objects" + File.separator + subDir.getName() + File.separator + subFile.getName(), subFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File assets = new File(extension.getUserCache(), "assets-" + minecraftProvider.minecraftVersion);
|
|
||||||
if (!assets.exists()) {
|
if (!assets.exists()) {
|
||||||
assets.mkdirs();
|
assets.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
File assetsInfo = new File(assets, "indexes" + File.separator + assetIndex.id + ".json");
|
File assetsInfo = new File(assets, "indexes" + File.separator + assetIndex.getFabricId(minecraftProvider.minecraftVersion) + ".json");
|
||||||
if (!assetsInfo.exists() || !Checksum.equals(assetsInfo, assetIndex.sha1)) {
|
if (!assetsInfo.exists() || !Checksum.equals(assetsInfo, assetIndex.sha1)) {
|
||||||
project.getLogger().lifecycle(":downloading asset index");
|
project.getLogger().lifecycle(":downloading asset index");
|
||||||
FileUtils.copyURLToFile(new URL(assetIndex.url), assetsInfo);
|
FileUtils.copyURLToFile(new URL(assetIndex.url), assetsInfo);
|
||||||
|
@ -116,15 +103,6 @@ public class MinecraftLibraryProvider {
|
||||||
String sha1 = object.getHash();
|
String sha1 = object.getHash();
|
||||||
String filename = "objects" + File.separator + sha1.substring(0, 2) + File.separator + sha1;
|
String filename = "objects" + File.separator + sha1.substring(0, 2) + File.separator + sha1;
|
||||||
File file = new File(assets, filename);
|
File file = new File(assets, filename);
|
||||||
if (!file.exists() && assetFilenameToFile.containsKey(filename)) {
|
|
||||||
project.getLogger().debug(":copying asset " + entry.getKey());
|
|
||||||
for (File srcFile : assetFilenameToFile.get(filename)) {
|
|
||||||
if (Checksum.equals(srcFile, sha1)) {
|
|
||||||
FileUtils.copyFile(srcFile, file);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.exists() || !Checksum.equals(file, sha1)) {
|
if (!file.exists() || !Checksum.equals(file, sha1)) {
|
||||||
project.getLogger().debug(":downloading asset " + entry.getKey());
|
project.getLogger().debug(":downloading asset " + entry.getKey());
|
||||||
|
@ -138,6 +116,7 @@ public class MinecraftLibraryProvider {
|
||||||
progressLogger.progress(assetName + " - " + position + "/" + totalSize + " (" + (int) ((position / (double) totalSize) * 100) + "%) assets downloaded");
|
progressLogger.progress(assetName + " - " + position + "/" + totalSize + " (" + (int) ((position / (double) totalSize) * 100) + "%) assets downloaded");
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
|
|
||||||
progressLogger.completed();
|
progressLogger.completed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class PomfProvider {
|
||||||
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(MAPPINGS_TINY_GZ));
|
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(MAPPINGS_TINY_GZ));
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(MAPPINGS_TINY);
|
FileOutputStream fileOutputStream = new FileOutputStream(MAPPINGS_TINY);
|
||||||
int length;
|
int length;
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[4096];
|
||||||
while ((length = gzipInputStream.read(buffer)) > 0) {
|
while ((length = gzipInputStream.read(buffer)) > 0) {
|
||||||
fileOutputStream.write(buffer, 0, length);
|
fileOutputStream.write(buffer, 0, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class RunClientTask extends JavaExec {
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath(libs);
|
classpath(libs);
|
||||||
args("--tweakClass", Constants.FABRIC_CLIENT_TWEAKER, "--assetIndex", minecraftVersionInfo.assetIndex.id, "--assetsDir", new File(extension.getUserCache(), "assets-" + extension.getMinecraftProvider().minecraftVersion).getAbsolutePath(), "--fabricMappingFile", extension.getMinecraftProvider().pomfProvider.MAPPINGS_TINY.getAbsolutePath());
|
args("--tweakClass", Constants.FABRIC_CLIENT_TWEAKER, "--assetIndex", minecraftVersionInfo.assetIndex.getFabricId(extension.getMinecraftProvider().minecraftVersion), "--assetsDir", new File(extension.getUserCache(), "assets").getAbsolutePath(), "--fabricMappingFile", extension.getMinecraftProvider().pomfProvider.MAPPINGS_TINY.getAbsolutePath());
|
||||||
|
|
||||||
setWorkingDir(new File(getProject().getRootDir(), "run"));
|
setWorkingDir(new File(getProject().getRootDir(), "run"));
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class IdeaRunConfig {
|
||||||
ideaClient.configName = "Minecraft Client";
|
ideaClient.configName = "Minecraft Client";
|
||||||
ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
||||||
ideaClient.vmArgs = "-Dfabric.development=true";
|
ideaClient.vmArgs = "-Dfabric.development=true";
|
||||||
ideaClient.programArgs = "--tweakClass " + Constants.FABRIC_CLIENT_TWEAKER + " --assetIndex " + minecraftVersionInfo.assetIndex.id + " --assetsDir \"" + new File(extension.getUserCache(), "assets-" + minecraftProvider.minecraftVersion).getAbsolutePath() + "\" --fabricMappingFile \"" + minecraftProvider.pomfProvider.MAPPINGS_TINY.getAbsolutePath() + "\"";
|
ideaClient.programArgs = "--tweakClass " + Constants.FABRIC_CLIENT_TWEAKER + " --assetIndex " + minecraftVersionInfo.assetIndex.getFabricId(extension.getMinecraftProvider().minecraftVersion) + " --assetsDir \"" + new File(extension.getUserCache(), "assets").getAbsolutePath() + "\" --fabricMappingFile \"" + minecraftProvider.pomfProvider.MAPPINGS_TINY.getAbsolutePath() + "\"";
|
||||||
|
|
||||||
return ideaClient;
|
return ideaClient;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class IdeaRunConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String fromDummy() throws IOException {
|
public String fromDummy() throws IOException {
|
||||||
InputStream input = SetupIntelijRunConfigs.class.getClassLoader().getResourceAsStream("dummy_runconfig.xml");
|
InputStream input = SetupIntelijRunConfigs.class.getClassLoader().getResourceAsStream("idea_run_config_template.xml");
|
||||||
String dummyConfig = IOUtils.toString(input, StandardCharsets.UTF_8);
|
String dummyConfig = IOUtils.toString(input, StandardCharsets.UTF_8);
|
||||||
input.close();
|
input.close();
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,17 @@ public class MinecraftVersionInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AssetIndex {
|
public class AssetIndex {
|
||||||
public String id;
|
private String id;
|
||||||
public String sha1;
|
public String sha1;
|
||||||
public String url;
|
public String url;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFabricId(String version) {
|
||||||
|
return id.equals(version) ? version : version + "-" + id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Library {
|
public class Library {
|
||||||
|
|
Loading…
Reference in New Issue