-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
182 lines (152 loc) · 4.56 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
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
import net.fabricmc.loom.api.processor.MinecraftJarProcessor
import net.fabricmc.loom.api.processor.ProcessorContext
import net.fabricmc.loom.api.processor.SpecContext
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption;
plugins {
id 'maven-publish'
id 'fabric-loom' version "1.4-SNAPSHOT"
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven {
name = 'legacy-fabric'
url = 'https://maven.legacyfabric.net'
}
// Fixed LWJGL on Linux
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
maven {
url file('mavenRepo')
}
mavenCentral() //For fastutil
}
loom {
setIntermediaryUrl('https://maven.legacyfabric.net/net/legacyfabric/intermediary/%1$s/intermediary-%1$s-v2.jar');
accessWidenerPath = file('src/main/resources/foodspoilmod.accesswidener')
addMinecraftJarProcessor(
BTWJarReplacer, "BTWJarReplacer", projectDir.toString()
)
decompilers {
vineflower {
options.putAll([
mcs: "1",
rbr: "0",
rer: "0",
rsy: "0",
vvm: "1",
uto: "1",
shs: "1"
])
}
}
}
def lwjglVersion = System.getProperty("os.name").toLowerCase().contains("mac") ? "2.9.1" : "2.9.0"
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "btw.community:mappings:1.0.3"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation 'net.fabricmc:fabric-loom:1.4-SNAPSHOT'
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
implementation "org.lwjgl.lwjgl:lwjgl_util:${lwjglVersion}"
implementation "org.lwjgl.lwjgl:lwjgl:${lwjglVersion}"
implementation "org.lwjgl.lwjgl:lwjgl-platform:${lwjglVersion}"
implementation fileTree(dir: "libs", include: "**.zip")
modImplementation fileTree(dir: "otherMods", include: "**.jar")
implementation 'com.google.guava:guava:14.0.1'
// This is what MC 1.6 uses
implementation 'com.google.code.gson:gson:2.2.2'
}
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3') with {
module("org.lwjgl.lwjgl:lwjgl_util:${lwjglVersion}")
}
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3') with {
module("org.lwjgl.lwjgl:lwjgl:${lwjglVersion}")
}
}
force "org.lwjgl.lwjgl:lwjgl-platform:${lwjglVersion}"
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
java {
withSourcesJar()
}
jar {
from sourceSets.main.output.resourcesDir
from sourceSets.main.output.classesDirs
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
loom {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
runClient {
dependsOn(jar)
}
runServer {
dependsOn(jar)
}
class BTWJarReplacer implements MinecraftJarProcessor<Spec> {
String name
String path
@javax.inject.Inject
BTWJarReplacer(String name, String path) {
this.name = name
this.path = path
}
@Override
Spec buildSpec(SpecContext context) {
return new Spec(path)
}
@Override
void processJar(java.nio.file.Path jar, Spec spec, ProcessorContext context) throws IOException {
// Replace the Minecraft jar with the custom one from BTW_dev.
// This is just a straight up file replacement, no remapping or anything.
if (!Files.exists(Paths.get(path, "build_BTW/BTW_dev/BTW_dev.zip"))) {
// Print a warning if the BTW_dev zip doesn't exist.
System.err.println("BTW_dev zip not found, skipping BTWJarReplacer")
} else {
System.out.println("BTW_dev zip found, replacing Minecraft jar with BTW_dev jar.")
Files.copy(Paths.get(path, "build_BTW/BTW_dev/BTW_dev.zip"), jar, StandardCopyOption.REPLACE_EXISTING)
// Add Javadocs
Files.copy(Paths.get(path, "build_BTW/BTW_dev/BTW_dev-javadoc.jar"), jar.resolveSibling(jar.getFileName().toString().replace(".jar", "-javadoc.jar")), StandardCopyOption.REPLACE_EXISTING)
}
}
@Override
String getName() {
return name
}
class Spec implements MinecraftJarProcessor.Spec {
String path
Spec(String path) {
this.path = path
}
@Override
int hashCode() {
if (!Files.exists(Paths.get(path, "build_BTW/BTW_dev/BTW_dev.zip"))) {
return name.hashCode()
} else {
return Files.getLastModifiedTime(Paths.get(path, "build_BTW/BTW_dev/BTW_dev.zip")).hashCode() ^ name.hashCode()
}
}
}
}