Upload magma

This commit is contained in:
Diamond Creeper 2024-03-04 21:16:02 +13:00
commit dfa9ee0b24
5008 changed files with 653442 additions and 0 deletions

View file

@ -0,0 +1,70 @@
plugins {
id 'com.github.ben-manes.versions'
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
id 'org.cadixdev.licenser'
}
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply plugin: 'org.javamodularity.moduleplugin'
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
dependencies {
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
implementation(project(':fmlloader'))
implementation(project(':fmlcore'))
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
ext {
MANIFESTS = [
'': [
'FMLModType': 'LANGPROVIDER',
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Git-Commit': GIT_INFO.abbreviatedId,
'Git-Branch': GIT_INFO.branch,
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
] as LinkedHashMap,
'net/minecraftforge/fml/loading/': [
'Specification-Title': 'FMLLoader',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': '1',
'Implementation-Title': 'FML Loader',
'Implementation-Version': '1.0',
'Implementation-Vendor': 'Forge'
] as LinkedHashMap
]
}
jar.doFirst {
manifest.attributes['Automatic-Module-Name'] = project.name
MANIFESTS.each { pkg, values ->
if (pkg == '')
manifest.attributes(values)
else
manifest.attributes(values, pkg)
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
}
license {
header = rootProject.file('LICENSE-header.txt')
ext {
year = new Date().format("yyyy")
}
exclude 'net/minecraftforge/'
}
artifacts {
archives jar
archives sourcesJar
}

View file

@ -0,0 +1,9 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/</h1><hr><pre><a href="../">../</a>
<a href="src/">src/</a> 07-Oct-2023 14:12 -
<a href="build.gradle">build.gradle</a> 07-Oct-2023 14:12 1940
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="96d8cfc547807867681742bda08ba1fe" data-cf-beacon='{"rayId":"85f014ee2d2e50c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/</h1><hr><pre><a href="../">../</a>
<a href="services/">services/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="82a2a468550d404955719efbf616432c" data-cf-beacon='{"rayId":"85f016272f1050c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/services/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/services/</h1><hr><pre><a href="../">../</a>
<a href="net.minecraftforge.forgespi.language.IModLanguageProvider">net.minecraftforge.forgespi.language.IModLangua..&gt;</a> 07-Oct-2023 14:12 61
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="182ac73c4d7449ae63c2f7cf70e4d493" data-cf-beacon='{"rayId":"85f016dbf9bb50c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1 @@
net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/</h1><hr><pre><a href="../">../</a>
<a href="META-INF/">META-INF/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="dd506bae359c309eb0bfd876813b46cb" data-cf-beacon='{"rayId":"85f015ab29c250c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/</h1><hr><pre><a href="../">../</a>
<a href="main/">main/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="6a8511899035629a5e74c3fe3a85f946" data-cf-beacon='{"rayId":"85f01534b96950c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,9 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/</h1><hr><pre><a href="../">../</a>
<a href="java/">java/</a> 07-Oct-2023 14:12 -
<a href="resources/">resources/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="c562265da11342db21d27bd8d0e03fe4" data-cf-beacon='{"rayId":"85f01578e9d850c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/</h1><hr><pre><a href="../">../</a>
<a href="net/">net/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="5e0e82595cc8e84028bd49ed9de2fb2d" data-cf-beacon='{"rayId":"85f015a8cd1b50c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/</h1><hr><pre><a href="../">../</a>
<a href="minecraftforge/">minecraftforge/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="2f77969c6600057cba50e7f8e1331c0b" data-cf-beacon='{"rayId":"85f01624eb2350c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,94 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.function.Supplier;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.Bindings;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
/**
* This defines a Mod to FML.
* Any class found with this annotation applied will be loaded as a Mod. The instance that is loaded will
* represent the mod to other Mods in the system. It will be sent various subclasses of {@code ModLifecycleEvent}
* at pre-defined times during the loading of the game.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Mod
{
/**
* The unique mod identifier for this mod.
* <b>Required to be lowercased in the english locale for compatibility. Will be truncated to 64 characters long.</b>
*
* This will be used to identify your mod for third parties (other mods), it will be used to identify your mod for registries such as block and item registries.
* By default, you will have a resource domain that matches the modid. All these uses require that constraints are imposed on the format of the modid.
*/
String value();
/**
* Annotate a class which will be subscribed to an Event Bus at mod construction time.
* Defaults to subscribing the current modid to the {@code MinecraftForge#EVENT_BUS}
* on both sides.
*
* @see Bus
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface EventBusSubscriber {
/**
* Specify targets to load this event subscriber on. Can be used to avoid loading Client specific events
* on a dedicated server, for example.
*
* @return an array of Dist to load this event subscriber on
*/
Dist[] value() default { Dist.CLIENT, Dist.DEDICATED_SERVER };
/**
* Optional value, only necessary if this annotation is not on the same class that has a @Mod annotation.
* Needed to prevent early classloading of classes not owned by your mod.
* @return a modid
*/
String modid() default "";
/**
* Specify an alternative bus to listen to
*
* @return the bus you wish to listen to
*/
Bus bus() default Bus.FORGE;
enum Bus {
/**
* The main Forge Event Bus.
*
* <p>See {@code MinecraftForge#EVENT_BUS}</p>
*/
FORGE(Bindings.getForgeBus()),
/**
* The mod specific Event bus.
* @see FMLJavaModLoadingContext#getModEventBus()
*/
MOD(()-> FMLJavaModLoadingContext.get().getModEventBus());
private final Supplier<IEventBus> busSupplier;
Bus(final Supplier<IEventBus> eventBusSupplier) {
this.busSupplier = eventBusSupplier;
}
public Supplier<IEventBus> bus() {
return busSupplier;
}
}
}
}

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/common/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/common/</h1><hr><pre><a href="../">../</a>
<a href="Mod.java">Mod.java</a> 07-Oct-2023 14:12 3344
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="73d85e15ed6dbfcb463e629b34e7f03d" data-cf-beacon='{"rayId":"85f0270e182d1c5c","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,9 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/</h1><hr><pre><a href="../">../</a>
<a href="common/">common/</a> 07-Oct-2023 14:12 -
<a href="javafmlmod/">javafmlmod/</a> 06-Nov-2023 18:00 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="633c12eac1d314516b0591c63966c877" data-cf-beacon='{"rayId":"85f019aebc9250c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,72 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.javafmlmod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.forgespi.language.ModFileScanData;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.Type;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static net.minecraftforge.fml.Logging.LOADING;
/**
* Automatic eventbus subscriber - reads {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber}
* annotations and passes the class instances to the {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus}
* defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS}
*/
public class AutomaticEventSubscriber
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Type AUTO_SUBSCRIBER = Type.getType(Mod.EventBusSubscriber.class);
private static final Type MOD_TYPE = Type.getType(Mod.class);
public static void inject(final ModContainer mod, final ModFileScanData scanData, final ClassLoader loader)
{
if (scanData == null) return;
LOGGER.debug(LOADING,"Attempting to inject @EventBusSubscriber classes into the eventbus for {}", mod.getModId());
List<ModFileScanData.AnnotationData> ebsTargets = scanData.getAnnotations().stream().
filter(annotationData -> AUTO_SUBSCRIBER.equals(annotationData.annotationType())).
collect(Collectors.toList());
Map<String, String> modids = scanData.getAnnotations().stream().
filter(annotationData -> MOD_TYPE.equals(annotationData.annotationType())).
collect(Collectors.toMap(a -> a.clazz().getClassName(), a -> (String)a.annotationData().get("value")));
ebsTargets.forEach(ad -> {
@SuppressWarnings("unchecked")
final List<ModAnnotation.EnumHolder> sidesValue = (List<ModAnnotation.EnumHolder>)ad.annotationData().
getOrDefault("value", Arrays.asList(new ModAnnotation.EnumHolder(null, "CLIENT"), new ModAnnotation.EnumHolder(null, "DEDICATED_SERVER")));
final EnumSet<Dist> sides = sidesValue.stream().map(eh -> Dist.valueOf(eh.getValue())).
collect(Collectors.toCollection(() -> EnumSet.noneOf(Dist.class)));
final String modId = (String)ad.annotationData().getOrDefault("modid", modids.getOrDefault(ad.clazz().getClassName(), mod.getModId()));
final ModAnnotation.EnumHolder busTargetHolder = (ModAnnotation.EnumHolder)ad.annotationData().getOrDefault("bus", new ModAnnotation.EnumHolder(null, "FORGE"));
final Mod.EventBusSubscriber.Bus busTarget = Mod.EventBusSubscriber.Bus.valueOf(busTargetHolder.getValue());
if (Objects.equals(mod.getModId(), modId) && sides.contains(FMLEnvironment.dist)) {
try
{
LOGGER.debug(LOADING, "Auto-subscribing {} to {}", ad.clazz().getClassName(), busTarget);
busTarget.bus().get().register(Class.forName(ad.clazz().getClassName(), true, loader));
}
catch (ClassNotFoundException e)
{
LOGGER.fatal(LOADING, "Failed to load mod class {} for @EventBusSubscriber annotation", ad.clazz(), e);
throw new RuntimeException(e);
}
}
});
}
}

