mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
Move Registry Events to the mod event bus.
Add infrastructure to allow parallel or synchronous dispatch of mod events, and pass-through of events to the dispatch system. Signed-off-by: cpw <[email protected]>
This commit is contained in:
9 files changed
+162
-88
No files matched your search
@@ -39,7 +39,8 @@ 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.common.MinecraftForge.EVENT_BUS}
|
||||
* annotations and passes the class instances to the {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus}
|
||||
* defined by the annotation. Defaults to {@link MinecraftForge#EVENT_BUS}
|
||||
*/
|
||||
public class AutomaticEventSubscriber
|
||||
{
|
||||
@@ -60,10 +61,11 @@ public class AutomaticEventSubscriber
|
||||
final EnumSet<Dist> sides = sidesValue.stream().map(eh -> Dist.valueOf(eh.getValue())).
|
||||
collect(Collectors.toCollection(() -> EnumSet.noneOf(Dist.class)));
|
||||
final String modId = (String)ad.getAnnotationData().getOrDefault("modId", mod.getModId());
|
||||
final Mod.EventBusSubscriber.Bus busTarget = (Mod.EventBusSubscriber.Bus)ad.getAnnotationData().getOrDefault("bus", Mod.EventBusSubscriber.Bus.FORGE);
|
||||
if (Objects.equals(mod.getModId(), modId) && sides.contains(FMLEnvironment.dist)) {
|
||||
try
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(Class.forName(ad.getClassType().getClassName(), true, loader));
|
||||
busTarget.bus().get().register(Class.forName(ad.getClassType().getClassName(), true, loader));
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user