SkidSolutions
This commit is contained in:
commit
14b3235b41
7727 files changed
+864433
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import org.objectweb.asm.*;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
/**
|
||||
* Standalone Stage 4 bytecode pass (Zero baseJar dependency):
|
||||
* Removes source-only $novoline$booleanArgument(I)Z conversions when the original JVM call consumed an int as Z.
|
||||
*/
|
||||
public class BooleanArgumentBytecode implements Opcodes {
|
||||
private static final String MARKER = "toBooleanArg";
|
||||
private static final String CONVERSION = "(I)Z";
|
||||
|
||||
static void verifyMarker(MethodNode method) {
|
||||
var operations = new ArrayList<Integer>();
|
||||
for (var insn : method.instructions) if (insn.getOpcode() >= 0) operations.add(insn.getOpcode());
|
||||
if ((method.access & (ACC_PRIVATE | ACC_STATIC)) != (ACC_PRIVATE | ACC_STATIC) || !method.desc.equals(CONVERSION)
|
||||
|| !operations.equals(List.of(ILOAD, IFEQ, ICONST_1, GOTO, ICONST_0, IRETURN))) {
|
||||
throw new IllegalStateException("Invalid boolean conversion marker");
|
||||
}
|
||||
}
|
||||
|
||||
private static int restore(Path path, List<String> rows) throws Exception {
|
||||
ClassReader reader = new ClassReader(Files.readAllBytes(path));
|
||||
var node = new ClassNode();
|
||||
reader.accept(node, 0);
|
||||
List<MethodNode> markers = node.methods.stream().filter(method -> method.name.equals(MARKER)).toList();
|
||||
if (markers.isEmpty()) return 0;
|
||||
if (markers.size() != 1) throw new IllegalStateException("Multiple conversion markers: " + node.name);
|
||||
verifyMarker(markers.get(0));
|
||||
int changes = 0;
|
||||
for (MethodNode method : node.methods) for (var insn : method.instructions.toArray()) {
|
||||
if (!(insn instanceof MethodInsnNode marker) || !marker.owner.equals(node.name) || !marker.name.equals(MARKER)) continue;
|
||||
if (marker.getOpcode() != INVOKESTATIC || !marker.desc.equals(CONVERSION)) {
|
||||
throw new IllegalStateException("Invalid marker invocation in " + node.name + "." + method.name);
|
||||
}
|
||||
AbstractInsnNode next = marker.getNext();
|
||||
while (next != null && next.getOpcode() < 0) {
|
||||
if (next instanceof FrameNode) throw new IllegalStateException("Stack map between marker and target");
|
||||
next = next.getNext();
|
||||
}
|
||||
if (!(next instanceof MethodInsnNode call)) throw new IllegalStateException("Expected a direct call after the marker");
|
||||
Type[] parameters = Type.getArgumentTypes(call.desc);
|
||||
if (parameters.length == 0 || !parameters[parameters.length - 1].equals(Type.BOOLEAN_TYPE)) {
|
||||
throw new IllegalStateException("Expected a boolean as the last target parameter");
|
||||
}
|
||||
method.instructions.remove(marker);
|
||||
rows.add(node.name + "\t" + method.name + method.desc + "\t" + call.owner + "." + call.name + call.desc);
|
||||
changes++;
|
||||
}
|
||||
if (changes == 0) throw new IllegalStateException("Unused conversion marker: " + node.name);
|
||||
node.methods.remove(markers.get(0));
|
||||
var writer = new ClassWriter(reader, 0);
|
||||
node.accept(writer);
|
||||
Files.write(path, writer.toByteArray());
|
||||
return changes;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int changed = 0;
|
||||
var report = new ArrayList<String>(List.of("class\tcaller\toriginal-target"));
|
||||
try (var paths = Files.walk(Path.of(args[0]))) {
|
||||
for (Path path : paths.filter(p -> p.toString().endsWith(".class")).sorted().toList()) {
|
||||
changed += restore(path, report);
|
||||
}
|
||||
}
|
||||
if (args.length > 1) Files.write(Path.of(args[1]), report);
|
||||
System.out.println("Preserved the original integer arguments of " + changed + " boolean call sites");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.*;
|
||||
|
||||
public final class BuildStandaloneClientJar {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Path classesDir = Paths.get(args[0]);
|
||||
Path resourcesDir = Paths.get(args[1]);
|
||||
String thirdPartyPathList = args[2];
|
||||
Path outJar = Paths.get(args[3]);
|
||||
Files.createDirectories(outJar.getParent());
|
||||
|
||||
Path tmpJar = outJar.resolveSibling(outJar.getFileName().toString() + ".tmp");
|
||||
Set<String> written = new HashSet<>();
|
||||
byte[] buf = new byte[32768];
|
||||
int classCount = 0, resCount = 0, libCount = 0;
|
||||
|
||||
try (ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(tmpJar), 65536))) {
|
||||
written.add("META-INF/MANIFEST.MF");
|
||||
zout.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
|
||||
zout.write("Manifest-Version: 1.0\r\nMain-Class: net.minecraft.client.main.Main\r\n\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
zout.closeEntry();
|
||||
|
||||
if (Files.isDirectory(classesDir)) {
|
||||
List<Path> clsFiles;
|
||||
try (Stream<Path> s = Files.walk(classesDir)) {
|
||||
clsFiles = s.filter(p -> Files.isRegularFile(p) && p.toString().endsWith(".class")).sorted().toList();
|
||||
}
|
||||
for (Path p : clsFiles) {
|
||||
classCount++;
|
||||
String rel = classesDir.relativize(p).toString().replace('\\', '/');
|
||||
if (!written.add(rel)) continue;
|
||||
zout.putNextEntry(new ZipEntry(rel));
|
||||
Files.copy(p, zout);
|
||||
zout.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
if (Files.isDirectory(resourcesDir)) {
|
||||
List<Path> resFiles;
|
||||
try (Stream<Path> s = Files.walk(resourcesDir)) {
|
||||
resFiles = s.filter(Files::isRegularFile).sorted().toList();
|
||||
}
|
||||
for (Path p : resFiles) {
|
||||
resCount++;
|
||||
String rel = resourcesDir.relativize(p).toString().replace('\\', '/');
|
||||
if (!written.add(rel)) continue;
|
||||
zout.putNextEntry(new ZipEntry(rel));
|
||||
Files.copy(p, zout);
|
||||
zout.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
for (String entry : thirdPartyPathList.split(File.pathSeparator)) {
|
||||
if (entry == null || entry.trim().isEmpty()) continue;
|
||||
Path jarPath = Paths.get(entry.trim());
|
||||
if (!Files.isRegularFile(jarPath)) continue;
|
||||
try (ZipFile ztp = new ZipFile(jarPath.toFile())) {
|
||||
Enumeration<? extends ZipEntry> en = ztp.entries();
|
||||
while (en.hasMoreElements()) {
|
||||
ZipEntry ze = en.nextElement();
|
||||
String nm = ze.getName();
|
||||
if (nm.endsWith("/")) continue;
|
||||
if (nm.startsWith("META-INF/") && (nm.endsWith(".SF") || nm.endsWith(".RSA") || nm.endsWith(".DSA"))) continue;
|
||||
if (!written.add(nm)) continue;
|
||||
libCount++;
|
||||
ZipEntry ne = new ZipEntry(nm);
|
||||
if (ze.getTime() != -1) ne.setTime(ze.getTime());
|
||||
zout.putNextEntry(ne);
|
||||
try (InputStream in = ztp.getInputStream(ze)) {
|
||||
int n;
|
||||
while ((n = in.read(buf)) != -1) zout.write(buf, 0, n);
|
||||
}
|
||||
zout.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Files.move(tmpJar, outJar, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.println("Built standalone runtime JAR: " + outJar + " (" + Files.size(outJar)
|
||||
+ " bytes; " + classCount + " compiled classes, " + resCount + " resources, " + libCount + " bundled library entries)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.objectweb.asm.*;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
/**
|
||||
* Standalone Stage 4 Property Bridge Restorer (Zero baseJar dependency at build time!):
|
||||
* Restores the 30 JVM generic bridge declarations on the 8 @Property classes from tools/property-bridges.tsv.
|
||||
*/
|
||||
public class PropertySignatures implements Opcodes {
|
||||
static final String PREFIX = "cc/novoline/modules/configurations/property/";
|
||||
static final String BASE = PREFIX + "AbstractNumberProperty";
|
||||
static final List<String> NAMES = List.of(
|
||||
BASE,
|
||||
PREFIX + "object/IntProperty",
|
||||
PREFIX + "object/LongProperty",
|
||||
PREFIX + "object/FloatProperty",
|
||||
PREFIX + "object/DoubleProperty",
|
||||
PREFIX + "object/ColorProperty",
|
||||
PREFIX + "object/StringProperty",
|
||||
PREFIX + "object/ListProperty"
|
||||
);
|
||||
static final Map<String, String> ALIASES = Map.of(
|
||||
"b(Ljava/lang/Number;)Z", "isGreaterThan",
|
||||
"f(Ljava/lang/Number;)Z", "isGreaterThanOrEqual",
|
||||
"j(Ljava/lang/Number;)Z", "isLessThan",
|
||||
"c(Ljava/lang/Number;)Z", "isLessThanOrEqual",
|
||||
"d(Ljava/lang/Number;)Z", "isWithinBounds",
|
||||
"a(Ljava/lang/Number;)V", "subtract",
|
||||
"g(Ljava/lang/Number;)V", "add",
|
||||
"e(Ljava/lang/Number;)L" + BASE + ";", "setMinimum",
|
||||
"c()L" + BASE + ";", "self"
|
||||
);
|
||||
|
||||
record BridgeSpec(String owner, String bridgeName, String bridgeDesc, String visibility,
|
||||
String targetName, String targetDesc, String sourceName) {
|
||||
String sourceBridge() { return sourceName + bridgeDesc; }
|
||||
String sourceTarget() { return sourceName + targetDesc; }
|
||||
boolean alreadyDeclared() { return sourceName.equals(targetName); }
|
||||
|
||||
MethodNode synthesize() {
|
||||
int acc = ("public".equals(visibility) ? ACC_PUBLIC : ACC_PROTECTED) | ACC_BRIDGE | ACC_SYNTHETIC;
|
||||
MethodNode mn = new MethodNode(acc, bridgeName, bridgeDesc, null, null);
|
||||
Type[] targetArgs = Type.getArgumentTypes(targetDesc);
|
||||
mn.instructions.add(new VarInsnNode(ALOAD, 0));
|
||||
if (targetArgs.length == 1) {
|
||||
mn.instructions.add(new VarInsnNode(ALOAD, 1));
|
||||
mn.instructions.add(new TypeInsnNode(CHECKCAST, targetArgs[0].getInternalName()));
|
||||
}
|
||||
mn.instructions.add(new MethodInsnNode(INVOKEVIRTUAL, owner, targetName, targetDesc, false));
|
||||
mn.instructions.add(new InsnNode(Type.getReturnType(bridgeDesc).getOpcode(IRETURN)));
|
||||
mn.maxStack = targetArgs.length == 0 ? 1 : 2;
|
||||
mn.maxLocals = targetArgs.length == 0 ? 1 : 2;
|
||||
return mn;
|
||||
}
|
||||
}
|
||||
|
||||
static ClassNode read(byte[] bytes) {
|
||||
var result = new ClassNode();
|
||||
new ClassReader(bytes).accept(result, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void extractPlanFromJar(ZipFile jar, Path output) throws Exception {
|
||||
var rows = new ArrayList<String>(List.of("class\tbridge\tdescriptor\tvisibility\ttarget\ttarget-descriptor\tsource-method"));
|
||||
for (String name : NAMES) {
|
||||
ClassNode type;
|
||||
try (var stream = jar.getInputStream(jar.getEntry(name + ".class"))) {
|
||||
type = read(stream.readAllBytes());
|
||||
}
|
||||
for (var method : type.methods) {
|
||||
if ((method.access & ACC_BRIDGE) == 0) continue;
|
||||
var ops = new ArrayList<AbstractInsnNode>();
|
||||
for (var insn : method.instructions) if (insn.getOpcode() >= 0) ops.add(insn);
|
||||
int args = Type.getArgumentTypes(method.desc).length;
|
||||
int invoke = args == 0 ? 1 : 3;
|
||||
MethodInsnNode call = (MethodInsnNode) ops.get(invoke);
|
||||
String vis = (method.access & ACC_PUBLIC) != 0 ? "public" : "protected";
|
||||
String srcName = ALIASES.getOrDefault(method.name + method.desc, method.name);
|
||||
rows.add(String.join("\t", name, method.name, method.desc, vis, call.name, call.desc, srcName));
|
||||
}
|
||||
}
|
||||
Files.createDirectories(output.getParent());
|
||||
Files.write(output, rows, StandardCharsets.UTF_8);
|
||||
System.out.println("Wrote " + (rows.size() - 1) + " standalone bridge specs to " + output);
|
||||
}
|
||||
|
||||
static String originalName(String name, String desc) {
|
||||
for (var alias : ALIASES.entrySet()) {
|
||||
if (alias.getValue().equals(name) && alias.getKey().endsWith(desc)) {
|
||||
return alias.getKey().substring(0, alias.getKey().indexOf('('));
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
static void restoreFromPlan(Path planTsv, Path compiled, Path destination) throws Exception {
|
||||
Map<String, List<BridgeSpec>> byClass = new LinkedHashMap<>();
|
||||
for (String n : NAMES) byClass.put(n, new ArrayList<>());
|
||||
List<String> lines = Files.readAllLines(planTsv, StandardCharsets.UTF_8);
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
String ln = lines.get(i).trim();
|
||||
if (ln.isEmpty()) continue;
|
||||
String[] p = ln.split("\t");
|
||||
byClass.get(p[0]).add(new BridgeSpec(p[0], p[1], p[2], p[3], p[4], p[5], p[6]));
|
||||
}
|
||||
|
||||
int copied = 0, removed = 0, extra = 0;
|
||||
for (String name : NAMES) {
|
||||
ClassNode rebuilt = read(Files.readAllBytes(compiled.resolve(name + ".class")));
|
||||
List<BridgeSpec> bridges = byClass.get(name);
|
||||
for (BridgeSpec bridge : bridges) {
|
||||
var generated = rebuilt.methods.stream().filter(m -> (m.name + m.desc).equals(bridge.sourceBridge())).findFirst().orElseThrow(
|
||||
() -> new IllegalStateException("javac bridge missing: " + name + "." + bridge.sourceBridge()));
|
||||
if ((generated.access & ACC_BRIDGE) == 0) throw new IllegalStateException("Expected a javac-generated bridge");
|
||||
rebuilt.methods.remove(generated);
|
||||
if (!bridge.alreadyDeclared()) {
|
||||
var implementation = rebuilt.methods.stream().filter(m -> (m.name + m.desc).equals(bridge.sourceTarget())).findFirst().orElseThrow();
|
||||
rebuilt.methods.remove(implementation);
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
for (var method : List.copyOf(rebuilt.methods)) {
|
||||
if ((method.access & ACC_BRIDGE) != 0) {
|
||||
rebuilt.methods.remove(method);
|
||||
extra++;
|
||||
}
|
||||
}
|
||||
var remapped = new ClassNode();
|
||||
rebuilt.accept(new ClassRemapper(remapped, new Remapper(ASM9) {
|
||||
@Override public String mapMethodName(String owner, String method, String desc) {
|
||||
return NAMES.contains(owner) ? originalName(method, desc) : method;
|
||||
}
|
||||
}));
|
||||
for (BridgeSpec bridge : bridges) {
|
||||
remapped.methods.add(bridge.synthesize());
|
||||
copied++;
|
||||
}
|
||||
var writer = new ClassWriter(0);
|
||||
remapped.accept(writer);
|
||||
Path output = destination.resolve(name + ".class");
|
||||
Files.createDirectories(output.getParent());
|
||||
Files.write(output, writer.toByteArray());
|
||||
}
|
||||
System.out.println("Restored " + copied + " standalone bridges and removed " + removed
|
||||
+ " compile-time forwarding declarations and " + extra + " extra javac bridges");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args[0].equals("plan")) {
|
||||
try (var jar = new ZipFile(args[1])) {
|
||||
extractPlanFromJar(jar, Path.of(args[2]));
|
||||
}
|
||||
} else if (args[0].equals("restore")) {
|
||||
restoreFromPlan(Path.of(args[1]), Path.of(args[2]), Path.of(args[3]));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected plan or restore");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import org.objectweb.asm.*;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
* Standalone Stage 4 Post-Compile Bytecode Alignment (Zero baseJar dependency!):
|
||||
* Reads plain-text manifests tools/bridge-delegates.tsv and tools/bytecode-metadata.tsv.
|
||||
*/
|
||||
public final class Stage4BytecodeRestore {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Path bridgeTsv = Paths.get(args[0]);
|
||||
Path metaTsv = Paths.get(args[1]);
|
||||
Path classesDir = Paths.get(args[2]);
|
||||
|
||||
// 1. Apply bridge delegate fixes from tools/bridge-delegates.tsv
|
||||
if (Files.isRegularFile(bridgeTsv)) {
|
||||
List<String> lines = Files.readAllLines(bridgeTsv, StandardCharsets.UTF_8);
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
String ln = lines.get(i).trim();
|
||||
if (ln.isEmpty() || ln.startsWith("#")) continue;
|
||||
String[] p = ln.split("\t");
|
||||
String kind = p[0];
|
||||
Path cf = classesDir.resolve(p[1] + ".class");
|
||||
if (!Files.isRegularFile(cf)) continue;
|
||||
if ("BRIDGE".equals(kind)) {
|
||||
fixBridgeDelegate(cf, p[2], p[3], p[4], p[5]);
|
||||
} else if ("DROP_BRIDGE".equals(kind)) {
|
||||
ClassNode cn = new ClassNode();
|
||||
new ClassReader(Files.readAllBytes(cf)).accept(cn, 0);
|
||||
if (cn.methods.removeIf(mn -> mn.name.equals(p[2]) && mn.desc.equals(p[3]) && (mn.access & ACC_BRIDGE) != 0)) {
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
Files.write(cf, cw.toByteArray());
|
||||
}
|
||||
} else if ("METHOD_SIG".equals(kind)) {
|
||||
ClassNode cn = new ClassNode();
|
||||
new ClassReader(Files.readAllBytes(cf)).accept(cn, 0);
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (mn.name.equals(p[2]) && mn.desc.equals(p[3])) mn.signature = p[4];
|
||||
}
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
Files.write(cf, cw.toByteArray());
|
||||
} else if ("UHC_CTOR_SIG".equals(kind)) {
|
||||
ClassNode cn = new ClassNode();
|
||||
new ClassReader(Files.readAllBytes(cf)).accept(cn, 0);
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (mn.name.equals("<init>") && mn.signature != null) {
|
||||
mn.signature = mn.signature.replace("(Lcc/novoline/modules/misc/uhc/UhcProfessionRegistry;", "(");
|
||||
}
|
||||
}
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
Files.write(cf, cw.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Load tools/bytecode-metadata.tsv (version, access, noInit, genuine I2B/I2S methods)
|
||||
Map<String, String[]> metaMap = new HashMap<>();
|
||||
Set<String> genuineI2B = new HashSet<>();
|
||||
Set<String> genuineI2S = new HashSet<>();
|
||||
if (Files.isRegularFile(metaTsv)) {
|
||||
List<String> lines = Files.readAllLines(metaTsv, StandardCharsets.UTF_8);
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
String ln = lines.get(i).trim();
|
||||
if (ln.isEmpty()) continue;
|
||||
String[] p = ln.split("\t", -1);
|
||||
String kind = p[0];
|
||||
if ("CLS".equals(kind)) {
|
||||
metaMap.put(p[1], p);
|
||||
} else if ("I2B".equals(kind)) {
|
||||
genuineI2B.add(p[1] + "." + p[2]);
|
||||
} else if ("I2S".equals(kind)) {
|
||||
genuineI2S.add(p[1] + "." + p[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Path> allCompiled;
|
||||
try (Stream<Path> s = Files.walk(classesDir)) {
|
||||
allCompiled = s.filter(p -> Files.isRegularFile(p) && p.toString().endsWith(".class")).sorted().toList();
|
||||
}
|
||||
|
||||
int strippedNarrow = 0;
|
||||
for (Path cf : allCompiled) {
|
||||
String clsName = classesDir.relativize(cf).toString().replace('\\', '/');
|
||||
clsName = clsName.substring(0, clsName.length() - 6);
|
||||
|
||||
ClassNode comp = new ClassNode();
|
||||
new ClassReader(Files.readAllBytes(cf)).accept(comp, 0);
|
||||
boolean changed = false;
|
||||
|
||||
String[] mrow = metaMap.get(clsName);
|
||||
if (mrow != null) {
|
||||
int origVer = Integer.parseInt(mrow[2]);
|
||||
if ((origVer & 0xFFFF) < 50) {
|
||||
origVer = 52;
|
||||
}
|
||||
int origAcc = Integer.parseInt(mrow[3]);
|
||||
if ((origAcc & ACC_INTERFACE) != 0) {
|
||||
origAcc |= ACC_ABSTRACT;
|
||||
}
|
||||
if ((origAcc & ACC_ENUM) != 0 && !"java/lang/Enum".equals(comp.superName)) {
|
||||
origAcc &= ~ACC_ENUM;
|
||||
}
|
||||
boolean noInit = "1".equals(mrow[4]);
|
||||
if (comp.version != origVer || comp.access != origAcc) {
|
||||
comp.version = origVer;
|
||||
comp.access = origAcc;
|
||||
changed = true;
|
||||
}
|
||||
if (noInit) {
|
||||
if (comp.methods.removeIf(m -> m.name.equals("<init>") && m.desc.equals("()V"))) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strip spurious Vineflower/repair I2B / I2S narrowing casts on methods that had 0 in original bytecode
|
||||
for (MethodNode cm : comp.methods) {
|
||||
if ((cm.access & (ACC_BRIDGE | ACC_SYNTHETIC)) != 0) continue;
|
||||
String mkey = clsName + "." + cm.name + cm.desc;
|
||||
boolean allowB = genuineI2B.contains(mkey) || cm.desc.endsWith(")B");
|
||||
boolean allowS = genuineI2S.contains(mkey) || cm.desc.endsWith(")S");
|
||||
if (allowB && allowS) continue;
|
||||
List<AbstractInsnNode> toRemove = new ArrayList<>();
|
||||
for (AbstractInsnNode in : cm.instructions) {
|
||||
int op = in.getOpcode();
|
||||
if ((op == I2B && !allowB) || (op == I2S && !allowS)) {
|
||||
AbstractInsnNode nxt = in.getNext();
|
||||
while (nxt != null && nxt.getOpcode() < 0) nxt = nxt.getNext();
|
||||
boolean keep = false;
|
||||
if (nxt instanceof MethodInsnNode mi) {
|
||||
if (mi.desc.contains("B") || mi.desc.contains("S")) {
|
||||
keep = true;
|
||||
}
|
||||
} else if (nxt instanceof FieldInsnNode fi) {
|
||||
if ("B".equals(fi.desc) || "S".equals(fi.desc)) {
|
||||
keep = true;
|
||||
}
|
||||
} else if (nxt != null && (nxt.getOpcode() == BASTORE || nxt.getOpcode() == SASTORE)) {
|
||||
keep = true;
|
||||
}
|
||||
if (!keep) toRemove.add(in);
|
||||
}
|
||||
}
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (AbstractInsnNode rem : toRemove) cm.instructions.remove(rem);
|
||||
strippedNarrow += toRemove.size();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
comp.accept(cw);
|
||||
Files.write(cf, cw.toByteArray());
|
||||
}
|
||||
}
|
||||
System.out.println("Stage4BytecodeRestore complete (stripped " + strippedNarrow + " spurious I2B/I2S casts).");
|
||||
}
|
||||
|
||||
private static void fixBridgeDelegate(Path clsFile, String bridgeName, String concreteDesc, String bridgeDesc, String realTargetName) throws Exception {
|
||||
ClassNode cn = new ClassNode();
|
||||
new ClassReader(Files.readAllBytes(clsFile)).accept(cn, 0);
|
||||
cn.methods.removeIf(mn -> mn.name.equals(bridgeName) && mn.desc.equals(concreteDesc) && (mn.access & ACC_BRIDGE) == 0);
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (mn.name.equals(bridgeName) && mn.desc.equals(bridgeDesc)) {
|
||||
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
||||
if (insn instanceof MethodInsnNode mi && mi.name.equals(bridgeName) && mi.desc.equals(concreteDesc)) {
|
||||
mi.name = realTargetName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
Files.write(clsFile, cw.toByteArray());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
kind class method desc1 desc2 target
|
||||
BRIDGE cc/novoline/utils/bends/LayerBendsArmor func_177179_a (Lnet/minecraft/client/model/ModelBiped;I)V (Lnet/minecraft/client/model/ModelBase;I)V a
|
||||
BRIDGE cc/novoline/utils/bends/LayerBendsCape doRenderLayer (Lnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V (Lnet/minecraft/entity/EntityLivingBase;FFFFFFF)V a
|
||||
BRIDGE cc/novoline/modules/configurations/property/object/ImmutableBooleanProperty set (Ljava/lang/Boolean;)V (Ljava/lang/Object;)V runVoidA
|
||||
BRIDGE cc/novoline/utils/messages/TextMessage appendText (Ljava/lang/String;)Lcc/novoline/utils/messages/TextMessage; (Ljava/lang/String;)Lnet/minecraft/util/IChatComponent; d
|
||||
BRIDGE cc/novoline/utils/messages/TextMessage appendSibling (Lnet/minecraft/util/IChatComponent;)Lcc/novoline/utils/messages/TextMessage; (Lnet/minecraft/util/IChatComponent;)Lnet/minecraft/util/IChatComponent; b
|
||||
BRIDGE cc/novoline/utils/messages/TextMessage createCopy ()Lcc/novoline/utils/messages/TextMessage; ()Lnet/minecraft/util/IChatComponent; c
|
||||
BRIDGE cc/novoline/utils/bends/RenderBendsPlayer getMainModel ()Lcc/novoline/utils/bends/ModelBendsPlayerBase; ()Lnet/minecraft/client/model/ModelBase; a
|
||||
BRIDGE cc/novoline/utils/bends/RenderBendsPlayer preRenderCallback (Lnet/minecraft/client/entity/AbstractClientPlayer;F)V (Lnet/minecraft/entity/EntityLivingBase;F)V a
|
||||
BRIDGE cc/novoline/utils/bends/RenderBendsPlayer rotateCorpse (Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V (Lnet/minecraft/entity/EntityLivingBase;FFF)V a
|
||||
BRIDGE cc/novoline/utils/bends/RenderBendsPlayer getEntityTexture (Lnet/minecraft/client/entity/AbstractClientPlayer;)Lnet/minecraft/util/ResourceLocation; (Lnet/minecraft/entity/Entity;)Lnet/minecraft/util/ResourceLocation; c
|
||||
BRIDGE cc/novoline/utils/bends/RenderBendsPlayer b (Lnet/minecraft/client/entity/AbstractClientPlayer;DDD)V (Lnet/minecraft/entity/EntityLivingBase;DDD)V a
|
||||
DROP_BRIDGE cc/novoline/utils/bends/RenderBendsPlayer a (Lnet/minecraft/entity/EntityLivingBase;DDD)V
|
||||
BRIDGE net/minecraft/client/renderer/entity/layers/LayerDeadmau5Head doRenderLayer (Lnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V (Lnet/minecraft/entity/EntityLivingBase;FFFFFFF)V a
|
||||
BRIDGE net/minecraft/client/renderer/tileentity/TileEntityEnderChestRenderer renderTileEntityAt (Lnet/minecraft/tileentity/TileEntityEnderChest;DDDFI)V (Lnet/minecraft/tileentity/TileEntity;DDDFI)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderEntityItem getEntityTexture (Lnet/minecraft/entity/item/EntityItem;)Lnet/minecraft/util/ResourceLocation; (Lnet/minecraft/entity/Entity;)Lnet/minecraft/util/ResourceLocation; a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderEntityItem doRender (Lnet/minecraft/entity/item/EntityItem;DDDFF)V (Lnet/minecraft/entity/Entity;DDDFF)V b
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer getEntityTexture (Lnet/minecraft/client/entity/AbstractClientPlayer;)Lnet/minecraft/util/ResourceLocation; (Lnet/minecraft/entity/Entity;)Lnet/minecraft/util/ResourceLocation; c
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer getMainModel ()Lcc/novoline/utils/bends/ModelBendsPlayerBase; ()Lnet/minecraft/client/model/ModelBase; a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer preRenderCallback (Lnet/minecraft/client/entity/AbstractClientPlayer;F)V (Lnet/minecraft/entity/EntityLivingBase;F)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer rotateCorpse (Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V (Lnet/minecraft/entity/EntityLivingBase;FFF)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer doRender (Lnet/minecraft/client/entity/AbstractClientPlayer;DDDFF)V (Lnet/minecraft/entity/EntityLivingBase;DDDFF)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer doRender (Lnet/minecraft/client/entity/AbstractClientPlayer;DDDFF)V (Lnet/minecraft/entity/Entity;DDDFF)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer renderOffsetLivingLabel (Lnet/minecraft/client/entity/AbstractClientPlayer;DDDLjava/lang/String;FD)V (Lnet/minecraft/entity/Entity;DDDLjava/lang/String;FD)V a
|
||||
BRIDGE net/minecraft/client/renderer/entity/RenderPlayer b (Lnet/minecraft/client/entity/AbstractClientPlayer;DDD)V (Lnet/minecraft/entity/EntityLivingBase;DDD)V a
|
||||
DROP_BRIDGE net/minecraft/client/renderer/entity/RenderPlayer a (Lnet/minecraft/entity/EntityLivingBase;DDD)V
|
||||
BRIDGE net/minecraft/client/renderer/entity/RendererLivingEntity renderName (Lnet/minecraft/entity/EntityLivingBase;DDD)V (Lnet/minecraft/entity/Entity;DDD)V a
|
||||
BRIDGE net/minecraft/client/settings/KeyBinding compareTo (Lnet/minecraft/client/settings/KeyBinding;)I (Ljava/lang/Object;)I a
|
||||
METHOD_SIG net/minecraft/client/renderer/entity/Render b (Lnet/minecraft/entity/Entity;)Z (TT;)Z
|
||||
UHC_CTOR_SIG cc/novoline/modules/misc/uhc/UhcProfession
|
||||
|
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
class bridge descriptor visibility target target-descriptor source-method
|
||||
cc/novoline/modules/configurations/property/AbstractNumberProperty set (Ljava/lang/Object;)V public i (Ljava/lang/Number;)V set
|
||||
cc/novoline/modules/configurations/property/object/IntProperty c ()Lcc/novoline/modules/configurations/property/AbstractNumberProperty; protected getIntPropertyF ()Lcc/novoline/modules/configurations/property/object/IntProperty; self
|
||||
cc/novoline/modules/configurations/property/object/IntProperty b (Ljava/lang/Number;)Z public b (Ljava/lang/Integer;)Z isGreaterThan
|
||||
cc/novoline/modules/configurations/property/object/IntProperty j (Ljava/lang/Number;)Z public is2FlagD (Ljava/lang/Integer;)Z isLessThan
|
||||
cc/novoline/modules/configurations/property/object/IntProperty d (Ljava/lang/Number;)Z protected is6FlagC (Ljava/lang/Integer;)Z isWithinBounds
|
||||
cc/novoline/modules/configurations/property/object/IntProperty g (Ljava/lang/Number;)V public a (Ljava/lang/Integer;)V add
|
||||
cc/novoline/modules/configurations/property/object/IntProperty a (Ljava/lang/Number;)V public runVoid3E (Ljava/lang/Integer;)V subtract
|
||||
cc/novoline/modules/configurations/property/object/LongProperty a (Ljava/lang/Number;)V protected d (Ljava/lang/Long;)V subtract
|
||||
cc/novoline/modules/configurations/property/object/LongProperty j (Ljava/lang/Number;)Z protected e (Ljava/lang/Long;)Z isLessThan
|
||||
cc/novoline/modules/configurations/property/object/LongProperty c ()Lcc/novoline/modules/configurations/property/AbstractNumberProperty; protected getLongPropertyB ()Lcc/novoline/modules/configurations/property/object/LongProperty; self
|
||||
cc/novoline/modules/configurations/property/object/LongProperty b (Ljava/lang/Number;)Z protected b (Ljava/lang/Long;)Z isGreaterThan
|
||||
cc/novoline/modules/configurations/property/object/LongProperty d (Ljava/lang/Number;)Z protected a (Ljava/lang/Long;)Z isWithinBounds
|
||||
cc/novoline/modules/configurations/property/object/LongProperty g (Ljava/lang/Number;)V protected c (Ljava/lang/Long;)V add
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty a (Ljava/lang/Number;)V protected c (Ljava/lang/Float;)V subtract
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty c ()Lcc/novoline/modules/configurations/property/AbstractNumberProperty; protected getFloatPropertyA ()Lcc/novoline/modules/configurations/property/object/FloatProperty; self
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty g (Ljava/lang/Number;)V protected b (Ljava/lang/Float;)V add
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty j (Ljava/lang/Number;)Z protected d (Ljava/lang/Float;)Z isLessThan
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty d (Ljava/lang/Number;)Z protected e (Ljava/lang/Float;)Z isWithinBounds
|
||||
cc/novoline/modules/configurations/property/object/FloatProperty b (Ljava/lang/Number;)Z protected f (Ljava/lang/Float;)Z isGreaterThan
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty j (Ljava/lang/Number;)Z protected f (Ljava/lang/Double;)Z isLessThan
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty a (Ljava/lang/Number;)V protected d (Ljava/lang/Double;)V subtract
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty d (Ljava/lang/Number;)Z protected e (Ljava/lang/Double;)Z isWithinBounds
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty g (Ljava/lang/Number;)V protected b (Ljava/lang/Double;)V add
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty b (Ljava/lang/Number;)Z protected c (Ljava/lang/Double;)Z isGreaterThan
|
||||
cc/novoline/modules/configurations/property/object/DoubleProperty c ()Lcc/novoline/modules/configurations/property/AbstractNumberProperty; protected getDoublePropertyB ()Lcc/novoline/modules/configurations/property/object/DoubleProperty; self
|
||||
cc/novoline/modules/configurations/property/object/ColorProperty i (Ljava/lang/Number;)V public d (Ljava/lang/Integer;)V i
|
||||
cc/novoline/modules/configurations/property/object/ColorProperty get ()Ljava/lang/Object; public getIntegerB ()Ljava/lang/Integer; get
|
||||
cc/novoline/modules/configurations/property/object/ColorProperty set (Ljava/lang/Object;)V public d (Ljava/lang/Integer;)V set
|
||||
cc/novoline/modules/configurations/property/object/StringProperty set (Ljava/lang/Object;)V public d (Ljava/lang/String;)V set
|
||||
cc/novoline/modules/configurations/property/object/ListProperty set (Ljava/lang/Object;)V public c (Ljava/util/List;)V set
|
||||
|
Reference in new issue
Block a user