View file

@ -0,0 +1,106 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.javafmlmod;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import net.minecraftforge.fml.ModLoadingException;
import net.minecraftforge.fml.ModLoadingStage;
import net.minecraftforge.forgespi.language.ILifecycleEvent;
import net.minecraftforge.forgespi.language.IModLanguageProvider;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.Type;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import static net.minecraftforge.fml.Logging.SCAN;
import static net.minecraftforge.fml.Logging.LOADING;
public class FMLJavaModLanguageProvider implements IModLanguageProvider
{
private static final Logger LOGGER = LogManager.getLogger();
private static class FMLModTarget implements IModLanguageProvider.IModLanguageLoader {
private static final Logger LOGGER = FMLJavaModLanguageProvider.LOGGER;
private final String className;
private final String modId;
private FMLModTarget(String className, String modId)
{
this.className = className;
this.modId = modId;
}
public String getModId()
{
return modId;
}
@SuppressWarnings("unchecked")
@Override
public <T> T loadMod(final IModInfo info, final ModFileScanData modFileScanResults, ModuleLayer gameLayer)
{
// This language class is loaded in the system level classloader - before the game even starts
// So we must treat container construction as an arms length operation, and load the container
// in the classloader of the game - the context classloader is appropriate here.
try
{
final Class<?> fmlContainer = Class.forName("net.minecraftforge.fml.javafmlmod.FMLModContainer", true, Thread.currentThread().getContextClassLoader());
LOGGER.debug(LOADING, "Loading FMLModContainer from classloader {} - got {}", Thread.currentThread().getContextClassLoader(), fmlContainer.getClassLoader());
final Constructor<?> constructor = fmlContainer.getConstructor(IModInfo.class, String.class, ModFileScanData.class, ModuleLayer.class);
return (T)constructor.newInstance(info, className, modFileScanResults, gameLayer);
}
catch (InvocationTargetException e) {
LOGGER.fatal(LOADING, "Failed to build mod", e);
if (e.getTargetException() instanceof ModLoadingException mle) {
throw mle;
} else {
throw new ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e);
}
}
catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException e)
{
LOGGER.fatal(LOADING,"Unable to load FMLModContainer, wut?", e);
final Class<RuntimeException> mle = (Class<RuntimeException>)LamdbaExceptionUtils.uncheck(()->Class.forName("net.minecraftforge.fml.ModLoadingException", true, Thread.currentThread().getContextClassLoader()));
final Class<ModLoadingStage> mls = (Class<ModLoadingStage>) LamdbaExceptionUtils.uncheck(()->Class.forName("net.minecraftforge.fml.ModLoadingStage", true, Thread.currentThread().getContextClassLoader()));
throw LamdbaExceptionUtils.uncheck(()->LamdbaExceptionUtils.uncheck(()->mle.getConstructor(IModInfo.class, mls, String.class, Throwable.class)).newInstance(info, Enum.valueOf(mls, "CONSTRUCT"), "fml.modloading.failedtoloadmodclass", e));
}
}
}
public static final Type MODANNOTATION = Type.getType("Lnet/minecraftforge/fml/common/Mod;");
@Override
public String name()
{
return "javafml";
}
@Override
public Consumer<ModFileScanData> getFileVisitor() {
return scanResult -> {
final Map<String, FMLModTarget> modTargetMap = scanResult.getAnnotations().stream()
.filter(ad -> ad.annotationType().equals(MODANNOTATION))
.peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.clazz().getClassName(), ad.annotationData().get("value")))
.map(ad -> new FMLModTarget(ad.clazz().getClassName(), (String)ad.annotationData().get("value")))
.collect(Collectors.toMap(FMLModTarget::getModId, Function.identity(), (a,b)->a));
scanResult.addLanguageLoader(modTargetMap);
};
}
@Override
public <R extends ILifecycleEvent<R>> void consumeLifecycleEvent(final Supplier<R> consumeEvent) {
}
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.javafmlmod;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
public class FMLJavaModLoadingContext
{
private final FMLModContainer container;
FMLJavaModLoadingContext(FMLModContainer container) {
this.container = container;
}
/**
* @return The mod's event bus, to allow subscription to Mod specific events
*/
public IEventBus getModEventBus()
{
return container.getEventBus();
}
/**
* Helper to get the right instance from the {@link ModLoadingContext} correctly.
* @return The FMLJavaMod language specific extension from the ModLoadingContext
*/
public static FMLJavaModLoadingContext get() {
return ModLoadingContext.get().extension();
}
}

