Skip to content

Commit 459a829

Browse files
authored
Merge pull request #15 from Turnip-Labs/7.3-new
Update 7.3 branch
2 parents d8abcbf + 9a662e3 commit 459a829

File tree

13 files changed

+442
-330
lines changed

13 files changed

+442
-330
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto eol=lf
2+
gradlew text eol=lf
3+
*.bat text eol=crlf
4+
*.cmd text eol=crlf
5+
gradle-wrapper.jar -text -diff -merge -filter

.github/workflows/build.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,30 @@ jobs:
1212
matrix:
1313
# Use these Java versions
1414
java: [
15-
17, # Current Java LTS & minimum supported by Minecraft
15+
21, # Current Java LTS & minimum supported by Minecraft
1616
]
1717
# and run on both Linux and Windows
1818
os: [ubuntu-latest, windows-latest]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- name: checkout repository
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2323
- name: validate gradle wrapper
24-
uses: gradle/wrapper-validation-action@v2
24+
uses: gradle/actions/wrapper-validation@v5
2525
- name: setup jdk ${{ matrix.java }}
26-
uses: actions/setup-java@v4
26+
uses: actions/setup-java@v5
2727
with:
2828
java-version: ${{ matrix.java }}
2929
distribution: 'temurin'
30+
cache: gradle
3031
- name: make gradle wrapper executable
3132
if: ${{ runner.os != 'Windows' }}
3233
run: chmod +x ./gradlew
3334
- name: build
3435
run: ./gradlew build
3536
- name: capture build artifacts
36-
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
37-
uses: actions/upload-artifact@v4
37+
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
38+
uses: actions/upload-artifact@v5
3839
with:
3940
name: Artifacts
4041
path: build/libs/

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Template for making Babric mods for BTA!
55
**Note: *DO NOT fork this repository unless you want to contribute!***
66

