Skip to content

Commit 7c1d035

Browse files
authored
Merge branch 'MeteorDevelopment:master' into master
2 parents 29d4a75 + 67b27b8 commit 7c1d035

407 files changed

Lines changed: 10845 additions & 3996 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/builds/mc_version.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@
44
*/
55

66
import * as fs from "fs"
7-
import * as readline from "readline"
7+
import * as path from "path"
8+
import {fileURLToPath} from "url"
89

9-
export async function getMcVersion() {
10-
let lines = readline.createInterface({
11-
input: fs.createReadStream("../../gradle.properties"),
12-
crlfDelay: Infinity
13-
})
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1411

15-
let mcVersion = ""
12+
export async function getMcVersion() {
13+
const filePath = path.resolve(__dirname, "../../gradle/libs.versions.toml")
1614

17-
for await (const line of lines) {
18-
if (line.startsWith("minecraft_version")) {
19-
mcVersion = line.substring(line.indexOf("=") + 1)
20-
break
21-
}
15+
if (!fs.existsSync(filePath)) {
16+
throw new Error(`File not found: ${filePath}`)
2217
}
2318

24-
if (mcVersion === "") {
25-
console.log("Failed to read minecraft_version")
26-
process.exit(1)
27-
}
19+
const content = await fs.promises.readFile(filePath, "utf-8")
20+
21+
const match = content.match(/^\s*minecraft\s*=\s*["']([^"']+)["']\s*$/m)
22+
if (match) return match[1].trim()
2823

29-
return mcVersion
24+
throw new Error(`Failed to find minecraft version in ${filePath}`)
3025
}

build.gradle.kts

Lines changed: 100 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
plugins {
2-
id("fabric-loom") version "1.10-SNAPSHOT"
2+
alias(libs.plugins.fabric.loom)
33
id("maven-publish")
4-
id("com.gradleup.shadow") version "9.0.0-beta11"
54
}
65

76
base {
87
archivesName = properties["archives_base_name"] as String
98
group = properties["maven_group"] as String
109

11-
val suffix = if (project.hasProperty("build_number")) {
12-
project.findProperty("build_number")
13-
} else {
14-
"local"
15-
}
16-
17-
version = properties["minecraft_version"] as String + "-" + suffix
10+
val suffix = providers.gradleProperty("build_number").getOrElse("local")
11+
version = "${libs.versions.minecraft.get()}-$suffix"
1812
}
1913

2014
repositories {
@@ -50,7 +44,7 @@ repositories {
5044
}
5145

5246
val modInclude: Configuration by configurations.creating
53-
val library: Configuration by configurations.creating
47+
val jij: Configuration by configurations.creating
5448

5549
configurations {
5650
// include mods
@@ -61,71 +55,109 @@ configurations {
6155
extendsFrom(modInclude)
6256
}
6357

64-
// include libraries
58+
// include libraries (jar-in-jar)
6559
implementation.configure {
66-
extendsFrom(library)
60+
extendsFrom(jij)
6761
}
68-
shadow.configure {
69-
extendsFrom(library)
62+
include.configure {
63+
extendsFrom(jij)
7064
}
7165
}
7266

7367
dependencies {
7468
// Fabric
75-
minecraft("com.mojang:minecraft:${properties["minecraft_version"] as String}")
76-
mappings("net.fabricmc:yarn:${properties["yarn_mappings"] as String}:v2")
77-
modImplementation("net.fabricmc:fabric-loader:${properties["loader_version"] as String}")
69+
minecraft(libs.minecraft)
70+
mappings(variantOf(libs.yarn) { classifier("v2") })
71+
modImplementation(libs.fabric.loader)
7872

79-
modInclude(fabricApi.module("fabric-api-base", properties["fapi_version"] as String))
80-
modInclude(fabricApi.module("fabric-resource-loader-v0", properties["fapi_version"] as String))
73+
val fapiVersion = libs.versions.fabric.api.get()
74+
modInclude(fabricApi.module("fabric-api-base", fapiVersion))
75+
modInclude(fabricApi.module("fabric-resource-loader-v1", fapiVersion))
8176

8277
// Compat fixes
83-
modCompileOnly(fabricApi.module("fabric-renderer-indigo", properties["fapi_version"] as String))
84-
modCompileOnly("maven.modrinth:sodium:${properties["sodium_version"] as String}") { isTransitive = false }
85-
modCompileOnly("maven.modrinth:lithium:${properties["lithium_version"] as String}") { isTransitive = false }
86-
modCompileOnly("maven.modrinth:iris:${properties["iris_version"] as String}") { isTransitive = false }
87-
modCompileOnly("com.viaversion:viafabricplus:${properties["viafabricplus_version"] as String}") { isTransitive = false }
88-
modCompileOnly("com.viaversion:viafabricplus-api:${properties["viafabricplus_version"] as String}") { isTransitive = false }
89-
90-
// Baritone (https://github.com/MeteorDevelopment/baritone)
91-
modCompileOnly("meteordevelopment:baritone:${properties["baritone_version"] as String}-SNAPSHOT")
92-
// ModMenu (https://github.com/TerraformersMC/ModMenu)
93-
modCompileOnly("com.terraformersmc:modmenu:${properties["modmenu_version"] as String}")
94-
95-
// Libraries
96-
library("meteordevelopment:orbit:${properties["orbit_version"] as String}")
97-
library("org.meteordev:starscript:${properties["starscript_version"] as String}")
98-
library("meteordevelopment:discord-ipc:${properties["discordipc_version"] as String}")
99-
library("org.reflections:reflections:${properties["reflections_version"] as String}")
100-
library("io.netty:netty-handler-proxy:${properties["netty_version"] as String}") { isTransitive = false }
101-
library("io.netty:netty-codec-socks:${properties["netty_version"] as String}") { isTransitive = false }
102-
library("de.florianmichael:WaybackAuthLib:${properties["waybackauthlib_version"] as String}")
103-
104-
// Launch sub project
105-
shadow(project(":launch"))
78+
modCompileOnly(fabricApi.module("fabric-renderer-indigo", fapiVersion))
79+
modCompileOnly(libs.sodium) { isTransitive = false }
80+
modCompileOnly(libs.lithium) { isTransitive = false }
81+
modCompileOnly(libs.iris) { isTransitive = false }
82+
modCompileOnly(libs.viafabricplus) { isTransitive = false }
83+
modCompileOnly(libs.viafabricplus.api) { isTransitive = false }
84+
85+
modCompileOnly(libs.baritone)
86+
modCompileOnly(libs.modmenu)
87+
88+
// Libraries (JAR-in-JAR)
89+
jij(libs.orbit)
90+
jij(libs.starscript)
91+
jij(libs.discord.ipc)
92+
jij(libs.reflections)
93+
jij(libs.netty.handler.proxy) { isTransitive = false }
94+
jij(libs.netty.codec.socks) { isTransitive = false }
95+
jij(libs.waybackauthlib)
10696
}
10797

108-
loom {
109-
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
98+
sourceSets {
99+
val launcher by creating {
100+
java {
101+
srcDir("src/launcher/java")
102+
}
103+
}
104+
}
105+
106+
java {
107+
sourceCompatibility = JavaVersion.VERSION_21
108+
targetCompatibility = JavaVersion.VERSION_21
109+
110+
if (System.getenv("CI")?.toBoolean() == true) {
111+
withSourcesJar()
112+
withJavadocJar()
113+
}
110114
}
111115

116+
// Handle transitive dependencies for jar-in-jar
117+
// Based on implementation from BaseProject by FlorianMichael/EnZaXD
118+
// Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
119+
// Licensed under Apache License 2.0
112120
afterEvaluate {
113-
tasks.migrateMappings.configure {
114-
outputDir.set(project.file("src/main/java"))
121+
val jijConfig = configurations.findByName("jij") ?: return@afterEvaluate
122+
123+
// Dependencies to exclude from jar-in-jar
124+
val excluded = setOf(
125+
"org.slf4j", // Logging provided by Minecraft
126+
"jsr305" // Compile time annotations only
127+
)
128+
129+
jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
130+
val requested = dep.requested.displayName
131+
132+
if (excluded.any { requested.contains(it) }) return@forEach
133+
134+
val compileOnlyDep = dependencies.create(requested) {
135+
isTransitive = false
136+
}
137+
138+
val implDep = dependencies.create(compileOnlyDep)
139+
140+
dependencies.add("compileOnlyApi", compileOnlyDep)
141+
dependencies.add("implementation", implDep)
142+
dependencies.add("include", compileOnlyDep)
115143
}
116144
}
117145

146+
loom {
147+
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
148+
}
149+
118150
tasks {
119151
processResources {
120-
val buildNumber = project.findProperty("build_number")?.toString() ?: ""
121-
val commit = project.findProperty("commit")?.toString() ?: ""
152+
val buildNumber = providers.gradleProperty("build_number").getOrElse("")
153+
val commit = providers.gradleProperty("commit").getOrElse("")
122154

123155
val propertyMap = mapOf(
124156
"version" to project.version,
125157
"build_number" to buildNumber,
126158
"commit" to commit,
127-
"minecraft_version" to project.property("minecraft_version"),
128-
"loader_version" to project.property("loader_version")
159+
"minecraft_version" to libs.versions.minecraft.get(),
160+
"loader_version" to libs.versions.fabric.loader.get()
129161
)
130162

131163
inputs.properties(propertyMap)
@@ -134,53 +166,35 @@ tasks {
134166
}
135167
}
136168

169+
// Compile launcher with Java 8 for backwards compatibility
170+
named<JavaCompile>("compileLauncherJava").configure {
171+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
172+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
173+
options.compilerArgs.add("-Xlint:-options")
174+
}
175+
137176
jar {
138177
inputs.property("archivesName", project.base.archivesName.get())
139178

140179
from("LICENSE") {
141180
rename { "${it}_${inputs.properties["archivesName"]}" }
142181
}
143182

183+
// Include launcher classes
184+
from(sourceSets["launcher"].output)
185+
144186
manifest {
145187
attributes["Main-Class"] = "meteordevelopment.meteorclient.Main"
146188
}
147189
}
148190

149-
java {
150-
sourceCompatibility = JavaVersion.VERSION_21
151-
targetCompatibility = JavaVersion.VERSION_21
152-
153-
if (System.getenv("CI")?.toBoolean() == true) {
154-
withSourcesJar()
155-
withJavadocJar()
156-
}
157-
}
158-
159-
withType<JavaCompile> {
160-
options.release = 21
161-
options.compilerArgs.add("-Xlint:deprecation")
162-
options.compilerArgs.add("-Xlint:unchecked")
163-
}
164-
165-
shadowJar {
166-
configurations = listOf(project.configurations.shadow.get())
167-
168-
inputs.property("archivesName", project.base.archivesName.get())
169-
170-
from("LICENSE") {
171-
rename { "${it}_${inputs.properties["archivesName"]}" }
172-
}
173-
174-
dependencies {
175-
exclude {
176-
it.moduleGroup == "org.slf4j"
177-
}
178-
}
179-
}
180-
181-
remapJar {
182-
dependsOn(shadowJar)
183-
inputFile.set(shadowJar.get().archiveFile)
191+
withType<JavaCompile>().configureEach {
192+
options.compilerArgs.addAll(
193+
listOf(
194+
"-Xlint:deprecation",
195+
"-Xlint:unchecked"
196+
)
197+
)
184198
}
185199

186200
javadoc {
@@ -204,7 +218,7 @@ publishing {
204218
from(components["java"])
205219
artifactId = "meteor-client"
206220

207-
version = properties["minecraft_version"] as String + "-SNAPSHOT"
221+
version = "${libs.versions.minecraft.get()}-SNAPSHOT"
208222
}
209223
}
210224

gradle.properties

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
org.gradle.jvmargs=-Xmx2G
2-
org.gradle.configuration-cache=true
3-
4-
# Fabric (https://fabricmc.net/develop)
5-
minecraft_version=1.21.8
6-
yarn_mappings=1.21.8+build.1
7-
loader_version=0.16.14
8-
fapi_version=0.129.0+1.21.8
2+
org.gradle.configuration-cache=false
93

104
# Mod Properties
115
maven_group=meteordevelopment
126
archives_base_name=meteor-client
13-
14-
# Dependency Versions
15-
16-
# Baritone (https://github.com/MeteorDevelopment/baritone)
17-
baritone_version=1.21.5
18-
19-
# Sodium (https://github.com/CaffeineMC/sodium-fabric)
20-
sodium_version=mc1.21.6-0.6.13-fabric
21-
22-
# Lithium (https://github.com/CaffeineMC/lithium-fabric)
23-
lithium_version=mc1.21.6-0.17.0-fabric
24-
25-
# Iris (https://github.com/IrisShaders/Iris)
26-
iris_version=1.9.0+1.21.6-fabric
27-
28-
# ModMenu (https://github.com/TerraformersMC/ModMenu)
29-
modmenu_version=15.0.0-beta.3
30-
31-
# Orbit (https://github.com/MeteorDevelopment/orbit)
32-
orbit_version=0.2.4
33-
34-
# Starscript (https://github.com/MeteorDevelopment/starscript)
35-
starscript_version=0.2.4
36-
37-
# DiscordRPC (https://github.com/MeteorDevelopment/java-discord-rpc)
38-
discordipc_version=1.1
39-
40-
# Reflections (https://github.com/ronmamo/reflections)
41-
reflections_version=0.10.2
42-
43-
# Netty (https://github.com/netty/netty)
44-
netty_version=4.1.118.Final
45-
46-
# ViaFabricPlus (https://github.com/ViaVersion/ViaFabricPlus)
47-
viafabricplus_version=4.1.5
48-
49-
# WaybackAuthLib (https://github.com/FlorianMichael/WaybackAuthLib)
50-
waybackauthlib_version=1.0.1

0 commit comments

Comments
 (0)