View file

@ -0,0 +1,120 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.javafmlmod;
import net.minecraftforge.eventbus.EventBusErrorMessage;
import net.minecraftforge.eventbus.api.BusBuilder;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.IEventListener;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModLoadingException;
import net.minecraftforge.fml.ModLoadingStage;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.Optional;
public class FMLModContainer extends ModContainer
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Marker LOADING = MarkerManager.getMarker("LOADING");
private final ModFileScanData scanResults;
private final IEventBus eventBus;
private Object modInstance;
private final Class<?> modClass;
public FMLModContainer(IModInfo info, String className, ModFileScanData modFileScanResults, ModuleLayer gameLayer)
{
super(info);
LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className);
this.scanResults = modFileScanResults;
activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod);
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).markerType(IModBusEvent.class).useModLauncher().build();
this.configHandler = Optional.of(ce->this.eventBus.post(ce.self()));
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
this.contextExtension = () -> contextExtension;
try
{
var layer = gameLayer.findModule(info.getOwningFile().moduleName()).orElseThrow();
modClass = Class.forName(layer, className);
LOGGER.trace(LOADING,"Loaded modclass {} with {}", modClass.getName(), modClass.getClassLoader());
}
catch (Throwable e)
{
// When a mod constructor throws an exception, it's wrapped in an InvocationTargetException which hides the
// actual exception from the mod loading error screen.
if (e instanceof InvocationTargetException wrapped)
e = Objects.requireNonNullElse(wrapped.getCause(), e); // unwrap the exception
LOGGER.error(LOADING, "Failed to load class {}", className, e);
throw new ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e);
}
}
private void onEventFailed(IEventBus iEventBus, Event event, IEventListener[] iEventListeners, int i, Throwable throwable)
{
LOGGER.error(new EventBusErrorMessage(event, i, iEventListeners, throwable));
}
private void constructMod()
{
try
{
LOGGER.trace(LOADING, "Loading mod instance {} of type {}", getModId(), modClass.getName());
this.modInstance = modClass.getDeclaredConstructor().newInstance();
LOGGER.trace(LOADING, "Loaded mod instance {} of type {}", getModId(), modClass.getName());
}
catch (Throwable e)
{
LOGGER.error(LOADING,"Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e);
throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
}
try {
LOGGER.trace(LOADING, "Injecting Automatic event subscribers for {}", getModId());
AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader());
LOGGER.trace(LOADING, "Completed Automatic event subscribers for {}", getModId());
} catch (Throwable e) {
LOGGER.error(LOADING,"Failed to register automatic subscribers. ModID: {}, class {}", getModId(), modClass.getName(), e);
throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
}
}
@Override
public boolean matches(Object mod)
{
return mod == modInstance;
}
@Override
public Object getMod()
{
return modInstance;
}
public IEventBus getEventBus()
{
return this.eventBus;
}
@Override
protected <T extends Event & IModBusEvent> void acceptEvent(final T e) {
try {
LOGGER.trace(LOADING, "Firing event for modid {} : {}", this.getModId(), e);
this.eventBus.post(e);
LOGGER.trace(LOADING, "Fired event for modid {} : {}", this.getModId(), e);
} catch (Throwable t) {
LOGGER.error(LOADING,"Caught exception during event {} dispatch for modid {}", e, this.getModId(), t);
throw new ModLoadingException(modInfo, modLoadingStage, "fml.modloading.errorduringevent", t);
}
}
}

