Compare commits

..

No commits in common. "52306daa091796e04db4a074fd1489da7bc32ad5" and "741c60001b9fa98409b8a94f4554d48d7034df97" have entirely different histories.

5 changed files with 15 additions and 35 deletions

View file

@ -7,7 +7,7 @@ plugins {
} }
group = "dev.frogmc" group = "dev.frogmc"
version = "0.0.1-alpha.29" version = "0.0.1-alpha.27"
repositories { repositories {
maven { maven {

View file

@ -1,5 +1,5 @@
#Sat May 11 16:50:23 CEST 2024 #Sat May 11 16:50:23 CEST 2024
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -1,31 +1,15 @@
package dev.frogmc.frogloader.api.exception; package dev.frogmc.frogloader.api.exception;
/**
* Exception if an extension cannot be resolved or instantiated
*/
public class ModExtensionResolutionException extends Exception { public class ModExtensionResolutionException extends Exception {
/**
* Instantiate this exception
* @param message A message describing this exception
*/
public ModExtensionResolutionException(String message) { public ModExtensionResolutionException(String message) {
super(message); super(message);
} }
/**
* Instantiate this exception
* @param cause The cause of this exception
*/
public ModExtensionResolutionException(Throwable cause) { public ModExtensionResolutionException(Throwable cause) {
super(cause); super(cause);
} }
/**
* Instantiate this exception
* @param message A message describing this exception
* @param cause The cause of this exception
*/
public ModExtensionResolutionException(String message, Throwable cause) { public ModExtensionResolutionException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }

View file

@ -4,11 +4,6 @@ import java.util.Collection;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/**
* Represents dependencies declared by a mod at runtime.
* @see ModProperties
* @see ModExtensions
*/
public interface ModDependencies { public interface ModDependencies {
/** /**

View file

@ -26,7 +26,7 @@ import dev.frogmc.frogloader.impl.mod.ModPropertiesImpl;
import dev.frogmc.frogloader.impl.util.SystemProperties; import dev.frogmc.frogloader.impl.util.SystemProperties;
import dev.frogmc.thyroxine.HttpHelper; import dev.frogmc.thyroxine.HttpHelper;
import dev.frogmc.thyroxine.Thyroxine; import dev.frogmc.thyroxine.Thyroxine;
import dev.frogmc.thyroxine.api.data.MappingData; import dev.frogmc.thyroxine.api.data.MappingBundle;
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser; import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser;
import dev.frogmc.thyroxine.provider.MojmapProvider; import dev.frogmc.thyroxine.provider.MojmapProvider;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -135,7 +135,7 @@ public class MinecraftGamePlugin implements GamePlugin {
if (!loader.isDevelopment()) { if (!loader.isDevelopment()) {
if (!Files.exists(remappedGamePath)) { if (!Files.exists(remappedGamePath)) {
LOGGER.atInfo().setMessage("Remapping game, this may take a moment...").log(); LOGGER.atInfo().setMessage("Remapping game, this may take a moment...").log();
MappingData mappings; MappingBundle mappings;
String mappingPath = System.getProperty(SystemProperties.INTERMEDIARY_MAPPINGS); String mappingPath = System.getProperty(SystemProperties.INTERMEDIARY_MAPPINGS);
try { try {
if (mappingPath != null) { if (mappingPath != null) {
@ -143,7 +143,7 @@ public class MinecraftGamePlugin implements GamePlugin {
} else { } else {
try { try {
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt")) mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt"))
.flattenData().reverse(); .reverse();
} catch (NullPointerException e) { // NPE is only thrown if the mappings for this version can't be found } 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); LOGGER.info("Mojmap is not available for version {}, using ornithe's calamus as a fallback!", version);
Path file = remappedGamePath.resolveSibling("calamus-"+version+".tiny"); Path file = remappedGamePath.resolveSibling("calamus-"+version+".tiny");
@ -155,29 +155,30 @@ public class MinecraftGamePlugin implements GamePlugin {
location.replaceAll("[.:]", "/")+"/"+groups[1]+"-"+groups[2]+".jar"), location.replaceAll("[.:]", "/")+"/"+groups[1]+"-"+groups[2]+".jar"),
file); file);
} }
mappings = TinyV2Parser.parse(Files.readString(file)).flattenData(); mappings = TinyV2Parser.parse(Files.readString(file));
} }
} }
if (mappings == null) { if (mappings == null) {
mappings = readIntemediaryMappings("/mappings/mappings.tiny"); mappings = readIntemediaryMappings("/mappings/mappings.tiny");
} }
if (mappings != null) { if (mappings != null) {
Thyroxine.remap(mappings, gamePath, remappedGamePath, true, false); Thyroxine.remap(mappings.flattenData(), gamePath, remappedGamePath, true, false);
} else { return;
}
} catch (Exception e) {
throw new IllegalStateException("Failed to remap game: ", e);
}
runtimePath = gamePath; runtimePath = gamePath;
LOGGER.error("No intermediary mappings found! The game will be launched obfuscated. Mods are likely to error! " + 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. " + "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!");
} }
} catch (Exception e) {
throw new IllegalStateException("Failed to remap game: ", e);
}
}
} }
FrogLoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL()); FrogLoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
} }
private MappingData readIntemediaryMappings(String path) throws IOException { private MappingBundle readIntemediaryMappings(String path) throws IOException {
URL resource = this.getClass().getResource(path); URL resource = this.getClass().getResource(path);
String data; String data;
if (resource != null) { if (resource != null) {
@ -186,7 +187,7 @@ public class MinecraftGamePlugin implements GamePlugin {
data = Files.readString(Paths.get(path)); data = Files.readString(Paths.get(path));
} }
try { try {
MappingData mappings = TinyV2Parser.parse(data).flattenData(); MappingBundle mappings = TinyV2Parser.parse(data);
LOGGER.warn("Using non-standard intermediary mappings! Mods may not work!"); LOGGER.warn("Using non-standard intermediary mappings! Mods may not work!");
return mappings; return mappings;
} catch (IllegalStateException e) { } catch (IllegalStateException e) {