Package net.neoforged.fml
Class ModContainer
java.lang.Object
net.neoforged.fml.ModContainer
- Direct Known Subclasses:
FMLModContainer
,MinecraftModContainer
The container that wraps around mods in the system.
The philosophy is that individual mod implementation technologies should not impact the actual loading and management of mod code. This class provides a mechanism by which we can wrap actual mod code so that the loader and other facilities can treat mods at arms length.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends net.neoforged.bus.api.Event & IModBusEvent>
voidacceptEvent
(net.neoforged.bus.api.EventPriority phase, T e) Accept an arbitrary event for processing by the mod.final <T extends net.neoforged.bus.api.Event & IModBusEvent>
voidacceptEvent
(T e) Accept an arbitrary event for processing by the mod.protected void
Function invoked by FML to construct the mod, right before the dispatch ofFMLConstructModEvent
.<T extends IExtensionPoint>
Optional<T> getCustomExtension
(Class<T> point) abstract @Nullable net.neoforged.bus.api.IEventBus
Returns the event bus for this mod, if available.final String
getModId()
final String
void
registerConfig
(ModConfig.Type type, IConfigSpec configSpec) Adds aModConfig
with the given type and spec.void
registerConfig
(ModConfig.Type type, IConfigSpec configSpec, String fileName) Adds aModConfig
with the given type, spec, and overridden file name.<T extends IExtensionPoint>
voidregisterExtensionPoint
(Class<T> point, Supplier<T> extension) Registers anIExtensionPoint
with the mod container.<T extends IExtensionPoint>
voidregisterExtensionPoint
(Class<T> point, T extension) Registers anIExtensionPoint
with the mod container.
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
modId
-
namespace
-
modInfo
-
extensionPoints
-
-
Constructor Details
-
ModContainer
-
-
Method Details
-
getModId
- Returns:
- the modid for this mod
-
getNamespace
- Returns:
- the resource prefix for the mod
-
getModInfo
-
getCustomExtension
-
registerExtensionPoint
Registers anIExtensionPoint
with the mod container. -
registerExtensionPoint
public <T extends IExtensionPoint> void registerExtensionPoint(Class<T> point, Supplier<T> extension) Registers anIExtensionPoint
with the mod container. This overload allows passing a supplier that will only be evaluated when the extension is requested. -
registerConfig
Adds aModConfig
with the given type and spec. An empty config spec will be ignored and a debug line will be logged.- Parameters:
type
- The type of configconfigSpec
- A config spec
-
registerConfig
Adds aModConfig
with the given type, spec, and overridden file name. An empty config spec will be ignored and a debug line will be logged.- Parameters:
type
- The type of configconfigSpec
- A config spec
-
constructMod
@OverrideOnly protected void constructMod()Function invoked by FML to construct the mod, right before the dispatch ofFMLConstructModEvent
. -
getEventBus
@Nullable public abstract @Nullable net.neoforged.bus.api.IEventBus getEventBus()Returns the event bus for this mod, if available.Not all mods have an event bus!
- Returns:
- the event bus for this mod, if available
-
acceptEvent
Accept an arbitrary event for processing by the mod. Posted togetEventBus()
.- Parameters:
e
- Event to accept
-
acceptEvent
public final <T extends net.neoforged.bus.api.Event & IModBusEvent> void acceptEvent(net.neoforged.bus.api.EventPriority phase, T e) Accept an arbitrary event for processing by the mod. Posted togetEventBus()
.- Parameters:
e
- Event to accept
-