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 voidFunction 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.IEventBusReturns the event bus for this mod, if available.final StringgetModId()final StringvoidregisterConfig(ModConfig.Type type, IConfigSpec configSpec) Adds aModConfigwith the given type and spec.voidregisterConfig(ModConfig.Type type, IConfigSpec configSpec, String fileName) Adds aModConfigwith the given type, spec, and overridden file name.<T extends IExtensionPoint>
voidregisterExtensionPoint(Class<T> point, Supplier<T> extension) Registers anIExtensionPointwith the mod container.<T extends IExtensionPoint>
voidregisterExtensionPoint(Class<T> point, T extension) Registers anIExtensionPointwith 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 anIExtensionPointwith the mod container. -
registerExtensionPoint
public <T extends IExtensionPoint> void registerExtensionPoint(Class<T> point, Supplier<T> extension) Registers anIExtensionPointwith the mod container. This overload allows passing a supplier that will only be evaluated when the extension is requested. -
registerConfig
Adds aModConfigwith 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 aModConfigwith 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
-