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

[RFC] Extension API #47

@5GameMaker

Description

@5GameMaker

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]);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions