|
|
|
@ -86,23 +86,21 @@ public class LOTRMaterialTransformer implements IClassTransformer {
|
|
|
|
classNode.fields.add(field);
|
|
|
|
classNode.fields.add(field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void modifyMaterial2(String fieldName, int durability, float protection, ClassNode classNode) {
|
|
|
|
public void modifyMaterial(String fieldName, int durability, float protection, ClassNode classNode) {
|
|
|
|
System.out.println("[CinderLoE] Attempting to modify " + fieldName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MethodNode clinit = null;
|
|
|
|
MethodNode clinit = null;
|
|
|
|
boolean foundField = false;
|
|
|
|
boolean foundField = false;
|
|
|
|
|
|
|
|
boolean durabilityModified = false;
|
|
|
|
|
|
|
|
boolean protectionModified = false;
|
|
|
|
|
|
|
|
|
|
|
|
// First, find the <clinit> method
|
|
|
|
// First, find the <clinit> method
|
|
|
|
for (MethodNode method : classNode.methods) {
|
|
|
|
for (MethodNode method : classNode.methods) {
|
|
|
|
if (method.name.equals("<clinit>")) {
|
|
|
|
if (method.name.equals("<clinit>")) {
|
|
|
|
System.out.println("[CinderLoE] Found clinit");
|
|
|
|
|
|
|
|
clinit = method;
|
|
|
|
clinit = method;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (clinit == null) {
|
|
|
|
if (clinit == null) {
|
|
|
|
System.out.println("[CinderLoE] clinit not found");
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -111,16 +109,9 @@ public class LOTRMaterialTransformer implements IClassTransformer {
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
AbstractInsnNode insn = iter.next();
|
|
|
|
AbstractInsnNode insn = iter.next();
|
|
|
|
|
|
|
|
|
|
|
|
if (insn instanceof LdcInsnNode) {
|
|
|
|
|
|
|
|
System.out.println("[CinderLoE] Reading node " + ((LdcInsnNode) insn).cst);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst.equals(fieldName)) {
|
|
|
|
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst.equals(fieldName)) {
|
|
|
|
foundField = true;
|
|
|
|
foundField = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (foundField && insn instanceof MethodInsnNode && ((MethodInsnNode) insn).name.equals("setProtection")) {
|
|
|
|
if (foundField && insn instanceof MethodInsnNode && ((MethodInsnNode) insn).name.equals("setProtection")) {
|
|
|
|
AbstractInsnNode protectionInsn = insn.getPrevious();
|
|
|
|
AbstractInsnNode protectionInsn = insn.getPrevious();
|
|
|
|
|
|
|
|
|
|
|
|
@ -131,42 +122,6 @@ public class LOTRMaterialTransformer implements IClassTransformer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!foundField) {
|
|
|
|
|
|
|
|
System.out.println("[CinderLoE] Field '" + fieldName + "' not found in <clinit>.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void modifyMaterial(String fieldName, int durability, ClassNode classNode) {
|
|
|
|
|
|
|
|
MethodNode clinit = null;
|
|
|
|
|
|
|
|
boolean foundField = false;
|
|
|
|
|
|
|
|
boolean durabilityModified = false;
|
|
|
|
|
|
|
|
boolean protectionModified = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// First, find the <clinit> method
|
|
|
|
|
|
|
|
for (MethodNode method : classNode.methods) {
|
|
|
|
|
|
|
|
if (method.name.equals("<clinit>")) {
|
|
|
|
|
|
|
|
clinit = method;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (clinit == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Iterator<AbstractInsnNode> iter = clinit.instructions.iterator();
|
|
|
|
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
|
|
|
|
AbstractInsnNode insn = iter.next();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst.equals(fieldName)) {
|
|
|
|
|
|
|
|
foundField = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (foundField && !durabilityModified && insn instanceof MethodInsnNode && ((MethodInsnNode) insn).name.equals("setUses")) {
|
|
|
|
if (foundField && !durabilityModified && insn instanceof MethodInsnNode && ((MethodInsnNode) insn).name.equals("setUses")) {
|
|
|
|
AbstractInsnNode durabilityInsn = insn.getPrevious();
|
|
|
|
AbstractInsnNode durabilityInsn = insn.getPrevious();
|
|
|
|
|
|
|
|
|
|
|
|
|