From 4f6c61bd10a62584f02431316d4139b178191bf1 Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Sun, 12 Feb 2023 19:01:48 +0000 Subject: [PATCH 1/4] Create 0000-normalize-mod-ids.md --- rfc/0000-normalize-mod-ids.md | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rfc/0000-normalize-mod-ids.md diff --git a/rfc/0000-normalize-mod-ids.md b/rfc/0000-normalize-mod-ids.md new file mode 100644 index 00000000..c00f5baa --- /dev/null +++ b/rfc/0000-normalize-mod-ids.md @@ -0,0 +1,49 @@ + +# Normalise Mod ID Separators + +## Summary + +Treat dashes and underscores as the same for mod id comparison purposes. + +## Motivation + +An occasional cause for confusion is when two different mods only differ by underscores (`_`) and dashes(`-`) in their mod-ids. Since those characters aren't usually used to discriminate between mods, I propose we consider them as the same for the purposes of mod resolution and solving. + +## Explanation + +I propose we normalise all quilt mod-ids by replacing every dash (`-`) and underscore (`_`) with an internal character (likely `#`, but any character that's not permitted by the specification, and is unlikely to be part of the specification in the future, would work. Ascii is preferable due to string optimisations though). + +This normalisation would purely happen internally to quilt-loader, and wouldn't be shown to users, or exposed in methods like `ModContainer.getId()`. Instead this would allow dependencies and breaks to accidently target the wrong ID without causing issues, and would automatically cause mods with underscores or dashes to "provide" the other representations automatically. + +For example, a mod with an ID "potion_craft-expanded" would result in: +- `QuiltLoader.getModContainer("potion_craft-expanded")` would return the mod +- `QuiltLoader.getModContainer("potion-craft-expanded")` would return the same mod +- The same mod is also returned for strings `potion_craft_expanded` and `potion-craft_expanded` +- `QuiltLoader.isModLoaded` would return true for all 4 strings +- `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id. +- `QuiltLoader.getAllMods().stream().filter(mod -> mod.metadata().id().equals("potion_craft-expanded")).toList()` would result in a single mod in the list. +- `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (if no provided entries exist in the quilt.mod.json) + + +## Drawbacks + +If someone intentionally uses dashes and underscores as a way to differentiate mods then their mods will be broken by this change. Personally I think this is unlikely though. + + +## Rationale and Alternatives + +We could instead normalise all dashes to underscores (or vice versa) but that has a few issues: +* During debugging, it won't be easy to tell if a string contains a normalised modid or a non-normalised id, leading to more bugs. +* We'd have to choose a favourite character, which could result in a fairly lengthy debate. Sidestepping that seems useful. + +We could even remove both characters entirely during normalisation, so `quilt_loader` would get normalised to `quiltloader`. However this has another problem, in addition to those listed above: +* It disallows the use of separator characters in mod-ids, which are genuinly quite useful. + +## Prior Art + +I'm not aware of forge, fabric, or quilt related projects doing this before. + +## Unresolved questions + +I'm not certain what character should be used, but '#' seems like a good candidate. +I'm not sure if calls to `QuiltLoader.getModContainer` or `QuiltLoader.isModLoaded` using the normalised ID should return the mod, null, or if that should be left unspecified. From f1c584750efbe65de4614a150d7f8162a2790762 Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Sun, 12 Feb 2023 19:05:57 +0000 Subject: [PATCH 2/4] Update 0000-normalize-mod-ids.md --- rfc/0000-normalize-mod-ids.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rfc/0000-normalize-mod-ids.md b/rfc/0000-normalize-mod-ids.md index c00f5baa..36a88347 100644 --- a/rfc/0000-normalize-mod-ids.md +++ b/rfc/0000-normalize-mod-ids.md @@ -19,9 +19,10 @@ For example, a mod with an ID "potion_craft-expanded" would result in: - `QuiltLoader.getModContainer("potion_craft-expanded")` would return the mod - `QuiltLoader.getModContainer("potion-craft-expanded")` would return the same mod - The same mod is also returned for strings `potion_craft_expanded` and `potion-craft_expanded` +- The returned `ModContainer` will return `potion_craft-expanded` from `ModContainer.metadata().id()`. - `QuiltLoader.isModLoaded` would return true for all 4 strings - `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id. -- `QuiltLoader.getAllMods().stream().filter(mod -> mod.metadata().id().equals("potion_craft-expanded")).toList()` would result in a single mod in the list. +- `QuiltLoader.getAllMods()` will only contain a single entry - `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (if no provided entries exist in the quilt.mod.json) From bf3ff04076a8e83b648d8b34a00c88a70960e6ea Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Sun, 12 Feb 2023 19:08:44 +0000 Subject: [PATCH 3/4] Rename 0000-normalize-mod-ids.md to 0000-normalise-mod-ids.md --- rfc/{0000-normalize-mod-ids.md => 0000-normalise-mod-ids.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rfc/{0000-normalize-mod-ids.md => 0000-normalise-mod-ids.md} (100%) diff --git a/rfc/0000-normalize-mod-ids.md b/rfc/0000-normalise-mod-ids.md similarity index 100% rename from rfc/0000-normalize-mod-ids.md rename to rfc/0000-normalise-mod-ids.md From 059401eb0f481cb3ecdd1dd53069857d1df48e74 Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Sun, 12 Feb 2023 19:12:27 +0000 Subject: [PATCH 4/4] Update and rename 0000-normalise-mod-ids.md to 0070-normalise-mod-ids.md --- rfc/{0000-normalise-mod-ids.md => 0070-normalise-mod-ids.md} | 1 - 1 file changed, 1 deletion(-) rename rfc/{0000-normalise-mod-ids.md => 0070-normalise-mod-ids.md} (99%) diff --git a/rfc/0000-normalise-mod-ids.md b/rfc/0070-normalise-mod-ids.md similarity index 99% rename from rfc/0000-normalise-mod-ids.md rename to rfc/0070-normalise-mod-ids.md index 36a88347..be078352 100644 --- a/rfc/0000-normalise-mod-ids.md +++ b/rfc/0070-normalise-mod-ids.md @@ -1,4 +1,3 @@ - # Normalise Mod ID Separators ## Summary