Class PlatformLoader
java.lang.Object
net.dillon.dillonlib.platform.PlatformLoader
Service loaders are a built-in Java feature that allow us to locate implementations of an interface that vary from one
environment to another. In the context of DillonLib we use this feature to access a mock API in the common code that
is swapped out for the platform-specific implementation at runtime.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T> collectionOf(Class<T> clazz) static intExecutes a given task (or method) for all instancesClientModPlatformclasses, and then returns the total amount of client platforms (excluding DillonLib's base client platform).static intexecuteForEachMixinPlatform(Consumer<MixinModPlatform> function) Executes a given task (or method) for all instancesMixinModPlatformclasses, and then returns the total amount of mixin platforms (excluding DillonLib's base mixin platform).static intexecuteForEachPlatform(Consumer<ModPlatform> function) Executes a given task (or method) for all instancesModPlatformclasses, and then returns the total amount of platforms (excluding DillonLib's base platform).static voidi_()Initializes this class.static <T> TThis code is used to load a service for the current environment.
-
Constructor Details
-
PlatformLoader
public PlatformLoader()
-
-
Method Details
-
load
This code is used to load a service for the current environment. Your implementation of the service must be defined manually by including a text file in META-INF/services named with the fully qualified class id of the service. Inside the file you should write the fully qualified class id of the implementation to load for the platform. For example our file on Forge points to ForgePlatformImpl while Fabric points to FabricPlatformImpl.- Parameters:
modId- should matchModPlatformorMixinModPlatformmod id!- See Also:
-
collectionOf
- Returns:
- all service loaders with a specified class. You can use this method in combo with
executeForEachPlatform(Consumer)to execute a task for all instances of a certain platform (an instance ofLoadable. - See Also:
-
executeForEachPlatform
Executes a given task (or method) for all instancesModPlatformclasses, and then returns the total amount of platforms (excluding DillonLib's base platform). -
executeForEachMixinPlatform
Executes a given task (or method) for all instancesMixinModPlatformclasses, and then returns the total amount of mixin platforms (excluding DillonLib's base mixin platform). -
executeForEachClientPlatform
Executes a given task (or method) for all instancesClientModPlatformclasses, and then returns the total amount of client platforms (excluding DillonLib's base client platform). -
i_
public static void i_()Initializes this class.
-