Package de.cech12.bucketlib.platform
Class Services
java.lang.Object
de.cech12.bucketlib.platform.Services
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 MultiLoader we use this feature to access a mock API in the common code that
is swapped out for the platform specific implementation at runtime.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IBucketHelperbucket helper instancestatic final IConfigHelperConfig helper instancestatic final IFluidHelperFluid helper instancestatic final IPlatformHelperPlatform helper instancestatic final IRegistryHelperRegistry helper instance -
Method Summary
-
Field Details
-
BUCKET
bucket helper instance -
CONFIG
Config helper instance -
FLUID
Fluid helper instance -
PLATFORM
Platform helper instance -
REGISTRY
Registry helper instance
-
-
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 name of the service. Inside the file you should write the fully qualified class name of the implementation to load for the platform. For example our file on Forge points to ForgePlatformHelper while Fabric points to FabricPlatformHelper.- Type Parameters:
T- Type of service class- Parameters:
clazz- Service class, which should be loaded.- Returns:
- service instance
-