-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
154 lines (136 loc) · 4.76 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
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
version = "1.4.7"
group = "guichaguri.betterfps"
archivesBaseName = "BetterFps"
minecraft {
version = "1.12.1"
runDir = "run"
tweakClass = "guichaguri.betterfps.tweaker.BetterFpsTweaker"
mappings = "snapshot_20170624"
at 'betterfps_at.cfg'
}
reobf {
jar {
extraLines 'PK: com/eclipsesource/json guichaguri/betterfps/json'
}
}
configurations {
shade
compile.extendsFrom shade
}
sourceCompatibility = targetCompatibility = "1.8"
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
dependencies {
//compile 'org.ow2.asm:asm-debug-all:5.0.3'
//compile 'net.minecraft:launchwrapper:1.12'
shade 'com.eclipsesource.minimal-json:minimal-json:0.9.4'
testCompile 'junit:junit:4.12'
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes 'TweakClass': project.minecraft.tweakClass,
'TweakOrder': '600',
'TweakMetaFile': 'betterfps.json',
'TweakName': 'BetterFps',
'TweakAuthor': 'Guichaguri',
'TweakVersion': project.version,
'Main-Class': 'guichaguri.betterfps.installer.BetterFpsInstaller'
}
}
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/betterfps.json'
expand 'version': project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/betterfps.json'
}
}
//TODO?
/*
File mappingsFile = file('src/main/java/guichaguri/betterfps/tweaker/Mappings.java');
Pattern mappingRegex = Pattern.compile("\\(Type\\.([A-Z]+), ([a-zA-Z0-9_ \".\\(\\)\\;\\/,\\$]+)\\)");
task processMappings() {
}*/
String srgInput = 'mappings.srg'
String srgOutput = 'src/main/resources/betterfps.srg'
/**
* Task created by Guichaguri to update the requested mappings of a SRG file
* You might have to update the input file when the mappings version change.
*/
task updateMappings(dependsOn: 'genSrgs') {
File notchToMcp = tasks['genSrgs'].getNotchToMcp();
if(!notchToMcp.exists()) {
println 'SRG file does not exist yet.'
return;
}
def classes = [:];
def fields = [:];
def methods = [:];
def i = 0;
println 'Searching mappings to update'
String[] reqMapping = file(srgInput).readLines()
reqMapping.each {
String[] mapping = it.split(' ')
if(it.startsWith('#')) {
// Comment
} else if(mapping[0].equals('CL:')) { // Class
if(mapping.length >= 2) classes.put(mapping[2], mapping[1]);
} else if(mapping[0].equals('FD:')) { // Field
if(mapping.length >= 2) fields.put(mapping[2], mapping[1]);
} else if(mapping[0].equals('MD:')) { // Method
if(mapping.length >= 3) methods.put(mapping[2] + mapping[3], mapping[1]);
}
}
println 'Updating mappings'
file(srgOutput).withWriter { out ->
String[] mappings = notchToMcp.readLines()
mappings.each {
String[] mapping = it.split(' ')
if (mapping[0].equals('CL:')) { // Class
if(mapping.length >= 3 && classes.containsKey(mapping[2])) {
out.println it + ' ' + classes.get(mapping[2])
i++
}
} else if(mapping[0].equals('FD:')) { // Field
if(mapping.length >= 3 && fields.containsKey(mapping[2])) {
out.println it + ' ' + fields.get(mapping[2])
i++
}
} else if(mapping[0].equals('MD:')) { // Method
if(mapping.length >= 5 && methods.containsKey(mapping[3] + mapping[4])) {
out.println it + ' ' + methods.get(mapping[3] + mapping[4])
i++
}
}
}
def entries = classes.size() + fields.size() + methods.size();
println 'Done. Updated ' + i + '/' + entries + ' entries'
if(i < entries) println 'WARNING: ' + (entries - i) + ' entries were not found! You should check them'
}
}