Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ JDK_DIR="$(pwd)/jdks"
mkdir -p "$JDK_DIR"

# JDK download URLs
# For JDK 25, update the URL to the correct Temurin 25 GA release from:
# https://github.com/adoptium/temurin25-binaries/releases
java_versions=(
"21 https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21+35/OpenJDK21U-jdk_x64_linux_hotspot_21_35.tar.gz"
"21 https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz"
"25 https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25%2B36/OpenJDK25U-jdk_x64_linux_hotspot_25_36.tar.gz"
)

# Minecraft and Fabric versions to build
# Minecraft and Fabric versions to build.
# Format for 1.x builds: "java_version minecraft_version yarn_mappings loader_version fabric_api_version"
# Format for 26.1+ builds: "java_version minecraft_version - loader_version fabric_api_version"
# '-' signals no Yarn mappings (game is unobfuscated from 26.1 onwards).
versions=(
# ── Minecraft 26.1.x (unobfuscated, Java 25, no Yarn mappings) ───────────────
"25 26.1.2 - 0.19.2 0.152.1+26.1.2"

# ── Minecraft 1.21.x ─────────────────────────────────────────────────────────
"21 1.21.11 1.21.11+build.4 0.18.4 0.141.3+1.21.11"
"21 1.21.10 1.21.10+build.3 0.18.4 0.138.4+1.21.10"
"21 1.21.9 1.21.9+build.1 0.18.4 0.134.1+1.21.9"
Expand Down Expand Up @@ -94,15 +104,26 @@ for version_info in "${versions[@]}"; do

JAVA_HOME="$JDK_DIR/jdk-$java_version"

echo "> building for $minecraft_version on java $java_version"

./gradlew build jar -q \
-Dorg.gradle.java.home="$JAVA_HOME" \
-Dorg.gradle.project.java_version="$java_version" \
-Dorg.gradle.project.minecraft_version="$minecraft_version" \
-Dorg.gradle.project.yarn_mappings="$yarn_mappings" \
-Dorg.gradle.project.loader_version="$loader_version" \
-Dorg.gradle.project.fabric_version="$fabric_version"
echo "> building for minecraft $minecraft_version on java $java_version"

if [ "$yarn_mappings" == "-" ]; then
# ── 26.1+ build: no Yarn mappings (game is unobfuscated) ─────────────────
./gradlew build jar -q \
-Dorg.gradle.java.home="$JAVA_HOME" \
-Dorg.gradle.project.java_version="$java_version" \
-Dorg.gradle.project.minecraft_version="$minecraft_version" \
-Dorg.gradle.project.loader_version="$loader_version" \
-Dorg.gradle.project.fabric_version="$fabric_version"
else
# ── Legacy build: Yarn mappings required ──────────────────────────────────
./gradlew build jar -q \
-Dorg.gradle.java.home="$JAVA_HOME" \
-Dorg.gradle.project.java_version="$java_version" \
-Dorg.gradle.project.minecraft_version="$minecraft_version" \
-Dorg.gradle.project.yarn_mappings="$yarn_mappings" \
-Dorg.gradle.project.loader_version="$loader_version" \
-Dorg.gradle.project.fabric_version="$fabric_version"
fi

echo "Done"
done
Expand Down
107 changes: 59 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,83 +1,94 @@
plugins {
id 'fabric-loom' version '1.13.3'
id 'maven-publish'
// Declare both plugin IDs but do not apply them yet
id 'net.fabricmc.fabric-loom' version '1.15.2' apply false
id 'net.fabricmc.fabric-loom-remap' version '1.15.2' apply false
id 'maven-publish'
}

def javaVersion = project.hasProperty('java_version') ? project.java_version.toInteger() : 17
def javaVersion = project.hasProperty('java_version') ? project.java_version.toInteger() : 21

// Detect 26.1+ builds: version strings use a year-based scheme (e.g. "26.1.2")
def is261Plus = project.hasProperty('minecraft_version') && !project.minecraft_version.startsWith('1.')

// Conditionally apply the correct Loom plugin based on the Minecraft version
if (is261Plus) {
apply plugin: 'net.fabricmc.fabric-loom'
} else {
apply plugin: 'net.fabricmc.fabric-loom-remap'
}

java {
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
withSourcesJar()
}

loom {
enableModProvidedJavadoc = false
enableModProvidedJavadoc = false
}

base {
archivesName = project.archives_base_name
archivesName = project.archives_base_name
}

version = "${project.mod_version}-${project.minecraft_version}"
group = project.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
// Loom adds the essential Minecraft / Fabric Maven repositories automatically.
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
// mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
minecraft "com.mojang:minecraft:${project.minecraft_version}"

if (!is261Plus) {
// ── Legacy builds (Minecraft 1.x, Yarn-mapped) ─────────────────────────────
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
} else {
// ── Modern builds (Minecraft 26.1+, unobfuscated) ──────────────────────────
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand(project.properties)
}
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand(project.properties)
}

// Inject the correct Mixin compatibility level so that:
// - Legacy builds (Java 21) produce JAVA_21 → mixin applies to 1.x class files
// - Modern builds (Java 25) produce JAVA_25 → mixin applies to 26.1+ class files
// If the level is too low for the target class, SpongePowered Mixin silently
// skips the injection at runtime, which would break the mod.
filesMatching("csam.mixins.json") {
expand(['mixin_java_level': "JAVA_${javaVersion}"])
}
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = javaVersion
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
it.options.release = javaVersion
it.options.encoding = 'UTF-8'
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
from("LICENSE") {
rename { "${it}_${project.archives_base_name}" }
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

repositories {
}
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
// Add publishing targets here if needed.
}
}
9 changes: 6 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
org.gradle.jvmargs=-Xmx1G
java_version=21

# Fabric Properties
# check these on https://fabricmc.net/develop
# Fabric Properties — defaults target 1.21.11 (Java 21, Yarn mappings).
# For 26.1.2 builds these are overridden by build-all.sh:
# java_version=25, no yarn_mappings, loader_version=0.19.2,
# fabric_version=0.152.1+26.1.2
# Check https://fabricmc.net/develop for the latest recommended versions.
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4

#Fabric api
# Fabric API
fabric_version=0.141.3+1.21.11

# Mod Properties
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/csam.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "nl.svenar.customserveraccess.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "${mixin_java_level}",
"mixins": [
],
"client": [
Expand Down