DimensionalDevelopment / Rift

A lightweight mod loader and API for Minecraft 1.13
MIT License
122 stars 52 forks source link

Add versioning and dependencies to Rift loader #21

Open LemmaEOF opened 6 years ago

LemmaEOF commented 6 years ago

Adds new elements to a Rift mod json: a version String and a dependencies Map<String, String>. The first String in the dependency map is the mod's id, and the second is the minimum version needed.

Version strings are parsed as loose SemVer, and will fail to load (without crashing the game) if there is a missing version (though we might want to give them a dummy version instead for backwards compat). Incorrect dependencies will throw a new MissingDependencyException.

To keep OptiFine being loadable, it has been given its own version string of "1.13".

This is tested and works perfectly. In the future, it would be good to make this crash without closing the Minecraft window a la Forge's dependency catcher, but that's not something I'm able to write at the moment.

Runemoro commented 6 years ago

Thanks for the PR, but I'd like to do dependencies differently. Rather than a map from modid string to version string, I'd like to have a list of Dependency objects with more information about whether they're a soft or hard dependency, whether it should be loaded before or after, what version range is allowed.

I'd also like to implement library dependencies, where the library is automatically downloaded from maven central, or other whitelisted maven repos. This way, mods can remain small in size, yet stay easy to install for users.

Another problem is that you set the Optifine version to 1.13, while it should in fact be 1.13-alpha8, or just "alpha8", with the information that it's just for a 1.13 as a dependency on "minecraft" with the version range [1.13, 1.13].

Adding a dependency on semver isn't necessary, I think. We're using just one feature of it, so that can probably be reimplemented as a simple compareVersions method.

LemmaEOF commented 6 years ago

SemVer is also being used to enforce SemVer versioning, cancelling the mod loading if it has a malformed version.

I don't know Gson that well, so I'm not sure how to add a Dependency into the mod json. Would I just do that by having a Dependency class and let gson work it out?