Skip to content

Commit

Permalink
Bump CoreMods and ModLauncher
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Mar 28, 2024
1 parent 7a8ab6d commit 8616902
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 174 deletions.
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mergetool_version=2.0.0
accesstransformers_version=10.0.1
# TODO fix veresion
coremods_version=6.0.6
coremods_version=7.0.3
eventbus_version=7.0.16
modlauncher_version=10.0.9
modlauncher_version=10.1.10
securejarhandler_version=2.1.23
bootstraplauncher_version=1.1.2
asm_version=9.5
Expand Down
1 change: 0 additions & 1 deletion loader/src/main/java/net/neoforged/fml/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ private ModLoader()
this.stateManager = new ModStateManager();
CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
CrashReportCallables.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList);
CrashReportCallables.registerCrashCallable("FML Language Providers", this::computeLanguageList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package net.neoforged.fml.core;

import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import net.neoforged.fml.IModStateTransition;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoadingStage;
Expand All @@ -21,7 +21,7 @@
record ParallelTransition(ModLoadingStage stage, Class<? extends ParallelDispatchEvent> event) implements IModStateTransition {
@Override
public Supplier<Stream<EventGenerator<?>>> eventFunctionStream() {
return () -> Stream.of(IModStateTransition.EventGenerator.fromFunction(LamdbaExceptionUtils.rethrowFunction((ModContainer mc) -> event.getConstructor(ModContainer.class, ModLoadingStage.class).newInstance(mc, stage))));
return () -> Stream.of(IModStateTransition.EventGenerator.fromFunction(LambdaExceptionUtils.rethrowFunction((ModContainer mc) -> event.getConstructor(ModContainer.class, ModLoadingStage.class).newInstance(mc, stage))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
public class FMLEnvironment
{
public static final Dist dist = FMLLoader.getDist();
public static final String naming = FMLLoader.getNaming();
public static final boolean production = FMLLoader.isProduction() || System.getProperties().containsKey("production");
public static final boolean secureJarsEnabled = FMLLoader.isSecureJarEnabled();

static void setupInteropEnvironment(IEnvironment environment) {
environment.computePropertyIfAbsent(IEnvironment.Keys.NAMING.get(), v->naming);
environment.computePropertyIfAbsent(Environment.Keys.DIST.get(), v->dist);
}

Expand Down
18 changes: 4 additions & 14 deletions loader/src/main/java/net/neoforged/fml/loading/FMLLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
import net.neoforged.accesstransformer.api.AccessTransformerEngine;
import net.neoforged.accesstransformer.ml.AccessTransformerService;
import net.neoforged.coremod.CoreModEngine;
import net.neoforged.coremod.CoreModScriptingEngine;
import net.neoforged.fml.common.asm.RuntimeDistCleaner;
import net.neoforged.fml.loading.mixin.DeferredMixinConfigRegistration;
import net.neoforged.fml.loading.moddiscovery.BackgroundScanHandler;
Expand All @@ -35,10 +35,9 @@ public class FMLLoader
private static final Logger LOGGER = LogUtils.getLogger();
private static AccessTransformerEngine accessTransformer;
private static ModDiscoverer modDiscoverer;
private static CoreModEngine coreModEngine;
private static CoreModScriptingEngine coreModEngine;
private static LanguageLoadingProvider languageLoadingProvider;
private static Dist dist;
private static String naming;
private static LoadingModList loadingModList;
private static RuntimeDistCleaner runtimeDistCleaner;
private static Path gamePath;
Expand Down Expand Up @@ -88,7 +87,7 @@ static void onInitialLoad(IEnvironment environment, Set<String> otherServices) t
});
LOGGER.debug(LogMarkers.CORE, "Found Runtime Dist Cleaner");

coreModEngine = new CoreModEngine();
coreModEngine = new CoreModScriptingEngine();
LOGGER.debug(LogMarkers.CORE, "FML found CoreMods version : {}", coreModEngine.getClass().getPackage().getImplementationVersion());

LOGGER.debug(LogMarkers.CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion());
Expand Down Expand Up @@ -126,7 +125,6 @@ static void setupLaunchHandler(final IEnvironment environment, final Map<String,
launchHandlerName = launchHandler.get().name();
gamePath = environment.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElse(Paths.get(".").toAbsolutePath());

naming = commonLaunchHandler.getNaming();
dist = commonLaunchHandler.getDist();
production = commonLaunchHandler.isProduction();

Expand Down Expand Up @@ -157,7 +155,7 @@ public static List<ITransformationService.Resource> completeScan(IModuleLayerMan
return List.of(modValidator.getModResources());
}

static CoreModEngine getCoreModEngine() {
static CoreModScriptingEngine getCoreModEngine() {
return coreModEngine;
}

Expand Down Expand Up @@ -206,14 +204,6 @@ public static Path getGamePath()
return gamePath;
}

public static String getNaming() {
return naming;
}

public static Optional<BiFunction<INameMappingService.Domain, String, String>> getNameFunction(final String naming) {
return Launcher.INSTANCE.environment().findNameMapping(naming);
}

public static String getLauncherInfo() {
return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MLIMPL_VERSION.get()).orElse("MISSING");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public void argumentValues(OptionResult option)
}

@Override
public @NotNull List<ITransformer> transformers()
public @NotNull List<? extends ITransformer<?>> transformers()
{
LOGGER.debug(CORE, "Loading coremod transformers");
return (List) FMLLoader.getCoreModEngine().initializeCoreMods();
return FMLLoader.getCoreModEngine().initializeCoreMods();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package net.neoforged.fml.loading;

import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import net.neoforged.fml.loading.mixin.DeferredMixinConfigRegistration;
import net.neoforged.fml.loading.moddiscovery.BackgroundScanHandler;
import net.neoforged.fml.loading.moddiscovery.ModFile;
Expand Down Expand Up @@ -151,7 +151,7 @@ private URL findNextURL() {
final ModFileInfo next = modFileIterator.next();
final Path resource = next.getFile().findResource(resourceName);
if (Files.exists(resource)) {
return LamdbaExceptionUtils.uncheck(()->new URL("modjar://" + next.getMods().get(0).getModId() + "/" + resourceName));
return LambdaExceptionUtils.uncheck(()->new URL("modjar://" + next.getMods().get(0).getModId() + "/" + resourceName));
}
}
return null;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public List<Resource> beginScanning(IEnvironment environment) {
}

@Override
public @NotNull List<ITransformer> transformers() {
public @NotNull List<? extends ITransformer<?>> transformers() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.fml.loading;

import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import cpw.mods.modlauncher.api.NamedPath;
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -88,7 +88,7 @@ private static void scan(final Path gameDirectory) {
private static boolean shouldLoadInServiceLayer(Path path) {
if (!Files.isRegularFile(path)) return false;
if (!path.toString().endsWith(".jar")) return false;
if (LamdbaExceptionUtils.uncheck(() -> Files.size(path)) == 0) return false;
if (LambdaExceptionUtils.uncheck(() -> Files.size(path)) == 0) return false;

return TransformerDiscovererConstants.shouldLoadInServiceLayer(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.fml.loading;

import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import org.slf4j.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -84,7 +84,7 @@ public long getContentLengthLong() {
// Used to cache protectiondomains by "top level object" aka the modid
@Override
public URL getURL() {
return LamdbaExceptionUtils.uncheck(()->new URL("modjar://"+modid));
return LambdaExceptionUtils.uncheck(()->new URL("modjar://"+modid));
}

public Optional<Manifest> getManifest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package net.neoforged.fml.loading.moddiscovery;

import net.neoforged.coremod.ICoreModFile;
import net.neoforged.coremod.ICoreModScriptSource;

import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;

public class CoreModFile implements ICoreModFile {
public class CoreModFile implements ICoreModScriptSource {
private final Path internalPath;
private final ModFile file;
private final String name;
Expand All @@ -29,8 +29,8 @@ public Reader readCoreMod() throws IOException {
}

@Override
public Path getPath() {
return this.internalPath;
public String getDebugSource() {
return this.internalPath.toString();
}

@Override
Expand All @@ -45,6 +45,6 @@ public String getOwnerId() {

@Override
public String toString() {
return "{Name: " + name + ", Owner: " + getOwnerId() + " @ " + getPath() + "}";
return "{Name: " + name + ", Owner: " + getOwnerId() + " @ " + getDebugSource() + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package net.neoforged.fml.loading.moddiscovery;

import cpw.mods.modlauncher.api.LamdbaExceptionUtils.Supplier_WithExceptions;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import net.neoforged.fml.loading.StringUtils;

import java.nio.file.Path;
Expand All @@ -14,8 +14,6 @@
import java.util.function.BiPredicate;
import java.util.zip.ZipFile;

import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.*;

public enum InvalidModIdentifier {

OLDFORGE(filePresent("mcmod.info")),
Expand All @@ -39,12 +37,12 @@ private String getReason()

public static Optional<String> identifyJarProblem(Path path)
{
Optional<ZipFile> zfo = optionalFromException(() -> new ZipFile(path.toFile()));
Optional<ZipFile> zfo = tryOpenFile(path);
Optional<String> result = Arrays.stream(values()).
filter(i -> i.ident.test(path, zfo)).
map(InvalidModIdentifier::getReason).
findAny();
zfo.ifPresent(rethrowConsumer(ZipFile::close));
zfo.ifPresent(LambdaExceptionUtils.rethrowConsumer(ZipFile::close));
return result;
}

Expand All @@ -53,14 +51,10 @@ private static BiPredicate<Path, Optional<ZipFile>> filePresent(String filename)
return (f, zfo) -> zfo.map(zf -> zf.getEntry(filename) != null).orElse(false);
}

private static <T> Optional<T> optionalFromException(Supplier_WithExceptions<T, ? extends Exception> supp)
{
try
{
return Optional.of(supp.get());
}
catch (Exception e)
{
private static Optional<ZipFile> tryOpenFile(Path path) {
try {
return Optional.of(new ZipFile(path.toFile()));
} catch (Exception ignored) {
return Optional.empty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean identifyMods() {
if (this.modFileInfo == null) return this.getType() != Type.MOD;
LOGGER.debug(LogMarkers.LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders());
this.coreMods = ModFileParser.getCoreMods(this);
this.coreMods.forEach(mi-> LOGGER.debug(LogMarkers.LOADING,"Found coremod {}", mi.getPath()));
this.coreMods.forEach(mi-> LOGGER.debug(LogMarkers.LOADING,"Found coremod {}", mi.getDebugSource()));
this.mixinConfigs = ModFileParser.getMixinConfigs(this.modFileInfo);
this.mixinConfigs.forEach(mc -> LOGGER.debug(LogMarkers.LOADING,"Found mixin config {}", mc));
this.accessTransformers = ModFileParser.getAccessTransformers(this.modFileInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.google.common.base.Strings;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import net.neoforged.fml.loading.LogMarkers;
import net.neoforged.fml.loading.StringUtils;
import net.neoforged.neoforgespi.language.IConfigurable;
Expand Down Expand Up @@ -173,8 +173,8 @@ public Optional<String> getCodeSigningFingerprint() {
return (signers == null ? Stream.<CodeSigner>of() : Arrays.stream(signers))
.flatMap(csa->csa.getSignerCertPath().getCertificates().stream())
.findFirst()
.map(LamdbaExceptionUtils.rethrowFunction(Certificate::getEncoded))
.map(bytes->LamdbaExceptionUtils.uncheck(()->MessageDigest.getInstance("SHA-256")).digest(bytes))
.map(LambdaExceptionUtils.rethrowFunction(Certificate::getEncoded))
.map(bytes->LambdaExceptionUtils.uncheck(()->MessageDigest.getInstance("SHA-256")).digest(bytes))
.map(StringUtils::binToHex)
.map(str-> String.join(":", str.split("(?<=\\G.{2})")));
}
Expand Down
Loading

0 comments on commit 8616902

Please sign in to comment.