Skip to content

Commit

Permalink
Add additional docs for OneConfig dep system
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Nov 29, 2024
1 parent cf27a6f commit 1314fe6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 4 additions & 0 deletions buildSrc/README.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int, Int, Int>?, loader: String): List<OCDependency> { // Either a String or ExternalModuleDependency
val libs = project
.extensions
Expand Down
25 changes: 21 additions & 4 deletions modules/dependencies/README.md
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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?
Expand All @@ -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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1314fe6

Please sign in to comment.