77
## Prerequisites
8-
- JDK for Java 17 ([Eclipse Temurin](https://adoptium.net/temurin/releases/) recommended)
8+
- JDK for Java 21 ([Eclipse Temurin](https://adoptium.net/temurin/releases/) recommended)
99
- [Intellij IDEA](https://www.jetbrains.com/idea/download/) (Scroll down for the free community edition, if using linux **DO NOT** use the flatpak distribution)
1010
- Minecraft Development plugin (Optional, but highly recommended)
1111

@@ -32,6 +32,8 @@ Template for making Babric mods for BTA!
3232
1. If you haven't already you should join the BTA modding discord! https://discord.gg/FTUNJhswBT
3333
2. You can set your username when launching the client run configuration by setting `--username <username>` in your program arguments.
3434
3. When launching the server run configuration you may want to remove the `nogui` program argument in order to see the regular server GUI.
35-
4. In Intellij you can double press shift or press ctrl+N to search class files, change the search from the default `Project Files` to `All Places` you can easily explore the classes for you dependencies and even BTA itself.
36-
5. In Intellij if ctrl+left click on a field or method you can quickly get information on when and where that field or method is assign or used.
35+
4. In Intellij you can double press shift or press ctrl+N to search class files, change the search from the default `Project Files` to `All Places` you can easily explore the classes for your dependencies and even BTA itself.
36+
5. In Intellij if ctrl+left-click on a field or method you can quickly get information on when and where that field or method is assign or used.
37+
6. Ensure IntelliJ is updated to the latest version. This is important because this template uses the latest Gradle version and if your IntelliJ installation is outdated, it may not support the latest version.
38+
7. In the `examplemod.mixins.json` you'll see `"compatibilityLevel": "JAVA_${java}",` along with an error message from the `Minecraft Development` plugin stating `Cannot resolve compatibility level 'JAVA_${java}'`. You can safely ignore this. The Gradle build system has been set up to grab the Java version from your `gradle.properties` and replace `${java}` with it. So the compiled binary will properly have it as `JAVA_8`.
3739

build.gradle.kts

Lines changed: 137 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3,157 +3,176 @@
33
import org.apache.tools.ant.taskdefs.condition.Os
44

55
plugins {
6-
id("fabric-loom") version "1.10.0-bta"
7-
id("java")
6+
id("fabric-loom")
7+
java
88
}
99

10-
val lwjglVersion = "3.3.4"
11-
10+
val lwjglVersion = providers.gradleProperty("lwjgl_version")
1211
val lwjglNatives = when {
1312
Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC) -> "natives-linux"
1413
Os.isFamily(Os.FAMILY_WINDOWS) -> "natives-windows"
1514
Os.isFamily(Os.FAMILY_MAC) -> "natives-macos${if (Os.isArch("aarch64")) "-arm64" else ""}"
1615
else -> error("Unsupported OS")
1716
}
1817

19-
val mod_group: String by project
20-
val mod_name: String by project
21-
val mod_version: String by project
18+
val modVersion = providers.gradleProperty("mod_version")
19+
val modGroup = providers.gradleProperty("mod_group")
20+
val modName = providers.gradleProperty("mod_name")
21+
22+
val btaChannel = providers.gradleProperty("bta_channel")
23+
val btaVersion = providers.gradleProperty("bta_version")
2224

23-
val bta_channel: String by project
24-
val bta_version: String by project
25+
val loaderVersion = providers.gradleProperty("loader_version")
2526

26-
val loader_version: String by project
27+
val halplibeVersion = providers.gradleProperty("halplibe_version")
28+
val modMenuVersion = providers.gradleProperty("mod_menu_version")
2729

28-
val halplibe_version: String by project
29-
val mod_menu_version: String by project
30+
val slf4jApiVersion = providers.gradleProperty("slf4j_api_version")
31+
val log4jVersion = providers.gradleProperty("log4j_version")
32+
val guavaVersion = providers.gradleProperty("guava_version")
33+
val gsonVersion = providers.gradleProperty("gson_version")
34+
val commonsLang3Version = providers.gradleProperty("commons_lang3_version")
3035

31-
group = mod_group
32-
base.archivesName.set(mod_name)
33-
version = mod_version
36+
val javaVersion = providers.gradleProperty("java_version")
37+
38+
group = modGroup.get()
39+
base.archivesName = modName.get()
40+
version = modVersion.get()
3441

3542
loom {
3643
noIntermediateMappings()
37-
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/$bta_channel/v$bta_version/manifest.json")
44+
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/v${btaVersion.get()}/manifest.json")
3845
}
3946

4047
repositories {
4148
mavenCentral()
42-
maven { url = uri("https://jitpack.io") }
43-
maven {
44-
name = "Babric"
45-
url = uri("https://maven.glass-launcher.net/babric")
46-
}
47-
maven {
48-
name = "Fabric"
49-
url = uri("https://maven.fabricmc.net/")
50-
}
51-
maven {
52-
name = "SignalumMavenInfrastructure"
53-
url = uri("https://maven.thesignalumproject.net/infrastructure")
54-
}
55-
maven {
56-
name = "SignalumMavenReleases"
57-
url = uri("https://maven.thesignalumproject.net/releases")
58-
}
59-
ivy {
60-
url = uri("https://github.com/Better-than-Adventure")
61-
patternLayout {
62-
artifact("[organisation]/releases/download/v[revision]/[module].jar")
63-
}
49+
maven("https://jitpack.io")
50+
maven("https://maven.glass-launcher.net/babric") { name = "Babric" }
51+
maven("https://maven.fabricmc.net/") { name = "Fabric" }
52+
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
53+
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
54+
ivy("https://github.com/Better-than-Adventure") {
55+
patternLayout { artifact("[organisation]/releases/download/v[revision]/[module].jar") }
6456
metadataSources { artifact() }
6557
}
66-
ivy {
67-
url = uri("https://downloads.betterthanadventure.net/bta-client/$bta_channel/")
68-
patternLayout {
69-
artifact("/v[revision]/client.jar")
70-
}
58+
ivy("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/") {
59+
patternLayout { artifact("/v[revision]/client.jar") }
7160
metadataSources { artifact() }
7261
}
73-
ivy {
74-
url = uri("https://downloads.betterthanadventure.net/bta-server/$bta_channel/")
75-
patternLayout {
76-
artifact("/v[revision]/server.jar")
77-
}
62+
ivy("https://downloads.betterthanadventure.net/bta-server/${btaChannel.get()}/") {
63+
patternLayout { artifact("/v[revision]/server.jar") }
7864
metadataSources { artifact() }
7965
}
80-
ivy {
81-
url = uri("https://piston-data.mojang.com")
82-
patternLayout {
83-
artifact("v1/[organisation]/[revision]/[module].jar")
84-
}
66+
ivy("https://piston-data.mojang.com") {
67+
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
8568
metadataSources { artifact() }
8669
}
8770
}
8871

8972
dependencies {
90-
minecraft("::${bta_version}")
73+
minecraft("::${btaVersion.get()}")
9174
mappings(loom.layered {})
9275

93-
modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45") // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
94-
modImplementation("net.fabricmc:fabric-loader:$loader_version")
95-
96-
// Helper library
97-
// If you do not need Halplibe you can comment this line out or delete this line
98-
modImplementation("turniplabs:halplibe:$halplibe_version")
99-
100-
modImplementation("turniplabs:modmenu-bta:$mod_menu_version")
101-
102-
implementation("org.slf4j:slf4j-api:1.8.0-beta4")
103-
implementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0")
104-
105-
implementation("com.google.guava:guava:33.0.0-jre")
106-
implementation("com.google.code.gson:gson:2.10.1")
107-
108-
val log4jVersion = "2.20.0"
109-
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
110-
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
111-
implementation("org.apache.logging.log4j:log4j-1.2-api:$log4jVersion")
112-
113-
implementation("org.apache.commons:commons-lang3:3.12.0")
114-
include("org.apache.commons:commons-lang3:3.12.0")
115-
116-
modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5")
117-
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
118-
119-
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
120-
runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives")
121-
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
122-
runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives")
123-
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
124-
runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives")
125-
implementation("org.lwjgl:lwjgl:$lwjglVersion")
126-
implementation("org.lwjgl:lwjgl-assimp:$lwjglVersion")
127-
implementation("org.lwjgl:lwjgl-glfw:$lwjglVersion")
128-
implementation("org.lwjgl:lwjgl-openal:$lwjglVersion")
129-
implementation("org.lwjgl:lwjgl-opengl:$lwjglVersion")
130-
implementation("org.lwjgl:lwjgl-stb:$lwjglVersion")
131-
}
132-
133-
java {
134-
sourceCompatibility = JavaVersion.VERSION_1_8
135-
targetCompatibility = JavaVersion.VERSION_1_8
136-
withSourcesJar()
137-
}
138-
139-
tasks.compileJava {
140-
options.release.set(8)
76+
// https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
77+
modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45")
78+
// If you do not need Halplibe you can comment out or delete this line.
79+
modImplementation("turniplabs:halplibe:${halplibeVersion.get()}")
80+
modImplementation("turniplabs:modmenu-bta:${modMenuVersion.get()}")
81+
modImplementation("net.fabricmc:fabric-loader:${loaderVersion.get()}")
82+
modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5")
83+
84+
implementation(platform("org.lwjgl:lwjgl-bom:${lwjglVersion.get()}"))
85+
implementation("org.slf4j:slf4j-api:${slf4jApiVersion.get()}")
86+
87+
implementation("com.google.guava:guava:${guavaVersion.get()}")
88+
implementation("com.google.code.gson:gson:${gsonVersion.get()}")
89+
90+
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion.get()}")
91+
implementation("org.apache.logging.log4j:log4j-core:${log4jVersion.get()}")
92+
implementation("org.apache.logging.log4j:log4j-api:${log4jVersion.get()}")
93+
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion.get()}")
94+
95+
implementation("org.apache.commons:commons-lang3:${commonsLang3Version.get()}")
96+
include("org.apache.commons:commons-lang3:${commonsLang3Version.get()}")
97+
98+
implementation("org.lwjgl:lwjgl:${lwjglVersion.get()}")
99+
implementation("org.lwjgl:lwjgl-assimp:${lwjglVersion.get()}")
100+
implementation("org.lwjgl:lwjgl-glfw:${lwjglVersion.get()}")
101+
implementation("org.lwjgl:lwjgl-openal:${lwjglVersion.get()}")
102+
implementation("org.lwjgl:lwjgl-opengl:${lwjglVersion.get()}")
103+
implementation("org.lwjgl:lwjgl-stb:${lwjglVersion.get()}")
104+
105+
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
106+
runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives")
107+
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
108+
runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives")
109+
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
110+
runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives")
141111
}
142112

143-
tasks.jar {
144-
from("LICENSE") {
145-
rename { "${it}_${base.archivesName.get()}" }
146-
}
147-
}
148-
149-
configurations.configureEach {
150-
// Removes LWJGL2 dependencies
151-
exclude(group = "org.lwjgl.lwjgl")
152-
}
153-
154-
tasks.processResources {
155-
inputs.property("version", version)
156-
filesMatching("fabric.mod.json") {
157-
expand("version" to version)
158-
}
113+
tasks {
114+
withType<JavaCompile>().configureEach {
115+
options.encoding = "UTF-8"
116+
sourceCompatibility = javaVersion.get()
117+
targetCompatibility = javaVersion.get()
118+
if (javaVersion.get().toInt() > 8) options.release = javaVersion.get().toInt()
119+
}
120+
withType<JavaExec>().configureEach { defaultCharacterEncoding = "UTF-8" }
121+
withType<Javadoc>().configureEach { options.encoding = "UTF-8" }
122+
withType<Test>().configureEach { defaultCharacterEncoding = "UTF-8" }
123+
named<Jar>("jar") {
124+
val rootLicense = layout.projectDirectory.file("LICENSE")
125+
val parentLicense = layout.projectDirectory.file("../LICENSE")
126+
val licenseFile = when {
127+
rootLicense.asFile.exists() -> {
128+
logger.lifecycle("Using LICENSE from project root: ${rootLicense.asFile}")
129+
rootLicense
130+
}
131+
parentLicense.asFile.exists() -> {
132+
logger.lifecycle("Using LICENSE from parent directory: ${parentLicense.asFile}")
133+
parentLicense
134+
}
135+
else -> {
136+
logger.warn("No LICENSE file found in project or parent directory.")
137+
null
138+
}
139+
}
140+
licenseFile?.let {
141+
from(it) {
142+
rename { original -> "${original}_${archiveBaseName.get()}" }
143+
}
144+
}
145+
}
146+
processResources {
147+
val stringModVersion = modVersion.get()
148+
val stringLoaderVersion = loaderVersion.get()
149+
val stringJavaVersion = javaVersion.get()
150+
val stringHalplibeVersion = halplibeVersion.get()
151+
val stringModMenuVersion = modMenuVersion.get()
152+
inputs.property("modVersion", stringModVersion)
153+
inputs.property("loaderVersion", stringLoaderVersion)
154+
inputs.property("javaVersion", stringJavaVersion)
155+
inputs.property("HalplibeVersion", stringHalplibeVersion)
156+
inputs.property("modMenuVersion", stringModMenuVersion)
157+
filesMatching("fabric.mod.json") {
158+
expand(
159+
mapOf(
160+
"version" to stringModVersion,
161+
"fabricloader" to stringLoaderVersion,
162+
"halplibe" to stringHalplibeVersion,
163+
"java" to stringJavaVersion,
164+
"modmenu" to stringModMenuVersion
165+
)
166+
)
167+
}
168+
filesMatching("*.mixins.json") { expand(mapOf("java" to stringJavaVersion)) }
169+
}
170+
java {
171+
toolchain.languageVersion = JavaLanguageVersion.of(javaVersion.get())
172+
sourceCompatibility = JavaVersion.toVersion(javaVersion.get().toInt())
173+
targetCompatibility = JavaVersion.toVersion(javaVersion.get().toInt())
174+
withSourcesJar()
175+
}
159176
}
177+
// Removes LWJGL2 dependencies
178+
configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") }

0 commit comments

Comments
 (0)