Skip to content

Commit 1314fe6

Browse files
committed
Add additional docs for OneConfig dep system
1 parent cf27a6f commit 1314fe6

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

buildSrc/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# `buildSrc` module
2+
3+
This module contains the `addDependencies` file, which is used to generate a list of dependencies given the platform version and mod loader.
4+
In order to add a dependency, you simply add it to the `addDependencies` file in the `buildSrc` module. The method will automatically handle the rest.

buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import org.gradle.api.Project
44
import org.gradle.api.artifacts.VersionCatalogsExtension
55
import org.gradle.kotlin.dsl.getByType
66

7+
/**
8+
* Provides the dependencies that should be included in the final jar.
9+
* All deps are marked NON-TRANSITIVE; thus, all transitive deps must be explicitly included.
10+
* @param version The version of Minecraft. If null, the method is running inside the `:dependencies:legacy` module.
11+
* @param loader The mod loader being used.
12+
*/
713
fun Project.provideIncludedDependencies(version: Triple<Int, Int, Int>?, loader: String): List<OCDependency> { // Either a String or ExternalModuleDependency
814
val libs = project
915
.extensions

modules/dependencies/README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# OneConfig dependencies
22

3-
This directory contains the dependencies for the OneConfig project.
3+
This directory contains the dependencies for the OneConfig project (well, not really, but we'll get to that later).
4+
5+
## TLDR:
6+
Dealing with mod loaders suck, but we figured it out. Go to the `buildSrc`
7+
module and go to the `addDependencies` file to modify our dependencies list.
8+
In most cases, you should not need to touch anything in this module or any other
9+
buildscript.
410

511
## Complications
612
The dependencies we use are also used by various other projects. Hence,
@@ -28,8 +34,7 @@ of handling dependencies, with varying levels of complexity:
2834
Fabric.
2935

3036
In addition, the `UniversalCraft` library is per-MC version, adding a new
31-
level of complexity, LWJGL is split between LWJGL2 (1.12 and below) and
32-
LWJGL3 (1.13 and above), and we require the `PolyMixin` library for
37+
level of complexity, and we require the `PolyMixin` library for
3338
1.12.2 and below.
3439

3540
## So... what do we do?
@@ -43,4 +48,16 @@ LWJGL3 (1.13 and above), and we require the `PolyMixin` library for
4348
- **On Fabric:** We use the `include` configuration to include the
4449
dependencies in the final JAR file.
4550
- **On NeoForge / modern Forge with JiJ:** We use the same system as
46-
Fabric.
51+
Fabric.
52+
53+
## Ok... but how do you actually do it?
54+
55+
(Here comes the stupidity)
56+
57+
At this point, it's not worth putting everything in the platform module's
58+
buildscript. This would require mental gymnastics that would make this
59+
even more complicated than it already is. So we have a `buildSrc` module
60+
that contains a method to generate a list of dependencies given the platform
61+
version and mod loader. In order to add a dependency, you simply add it
62+
to the `addDependencies` file in the `buildSrc` module. The method will
63+
automatically handle the rest.

versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.polyfrost.oneconfig.api.hud.v1.HudManager;
3838
import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils;
3939
import org.polyfrost.oneconfig.api.platform.v1.Platform;
40+
import org.polyfrost.oneconfig.api.ui.v1.UIManager;
4041
import org.polyfrost.oneconfig.api.ui.v1.internal.BlurHandler;
4142
import org.polyfrost.oneconfig.api.ui.v1.keybind.OCKeybindHelper;
4243
import org.polyfrost.oneconfig.internal.ui.OneConfigUI;
@@ -137,7 +138,9 @@ private static void preloadPolyUI() {
137138

138139
// OneConfig PolyUI renderer
139140
// todo: fix for fabric loaders as fails due to running too early
140-
// UIManager.INSTANCE.getRenderer();
141+
//#if FORGE
142+
UIManager.INSTANCE.getRenderer();
143+
//#endif
141144
} catch (Exception e) {
142145
throw new IllegalStateException("Failed to preload necessary PolyUI classes", e);
143146
}

0 commit comments

Comments
 (0)