Skip to content

Commit 70d441a

Browse files
authored
Merge pull request #4 from Chocohead/moderniser
1.13.1 Port
2 parents 3986a9c + b3951bc commit 70d441a

File tree

14 files changed

+364
-246
lines changed

14 files changed

+364
-246
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ dependencies {
7474
compile 'com.nothome:javaxdelta:2.0.1' // GDIFF implementation for BinPatches
7575
compile 'com.google.code.gson:gson:2.2.4' // Used instead of Argo for buuilding changelog.
7676
compile 'com.github.tony19:named-regexp:0.2.3' // 1.7 Named regexp features
77-
compile 'net.minecraftforge:forgeflower:1.0.342-SNAPSHOT' // Fernflower Forge edition
77+
compile 'net.minecraftforge:forgeflower:1.5.380.22' // Fernflower Forge edition
7878

79-
shade 'net.md-5:SpecialSource:1.8.2' // deobf and reobf
79+
shade 'net.md-5:SpecialSource:1.8.3' // deobf and reobf
8080

8181
// because curse
8282
compile 'org.apache.httpcomponents:httpclient:4.3.3'
8383
compile 'org.apache.httpcomponents:httpmime:4.3.3'
8484

8585
// mcp stuff
8686
shade 'de.oceanlabs.mcp:RetroGuard:3.6.6'
87-
shade('de.oceanlabs.mcp:mcinjector:3.4-SNAPSHOT'){
87+
shade('de.oceanlabs.mcp:mcinjector:3.7.3'){
8888
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
8989
}
9090
shade('net.minecraftforge.srg2source:Srg2Source:4.0-SNAPSHOT'){
@@ -94,7 +94,7 @@ dependencies {
9494

9595
//Stuff used in the GradleStart classes
9696
compileOnly 'com.mojang:authlib:1.5.16'
97-
compileOnly('net.minecraft:launchwrapper:1.11'){
97+
compileOnly('net.minecraft:launchwrapper:1.12'){
9898
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
9999
}
100100

@@ -214,7 +214,7 @@ pluginBundle {
214214
uploadArchives {
215215
repositories.mavenDeployer {
216216

217-
dependsOn 'build'
217+
dependsOn 'jar'
218218

219219
if (project.hasProperty('forgeMavenPass'))
220220
{

src/main/java/net/minecraftforge/gradle/common/BasePlugin.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected void afterEvaluate()
223223
// ApplyFernFlowerTask ffTask = ((ApplyFernFlowerTask) project.getTasks().getByName("decompileJar"));
224224
// ffTask.setClasspath(javaConv.getSourceSets().getByName("main").getCompileClasspath());
225225

226-
// http://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp/1.7.10/mcp-1.7.10-srg.zip
226+
// http://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_config/1.13.1/mcp_config-1.13.1.zip
227227
project.getDependencies().add(CONFIG_MAPPINGS, ImmutableMap.of(
228228
"group", "de.oceanlabs.mcp",
229229
"name", delayedString("mcp_" + REPLACE_MCP_CHANNEL).call(),
@@ -233,9 +233,8 @@ protected void afterEvaluate()
233233

234234
project.getDependencies().add(CONFIG_MCP_DATA, ImmutableMap.of(
235235
"group", "de.oceanlabs.mcp",
236-
"name", "mcp",
236+
"name", "mcp_config",
237237
"version", delayedString(REPLACE_MC_VERSION).call(),
238-
"classifier", "srg",
239238
"ext", "zip"
240239
));
241240

@@ -523,7 +522,7 @@ public String call()
523522
merge.setDescription(null);
524523
}
525524

526-
ExtractConfigTask extractMcpData = makeTask(TASK_EXTRACT_MCP, ExtractConfigTask.class);
525+
ExtractConfigTask extractMcpData = makeTask(TASK_EXTRACT_MCP, ExtractMcpConfigTask.class);
527526
{
528527
extractMcpData.setDestinationDir(delayedFile(DIR_MCP_DATA));
529528
extractMcpData.setConfig(CONFIG_MCP_DATA);
@@ -540,7 +539,7 @@ public String call()
540539
GenSrgs genSrgs = makeTask(TASK_GENERATE_SRGS, GenSrgs.class);
541540
{
542541
genSrgs.setInSrg(delayedFile(MCP_DATA_SRG));
543-
genSrgs.setInExc(delayedFile(MCP_DATA_EXC));
542+
genSrgs.setInConstructors(delayedFile(MCP_DATA_CONSTRUCTORS));
544543
genSrgs.setInStatics(delayedFile(MCP_DATA_STATICS));
545544
genSrgs.setMethodsCsv(delayedFile(CSV_METHOD));
546545
genSrgs.setFieldsCsv(delayedFile(CSV_FIELD));

src/main/java/net/minecraftforge/gradle/common/Constants.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,16 @@ public Boolean call(Object o)
169169
};
170170

171171
// mcp data constants
172-
public static final String MCP_DATA_SRG = DIR_MCP_DATA + "/joined.srg";
173-
public static final String MCP_DATA_EXC = DIR_MCP_DATA + "/joined.exc";
174-
public static final String MCP_DATA_EXC_JSON = DIR_MCP_DATA + "/exceptor.json";
175-
public static final String MCP_DATA_STYLE = DIR_MCP_DATA + "/astyle.cfg";
176-
public static final String MCP_DATA_STATICS = DIR_MCP_DATA + "/static_methods.txt";
177-
public static final String MCP_PATCHES_CLIENT = DIR_MCP_DATA + "/patches/minecraft_ff";
178-
public static final String MCP_PATCHES_SERVER = DIR_MCP_DATA + "/patches/minecraft_server_ff";
179-
public static final String MCP_PATCHES_MERGED = DIR_MCP_DATA + "/patches/minecraft_merged_ff";
180-
public static final String MCP_INJECT = DIR_MCP_DATA + "/patches/inject";
172+
public static final String MCP_DATA_SRG = DIR_MCP_DATA + "/config/joined.srg";
173+
public static final String MCP_DATA_STYLE = DIR_MCP_DATA + "/astyle.cfg";
174+
public static final String MCP_DATA_ACCESS = DIR_MCP_DATA + "/config/access.txt";
175+
public static final String MCP_DATA_EXCEPTIONS = DIR_MCP_DATA + "/config/exceptions.txt";
176+
public static final String MCP_DATA_CONSTRUCTORS = DIR_MCP_DATA + "/config/constructors.txt";
177+
public static final String MCP_DATA_STATICS = DIR_MCP_DATA + "/config/static_methods.txt";
178+
public static final String MCP_PATCHES_CLIENT = DIR_MCP_DATA + "/patches/client";
179+
public static final String MCP_PATCHES_SERVER = DIR_MCP_DATA + "/patches/server";
180+
public static final String MCP_PATCHES_MERGED = DIR_MCP_DATA + "/patches/joined";
181+
public static final String MCP_INJECT = DIR_MCP_DATA + "/config/inject";
181182

182183
// generated off of MCP data constants
183184
public static final String CSV_METHOD = DIR_MCP_MAPPINGS + "/methods.csv";

src/main/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ protected void makeGeneralSetupTasks()
112112
deobfJar.setOutJar(delayedFile(JAR_DEOBF));
113113
deobfJar.setSrg(delayedFile(SRG_NOTCH_TO_SRG));
114114
deobfJar.setExceptorCfg(delayedFile(EXC_SRG));
115-
deobfJar.setExceptorJson(delayedFile(MCP_DATA_EXC_JSON));
116-
deobfJar.setApplyMarkers(true);
115+
deobfJar.setAccessCfg(delayedFile(MCP_DATA_ACCESS));
116+
deobfJar.setConstructorCfg(delayedFile(MCP_DATA_CONSTRUCTORS));
117+
deobfJar.setExceptionsCfg(delayedFile(MCP_DATA_EXCEPTIONS));
117118
deobfJar.setDoesCache(false);
118119
// access transformers are added afterEvaluate
119120
deobfJar.dependsOn(TASK_MERGE_JARS, TASK_GENERATE_SRGS);

src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java

Lines changed: 43 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,32 @@
2525
import com.google.common.collect.Maps;
2626
import com.google.common.io.Files;
2727
import com.google.common.io.LineProcessor;
28-
import de.oceanlabs.mcp.mcinjector.LVTNaming;
29-
import de.oceanlabs.mcp.mcinjector.MCInjectorImpl;
28+
29+
import de.oceanlabs.mcp.mcinjector.lvt.LVTNaming;
30+
import de.oceanlabs.mcp.mcinjector.MCInjector;
31+
3032
import groovy.lang.Closure;
33+
3134
import net.md_5.specialsource.*;
3235
import net.md_5.specialsource.provider.JarProvider;
3336
import net.md_5.specialsource.provider.JointProvider;
37+
3438
import net.minecraftforge.gradle.common.Constants;
3539
import net.minecraftforge.gradle.util.caching.Cached;
3640
import net.minecraftforge.gradle.util.caching.CachedTask;
37-
import net.minecraftforge.gradle.util.json.JsonFactory;
38-
import net.minecraftforge.gradle.util.json.MCInjectorStruct;
39-
import net.minecraftforge.gradle.util.json.MCInjectorStruct.InnerClass;
41+
4042
import org.gradle.api.file.FileCollection;
4143
import org.gradle.api.tasks.*;
42-
import org.gradle.api.tasks.Optional;
4344

4445
import java.io.BufferedReader;
4546
import java.io.File;
4647
import java.io.IOException;
47-
import java.nio.charset.Charset;
48-
import java.util.*;
49-
import java.util.zip.ZipFile;
48+
import java.util.ArrayList;
49+
import java.util.Collection;
50+
import java.util.HashSet;
51+
import java.util.Map;
52+
import java.util.Set;
5053

51-
import static org.objectweb.asm.Opcodes.*;
5254

5355
public class DeobfuscateJar extends CachedTask
5456
{
@@ -69,10 +71,13 @@ public class DeobfuscateJar extends CachedTask
6971
private Object exceptorCfg;
7072

7173
@InputFile
72-
private Object exceptorJson;
73-
74-
@Input
75-
private boolean applyMarkers = false;
74+
private Object access;
75+
76+
@InputFile
77+
private Object constructors;
78+
79+
@InputFile
80+
private Object exceptions;
7681

7782
@Input
7883
private boolean failOnAtError = true;
@@ -163,158 +168,22 @@ private void deobfJar(File inJar, File outJar, File srg, Collection<File> ats) t
163168
}
164169
}
165170

166-
private int fixAccess(int access, String target)
167-
{
168-
int ret = access & ~7;
169-
int t = 0;
170-
171-
if (target.startsWith("public"))
172-
t = ACC_PUBLIC;
173-
else if (target.startsWith("private"))
174-
t = ACC_PRIVATE;
175-
else if (target.startsWith("protected"))
176-
t = ACC_PROTECTED;
177-
178-
switch (access & 7)
179-
{
180-
case ACC_PRIVATE:
181-
ret |= t;
182-
break;
183-
case 0:
184-
ret |= (t != ACC_PRIVATE ? t : 0);
185-
break;
186-
case ACC_PROTECTED:
187-
ret |= (t != ACC_PRIVATE && t != 0 ? t : ACC_PROTECTED);
188-
break;
189-
case ACC_PUBLIC:
190-
ret |= ACC_PUBLIC;
191-
break;
192-
}
193-
194-
if (target.endsWith("-f"))
195-
ret &= ~ACC_FINAL;
196-
else if (target.endsWith("+f"))
197-
ret |= ACC_FINAL;
198-
return ret;
199-
}
200-
201171
public void applyExceptor(File inJar, File outJar, File config, File log, Set<File> ats) throws IOException
202172
{
203-
String json = null;
204-
File getJson = getExceptorJson();
205-
if (getJson != null)
206-
{
207-
final Map<String, MCInjectorStruct> struct = JsonFactory.loadMCIJson(getJson);
208-
for (File at : ats)
209-
{
210-
getLogger().info("loading AT: " + at.getCanonicalPath());
211-
212-
Files.readLines(at, Charset.defaultCharset(), new LineProcessor<Object>()
213-
{
214-
@Override
215-
public boolean processLine(String line) throws IOException
216-
{
217-
if (line.indexOf('#') != -1)
218-
line = line.substring(0, line.indexOf('#'));
219-
line = line.trim().replace('.', '/');
220-
if (line.isEmpty())
221-
return true;
222-
223-
String[] s = line.split(" ");
224-
if (s.length == 2 && s[1].indexOf('$') > 0)
225-
{
226-
String parent = s[1].substring(0, s[1].indexOf('$'));
227-
for (MCInjectorStruct cls : new MCInjectorStruct[] { struct.get(parent), struct.get(s[1]) })
228-
{
229-
if (cls != null && cls.innerClasses != null)
230-
{
231-
for (InnerClass inner : cls.innerClasses)
232-
{
233-
if (inner.inner_class.equals(s[1]))
234-
{
235-
int access = fixAccess(inner.getAccess(), s[0]);
236-
inner.access = (access == 0 ? null : Integer.toHexString(access));
237-
}
238-
}
239-
}
240-
}
241-
}
242-
243-
return true;
244-
}
245-
246-
@Override
247-
public Object getResult()
248-
{
249-
return null;
250-
}
251-
});
252-
}
253-
254-
// Remove unknown classes from configuration
255-
removeUnknownClasses(inJar, struct);
256-
257-
File jsonTmp = new File(this.getTemporaryDir(), "transformed.json");
258-
json = jsonTmp.getCanonicalPath();
259-
Files.write(JsonFactory.GSON.toJson(struct).getBytes(), jsonTmp);
260-
}
261-
262173
getLogger().debug("INPUT: " + inJar);
263174
getLogger().debug("OUTPUT: " + outJar);
264175
getLogger().debug("CONFIG: " + config);
265-
getLogger().debug("JSON: " + json);
176+
getLogger().debug("ACCESS: " + getAccessCfg());
177+
getLogger().debug("CONSTRUCTOR: " + getConstructorCfg());
178+
getLogger().debug("EXCEPTION: " + getExceptionsCfg());
266179
getLogger().debug("LOG: " + log);
267180
getLogger().debug("PARAMS: true");
268181

269-
MCInjectorImpl.process(inJar.getCanonicalPath(),
270-
outJar.getCanonicalPath(),
271-
config.getCanonicalPath(),
272-
log.getCanonicalPath(),
273-
null,
274-
0,
275-
json,
276-
isApplyMarkers(),
277-
true,
278-
LVTNaming.LVT
279-
);
280-
}
281-
282-
private void removeUnknownClasses(File inJar, Map<String, MCInjectorStruct> config) throws IOException
283-
{
284-
try (ZipFile zip = new ZipFile(inJar))
285-
{
286-
Iterator<Map.Entry<String, MCInjectorStruct>> entries = config.entrySet().iterator();
287-
while (entries.hasNext())
288-
{
289-
Map.Entry<String, MCInjectorStruct> entry = entries.next();
290-
String className = entry.getKey();
291-
292-
// Verify the configuration contains only classes we actually have
293-
if (zip.getEntry(className + ".class") == null)
294-
{
295-
getLogger().info("Removing unknown class {}", className);
296-
entries.remove();
297-
continue;
298-
}
299-
300-
MCInjectorStruct struct = entry.getValue();
301-
302-
// Verify the inner classes in the configuration actually exist in our deobfuscated JAR file
303-
if (struct.innerClasses != null)
304-
{
305-
Iterator<InnerClass> innerClasses = struct.innerClasses.iterator();
306-
while (innerClasses.hasNext())
307-
{
308-
InnerClass innerClass = innerClasses.next();
309-
if (zip.getEntry(innerClass.inner_class + ".class") == null)
310-
{
311-
getLogger().info("Removing unknown inner class {} from {}", innerClass.inner_class, className);
312-
innerClasses.remove();
313-
}
314-
}
315-
}
316-
}
317-
}
182+
new MCInjector(inJar.toPath(), outJar.toPath()).log(log.toPath())
183+
.access(getAccessCfg().toPath())
184+
.constructors(getConstructorCfg().toPath())
185+
.exceptions(getExceptionsCfg().toPath())
186+
.lvt(LVTNaming.LVT).process();
318187
}
319188

320189
public File getExceptorCfg()
@@ -327,27 +196,28 @@ public void setExceptorCfg(Object exceptorCfg)
327196
this.exceptorCfg = exceptorCfg;
328197
}
329198

330-
public File getExceptorJson()
331-
{
332-
if (exceptorJson == null)
333-
return null;
334-
else
335-
return getProject().file(exceptorJson);
199+
public File getAccessCfg() {
200+
return getProject().file(access);
336201
}
337202

338-
public void setExceptorJson(Object exceptorJson)
339-
{
340-
this.exceptorJson = exceptorJson;
203+
public void setAccessCfg(Object accessCfg) {
204+
access = accessCfg;
341205
}
342206

343-
public boolean isApplyMarkers()
344-
{
345-
return applyMarkers;
207+
public File getConstructorCfg() {
208+
return getProject().file(constructors);
346209
}
347210

348-
public void setApplyMarkers(boolean applyMarkers)
349-
{
350-
this.applyMarkers = applyMarkers;
211+
public void setConstructorCfg(Object constructorCfg) {
212+
constructors = constructorCfg;
213+
}
214+
215+
public File getExceptionsCfg() {
216+
return getProject().file(exceptions);
217+
}
218+
219+
public void setExceptionsCfg(Object exceptionCfg) {
220+
exceptions = exceptionCfg;
351221
}
352222

353223
public boolean isFailOnAtError()

0 commit comments

Comments
 (0)