generated from DrFair/ExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
154 lines (121 loc) · 5.75 KB
/
build.gradle
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
plugins {
id 'java'
}
// Change the values below this to your mods values
// To change the project name, edit the settings.gradle file
project.ext.modID = "ragno.ragnosresources" // The unique id of your mod. Must be all lowercase and cannot use special characters.
project.ext.modName = "Ragnos Resourcepack" // The display name of your mod.
project.ext.modVersion = "0.3" // Your current builds version. Must follow the xx.xx... format.
project.ext.gameVersion = "0.21.29" // The target game version.
project.ext.modDescription = "Aims to improve the graphics of the game. Currently revamps (roughly) 528/2587 textures." // Short description of what your mod is.
project.ext.author = "Ragno" // Your name
/**
* When setting clientside to true, it means servers do not need this mod for clients to connect and vice versa.
* IMPORTANT: If you set this to true, make sure that your mod does not add any content or do anything
* that could cause clients and servers to desync. This includes registering any items, objects, tiles, packets etc.
*/
project.ext.clientside = true
/**
* The other mod dependencies of this mod
* Dependencies define the default load order of mods
* Uncomment and configure these if your mod has dependencies
*/
//project.ext.modDependencies = ["other.modid1", "other.modid2"]
//project.ext.modOptionalDependencies = ["optional.modid1", "optional.modid2"]
// The path to the games install directory
def gameDirectory = "C:/Program Files (x86)/Steam/steamapps/common/Necesse"
// =================================================
// ========== DO NOT EDIT BELOW THIS LINE ==========
// =================================================
// Name of the jar
def jarName = "${project.ext.modName.replace(" ", "")}-${project.ext.gameVersion}-${project.ext.modVersion}"
group project.ext.modID
version project.ext.modVersion
setSourceCompatibility(JavaVersion.VERSION_1_8)
setTargetCompatibility(JavaVersion.VERSION_1_8)
repositories {
mavenCentral()
}
configurations {
libDepends
}
sourceSets.main.output.resourcesDir = file("build/mod/resources/")
sourceSets.main.java.outputDir = file("build/mod/")
sourceSets.main.compileClasspath += configurations.libDepends // Adds libDepends configuration to classpath
def buildLocation = "build/jar"
compileJava.options.encoding = "UTF-8"
if (!file(gameDirectory + "/Necesse.jar").exists()) {
throw new Exception("Could not find game install directory. Make sure it is correct in build.gradle file.")
}
dependencies {
implementation files(gameDirectory + "/Necesse.jar")
implementation fileTree(gameDirectory + "/lib/")
implementation fileTree("./mods/") // Add all mods located in local mods folder
// Add any third party library dependencies here. Remember to use libDepends, so that they will be added to your jar on build
// These are some examples:
// libDepends group: 'com.google.guava', name: 'guava', version: '31.1-jre'
// libDepends files("path/to/library/jar.jar")
}
task createAppID {
group "necesse"
description "Creates steam_appid.txt file"
doLast {
file("steam_appid.txt").text = "1169040"
}
}
task createModInfoFile(type: JavaExec) {
group "necesse"
description "Creates the mod info file"
classpath = files(gameDirectory + "/Necesse.jar")
main = "CreateModInfoFile"
args "-file", "${sourceSets.main.java.outputDir}/mod.info",
"-id", "${project.ext.modID}",
"-name", "${project.ext.modName}",
"-version", "${project.ext.modVersion}",
"-gameVersion", "${project.ext.gameVersion}",
"-description", "${project.ext.modDescription}",
"-author", "${project.ext.author}",
"-clientside", "${project.ext.clientside}",
"-dependencies", project.ext.has("modDependencies") ? "[" + project.ext.modDependencies.join(", ") + "]" : "",
"-optionalDependencies", project.ext.has("modOptionalDependencies") ? "[" + project.ext.modOptionalDependencies.join(", ") + "]" : ""
}
// Makes compiling also create mod info file
classes.dependsOn("createModInfoFile")
task runClient(type: JavaExec) {
group "necesse"
description "Run client with current mod"
dependsOn "buildModJar", "createAppID"
classpath = files(gameDirectory + "/Necesse.jar")
main = "StartClient"
jvmArgs "-Xms512m", "-Xmx3G", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:G1NewSizePercent=20", "-XX:G1ReservePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M"
args "-mod \"${buildLocation}\""
}
task runDevClient(type: JavaExec) {
group "necesse"
description "Run client with current mod"
dependsOn "buildModJar", "createAppID"
classpath = files(gameDirectory + "/Necesse.jar")
main = "StartClient"
jvmArgs "-Xms512m", "-Xmx3G", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:G1NewSizePercent=20", "-XX:G1ReservePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M"
args "-dev 1", "-mod \"${buildLocation}\""
}
task runServer(type: JavaExec) {
group "necesse"
description "Run server with current mod"
dependsOn "buildModJar"
classpath = files(gameDirectory + "/Server.jar")
main = "StartServer"
jvmArgs "-Xms512m", "-Xmx3G", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:G1NewSizePercent=20", "-XX:G1ReservePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M"
args "-mod \"${buildLocation}\""
}
task buildModJar(type: Jar) {
group "necesse"
description "Generates the mod jar into the build folder"
dependsOn "classes"
// Add mod output
from sourceSets.main.java.outputDir
// Add the dependencies
from configurations.libDepends.collect { it.isDirectory() ? it : zipTree(it) }
archiveName "${jarName}.jar"
destinationDir file(buildLocation)
}