Repository navigation
Expand file tree
/
Copy pathcommon.gradle
More file actions
158 lines (133 loc) · 5.16 KB
/
Copy pathcommon.gradle
File metadata and controls
158 lines (133 loc) · 5.16 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
boolean nonObfuscatedMc = rootProject.isNonObfuscatedMc.call(project.minecraft_version)
def loomPlugin = nonObfuscatedMc ? libs.plugins.fabric.loom.noremap : libs.plugins.fabric.loom.remap
pluginManager.apply(loomPlugin.get().pluginId)
pluginManager.apply(libs.plugins.preprocessor.get().pluginId)
pluginManager.apply(libs.plugins.yamlang.get().pluginId)
pluginManager.apply(libs.plugins.replace.token.get().pluginId)
repositories {
maven {
name = "CottonMC"
url = "https://staging.alexiil.uk/maven"
}
maven {
name = "Modrinth Maven"
url = "https://api.modrinth.com/maven"
}
maven {
name = "Nyan Maven"
url = "https://maven.hendrixshen.moe/releases"
}
mavenCentral()
mavenLocal()
}
Closure<Dependency> modApi = { Object notation -> dependencies.add(nonObfuscatedMc ? "api" : "modApi", notation) }
dependencies {
// Development environment
minecraft("com.mojang:minecraft:${project.minecraft_version}")
if (!nonObfuscatedMc) {
mappings(loom.officialMojangMappings())
}
modApi(libs.fabric.loader)
// Annotation processor
modApi(libs.lombok)
annotationProcessor(libs.lombok)
// Dependencies
modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modApi("io.github.cottonmc:LibGui:${project.libgui_version}")
modApi("maven.modrinth:modmenu:${project.modmenu_version}")
}
tasks.named("runClient") {
doFirst {
layout.projectDirectory.file("run/client/options.txt").asFile.with { File file ->
if (!file.exists()) {
file.parentFile.mkdirs()
file.withWriter { BufferedWriter writer ->
writer.writeLine("autoJump:false")
writer.writeLine("enableVsync:false")
writer.writeLine("forceUnicodeFont:true")
writer.writeLine("fov:1.0")
writer.writeLine("gamma:1.0")
writer.writeLine("guiScale:3")
writer.writeLine("lang:${Locale.getDefault().toString()}")
writer.writeLine("maxFps:260")
writer.writeLine("renderDistance:10")
writer.writeLine("soundCategory_master:0.0")
}
}
null // We don't need to return anything.
}
}
}
loom {
runConfigs.configureEach {
systemProperties.putAll(Map.of(
"mixin.debug.export", "true" // Dump modified classes automatically.
))
}
// We need large window.
runConfigs.client {
getProgramArguments().addAll(
"--width", "1920",
"--height", "1080",
)
getRunDirectory().set(project.file("run/client"))
}
mixin {
// suppress "Cannot remap xxx because it does not exists in any of the targets" warning. It does not respect `remap = false` :(
useLegacyMixinAp = !nonObfuscatedMc
}
}
base {
version = project.parent.version
group = project.maven_group
archivesName = "${project.archives_base_name}-mc${project.minecraft_out}"
}
replaceToken {
targetSourceSets.set([sourceSets.main])
replace("@MOD_ID@", project.mod_id)
replaceIn("work/msdnicrosoft/commandbuttons/CommandButtonsReference")
}
yamlang {
targetSourceSets = [sourceSets.main]
inputDir = 'assets/mgbuttons/lang'
}
processResources {
filteringCharset = "UTF-8"
outputs.upToDateWhen { false }
inputs.property("minecraft_dependency", project.minecraft_dependency)
inputs.property("minecraft_version_id", project.minecraft_version.replace(".", "_"))
inputs.property("minecraft_version_out", project.minecraft_out)
inputs.property("mod_id", project.mod_id)
inputs.property("mod_name", project.mod_name)
inputs.property("mod_license", project.mod_license)
inputs.property("mod_sources", project.mod_sources)
inputs.property("mod_version", project.version)
inputs.property("keymapping_api_module", nonObfuscatedMc ? "fabric-key-mapping-api-v1" : "fabric-key-binding-api-v1")
filesMatching("fabric.mod.json") {
expand([
"minecraft_dependency" : inputs.properties["minecraft_dependency"],
"minecraft_version_id" : inputs.properties["minecraft_version_id"],
"minecraft_version_out": inputs.properties["minecraft_version_out"],
"mod_id" : inputs.properties["mod_id"],
"mod_name" : inputs.properties["mod_name"],
"mod_license" : inputs.properties["mod_license"],
"mod_sources" : inputs.properties["mod_sources"],
"mod_version" : inputs.properties["mod_version"],
"keymapping_api_module": inputs.properties["keymapping_api_module"],
])
}
}
java {
sourceCompatibility = JavaVersion.toVersion(project.java_version)
targetCompatibility = JavaVersion.toVersion(project.java_version)
withSourcesJar()
}
jar {
from(project.rootProject.file("LICENSE"))
}
tasks.register("cleanRun") {
doLast {
// Clean up the run directory.
layout.projectDirectory.dir("run").asFile.deleteDir()
}
}