Sync local working tree: injector, engine, mixin and build updates

Add compatibility notes, resource-provider and hook checks, and payload
bundling script. Remove generated engine mixin stubs, engine target lists
and prebuilt binaries now produced by the build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
aidanandClaude Opus 5.5 committed 2026-11-10 17:27:24 -06:00
1 parent 6d94493e58
commit 05d169a2dd
210 files changed
+1862 -849

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
"""Run with python check/bundle_payloads_check.py."""
import importlib.util
import tempfile
import zipfile
from pathlib import Path
spec = importlib.util.spec_from_file_location('bundle_payloads', Path(__file__).resolve().parents[1] / 'scripts/bundle_payloads.py')
bundle = importlib.util.module_from_spec(spec)
spec.loader.exec_module(bundle)
def entries(path):
with zipfile.ZipFile(path) as jar:
return {name: jar.read(name) for name in jar.namelist()}
test_root = Path(__file__).resolve().parents[1] / 'work'
test_root.mkdir(exist_ok=True)
with tempfile.TemporaryDirectory(dir=test_root) as temporary:
directory = Path(temporary)
inputs = {}
for version in ('1.21.1', '1.21.11'):
path = directory / f'input-{version}.jar'
with zipfile.ZipFile(path, 'w') as jar:
jar.writestr('prestige-engine/minecraft-version.txt', version)
jar.writestr('imgui/ImGui.class', b'shared library')
jar.writestr('library/Different.class', version.encode())
jar.writestr('dev/zprestige/Prestige.class', b'keep game code local')
jar.writestr('fabric.mod.json', b'keep metadata local')
inputs[version] = path
output = directory / 'output'
bundle.pack(inputs, output)
common = entries(output / 'common.jar')
assert common == {'imgui/ImGui.class': b'shared library'}
for version, original in inputs.items():
variant = entries(output / f'{version}.jar')
assert not common.keys() & variant.keys()
assert common | variant == entries(original), 'Split must reconstruct every original entry exactly'
try:
bundle.pack({'1.21.2': inputs['1.21.1']}, directory / 'bad')
except ValueError:
pass
else:
raise AssertionError('Mismatched payload target accepted')
print('Bundle reconstruction and target checks passed')
@@ -0,0 +1,70 @@
package dev.zprestige.prestige.engine;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import net.lenni0451.classtransform.utils.tree.IClassProvider;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
/** Exercises an actual resource-less generated class without requiring native injection. */
public final class ResourceClassProviderCheck {
public static void main(String[] args) throws Exception {
String name = "prestige.check.GeneratedLocalRef";
String internal = name.replace('.', '/');
ClassWriter writer = new ClassWriter(0);
writer.visit(Opcodes.V21, Opcodes.ACC_PUBLIC, internal, null, "java/lang/Object", null);
MethodVisitor init = writer.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
init.visitCode();
init.visitTypeInsn(Opcodes.NEW, "java/lang/AssertionError");
init.visitInsn(Opcodes.DUP);
init.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/AssertionError", "<init>", "()V", false);
init.visitInsn(Opcodes.ATHROW);
init.visitMaxs(2, 0);
init.visitEnd();
writer.visitEnd();
byte[] definition = writer.toByteArray();
class GeneratedLoader extends ClassLoader {
GeneratedLoader() { super(ResourceClassProviderCheck.class.getClassLoader()); }
Class<?> define() { return defineClass(name, definition, 0, definition.length); }
}
GeneratedLoader loader = new GeneratedLoader();
Class<?> generated = loader.define();
if (loader.getResourceAsStream(internal + ".class") != null) throw new AssertionError("fixture has a resource");
AtomicInteger calls = new AtomicInteger();
Function<Class<?>, byte[]> live = type -> {
calls.incrementAndGet();
if (type != generated) throw new AssertionError("wrong generated class");
return definition;
};
IClassProvider provider = provider(loader, null, live);
if (!Arrays.equals(definition, provider.getClass(name))) throw new AssertionError("wrong live bytes");
provider.getClass("java.lang.String");
if (calls.get() != 1) throw new AssertionError("resource-backed classes must not use live capture");
String tiny = "tiny\t2\t0\tintermediary\tnamed\nc\t" + internal + "\tprestige/check/NamedLocalRef\n";
if (!Arrays.equals(definition, provider(loader, tiny.getBytes(StandardCharsets.UTF_8), live)
.getClass("prestige.check.NamedLocalRef"))) throw new AssertionError("mapped fallback failed");
rejects(provider(loader, null, null), name);
rejects(provider(loader, null, type -> null), name);
rejects(provider(loader, null, type -> new byte[0]), name);
rejects(provider(loader, null, live), "prestige.check.MissingClass");
System.out.println("Generated-class resource fallback checks passed (class was not initialized)");
}
private static IClassProvider provider(ClassLoader loader, byte[] tiny, Function<Class<?>, byte[]> live) throws Exception {
Class<?> type = Class.forName("dev.zprestige.prestige.engine.EnginePlugin$ResourceClassProvider");
Constructor<?> constructor = type.getDeclaredConstructor(ClassLoader.class, Set.class, byte[].class, Function.class);
constructor.setAccessible(true);
return (IClassProvider) constructor.newInstance(loader, Set.of(), tiny, live);
}
private static void rejects(IClassProvider provider, String name) throws Exception {
try { provider.getClass(name); }
catch (ClassNotFoundException expected) { return; }
throw new AssertionError("accepted unavailable bytes for " + name);
}
}
@@ -0,0 +1,28 @@
package dev.zprestige.prestige.inject;
/** JDK-only check; no game, Fabric runtime or native injection required. */
public final class MinecraftTargetCheck {
public static void main(String[] args) {
for (int patch = 1; patch <= 11; patch++) {
String target = "1.21." + patch;
MinecraftTarget.require(target, target);
for (int other = 1; other <= 11; other++) {
if (patch != other) rejects(target, "1.21." + other);
}
}
rejects("1.21.11", "1.21.11-pre1");
rejects("1.21.11", "1.21.110");
rejects("", "");
System.out.println("Minecraft target checks passed");
}
private static void rejects(String target, String actual) {
try {
MinecraftTarget.require(target, actual);
} catch (IllegalStateException expected) {
if (!expected.getMessage().contains(actual)) throw new AssertionError(expected);
return;
}
throw new AssertionError("Accepted mismatched target " + target + " / " + actual);
}
}
+17
View File
@@ -0,0 +1,17 @@
// Run with: gradlew -I check/resource-provider.gradle resourceProviderCheck
gradle.projectsEvaluated {
def project = gradle.rootProject.project(':1.21.11')
def compileCheck = project.tasks.register('compileResourceProviderCheck', JavaCompile) {
dependsOn project.tasks.named('classes')
source project.rootProject.file('check/dev/zprestige/prestige/engine/ResourceClassProviderCheck.java')
classpath = project.sourceSets.main.runtimeClasspath
destinationDirectory = project.layout.buildDirectory.dir('checks/resource-provider')
options.release = 21
options.encoding = 'UTF-8'
}
project.tasks.register('resourceProviderCheck', JavaExec) {
dependsOn compileCheck
classpath = project.files(compileCheck.flatMap { it.destinationDirectory }) + project.sourceSets.main.runtimeClasspath
mainClass = 'dev.zprestige.prestige.engine.ResourceClassProviderCheck'
}
}