View file

@ -0,0 +1,11 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/</h1><hr><pre><a href="../">../</a>
<a href="AutomaticEventSubscriber.java">AutomaticEventSubscriber.java</a> 07-Oct-2023 14:12 3812
<a href="FMLJavaModLanguageProvider.java">FMLJavaModLanguageProvider.java</a> 07-Oct-2023 14:12 5146
<a href="FMLJavaModLoadingContext.java">FMLJavaModLoadingContext.java</a> 07-Oct-2023 14:12 924
<a href="FMLModContainer.java">FMLModContainer.java</a> 06-Nov-2023 18:00 5321
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="600bb485f41808a0f0b4cc37ca5aaff7" data-cf-beacon='{"rayId":"85f027108c421c5c","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/java/net/minecraftforge/</h1><hr><pre><a href="../">../</a>
<a href="fml/">fml/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="7ba908f4e3ff304db3c1b2dc578c794e" data-cf-beacon='{"rayId":"85f016d96a2950c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/</h1><hr><pre><a href="../">../</a>
<a href="services/">services/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="82a2a468550d404955719efbf616432c" data-cf-beacon='{"rayId":"85f016272f1050c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/services/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/META-INF/services/</h1><hr><pre><a href="../">../</a>
<a href="net.minecraftforge.forgespi.language.IModLanguageProvider">net.minecraftforge.forgespi.language.IModLangua..&gt;</a> 07-Oct-2023 14:12 61
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="182ac73c4d7449ae63c2f7cf70e4d493" data-cf-beacon='{"rayId":"85f016dbf9bb50c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1 @@
net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider

View file

@ -0,0 +1,8 @@
<html>
<head><title>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/</title></head>
<body>
<h1>Index of /mirror/src/Magma-1-20-x/javafmllanguage/src/main/resources/</h1><hr><pre><a href="../">../</a>
<a href="META-INF/">META-INF/</a> 07-Oct-2023 14:12 -
</pre><hr><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" nonce="dd506bae359c309eb0bfd876813b46cb" data-cf-beacon='{"rayId":"85f015ab29c250c2","version":"2024.2.4","r":1,"token":"583109dda43e47a593fd006526a81120","b":1}' crossorigin="anonymous"></script>
</body>
</html>