From 1314fe696285abe3ab309b1b64c84b8a29f3b998 Mon Sep 17 00:00:00 2001 From: ev chang Date: Sat, 30 Nov 2024 07:09:53 +0900 Subject: [PATCH] Add additional docs for OneConfig dep system --- buildSrc/README.md | 4 +++ .../org/polyfrost/gradle/addDependencies.kt | 6 +++++ modules/dependencies/README.md | 25 ++++++++++++++++--- .../oneconfig/internal/OneConfig.java | 5 +++- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 buildSrc/README.md diff --git a/buildSrc/README.md b/buildSrc/README.md new file mode 100644 index 000000000..a3a011d45 --- /dev/null +++ b/buildSrc/README.md @@ -0,0 +1,4 @@ +# `buildSrc` module + +This module contains the `addDependencies` file, which is used to generate a list of dependencies given the platform version and mod loader. +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. \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt b/buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt index 9a6d8ad52..8bd2f481f 100644 --- a/buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt +++ b/buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt @@ -4,6 +4,12 @@ import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.getByType +/** + * Provides the dependencies that should be included in the final jar. + * All deps are marked NON-TRANSITIVE; thus, all transitive deps must be explicitly included. + * @param version The version of Minecraft. If null, the method is running inside the `:dependencies:legacy` module. + * @param loader The mod loader being used. + */ fun Project.provideIncludedDependencies(version: Triple?, loader: String): List { // Either a String or ExternalModuleDependency val libs = project .extensions diff --git a/modules/dependencies/README.md b/modules/dependencies/README.md index 468cddc24..c199c5768 100644 --- a/modules/dependencies/README.md +++ b/modules/dependencies/README.md @@ -1,6 +1,12 @@ # OneConfig dependencies -This directory contains the dependencies for the OneConfig project. +This directory contains the dependencies for the OneConfig project (well, not really, but we'll get to that later). + +## TLDR: +Dealing with mod loaders suck, but we figured it out. Go to the `buildSrc` +module and go to the `addDependencies` file to modify our dependencies list. +In most cases, you should not need to touch anything in this module or any other +buildscript. ## Complications The dependencies we use are also used by various other projects. Hence, @@ -28,8 +34,7 @@ of handling dependencies, with varying levels of complexity: Fabric. In addition, the `UniversalCraft` library is per-MC version, adding a new -level of complexity, LWJGL is split between LWJGL2 (1.12 and below) and -LWJGL3 (1.13 and above), and we require the `PolyMixin` library for +level of complexity, and we require the `PolyMixin` library for 1.12.2 and below. ## So... what do we do? @@ -43,4 +48,16 @@ LWJGL3 (1.13 and above), and we require the `PolyMixin` library for - **On Fabric:** We use the `include` configuration to include the dependencies in the final JAR file. - **On NeoForge / modern Forge with JiJ:** We use the same system as - Fabric. \ No newline at end of file + Fabric. + +## Ok... but how do you actually do it? + +(Here comes the stupidity) + +At this point, it's not worth putting everything in the platform module's +buildscript. This would require mental gymnastics that would make this +even more complicated than it already is. So we have a `buildSrc` module +that contains a method to generate a list of dependencies given the platform +version and mod loader. 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. \ No newline at end of file diff --git a/versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java b/versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java index db826d4ba..70e7edfd8 100644 --- a/versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java +++ b/versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java @@ -37,6 +37,7 @@ import org.polyfrost.oneconfig.api.hud.v1.HudManager; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; import org.polyfrost.oneconfig.api.platform.v1.Platform; +import org.polyfrost.oneconfig.api.ui.v1.UIManager; import org.polyfrost.oneconfig.api.ui.v1.internal.BlurHandler; import org.polyfrost.oneconfig.api.ui.v1.keybind.OCKeybindHelper; import org.polyfrost.oneconfig.internal.ui.OneConfigUI; @@ -137,7 +138,9 @@ private static void preloadPolyUI() { // OneConfig PolyUI renderer // todo: fix for fabric loaders as fails due to running too early - // UIManager.INSTANCE.getRenderer(); + //#if FORGE + UIManager.INSTANCE.getRenderer(); + //#endif } catch (Exception e) { throw new IllegalStateException("Failed to preload necessary PolyUI classes", e); }