-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
275 lines (224 loc) · 8.93 KB
/
build.gradle
File metadata and controls
275 lines (224 loc) · 8.93 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import de.undercouch.gradle.tasks.download.Download
import java.nio.file.Files
import java.util.jar.JarFile
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.19-beta'
id "de.undercouch.download" version "5.6.0"
}
version = mod_version
group = mod_group_id
repositories {
mavenLocal()
maven {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
content {
includeGroup("software.bernie.geckolib")
}
}
maven {url 'https://libs.azuredoom.com:4443/mods'}
maven { url "https://maven.shedaniel.me/" }
maven { url = "https://maven.ithundxr.dev/snapshots" }
}
base {
archivesName = mod_id
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
neoForge {
// Specify the version of NeoForge to use.
version = project.neo_version
parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}
// This line is optional. Access Transformers are automatically detected
// accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
client()
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
data()
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// gameDirectory = project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
// applies to all the run configs above
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// mostly optional in a single mod project
// but multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources {
srcDir 'src/generated/resources'
exclude '**/textures/generation'
// exclude '**/minecraft/textures'
exclude '.cache'
}
dependencies {
implementation "software.bernie.geckolib:geckolib-neoforge-1.21:4.+"
// Example project dependency using a sister or child project:
// implementation project(":myproject")
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
compileOnly fileTree(dir: "libs", includes: ["*.jar"])
compileOnly "com.tterrag.registrate:Registrate:MC1.21-1.3.0+53"
runtimeOnly fileTree(dir: "libs", includes: ["*.jar"])
implementation "me.shedaniel.cloth:cloth-config-neoforge:15.0.130"
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml', 'pack.mcmeta']) {
expand replaceProperties
}
}
// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
}
}
repositories {
maven {
url "file://${project.projectDir}/repo"
}
}
}
def t = tasks.register("downloadAll") {
}
def i = 0;
def url = "https://archive.teacon.cn/jiachen/ci/build/"
def dir = layout.projectDirectory.dir("libs")
def jars = [
"team-anvilcraft/anvilcraft-69.jar"
]
def jarV = jars.stream().map {
def split = it.split("/")
def split1 = split[split.length - 1].split("-")
return [split[split.length - 1], split1[0]]
}.toList()
jar {
from(project.file("LICENSE"))
from(project.file("AUTHORS.MD"))
from(project.file("README.md"))
// jarV.forEach {
// exclude "assets/${it[1]}"
// }
exclude 'assets/minecraft'
}
jars.forEach { b->
def register = tasks.register("Download" + i, Download) {
src(url + b)
dest(dir)
}
i++
t.get().dependsOn(register.get())
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
List<String> keys = ["item"]
boolean isCompulsion = false
tasks.register("copyResources") {
func(layout.buildDirectory.dir("moddev").get().dir("artifacts").file("neoforge-${neo_version}-minecraft-resources-aka-client-extra.jar").asFile, "minecraft", isCompulsion, keys)
// jarV.forEach {
//
// def kv = it
// func(file("libs/${kv.get(0)}"), kv.get(1), isCompulsion, keys)
// }
}
def func(File jarFile, String modid, boolean isCompulsion,List<String> keys) {
def mcAssets = layout.projectDirectory.dir("src").dir("main").dir("resources").dir("assets").dir(modid).getAsFile().toPath()
if (Files.notExists(mcAssets) || isCompulsion) {
JarFile jf = new JarFile(jarFile)
def entries = jf.entries()
while (entries.hasMoreElements()) {
def entry = entries.nextElement()
if (entry.name.startsWith("assets/${modid}/textures/")) {
for (final def key in keys ) {
def newName = entry.name.replace("assets/${modid}/textures/", "")
if(newName.startsWith("${key}/")) {
newName = newName.replace("${key}/", "")
def parent = mcAssets.resolve("textures").resolve(key)
Files.createDirectories(parent)
def stream = jf.getInputStream(entry)
def writer =Files.newOutputStream(parent.resolve(newName))
byte[] buffer = new byte[1024]
int len
while ((len = stream.read(buffer)) > -1) {
writer.write(buffer, 0, len)
}
writer.flush()
writer.close()
stream.close()
}
}
}
}
}
}