Skip to content

Encourage depending on a subset of the Fabric API rather than the entire thing #175

@LoganDark

Description

@LoganDark

This project currently depends on the entire Fabric API, with no mention of fabricApi.module:

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

This encourages oversights like QuiltServerTools/Ledger#163, which force server / modpack admins to always include all of Fabric API, even those modules which are not actually required for the mods to function.

The first question on everyone's mind whenever I bring this up is usually "But why in the world wouldn't you want to always include the entirety of Fabric API?", I'll answer that first because it also explains why the current approach isn't the most optimal.

There are API modules that only add harmless mixin hooks, but there are also modules that introduce side effects that may not be needed to support many (or even most) mods. For example, registry sync is only relevant when the registries need syncing (AKA, only when registries are modified), resource loader is only necessary when resources need loading (for example, mod icons for Mod Menu), networking is only necessary when the client needs to know what communication channels the server supports, etc.

Fabric is much, much more performant even with Fabric API than any other mod loader, especially Forge, but having all these unnecessary modules still kind of irks me. Fabric API is designed to be modular and there's already support in Loom for easily declaring support on individual API modules, so why not use it?

I propose commenting out that modImplementation line, and adding one that only depends on a singular module - say fabric-resource-loader-v0 - along with an explanation of what the module does, why include only that module, and how to find the names of other modules you may need. Additionally, in fabric.mod.json, only declare dependencies on the modules you need.

It would look something like this:

	// Declare a dependency on the "fabric-resource-loader-v0" API module.
	// This module loads mod resources and data as resource and data packs.
	// You need it to be able to add textures to blocks, or use TranslatableText.
	// Another useful module is "fabric-registry-sync-v0" if your mod modifies any vanilla registries such as biomes.
	// You can find the full list of modules at https://github.com/FabricMC/fabric - each one has its own directory.
	modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_version))

(That's a rough draft, the final comment would probably look significant different - I'm not great at writing.)

This would teach beginning modders (and also seasoned modders just getting started with Fabric) that Fabric API is not a monolith, and you can pick and choose what you need. This should be encouraged, even - you should be precise, and avoid being too liberal with your dependencies.

This would improve my experience as a modder, as a user, and as a server admin. It will not fix existing mods on its own, but it will set an important precedent for new mods, and serve as a good example for existing ones, encouraging them to switch. I believe this approach is more sustainable than letting every mod depend on the entire ever-growing Fabric API, as not every setup should require every API module to be present.

Plus it would reinforce the fact that Fabric can be a really lightweight mod loader - I love the idea of it just being used to tweak the game and optimize it and build around it. Requiring the entire Fabric API all the time kind of detracts from that, you know?

This may be a niche use case, but I think it's an important one to consider, not because you can expect most or even more than a few Fabric users to install individual API modules, but because, in general, you shouldn't over-depend.

Thanks for reading my super long post, feel free to AMA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions