Skip to content
Shipping PKL Schemas in Your Jar

Shipping PKL Schemas in Your Jar

Let your users write typed PKL against your mod’s formats, without pkl4mc having to bundle your schemas.

1. Ship the schema as a resource

Put your schema in your jar under pkl/schema/:

src/main/resources/pkl/schema/machines.pkl

2. Register your classloader

From your mod’s init:

PklSchemaRegistry.register("mymod", MyMod::class.java.classLoader)

3. Users import it

Any .pkl file can now resolve your schema through the pklmc: scheme with your mod id as prefix:

amends "pklmc:mymod:machines.pkl"

pkl4mc’s module resolver looks up the registered classloader and loads pkl/schema/machines.pkl from your jar. Relative imports between your own schema files work normally.

Tips

  • Declare the JSON output renderer inside your schema so users never write output blocks.
  • Ship /// doc comments. pkl-lsp shows them on hover in users’ editors.
  • Ingredient-style id unions from the dump command are pkl4mc-internal. Type your fields as String, or define your own unions.