Lithium (Fabric)

Lithium (Fabric)

22M Downloads

Add API

Earthcomputer opened this issue ยท 11 comments

commented

Hi there,
I have come across a situation where my mod is incompatible with one of the optimizations in Lithium, and I would like a way to detect whether this optimization is enabled, and give the user a friendly message to disable this optimization.
Could you provide an API to enable other mods to determine which Lithium optimizations are enabled?
Thanks! ~Earth

commented

This could work as a temporary substitute until something official comes along, haven't tested it though

        try {
            if(LithiumConfig.SomeConfig.*) {
                ...
            }
        } catch (ClassNotFoundException e) {
            System.out.println("Lithium not loaded");
        }
commented

wait actually don't do that, there's an official way to do it

if(net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("Lithium") && LithiumConfig....) {
   ...
}
commented

The configuration file is not a stable type and we often add/remove fields from it (which would likely lead to a high maintenance burden on other mod author's part). As things are in a state of rather rapid iteration, providing a stable API to Lithium will be difficult. I will have to give this problem some thought.

If you don't mind me asking, what is the compatibility issue you are experiencing with Lithium? We may be able to resolve the issue without writing checks against each other's mods.

commented

If you don't mind me asking, what is the compatibility issue you are experiencing with Lithium?

Unfortunately my mod has to mess around with TrackedData, which conflicts with Lithium's array format.

commented

well, alternatively a simple set of all the active optimization names should be sufficient, at least I think, the only case where it would cause problems would be if a optimization was renamed (which is a valid concern but I don't think it's awfully difficult to solve)

commented

what would an api consist of in the event one is needed though

commented

what would an api consist of in the event one is needed though

Something like

public interface LithiumApi {
   Set<String> getCategories();
   Set<String> getOptions(String category);
   boolean isEnabled(String category, String option);
}
commented

hm, one for disabling optimizations would be something to look into as well if it's integral to the mod itself without having to ask the user to do it themselves, but I have no idea how to make that work

commented

That's not really possible, please refer to the discussion in #7

commented

Actually scratch that, it's possible. You could do something similar to the ModMenu API to ask mods whether a certain category can be enabled or not.

commented

How about make Lithium scan the fabric.mod.json's custom section and see if a mod wishes to disable a certain optimization, and also logging which mod(s) to console?