Skip to content

Commit

Permalink
Loom 0.2.7 and higher support.
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed May 5, 2020
1 parent 20e6511 commit 583d0c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT"
classpath "net.fabricmc:fabric-loom:0.4.3"
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G

minecraft_version=1.15.2
yarn_mappings=1.15.2+build.14
loader_version=0.7.8+build.189
loader_version=0.8.2+build.194

fabric_version=0.5.1+build.294-1.15
fabric_version=0.10.1+build.307-1.15
fabric_asm_version=v2.0
zt_zip_version=1.14
slf4j_version=1.7.30
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,28 @@ Path getMinecraftJar() throws FileNotFoundException {
Path path = entrypointResult.get().getParent();
Path minecraftJar = path.resolve(String.format("minecraft-%s-client.jar", OptifineVersion.minecraftVersion)); //Lets hope you are using loom in dev
if (!Files.exists(minecraftJar)) {
throw new FileNotFoundException("Could not find minecraft jar!");
return getNewMinecraftDevJar();
}
return minecraftJar;
}
return entrypointResult.get();
}

//Loom 0.2.7 fallback
Path getNewMinecraftDevJar() throws FileNotFoundException {
Optional<Path> entrypointResult = getSource(Knot.class.getClassLoader(), "mappings/mappings.tiny");

if (entrypointResult.isPresent()) {
Path path = entrypointResult.get().getParent();
Path minecraftJar = path.resolve(String.format("minecraft-%s-client.jar", OptifineVersion.minecraftVersion)); //Lets hope you are using loom in dev
if (Files.exists(minecraftJar)) {
return minecraftJar;
}
}

throw new FileNotFoundException("Could not find minecraft jar!");
}

//Stolen from fabric loader
static Optional<Path> findFirstClass(ClassLoader loader, List<String> classNames) {
List<String> entrypointFilenames = classNames.stream().map((ep) -> ep.replace('.', '/') + ".class").collect(Collectors.toList());
Expand Down

0 comments on commit 583d0c3

Please sign in to comment.