Removed AccessTransformer delegation, let for FML to handle

This commit is contained in:
Chicken-Bones committed 2014-10-01 10:10:04 +10:00
1 parent c8df05ad7a
commit 055e3480de
2 files changed
+20 -63

No files matched your search

@@ -16,99 +16,59 @@ import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
public class CodeChickenAccessTransformer extends AccessTransformer
{
private static CodeChickenAccessTransformer instance;
private static List<String> mapFileList = new LinkedList<String>();
private static boolean makeAllPublic;
private static Field f_classNameBiMap;
private static Object emptyMap = ImmutableBiMap.of();
public CodeChickenAccessTransformer() throws IOException
{
public CodeChickenAccessTransformer() throws IOException {
super();
instance = this;
for(String file : mapFileList)
readMapFile(file);
mapFileList = null;
loadPublicConfig();
}
private void loadPublicConfig() {
if(ObfMapping.obfuscated)
if (ObfMapping.obfuscated)
return;
makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic")
makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic")
.setComment("Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader." +
"\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers." +
"\nSuch mods are doing the wrong thing and should be fixed.")
.getBooleanValue(false);
if(!makeAllPublic)
"\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers." +
"\nSuch mods are doing the wrong thing and should be fixed.")
.getBooleanValue(false);
if (!makeAllPublic)
return;
try
{
try {
f_classNameBiMap = FMLDeobfuscatingRemapper.class.getDeclaredField("classNameBiMap");
f_classNameBiMap.setAccessible(true);
}
catch(Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void addTransformerMap(String mapFile)
{
if(instance == null)
mapFileList.add(mapFile);
else
instance.readMapFile(mapFile);
}
private void readMapFile(String mapFile)
{
CodeChickenCorePlugin.logger.debug("Adding Accesstransformer map: " + mapFile);
try
{
Method parentMapFile = AccessTransformer.class.getDeclaredMethod("readMapFile", String.class);
parentMapFile.setAccessible(true);
parentMapFile.invoke(this, mapFile);
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
@Override
public byte[] transform(String name, String transformedName, byte[] bytes) {
boolean setPublic = makeAllPublic && name.startsWith("net.minecraft.");
if(setPublic)
if (setPublic)
setClassMap(name);
bytes = super.transform(name, transformedName, bytes);
if(setPublic)
if (setPublic)
restoreClassMap();
return bytes;
}
private void restoreClassMap() {
try
{
try {
f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, emptyMap);
}
catch(Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void setClassMap(String name) {
try
{
try {
f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, ImmutableBiMap.of(name.replace('.', '/'), ""));
}
catch(Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -154,9 +154,6 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook
if (attr == null)
return;
String mapFile = attr.getValue("AccessTransformer");
if (mapFile != null)
CodeChickenAccessTransformer.addTransformerMap(mapFile);
String transformer = attr.getValue("CCTransformer");
if (transformer != null)
DelegatedTransformer.addTransformer(transformer, jar, file);