Skip to content

Extensions

Lortseam edited this page Sep 3, 2023 · 5 revisions

CompleteConfig provides a powerful extension system to support more types, add additional annotations or even implement custom features. To use an extension, subclass the proper extension interface.

DataExtension, ClientDataExtension and ServerDataExtension

DataExtension will be applied in both client and server environment, while the other ones will only be applied in their respective environment.

Method Description
getTypeSerializers Registers global type serializers.
getTransformations Registers global entry transformations.

ClothConfigGuiExtension

This extensions will only be applied when the associated module and library is installed.

Method Description
getProviders Registers global GUI providers.

Register extensions

To register extensions, create a class that implements CompleteConfigExtender:

public class MyCompleteConfigExtender implements CompleteConfigExtender {

    @Override
    public Collection<Class<? extends Extension>> getExtensions() {
        return List.of(MyDataExtension.class, MyClothConfigGuiExtension.class);
    }

}

Now add the completeconfig-extender entrypoint to your fabric.mod.json and add the path to your created extender class:

"entrypoints": {
  "completeconfig-extender": [
    "path.to.MyCompleteConfigExtender"
  ]
}

Child extensions

Every extension type has a children method which can be overriden to register child extensions. Only valid child extensions will be registered at runtime.

public final class MyDataExtension implements DataExtension {

    @Override
    public Set<Class<? extends Extension>> children() {
        return Set.of(MyClientDataExtension.class, MyServerDataExtension.class);
    }

}

Clone this wiki locally