QuiltMC / quilt-standard-libraries

A set of libraries to assist in making Quilt mods.
Apache License 2.0
152 stars 85 forks source link

Conditional Data API #344

Open RedstoneParadox opened 1 year ago

RedstoneParadox commented 1 year ago

A major flaw with data files is that if you want to add mod compatibility/integration in the form of data files (i.e. adding a recipe for another mod's workstation) is that you need to use mixins to prevent those data files from loading when the other mod is not present, otherwise, the console and logs are spammed with exceptions. Since this deals with inter-mod compatibility, I feel it would be a good fit for QSL to implement.

This API would consist of a simple event that would be fired every time MC finds a data file to load. Listeners would return a boolean to determine whether or not that file should be skipped. Since the most common use case would be checking whether a given mod is present, a helper function would also be available for creating a listener that checks if a given mod is loaded.

In the past, LibCD was used to accomplish this through a separate .mcmeta file for each data file you wanted to have conditionally loaded. In my experience, this approach was far from ergonomic.

lukebemish commented 1 year ago

I feel like the conditionality of data should be, itself, either data driven or possible to make data driven. This could be easily accomplished by hooking such an event up to the data callback system

RedstoneParadox commented 1 year ago

If it is data driven, it has to be more ergonomic than LibCD. That being said, I would personally prefer a code interface.

lukebemish commented 1 year ago

Hooking it up to the data callback system allows you to have both with relative ease