This repository was archived by the owner on Aug 10, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild.gradle
More file actions
176 lines (154 loc) · 6.1 KB
/
Copy pathbuild.gradle
File metadata and controls
176 lines (154 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
buildscript {
repositories {
maven { url = "https://maven.fabricmc.net/" }
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "net.fabricmc:fabric-loom:${property('loom_version')}"
}
}
def minecraft_version = property("minecraft_version")
def minecraft_version_range = findProperty("minecraft_version_range") ?: ">=1.21.1"
def version_suffix = findProperty("version_suffix") ?: minecraft_version
def isUnobfuscated = (findProperty("minecraft_version")?.toString() ?: "").startsWith("26")
// Numeric semver compare for Stonecutter-style gating in resources.
// Stonecutter handles per-file directives in .java, but its default config
// doesn't process .json — so version-gated mixin entries get templated in
// via the ProcessResources `expand(...)` step below.
def isAtLeast = { String currentVer, String minVer ->
def cur = currentVer.tokenize('.').collect { (it as String).isInteger() ? (it as int) : 0 }
def min = minVer.tokenize('.').collect { (it as String).isInteger() ? (it as int) : 0 }
for (int i = 0; i < Math.max(cur.size(), min.size()); i++) {
int a = i < cur.size() ? cur[i] : 0
int b = i < min.size() ? min[i] : 0
if (a != b) return a > b
}
return true
}
// KnownPacksManager class first ships in MC 1.20.5. On older targets we
// strip the mixin entry so the (no-op stub) class doesn't get loaded by
// Mixin and crash with "no @Mixin annotation".
def hasKnownPacksManager = isAtLeast(minecraft_version.toString(), "1.20.5")
def knownPacksMixinEntry = hasKnownPacksManager ? '\n\t\t"KnownPacksManagerMixin",' : ''
// Fabric's typed payload system (PayloadTypeRegistryImpl) first exists on MC 1.20.5.
// On older targets the inbound strict-decode fingerprint vector doesn't apply, so the
// (no-op stub) mixin is stripped to avoid Mixin loading a class with no @Mixin target.
def hasPayloadTypeRegistry = isAtLeast(minecraft_version.toString(), "1.20.5")
def payloadTypeRegistryMixinEntry = hasPayloadTypeRegistry ? '\n\t\t"PayloadTypeRegistryImplMixin",\n\t\t"AbstractChanneledNetworkAddonMixin",' : ''
// Apply the correct Loom plugin variant per version target:
// - net.fabricmc.fabric-loom (non-remap) for unobfuscated MC 26.1+
// - fabric-loom (legacy/remap) for obfuscated MC <=1.21.11
if (isUnobfuscated) {
apply plugin: "net.fabricmc.fabric-loom"
} else {
apply plugin: "fabric-loom"
}
apply plugin: "maven-publish"
group = property("maven_group")
version = property("mod_version")
base {
archivesName = "opsec-$version_suffix"
}
tasks.named("jar") {
archiveFileName = "${base.archivesName.get()}+v${project.version}.jar"
}
def remapJarTask = tasks.findByName("remapJar")
if (remapJarTask != null) {
remapJarTask.archiveFileName = "${base.archivesName.get()}+v${project.version}.jar"
}
loom {
splitEnvironmentSourceSets()
mods {
create("opsec") {
sourceSet(sourceSets.main)
sourceSet(sourceSets.client)
}
}
if (!isUnobfuscated) {
mixin {
useLegacyMixinAp = true
defaultRefmapName = "opsec.refmap.json"
}
}
}
sourceSets {
main {
resources.srcDirs("src/main/resources")
}
client {
java.srcDirs("src/client/java")
resources.srcDirs("src/client/resources")
}
}
repositories {
mavenCentral()
maven { url = "https://maven.terraformersmc.com/"; name = "Terraformers" }
maven { url = "https://repo.spongepowered.org/repository/maven-public/"; name = "Sponge" }
maven { url = "https://maven.bawnorton.com/releases"; name = "Bawnorton" }
}
dependencies {
minecraft("com.mojang:minecraft:${minecraft_version}")
if (!isUnobfuscated) {
mappings(loom.officialMojangMappings())
}
def loaderCoord = "net.fabricmc:fabric-loader:${loader_version}"
def apiCoord = "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
def modmenuCoord = "com.terraformersmc:modmenu:${modmenu_version}"
if (isUnobfuscated) {
implementation(loaderCoord)
implementation(apiCoord)
implementation("com.terraformersmc:modmenu:${modmenu_version}") {
exclude group: "eu.pb4", module: "placeholder-api"
}
} else {
modImplementation(loaderCoord)
modImplementation(apiCoord)
modImplementation("com.terraformersmc:modmenu:${modmenu_version}") {
exclude group: "eu.pb4", module: "placeholder-api"
}
}
// MixinSquared for cancelling other mods' mixins (Meteor Client fix)
include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.7-beta.1")))
}
def javaVersion = (findProperty("java_version") ?: (isUnobfuscated ? "25" : "21")) as int
tasks.withType(ProcessResources).configureEach {
def mixinCompatLevel = "JAVA_${javaVersion}"
inputs.property("version", project.version)
inputs.property("minecraft_version_range", minecraft_version_range)
inputs.property("mixin_compat_level", mixinCompatLevel)
inputs.property("java_version", javaVersion.toString())
inputs.property("known_packs_mixin_entry", knownPacksMixinEntry)
inputs.property("payload_type_registry_mixin_entry", payloadTypeRegistryMixinEntry)
filesMatching(["fabric.mod.json", "opsec.client.mixins.json"]) {
expand(
"version": project.version,
"minecraft_version_range": minecraft_version_range,
"mixin_compat_level": mixinCompatLevel,
"java_version": javaVersion.toString(),
"known_packs_mixin_entry": knownPacksMixinEntry,
"payload_type_registry_mixin_entry": payloadTypeRegistryMixinEntry
)
}
}
tasks.withType(JavaCompile).configureEach {
options.release = javaVersion
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
}
tasks.jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}" }
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = "opsec-$minecraft_version"
from(components.java)
}
}
}