Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

[RFC] Extension API #47

Open
5GameMaker opened this issue Jun 8, 2023 · 0 comments
Open

[RFC] Extension API #47

5GameMaker opened this issue Jun 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@5GameMaker
Copy link
Member

Overview

Extensions API is a way to extend Rosepad Loader by adding support for other mod loaders to make porting mods to Rosepad easier.

Extensions API should be able to:

  • Patch minecraft.jar before launch
  • Register mods as they were native Rosepad mods

Motivation

As we've seen with modern Minecraft modding, having multiple mod loaders is a hassle. We have mods that only support Fabric, or Forge, or using one of a quadrillion Fabric-Forge compatibility libraries like Architectery. Extensions API aims to remove the need for such compatibility libraries by allowing developers to add support for custom mod loader formats.

Registering a mod

A mod can be marked as an extension by adding main.loader entry to mod.toml

[main]
loader = "net.group.artifact.Extension"

Extension class must extend LoaderExtension class

class Extension extends LoaderExtension {
    // Custom entry point
    public class CustomModEntry implements EntryPoint {
        private JarLoader loader;
        public CustomModEntry(JarLoader loader) {
            this.loader = loader;
        }

        public void pre(Environment env) {
            // do stuff
        }
        public void init(Environment env) {
            // do other stuff
        }
    }

    @Override
    public void main(ExtensionContext context) {
        for (ModCandidate candidate : context.candidates()) {
            // ...do something with mods...
            candidate.register(
                new RosepadModEntry("modid", "1.0.0")
                    .setName("Modname")
                    .addEntryPoint(new CustomModEntry(candidate.getLoader()))
            );
            // Once a mod has been registered, that candidate will
            // not appear for any other mod loader
        }
        Path[] locations = context.patchMinecraftJar(); // Get source and destination
                                                        // paths for minecraft.jar
        Files.copy(locations[0], locations[1]);
    }
}
@5GameMaker 5GameMaker added the enhancement New feature or request label Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant