default to calamus(gen2) when mojmap isn't available
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s
This commit is contained in:
parent
f7c90d15e6
commit
ac3e0d86df
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.26"
|
||||
version = "0.0.1-alpha.27"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.frogmc.frogloader.api.FrogLoader;
|
||||
import dev.frogmc.frogloader.api.mod.ModDependencies;
|
||||
|
@ -22,6 +23,7 @@ import dev.frogmc.frogloader.api.plugin.GamePlugin;
|
|||
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
||||
import dev.frogmc.frogloader.impl.mod.ModPropertiesImpl;
|
||||
import dev.frogmc.frogloader.impl.util.SystemProperties;
|
||||
import dev.frogmc.thyroxine.HttpHelper;
|
||||
import dev.frogmc.thyroxine.Thyroxine;
|
||||
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
||||
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser;
|
||||
|
@ -32,6 +34,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class MinecraftGamePlugin implements GamePlugin {
|
||||
|
||||
protected static final String CALAMUS_META_URL = "https://meta.ornithemc.net/v3/versions/gen2/intermediary/%s";
|
||||
protected static final String CALAMUS_MAVEN_URL = "https://maven.ornithemc.net/releases/%s";
|
||||
protected final String[] MINECRAFT_CLASSES = new String[]{
|
||||
"net/minecraft/client/main/Main.class",
|
||||
"net/minecraft/client/MinecraftApplet.class",
|
||||
|
@ -136,8 +140,22 @@ public class MinecraftGamePlugin implements GamePlugin {
|
|||
if (mappingPath != null) {
|
||||
mappings = readIntemediaryMappings(mappingPath);
|
||||
} else {
|
||||
try {
|
||||
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt"))
|
||||
.reverse();
|
||||
} catch (NullPointerException e) { // NPE is only thrown if the mappings for this version can't be found
|
||||
LOGGER.info("Mojmap is not available for version {}, using ornithe's calamus as a fallback!", version);
|
||||
Path file = remappedGamePath.resolveSibling("calamus-"+version+".tiny");
|
||||
if (!Files.exists(file)) {
|
||||
String location = FrogLoaderImpl.getInstance().getGson().fromJson(HttpHelper.getString(String.format(CALAMUS_META_URL, version)), JsonArray.class)
|
||||
.get(0).getAsJsonObject().get("maven").getAsString();
|
||||
String[] groups = location.split(":");
|
||||
HttpHelper.download(String.format(CALAMUS_MAVEN_URL,
|
||||
location.replaceAll("[.:]", "/")+"/"+groups[1]+"-"+groups[2]+".jar"),
|
||||
file);
|
||||
}
|
||||
mappings = TinyV2Parser.parse(Files.readString(file));
|
||||
}
|
||||
}
|
||||
if (mappings == null) {
|
||||
mappings = readIntemediaryMappings("/mappings/mappings.tiny");
|
||||
|
@ -152,7 +170,7 @@ public class MinecraftGamePlugin implements GamePlugin {
|
|||
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!");
|
||||
"Use -D" + SystemProperties.INTERMEDIARY_MAPPINGS + " to specify a file!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue