quilt-loader icon indicating copy to clipboard operation
quilt-loader copied to clipboard

Add mutable filesystem overlays

Open AlexIIL opened this issue 3 months ago • 0 comments

This allows mods to add new files to their own filesystem via a separate "overlay" filesystem.

This allows mods to dynamically generate resources that will be automatically picked up by fabric-api or QSL's resource loading system, and they can be used by minecraft. This is somewhat similar to mods like ARRP, and QSL's InMemoryPack, except this is independent to the resource loader (and minecraft version).

Adding .class files in this way doesn't work, as quilt-loader has optimizations in place to make searching for classes faster. I don't expect this to be a major problem since mods can already define new classes with their own class loader.

A related new feature this adds to all quilt extended filesystems is dynamic files - these are defined as a Supplier<byte[]>, and generate the file contents every time they are accessed.

Mods must opt-in to this feature at the moment, by adding this to their quilt_loader block inside their quilt.mod.json file:

"required_features": [ "modifiable_filesystem_overlay" ]

The file system overlay can be accessed via ModContainer.getMutableFileOverlay(), which throws an UnsupportedOperationException if the mod hasn't requested the feature. Attempting to modify the mod via ModContainer.rootPath() will not work.

I originally wanted to support modifying the mod's entire filesystem, which would allow removing files and folders rather than just adding them. Unfortunately this would likely require mounting folders inside of an ExtendedFileSystem (to allow mods to reload resources inside a development environment) but this is a lot harder to implement than I first thought, so I'll leave that until later.

This also needs to be actually defined in the quilt.mod.json spec.

AlexIIL avatar Sep 03 '25 00:09 AlexIIL