try to fix alternative intermediary usage
All checks were successful
Publish to snapshot maven / build (push) Successful in 21s
All checks were successful
Publish to snapshot maven / build (push) Successful in 21s
This commit is contained in:
parent
d869085dd8
commit
0a602a5012
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.21"
|
||||
version = "0.0.1-alpha.22"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
|
|
@ -131,38 +131,47 @@ public class MinecraftGamePlugin implements GamePlugin {
|
|||
if (!Files.exists(remappedGamePath)) {
|
||||
MappingBundle mappings;
|
||||
String mappingPath = System.getProperty(SystemProperties.INTERMEDIARY_MAPPINGS);
|
||||
if (mappingPath != null) {
|
||||
URL resource = this.getClass().getResource("");
|
||||
String data;
|
||||
if (resource != null) {
|
||||
data = new BufferedReader(new InputStreamReader(resource.openStream())).lines().collect(Collectors.joining("\n"));
|
||||
} else {
|
||||
data = Files.readString(Paths.get(mappingPath));
|
||||
}
|
||||
try {
|
||||
mappings = TinyV2Parser.parse(data);
|
||||
} catch (IllegalStateException e) {
|
||||
throw new IllegalStateException("Failed to read intermediary mappings: " + data, e);
|
||||
}
|
||||
if (mappingPath != null) {
|
||||
mappings = readIntemediaryMappings(mappingPath);
|
||||
} else {
|
||||
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt")).orElseGet(() -> {
|
||||
LOGGER.warn("Failed to retrieve/parse mojmap for {}! If it isn't available you will need to specify intermediary mappings yourself!", version);
|
||||
return null;
|
||||
});
|
||||
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt")).orElse(null);
|
||||
}
|
||||
if (mappings == null) {
|
||||
mappings = readIntemediaryMappings("mappings/mappings.tiny");
|
||||
}
|
||||
if (mappings != null) {
|
||||
Thyroxine.remap(mappings.flattenData(), gamePath, remappedGamePath, true, false);
|
||||
} else {
|
||||
runtimePath = gamePath;
|
||||
LOGGER.warn("No intermediary mappings found! The game will be launched obfuscated. Mods are likely to error!");
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to remap game: ", e);
|
||||
}
|
||||
runtimePath = gamePath;
|
||||
LOGGER.error("No intermediary mappings found! The game will be launched obfuscated. Mods are likely to error! " +
|
||||
"You may need to specify the path of your mappings manually. " +
|
||||
"Use -D"+SystemProperties.INTERMEDIARY_MAPPINGS+" to specify a file!");
|
||||
}
|
||||
}
|
||||
|
||||
FrogLoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
|
||||
}
|
||||
|
||||
private MappingBundle readIntemediaryMappings(String path) throws IOException {
|
||||
URL resource = this.getClass().getResource(path);
|
||||
String data;
|
||||
if (resource != null) {
|
||||
data = new BufferedReader(new InputStreamReader(resource.openStream())).lines().collect(Collectors.joining("\n"));
|
||||
} else {
|
||||
data = Files.readString(Paths.get(path));
|
||||
}
|
||||
try {
|
||||
return TinyV2Parser.parse(data);
|
||||
} catch (IllegalStateException e) {
|
||||
throw new IllegalStateException("Failed to read intermediary mappings: " + data, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String queryVersion() {
|
||||
return version;
|
||||
|
|
Loading…
Reference in a new issue