Revert "Fix some streams not being closed, clean up the mod reobfuscater, fix runClient task"
This reverts commit 30a71c1
This commit is contained in:
parent
478573bde4
commit
0a5245d508
5 changed files with 20 additions and 26 deletions
|
@ -79,7 +79,6 @@ public class MixinServiceGradle extends MixinServiceLaunchWrapper implements ICl
|
|||
public byte[] getClassBytes(String name, String transformedName) throws IOException {
|
||||
InputStream inputStream = getResourceAsStream(name.replace(".", "/") + ".class");
|
||||
byte[] classBytes = ByteStreams.toByteArray(inputStream);
|
||||
inputStream.close();
|
||||
if(classBytes == null){
|
||||
return super.getClassBytes(name, transformedName);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public class RunClientTask extends JavaExec {
|
|||
|
||||
//Removes the deobf jars
|
||||
libs.removeIf(s -> s.contains(Constants.MINECRAFT_FINAL_JAR.get(extension).getName()));
|
||||
libs.removeIf(s -> s.contains(getProject().getName() + "-" + getProject().getVersion() + "-deobf.jar"));
|
||||
|
||||
classpath(libs);
|
||||
|
||||
|
@ -76,14 +77,6 @@ public class RunClientTask extends JavaExec {
|
|||
super.exec();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkingDir(File dir) {
|
||||
if(!dir.exists()){
|
||||
dir.mkdirs();
|
||||
}
|
||||
super.setWorkingDir(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMain() {
|
||||
return "net.minecraft.launchwrapper.Launch";
|
||||
|
|
|
@ -77,14 +77,6 @@ public class RunServerTask extends JavaExec {
|
|||
return "net.minecraft.launchwrapper.Launch";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkingDir(File dir) {
|
||||
if(!dir.exists()){
|
||||
dir.mkdirs();
|
||||
}
|
||||
super.setWorkingDir(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getJvmArgs() {
|
||||
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
|
|
@ -105,7 +105,6 @@ public class ModProcessor {
|
|||
remapper.read(mcDeps);
|
||||
remapper.apply(input.toPath(), outputConsumer);
|
||||
outputConsumer.finish();
|
||||
remapper.finish();
|
||||
} catch (Exception e){
|
||||
remapper.finish();
|
||||
throw new RuntimeException("Failed to remap JAR to " + toM, e);
|
||||
|
@ -122,10 +121,7 @@ public class ModProcessor {
|
|||
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
|
||||
// JSON file in root directory
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(stream);
|
||||
JsonObject json = gson.fromJson(inputStreamReader, JsonObject.class);
|
||||
inputStreamReader.close();
|
||||
stream.close();
|
||||
JsonObject json = gson.fromJson(new InputStreamReader(stream), JsonObject.class);
|
||||
if (json != null && json.has("refmap")) {
|
||||
mixinRefmapFilenames.add(json.get("refmap").getAsString());
|
||||
}
|
||||
|
|
|
@ -43,13 +43,25 @@ public class ModRemapper {
|
|||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
// TODO: What's the proper way of doing this?
|
||||
File libsDir = new File(project.getBuildDir(), "libs");
|
||||
File deobfJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-deobf.jar");
|
||||
File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar");
|
||||
|
||||
if (!modJar.exists()) {
|
||||
project.getLogger().error("Could not find mod .JAR at" + deobfJar.getAbsolutePath());
|
||||
project.getLogger().error("This is can be fixed by adding a 'settings.gradle' file specifying 'rootProject.name'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (deobfJar.exists()) {
|
||||
deobfJar.delete();
|
||||
}
|
||||
|
||||
FileUtils.touch(modJar); //Done to ensure that the file can be moved
|
||||
//Move the pre existing mod jar to the deobf jar
|
||||
if(!modJar.renameTo(deobfJar)){
|
||||
throw new RuntimeException("Failed to rename " + modJar);
|
||||
}
|
||||
|
||||
Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath();
|
||||
|
||||
String fromM = "named";
|
||||
|
@ -74,10 +86,10 @@ public class ModRemapper {
|
|||
|
||||
try {
|
||||
OutputConsumerPath outputConsumer = new OutputConsumerPath(modJar.toPath());
|
||||
outputConsumer.addNonClassFiles(modJar.toPath());
|
||||
remapper.read(modJar.toPath());
|
||||
outputConsumer.addNonClassFiles(deobfJar.toPath());
|
||||
remapper.read(deobfJar.toPath());
|
||||
remapper.read(classpath);
|
||||
remapper.apply(modJar.toPath(), outputConsumer);
|
||||
remapper.apply(deobfJar.toPath(), outputConsumer);
|
||||
outputConsumer.finish();
|
||||
remapper.finish();
|
||||
} catch (Exception e){
|
||||
|
@ -85,9 +97,11 @@ public class ModRemapper {
|
|||
throw new RuntimeException("Failed to remap JAR", e);
|
||||
}
|
||||
|
||||
if(!modJar.exists()){
|
||||
if(!deobfJar.exists() || !modJar.exists()){
|
||||
throw new RuntimeException("Failed to reobfuscate JAR");
|
||||
}
|
||||
|
||||
deobfJar.delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue