Skip to content

feat!: Use entrypoints and RendererProvider for more reliable Renderer registry#5185

Open
sylv256 wants to merge 29 commits intoFabricMC:26.1from
sylv256:rendering-0
Open

feat!: Use entrypoints and RendererProvider for more reliable Renderer registry#5185
sylv256 wants to merge 29 commits intoFabricMC:26.1from
sylv256:rendering-0

Conversation

@sylv256
Copy link
Member

@sylv256 sylv256 commented Feb 4, 2026

Problem

Because Renderer can be rendered at any point before or during Minecraft's initialization until it is used, problems arise when it's necessary to use it early. For example, in order to disable Indigo, FRAPI implementations need to add a custom field to their fabric.mod.json. Renderers should not need to add a field to their FMJ just to disable Indigo, let alone any other Renderer. Also, mods extending FRAPI such as Conduit need a defined point in time during and after which Renderer is ready to use. All of this introduces inconsistent behavior and quickly becomes a headache. See #3109 for more details.

Solution

This Pull Request overhauls and adds new concepts to FRAPI's Renderer registration.

RendererProvider

interface RendererProvider {
    static String getModId() { // Gets or finds the mod ID RendererProvider for the renderer that will be loaded
        // ...
    }

    @ApiStatus.OverrideOnly
    Renderer getRenderer(); // Gets or instantiates the Renderer implementation

    @ApiStatus.OverrideOnly
    default Collection<String> getOverrides() { // Renderers that this renderer overrides (any listed will not load)
        return List.of("fabric-renderer-indigo");
    }
}

Instead of manually calling Renderer#register, renderers are now registered with an entrypoint fabric-renderer-api-v1:renderer_provider set to the implementation of RendererProvider. This lets mods get basic information about the renderer that will be loaded at any point during the game's execution as they can be loaded immediately, and this is especially useful for Mixin Config Plugins.

The entrypoints section will look as follows:

"entrypoints": {
  "fabric-renderer-api-v1:renderer_provider": [
    "tiny.potato.renderer.impl.RendererProviderImpl"
  ]
}

and the class:

public final class RendererProviderImpl implements RendererProvider {
    private static Renderer renderer;

    @Override
    public Renderer getRenderer() {
        if (renderer == null) {
            renderer = new RendererImpl();
        }

        return renderer;
    }
}

Justification

Sometimes, mods will want to use Renderer right away, and this is where the issues with the prior system really reveal themselves. Previously, if a mod wanted Renderer, they would have to either use Renderer#get and hope it's already registered, or they would Mixin into Renderer#register to ensure that Renderer has been registered before using it.

Conduit is a library built to create and implement extensions for FRAPI. In order for Conduit's extensions, implementations, and users to use FRAPI and Conduit effectively, it must be possible to get the Renderer instance early. Some operations are best done at mod initialization after Renderer has been initialized, so having a lazily initialized Renderer to ensure code that requires Renderer does not use it before it is registered is powerful.

Tests & Integrity

I've added two checks: one in FRAPI itself to ensure a renderer is loaded, and a unit test to ensure the override ordering is correct. If either of these conditions fail, an exception is thrown.

Additional Information

Proof that it works
image

Fixes #3109

@sylv256 sylv256 added module: renderer indigo Pull requests and issues related to Indigo's implementation of the rendering api area: rendering labels Feb 4, 2026
@sylv256 sylv256 marked this pull request as draft February 4, 2026 05:54
@sylv256
Copy link
Member Author

sylv256 commented Feb 4, 2026

Setting to draft as changes were requested

 - Crash when no `RendererProvider` is present
 - Replace `fabric-renderer-indigo:contains_renderer` mechanism with the `RendererProvider#priority` system
# Conflicts:
#	fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/client/renderer/v1/Renderer.java
#	fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/impl/client/renderer/RendererManager.java
#	fabric-renderer-indigo/src/client/java/net/fabricmc/fabric/impl/client/indigo/Indigo.java
#	fabric-renderer-indigo/src/client/java/net/fabricmc/fabric/impl/client/indigo/IndigoMixinConfigPlugin.java
#	fabric-renderer-indigo/src/client/java/net/fabricmc/fabric/impl/client/indigo/renderer/IndigoRenderer.java
@sylv256 sylv256 marked this pull request as ready for review February 4, 2026 20:55
@PepperCode1 PepperCode1 self-requested a review February 5, 2026 04:22
@sylv256
Copy link
Member Author

sylv256 commented Feb 6, 2026

???
image

@sylv256 sylv256 changed the title feat!: Use ServiceLoader for Renderer registry, RendererReadyEntrypoint feat!: Use entrypoints and RendererProvider for Renderer registry Feb 10, 2026
@sylv256 sylv256 changed the title feat!: Use entrypoints and RendererProvider for Renderer registry feat!: Use entrypoints and RendererProvider for more reliable Renderer registry Feb 10, 2026
…/client/renderer/v1/RendererProvider.java

Co-authored-by: PepperCode1 <44146161+PepperCode1@users.noreply.github.com>
Copy link
Member

@Juuxel Juuxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look fine assuming this is something that renderer impls and consumers want (I'm not a huge expert in this area), just some minor comments from me.

Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

@modmuss50 modmuss50 added the status: last call If you care, make yourself heard right away! label Feb 11, 2026
@modmuss50
Copy link
Member

This is ready to merge, I can either do it now before the rendering API has been ported to the latest snapshot or after? Im not sure what is better.

@modmuss50 modmuss50 added the status: merge me please Pull requests that are ready to merge label Feb 15, 2026
@sylv256
Copy link
Member Author

sylv256 commented Feb 16, 2026

This is ready to merge, I can either do it now before the rendering API has been ported to the latest snapshot or after? Im not sure what is better.

Go ahead and merge this. The port is likely going to take a while, and I don't think this will interfere much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: rendering module: renderer indigo Pull requests and issues related to Indigo's implementation of the rendering api status: last call If you care, make yourself heard right away! status: merge me please Pull requests that are ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FRAPI relies on mod load order

4 participants