Skip to content

Commit

Permalink
Port to DGT + add more versions + add OmniCore + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Feb 15, 2025
1 parent 285b846 commit 84e6465
Show file tree
Hide file tree
Showing 137 changed files with 377 additions and 418 deletions.
64 changes: 21 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,52 +1,30 @@
import org.quiltmc.gradle.licenser.extension.QuiltLicenserGradleExtension

plugins {
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.pgt.defaults.repo) apply false
alias(libs.plugins.licenser) apply false
alias(libs.plugins.kotlin) apply(false)
alias(libs.plugins.licenser) apply(false)
alias(libs.plugins.jetbrains.idea.ext)
}

val major = project.properties["version_major"]
val minor = project.properties["version_minor"]
val patch = project.properties["version_patch"]
alias(libs.plugins.dgt.base) apply(false)
}

version = "$major.$minor.$patch"
group = properties["group"] as String
// Note for future devs: DON'T apply the java-library plugin to subprojects here.
// This will cause loom to completely break apart and throw itself into oblivion.
// I have no idea how to fix it, and honestly, I don't want to know.

subprojects {
version = rootProject.version
group = "${rootProject.group}.${rootProject.properties["mod_id"] as String}"

apply(plugin = rootProject.libs.plugins.licenser.get().pluginId)
// Note for future devs: DON'T apply the java-library plugin to subprojects here.
// This will cause loom to completely break apart and throw itself into oblivion.
// I have no idea how to fix it, and honestly, I don't want to know.
apply(plugin = "maven-publish")
apply(plugin = "signing")

afterEvaluate { // ew.
if (project.pluginManager.hasPlugin("java")) {
configure<JavaPluginExtension> {
withSourcesJar()
}
}
}

// configure<QuiltLicenserGradleExtension> {
// rule("${rootProject.rootDir}/FILEHEADER")
// include("**/*.kt")
// include("**/*.java")
// }

configure<PublishingExtension> {
repositories {
arrayOf("releases", "snapshots", "private").forEach { type ->
maven {
name = type
url = uri("https://repo.polyfrost.org/$type")
credentials(PasswordCredentials::class)
authentication { create<BasicAuthentication>("basic") }
pluginManager.withPlugin("java") {
apply(plugin = rootProject.libs.plugins.licenser.get().pluginId)
apply(plugin = rootProject.libs.plugins.dgt.publishing.maven.get().pluginId)
apply(plugin = "signing")

configure<PublishingExtension> {
repositories {
arrayOf("releases", "snapshots", "private").forEach { type ->
maven {
name = type
url = uri("https://repo.polyfrost.org/$type")
credentials(PasswordCredentials::class)
authentication { create<BasicAuthentication>("basic") }
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun Project.provideIncludedDependencies(version: Triple<Int, Int, Int>?, loader:
in 16..18 -> "3.2.2"
19 -> "3.3.1"
20 -> "3.3.2"
21 -> "3.3.3"
else -> error("Unsupported Minecraft version: ${version.toMCVer()}")
}

Expand Down Expand Up @@ -76,6 +77,7 @@ fun Project.provideIncludedDependencies(version: Triple<Int, Int, Int>?, loader:
}
if (version != null) {
actualDeps.add(OCDependency("org.polyfrost:universalcraft-${version.toMCVer()}-$loader:${libs.findVersion("universalcraft").get().displayName}", true))
actualDeps.add(OCDependency("dev.deftu:omnicore-${version.toMCVer()}-$loader:${libs.findVersion("omnicore").get().displayName}", true))
}
return actualDeps
}
Expand Down
30 changes: 12 additions & 18 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
group=org.polyfrost
name=OneConfig
mod_id=oneconfig
version_major=1
version_minor=0
version_patch=0-alpha.65

polyfrost.defaults.loom=3
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
org.gradle.jvmargs=-Xmx2G

kotlin.code.style=official

org.gradle.parallel=true
org.gradle.caching=true
#org.gradle.configuration-cache=true
org.gradle.configureondemand=true
org.gradle.parallel.threads=4
org.gradle.dependency.verification=strict
org.gradle.kotlin.dsl.allWarningsAsErrors=true
org.gradle.kotlin.dsl.precompiled.accessors.strict=true
org.gradle.workers.max=4
org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8
dgt.java.version=8

# Project Configuration
project.group=org.polyfrost
project.name=OneConfig
project.version=1.0.0-alpha.66
26 changes: 14 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ copycat = "0.1.3"
copycat-image-awt = "0.1.1"

# Per version
omnicore = "0.12.0"
universalcraft = "2.0.0"
lwjgl = "3.3.3" # All downloaded by the isolated-lwjgl3-loader

Expand All @@ -29,10 +30,9 @@ mixin-extras = "0.4.1"
asm = "5.2"

# Gradle
dgt = "2.24.0"
kotlinx-abi = "0.14.0"
pgt = "0.6.6"
shadow = "8.1.1"
licenser = "2.0.1"
licenser = "2.1.1"
jetbrains-idea-ext = "1.1.8"

log4j-api = "2.0-beta9" # used because this is the version that 1.8.9 supports, so we have to compile against the same (annoying)
Expand Down Expand Up @@ -97,14 +97,16 @@ test-core = ["junit", "logging-impl"]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-api-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-abi" }

pgt-main = { id = "org.polyfrost.multi-version", version.ref = "pgt" }
pgt-root = { id = "org.polyfrost.multi-version.root", version.ref = "pgt" }
pgt-api-validator = { id = "org.polyfrost.multi-version.api-validation", version.ref = "pgt" }
pgt-default = { id = "org.polyfrost.defaults", version.ref = "pgt" }
pgt-defaults-repo = { id = "org.polyfrost.defaults.repo", version.ref = "pgt" }
pgt-defaults-java = { id = "org.polyfrost.defaults.java", version.ref = "pgt" }

shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
licenser = { id = "org.quiltmc.gradle.licenser", version.ref = "licenser" }
dgt-base = { id = "dev.deftu.gradle.tools", version.ref = "dgt" }
dgt-multiversion-platform = { id = "dev.deftu.gradle.multiversion", version.ref = "dgt" }
dgt-multiversion-root = { id = "dev.deftu.gradle.multiversion-root", version.ref = "dgt" }
dgt-java = { id = "dev.deftu.gradle.tools.java", version.ref = "dgt" }
dgt-kotlin = { id = "dev.deftu.gradle.tools.kotlin", version.ref = "dgt" }
dgt-resources = { id = "dev.deftu.gradle.tools.resources", version.ref = "dgt" }
dgt-shadow = { id = "dev.deftu.gradle.tools.shadow", version.ref = "dgt" }
dgt-publishing-maven = { id = "dev.deftu.gradle.tools.publishing.maven", version.ref = "dgt" }
dgt-loom = { id = "dev.deftu.gradle.tools.minecraft.loom", version.ref = "dgt" }

licenser = { id = "dev.yumi.gradle.licenser", version.ref = "licenser" }

jetbrains-idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "jetbrains-idea-ext" }
File renamed without changes.
File renamed without changes.
161 changes: 161 additions & 0 deletions minecraft/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
@file:Suppress("UnstableApiUsage")
// Shared build logic for all versions of OneConfig.

import dev.deftu.gradle.utils.GameSide
import dev.deftu.gradle.utils.MinecraftVersion
import dev.deftu.gradle.utils.includeOrShade
import org.polyfrost.gradle.provideIncludedDependencies
import java.text.SimpleDateFormat

plugins {
java
alias(libs.plugins.kotlin)
id(libs.plugins.dgt.multiversion.platform.get().pluginId)
id(libs.plugins.dgt.base.get().pluginId)
id(libs.plugins.dgt.resources.get().pluginId)
id(libs.plugins.dgt.loom.get().pluginId)
id(libs.plugins.dgt.shadow.get().pluginId)
}

toolkitLoomHelper {
disableRunConfigs(GameSide.SERVER)

useProperty("mixin.debug.export", "true", GameSide.CLIENT)
useProperty("debugBytecode", "true", GameSide.CLIENT)
useProperty("forge.logging.console.level", "debug", GameSide.CLIENT)
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX) {
useProperty("fml.earlyprogresswindow", "false", GameSide.CLIENT)
}

if (mcData.isForge) {
useForgeMixin(modData.id)
}

if (mcData.isLegacyForge) {
useTweaker("org.polyfrost.oneconfig.internal.legacy.OneConfigTweaker")
}
}

if (mcData.isForge) {
loom.forge.mixinConfig("mixins.${modData.id}.init.json")
}

repositories {
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
maven("https://repo.hypixel.net/repository/Hypixel/")
maven("https://maven.deftu.dev/releases")
}

val shadow by configurations.creating

if (mcData.isLegacyForge) { // Quick substitution for relaunch in dev env, so that mixinextras works properly (yay!)
configurations.all {
resolutionStrategy {
dependencySubstitution {
all {
if (requested is ModuleComponentSelector) {
val module = (requested as ModuleComponentSelector)
if (module.group == "org.ow2.asm" && module.version == "5.0.3") {
logger.warn("Substituting ${module.group}:${module.module}:${module.version} with ${libs.asm.get()}")
useTarget(module.group + ":" + module.module + ":" + libs.asm.get().version)
}
}
}
}
}
}
}

dependencies {
compileOnly("gg.essential:vigilance-1.8.9-forge:295") {
isTransitive = false
}

provideIncludedDependencies(Triple(mcData.version.major, mcData.version.minor, mcData.version.patch), mcData.loader.friendlyString).forEach {
if (it.dep is String) {
shade(it.dep as String, it.mod)
} else {
shade(it.dep as ExternalModuleDependency, it.mod)
}
}

annotationProcessor(libs.mixin.extras)

for (dep in listOf("-nanovg").run { if (mcData.version < MinecraftVersion.VERSION_1_13) this else this + listOf("-tinyfd", "-stb", "") }) {
val lwjglDep = "org.lwjgl:lwjgl$dep:${libs.versions.lwjgl.get()}"
compileOnlyApi(lwjglDep) {
isTransitive = false
}
}

implementation(project(":modules:dependencies:bundled"))
implementation(project(":modules:internal")) {
isTransitive = false
}

if (mcData.isLegacyForge) {
compileOnly("cc.polyfrost:oneconfig-$mcData:0.2.2-alpha216") {
isTransitive = false
}
}
}

fun DependencyHandlerScope.shade(dependency: String, isMod: Boolean = false) {
val dep = project.dependencies.create(dependency) as ExternalModuleDependency
shade(dep, isMod)
}

fun DependencyHandlerScope.shade(dependency: Provider<MinimalExternalModuleDependency>, isMod: Boolean = false) {
shade(dependency.get(), isMod)
}

fun DependencyHandlerScope.shade(dependency: ExternalModuleDependency, isMod: Boolean = false) {
val dep = "${dependency.group}:${dependency.name}:${dependency.version}"
val configuration = if (isMod) modApi(dep) {
isTransitive = false
} else api(dep) {
isTransitive = false
}

includeOrShade(configuration)
}

tasks {
remapJar {
manifest {
val attributesMap = buildMap<String, Any> {
putAll(
mapOf(
"Specification-Title" to modData.id,
"Specification-Vendor" to "Polyfrost",
"Specification-Version" to "1", // We are version 1 of ourselves, whatever the hell that means
"Implementation-Title" to rootProject.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Polyfrost",
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(`java.util`.Date()),
"OneConfig-Main-Class" to "org.polyfrost.oneconfig.internal.bootstrap.Bootstrap"
)
)
}

attributes(attributesMap)
}
}
}

publishing {
publications {
register<MavenPublication>("java") {
from(components["java"])

groupId = group.toString()
artifactId = base.archivesName.get()

signing {
isRequired = project.properties["signing.keyId"] != null
sign(this@register)
}
}
}
}
4 changes: 4 additions & 0 deletions minecraft/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dgt.loom.mappings.flavor=parchment

mod.name=OneConfig
mod.id=oneconfig
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ net.minecraft.client.entity.player.ClientPlayerEntity net.minecraft.client.entit

net.minecraft.client.gui.screen.ChatScreen net.minecraft.client.gui.GuiChat

net.minecraft.client.gui.screen.Screen isPauseScreen() doesGuiPauseGame()
net.minecraft.client.gui.screen.Screen net.minecraft.client.gui.GuiScreen
net.minecraft.client.gui.screen.Screen resize() onResize()
net.minecraft.client.gui.screens.Screen isPauseScreen() doesGuiPauseGame()
net.minecraft.client.gui.screens.Screen net.minecraft.client.gui.GuiScreen
net.minecraft.client.gui.screens.Screen resize() onResize()

net.minecraft.client.gui.widget.button.Button net.minecraft.client.gui.GuiButton
net.minecraft.client.gui.widget.button.Button playDownSound() playPressSound()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 84e6465

Please sign in to comment.