Entity AI accessibility, also AccessTransformer can make certain classes public now

This commit is contained in:
Christian committed 2012-08-12 23:50:27 -04:00
1 parent 8d8f36bac0
commit 9b74df5e62
2 files changed
+37 -13

No files matched your search

@@ -49,7 +49,7 @@ import cpw.mods.fml.relauncher.IClassTransformer;
public class AccessTransformer implements IClassTransformer
{
private static final boolean DEBUG = false;
private static final boolean DEBUG = true;
private class Modifier
{
public String name = "";
@@ -59,13 +59,14 @@ public class AccessTransformer implements IClassTransformer
public int targetAccess = 0;
public boolean changeFinal = false;
public boolean markFinal = false;
protected boolean modifyClassVisibility;
private void setTargetAccess(String name)
{
if (name.startsWith("public")) targetAccess = ACC_PUBLIC;
else if (name.startsWith("private")) targetAccess = ACC_PRIVATE;
else if (name.startsWith("protected")) targetAccess = ACC_PROTECTED;
if (name.endsWith("-f"))
{
changeFinal = true;
@@ -119,23 +120,30 @@ public class AccessTransformer implements IClassTransformer
return true;
}
List<String> parts = Lists.newArrayList(Splitter.on(" ").trimResults().split(line));
if (parts.size()>2 || parts.get(1).indexOf('.') == -1)
if (parts.size()>2)
{
throw new RuntimeException("Invalid config file line "+ input);
}
Modifier m = new Modifier();
m.setTargetAccess(parts.get(0));
List<String> descriptor = Lists.newArrayList(Splitter.on(".").trimResults().split(parts.get(1)));
String nameReference = descriptor.get(1);
int parenIdx = nameReference.indexOf('(');
if (parenIdx>0)
if (descriptor.size() == 1)
{
m.desc = nameReference.substring(parenIdx);
m.name = nameReference.substring(0,parenIdx);
m.modifyClassVisibility = true;
}
else
{
m.name = nameReference;
String nameReference = descriptor.get(1);
int parenIdx = nameReference.indexOf('(');
if (parenIdx>0)
{
m.desc = nameReference.substring(parenIdx);
m.name = nameReference.substring(0,parenIdx);
}
else
{
m.name = nameReference;
}
}
modifiers.put(descriptor.get(0), m);
return true;
@@ -156,6 +164,15 @@ public class AccessTransformer implements IClassTransformer
Collection<Modifier> mods = modifiers.get(name);
for (Modifier m : mods)
{
if (m.modifyClassVisibility)
{
classNode.access = getFixedAccess(classNode.access, m);
if (DEBUG)
{
System.out.println(String.format("Class: %s %s -> %s", name, toBinary(m.oldAccess), toBinary(m.newAccess)));
}
continue;
}
if (m.desc.isEmpty())
{
for (FieldNode n : (List<FieldNode>) classNode.fields)
@@ -221,7 +238,7 @@ public class AccessTransformer implements IClassTransformer
default:
throw new RuntimeException("The fuck?");
}
// Clear the "final" marker on fields only if specified in control field
if (target.changeFinal && target.desc == "")
{
@@ -291,7 +308,7 @@ public class AccessTransformer implements IClassTransformer
e.printStackTrace();
System.exit(1);
}
if (!temp.delete())
{
System.out.println("Could not delete temp file: " + temp);
+9 -2
View File
@@ -182,5 +182,12 @@ public gw.h
# EntityPlayerMP getNextWindowId
public gt.bO()V
public gt.cq
# EntityAITaskEntry class -> public
public kw
# EntityAITasks taskList
public kv.a
# EntityLiving tasks
public jv.bg
#EntityAIOcelotSit nearestSittableBlock and isblocksittable
protected lh.a(Luo;III)Z
protected lh.f()Z