mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-27 23:45:52 +00:00
fix: preserve generated client render dispatch
This commit is contained in:
1 parent
60d060a3ff
commit
36e1a58bd9
7 files changed
+333
-7
No files matched your search
@@ -1550,3 +1550,25 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec
|
||||
five `@Mod` versions match both packaged jar versions. External Scala-trait tests remain green; existing manual
|
||||
client checks and Java-source model-bridge limitations remain. Next: `getBytes`, `classNode` and `internalDefine`
|
||||
class-byte loading/cache helpers, characterized first and without loader/cache algorithm changes.
|
||||
- Investigated the 2026-09-03 ProjectRed placement crash on `60d060a`. The failure occurs in multipart TESR rendering,
|
||||
not registration: the earlier client-trait port (`970e888`) left an `INVOKEVIRTUAL` call to
|
||||
`TileMultipartClient.hasDynamicParts()Z` in `MultipartRenderer$`, while Forge exposes that type as an interface.
|
||||
A raw-jar audit of calls/field accesses to all eight Java-authored tile trait inputs found this one unsafe external
|
||||
call. The recent Scala-trait registration extraction is not its cause.
|
||||
- Added four Forge regression cases executing the shipped renderer method body against generated client tiles.
|
||||
Only GL/pass services and the final drawing callback are recorded, because the dedicated server strips the actual
|
||||
`TMultiPart.renderDynamic` method. Static and empty early returns, non-client rejection, render-state setup and
|
||||
exact dynamic coordinates/frame/pass are covered. The final tests were rerun against the broken renderer: both
|
||||
nonempty cases raise the same `IncompatibleClassChangeError` as the supplied crash. This closes the call-site gap
|
||||
left by earlier client-tile tests, which invoked trait methods through method handles.
|
||||
- Added a default-false `TileMultipart.hasDynamicParts()` base hook and routed the renderer's flag query through it.
|
||||
Generated client tiles already supply the overriding getter. The original checked client-trait cast and guards
|
||||
remain; no generator algorithm or runtime trait interface changes. The additive base method is recorded in the
|
||||
existing divergence entry. Reference source/jar, reproduction reports and scripts are saved under ignored
|
||||
`run/renderer-compatibility-review/`; the manual checklist records the failed full-client check and required retest.
|
||||
- Clean formatting/checkstyle/build and Forge pass after stopping Gradle: 333 JVM / 163 Forge tests, zero
|
||||
failures/errors/skips. All 455 class APIs match except the new base hook, and 3,713 other method bodies match.
|
||||
No unsafe external calls/field accesses to the eight transformed Java tile inputs remain. All 40 generated outputs
|
||||
keep their instructions: 34 names/hashes are exact; six composites are renumbered by the new tests' earlier client
|
||||
tile construction. The dev config and forced Scala-compilation guard remain unchanged; all five `@Mod` versions
|
||||
match both packaged jars. Full-client placement/rendering with the fixed jar still needs confirmation.
|
||||
@@ -74,7 +74,7 @@ Other retained `$class` bridges and `MODULE$` companions are not covered by this
|
||||
| `JItemMultiPart` | Static `hitDepth` and `onItemUse(part, ...)` implementations |
|
||||
| `MicroMaterialRegistry` | Static `setupIDMap`, `calcMaxCuttingStrength` and `loadIcons` forwarders |
|
||||
| `PacketScheduler` / `TScheduledPacketPart` | Static `sendScheduled()` on the facade and `readMask(part, packet)` on the interface |
|
||||
| `TileMultipart` | No-op `renderStatic`, `renderDynamic` and `randomDisplayTick` hooks for dispatching generated overrides through a stable superclass |
|
||||
| `TileMultipart` | `hasDynamicParts` (false by default), `renderStatic`, `renderDynamic` and `randomDisplayTick` hooks for dispatching generated overrides through a stable superclass |
|
||||
| `MultipartMixinFactory` | Four additional static forwarders: `onCompiled`, `autoCompleteJavaTrait` and the two mangled `ASMMixinFactory` parent helpers. Scala emitted them when the base became Java with its original public JVM access; the Java facade retains them. Existing facade entries are unchanged. |
|
||||
|
||||
Previously abstract JVM interface methods now have Java defaults, allowing inheritance without Scala forwarders:
|
||||
|
||||
@@ -12,8 +12,8 @@ what breaks, and what is left. The other documents hold the reasoning.
|
||||
| `JAVA_MIGRATION_MANUAL_CHECKS.md` | What no automated test can cover, and must be checked by hand in a client |
|
||||
| `JAVA_MIGRATION_PROFILE.md` | The focused baseline, first measured result, findings, and exact rerun command |
|
||||
|
||||
Branch: `algent/java`. Base: `master`. 185 commits including the API-cleanup plan, divergence-log cleanup, ports
|
||||
through Scala-trait registration metadata, and the ASM characterization backfill and review fixes.
|
||||
Branch: `algent/java`. Base: `master`. 187 commits including the API-cleanup plan, divergence-log cleanup, ports
|
||||
through Scala-trait registration metadata, the ASM characterization backfill, and review/client-rendering fixes.
|
||||
|
||||
The multipart review corrections (`5af333c`) are on `algent/java`; subsequent migration work continues in that branch.
|
||||
|
||||
@@ -76,7 +76,7 @@ awk -F'"' '/<testsuite /{t+=$4;f+=$8;e+=$10} END{print "tests="t" failures="f" e
|
||||
grep -o 'tests="[0-9]*" skipped="[0-9]*" failures="[0-9]*" errors="[0-9]*"' run/server/junit-out/TEST-*.xml
|
||||
```
|
||||
|
||||
Current baseline: **333 plain-JVM tests and 159 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
Current baseline: **333 plain-JVM tests and 163 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
EULA is accepted in this checkout. GitHub Actions runs the same self-validating Forge suite in a dependent job after
|
||||
the shared GTNH build; keep both jobs required.
|
||||
|
||||
@@ -806,6 +806,29 @@ repeat the matches above; the dev config and forced Scala-compilation guard are
|
||||
match both packaged jar versions. External Scala-trait tests remain green; manual client checks and Java-source
|
||||
model-bridge limitations remain outstanding.
|
||||
|
||||
The 2026-09-03 client crash while placing a ProjectRed part on `60d060a` exposed a renderer regression from the earlier
|
||||
client-trait port (`970e888`): javac emitted `INVOKEVIRTUAL TileMultipartClient.hasDynamicParts()Z`, but Forge rewrites
|
||||
that class into an interface. Any nonempty multipart reaching the TESR could fail with `IncompatibleClassChangeError`.
|
||||
`MultipartRenderer$` now queries the same flag through a new `TileMultipart.hasDynamicParts()` base hook; generated
|
||||
client tiles already override that signature. The checked client-trait cast and empty/static early returns remain.
|
||||
The only ABI addition is that public boolean base hook, documented in the divergence ledger. No generator algorithm
|
||||
or runtime trait interface changed.
|
||||
|
||||
Four Forge regression tests execute the actual renderer method body against generated client tiles, replacing only
|
||||
GL/pass services and recording the drawing callback (the server strips `TMultiPart.renderDynamic`). They cover static
|
||||
and empty early returns, non-client rejection, state setup and dynamic dispatch with exact coordinates/frame/pass.
|
||||
Both nonempty cases reproduce the exact original crash before the fix; all four pass after it. Earlier client-tile
|
||||
tests used method handles and did not exercise the compiled renderer call site. Reference jar/source, reproduction
|
||||
reports and verification scripts are in ignored `run/renderer-compatibility-review/`.
|
||||
|
||||
Clean formatting/checkstyle/build and Forge pass after stopping Gradle: 333 JVM / 163 Forge, zero failures/errors/skips.
|
||||
All 455 class APIs match except the additive base hook; 3,713 other method bodies are unchanged. The raw-jar audit finds
|
||||
no remaining unsafe external calls/field accesses to the eight transformed Java tile inputs. All 40 generated outputs
|
||||
retain their instructions: 34 names/hashes match exactly, and six composite numbers move because the new tests create
|
||||
the client composite earlier. The dev config and forced Scala-compilation guard are unchanged, and all five `@Mod`
|
||||
versions match both packaged jar versions. The full client rendering check remains open until the fixed jar is tried
|
||||
in the pack; see the dated note in the manual checklist.
|
||||
|
||||
**Next: `ASMMixinCompiler` class-byte loading/cache helpers: `getBytes`, `classNode` and `internalDefine`.**
|
||||
Characterize name normalization, cache identity/invalidation, transformer exclusions/remapping, nulls and failure
|
||||
ordering before extraction. Preserve the existing loader and cache algorithm. Keep reflective class definition,
|
||||
|
||||
@@ -34,6 +34,13 @@ below its table.
|
||||
| [ ] | Run centre pipes/cables with several connection widths through hollow covers on all six faces, including glass | Each opening follows the connector size; opaque and transparent rims, breaking overlay and highlight have no missing, doubled or stale sections after neighbour changes | `HollowMicroblockClient.recalcBounds` / `renderHollow` / `drawBreaking` / `drawHighlight` |
|
||||
| [ ] | Place touching face, corner and edge microblocks of mixed sizes/transparency, then add and remove neighbours | Intersections choose the same winner, opaque covered faces stay masked, and every surviving segment refreshes without gaps or stale bounds | `MicroOcclusion` / `TMicroOcclusionClient.recalcBounds` |
|
||||
|
||||
2026-09-03: Placing a ProjectRed part with `1.7.12-algent-java.186+60d060a3ff` crashed in
|
||||
`MultipartRenderer$.renderTileEntityAt`: its class call to `TileMultipartClient.hasDynamicParts()` encountered the
|
||||
transformed runtime interface. The renderer now calls the generated getter through a stable `TileMultipart` base
|
||||
hook. Four headless Forge cases cover the actual renderer bytecode's guards and dispatch; both nonempty cases
|
||||
reproduced the original crash. Re-test placement, static/dynamic drawing and part updates in the full client with the
|
||||
fixed jar before marking the rendering entries complete.
|
||||
|
||||
## Placement and interaction
|
||||
|
||||
| Done | Check | Expected | From |
|
||||
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
package codechicken.multipart.test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.commons.RemappingMethodAdapter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import codechicken.multipart.TileMultipartClient;
|
||||
import codechicken.multipart.asm.MultipartMixinFactory;
|
||||
import scala.collection.JavaConversions;
|
||||
import scala.collection.immutable.Nil$;
|
||||
|
||||
/** Executes the shipped renderer method against real generated client tiles, replacing only its GL/pass services. */
|
||||
class MultipartRendererFunctionalTest {
|
||||
|
||||
@BeforeEach
|
||||
void resetRenderState() {
|
||||
RenderServices.events.clear();
|
||||
RenderServices.INSTANCE.useNormals = false;
|
||||
RenderServices.dynamicCalls = 0;
|
||||
RenderServices.position = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonemptyStaticTileReturnsWithoutTouchingRenderState() throws Exception {
|
||||
TileMultipart tile = newClientTile();
|
||||
RecordingPart part = new RecordingPart();
|
||||
setParts(tile, part);
|
||||
setField(tile, "hasDynamicParts", false);
|
||||
|
||||
render(tile);
|
||||
|
||||
assertTrue(RenderServices.events.isEmpty());
|
||||
assertEquals(0, RenderServices.dynamicCalls);
|
||||
}
|
||||
|
||||
@Test
|
||||
void dynamicTileInitializesStateAndDispatchesWithTheSameCoordinatesFrameAndPass() throws Exception {
|
||||
TileMultipart tile = newClientTile();
|
||||
RecordingPart part = new RecordingPart();
|
||||
setParts(tile, part);
|
||||
setField(tile, "hasDynamicParts", true);
|
||||
setField(tile, "codechicken$multipart$TileMultipartClient$$dynamicCache", new TMultiPart[] { part });
|
||||
|
||||
render(tile);
|
||||
|
||||
assertEquals(Arrays.asList("instance", "reset", "lightmap", "pass", "tile"), RenderServices.events);
|
||||
assertEquals(1, RenderServices.dynamicCalls);
|
||||
assertEquals(1.25, RenderServices.position.x);
|
||||
assertEquals(-2.5, RenderServices.position.y);
|
||||
assertEquals(3.75, RenderServices.position.z);
|
||||
assertEquals(0.625F, RenderServices.frame);
|
||||
assertEquals(1, RenderServices.pass);
|
||||
assertTrue(RenderServices.INSTANCE.useNormals);
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyTileShortCircuitsEvenWithADynamicFlagAndCache() throws Exception {
|
||||
TileMultipart tile = newClientTile();
|
||||
RecordingPart part = new RecordingPart();
|
||||
setField(tile, "hasDynamicParts", true);
|
||||
setField(tile, "codechicken$multipart$TileMultipartClient$$dynamicCache", new TMultiPart[] { part });
|
||||
|
||||
render(tile);
|
||||
|
||||
assertTrue(RenderServices.events.isEmpty());
|
||||
assertEquals(0, RenderServices.dynamicCalls);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsTilesWithoutTheClientTraitBeforeTouchingRenderState() throws Exception {
|
||||
assertThrows(ClassCastException.class, () -> render(new TileMultipart()));
|
||||
assertTrue(RenderServices.events.isEmpty());
|
||||
}
|
||||
|
||||
private static TileMultipart newClientTile() throws Exception {
|
||||
assertTrue(
|
||||
TileMultipartClient.class.isInterface(),
|
||||
"Exercise the transformed runtime type, not the Java input");
|
||||
BitSet traits = new BitSet();
|
||||
traits.set(MultipartMixinFactory.getId(TileMultipartClient.class.getName().replace('.', '/')));
|
||||
TileMultipart generated = (TileMultipart) MultipartMixinFactory.construct(traits, Nil$.MODULE$);
|
||||
// Keep the real generated interface/flag getter. Drawing is recorded because Forge strips the actual
|
||||
// TMultiPart.renderDynamic method on this dedicated server.
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
String parent = Type.getInternalName(generated.getClass());
|
||||
writer.visit(V1_8, ACC_PUBLIC, "codechicken/multipart/test/RendererRecordingTile", null, parent, null);
|
||||
MethodVisitor init = writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
init.visitCode();
|
||||
init.visitVarInsn(ALOAD, 0);
|
||||
init.visitMethodInsn(INVOKESPECIAL, parent, "<init>", "()V", false);
|
||||
init.visitInsn(RETURN);
|
||||
init.visitMaxs(0, 0);
|
||||
init.visitEnd();
|
||||
String descriptor = "(Lcodechicken/lib/vec/Vector3;FI)V";
|
||||
MethodVisitor draw = writer.visitMethod(ACC_PUBLIC, "renderDynamic", descriptor, null, null);
|
||||
draw.visitCode();
|
||||
draw.visitVarInsn(ALOAD, 1);
|
||||
draw.visitVarInsn(FLOAD, 2);
|
||||
draw.visitVarInsn(ILOAD, 3);
|
||||
draw.visitMethodInsn(INVOKESTATIC, Type.getInternalName(RenderServices.class), "draw", descriptor, false);
|
||||
draw.visitInsn(RETURN);
|
||||
draw.visitMaxs(0, 0);
|
||||
draw.visitEnd();
|
||||
writer.visitEnd();
|
||||
return (TileMultipart) new BodyLoader().define(writer.toByteArray()).getConstructor().newInstance();
|
||||
}
|
||||
|
||||
private static void setParts(TileMultipart tile, TMultiPart... parts) {
|
||||
tile.partList_$eq(JavaConversions.asScalaBuffer(Arrays.asList(parts)).toList());
|
||||
}
|
||||
|
||||
private static void setField(TileMultipart tile, String name, Object value) throws Exception {
|
||||
Field field = tile.getClass().getSuperclass().getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
field.set(tile, value);
|
||||
}
|
||||
|
||||
private static void render(TileEntity tile) throws Exception {
|
||||
Object renderer = RendererBody.TYPE.getConstructor().newInstance();
|
||||
try {
|
||||
RendererBody.METHOD.invoke(renderer, tile, 1.25, -2.5, 3.75, 0.625F);
|
||||
} catch (InvocationTargetException failure) {
|
||||
Throwable cause = failure.getCause();
|
||||
if (cause instanceof Error) throw (Error) cause;
|
||||
if (cause instanceof Exception) throw (Exception) cause;
|
||||
throw new AssertionError(cause);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RendererBody {
|
||||
|
||||
static final Class<?> TYPE;
|
||||
static final Method METHOD;
|
||||
|
||||
static {
|
||||
try {
|
||||
// Loading the client-only TESR class on a server is forbidden. Copy its actual method body without
|
||||
// changing any tile casts, field accesses or invocation opcodes; only rendering services are replaced.
|
||||
ClassNode source = new ClassNode();
|
||||
try (InputStream input = MultipartRendererFunctionalTest.class
|
||||
.getResourceAsStream("/codechicken/multipart/MultipartRenderer$.class")) {
|
||||
assertNotNull(input);
|
||||
new ClassReader(input).accept(source, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
}
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
String name = "codechicken/multipart/test/HeadlessMultipartRenderer";
|
||||
writer.visit(V1_8, ACC_PUBLIC, name, null, "java/lang/Object", null);
|
||||
MethodVisitor init = writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
init.visitCode();
|
||||
init.visitVarInsn(ALOAD, 0);
|
||||
init.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
init.visitInsn(RETURN);
|
||||
init.visitMaxs(0, 0);
|
||||
init.visitEnd();
|
||||
boolean found = false;
|
||||
for (MethodNode method : source.methods) {
|
||||
if (!method.name.equals("renderTileEntityAt")) continue;
|
||||
assertFalse(found);
|
||||
found = true;
|
||||
MethodVisitor target = writer.visitMethod(ACC_PUBLIC, method.name, method.desc, null, null);
|
||||
method.accept(new RemappingMethodAdapter(ACC_PUBLIC, method.desc, target, new Remapper() {
|
||||
|
||||
@Override
|
||||
public String map(String internalName) {
|
||||
if (internalName.equals("codechicken/lib/render/CCRenderState")
|
||||
|| internalName.equals("net/minecraftforge/client/MinecraftForgeClient"))
|
||||
return Type.getInternalName(RenderServices.class);
|
||||
return internalName;
|
||||
}
|
||||
}));
|
||||
}
|
||||
assertTrue(found);
|
||||
writer.visitEnd();
|
||||
TYPE = new BodyLoader().define(writer.toByteArray());
|
||||
METHOD = TYPE.getMethod(
|
||||
"renderTileEntityAt",
|
||||
TileEntity.class,
|
||||
double.class,
|
||||
double.class,
|
||||
double.class,
|
||||
float.class);
|
||||
} catch (Exception failure) {
|
||||
throw new ExceptionInInitializerError(failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BodyLoader extends ClassLoader {
|
||||
|
||||
BodyLoader() {
|
||||
super(MultipartRendererFunctionalTest.class.getClassLoader());
|
||||
}
|
||||
|
||||
Class<?> define(byte[] bytes) {
|
||||
return defineClass(null, bytes, 0, bytes.length);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class RenderServices {
|
||||
|
||||
static final RenderServices INSTANCE = new RenderServices();
|
||||
static final List<String> events = new ArrayList<>();
|
||||
public boolean useNormals;
|
||||
static int dynamicCalls;
|
||||
static Vector3 position;
|
||||
static float frame;
|
||||
static int pass;
|
||||
|
||||
public static void draw(Vector3 position, float frame, int pass) {
|
||||
assertTrue(INSTANCE.useNormals);
|
||||
events.add("tile");
|
||||
dynamicCalls++;
|
||||
RenderServices.position = position;
|
||||
RenderServices.frame = frame;
|
||||
RenderServices.pass = pass;
|
||||
}
|
||||
|
||||
public static RenderServices instance() {
|
||||
events.add("instance");
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void resetInstance() {
|
||||
events.add("reset");
|
||||
useNormals = false;
|
||||
}
|
||||
|
||||
public void pullLightmapInstance() {
|
||||
events.add("lightmap");
|
||||
}
|
||||
|
||||
public static int getRenderPass() {
|
||||
events.add("pass");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RecordingPart extends TMultiPart {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "renderer-regression";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,8 @@ public final class MultipartRenderer$ extends TileEntitySpecialRenderer implemen
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) {
|
||||
TileMultipartClient client = (TileMultipartClient) t;
|
||||
TileMultipart tile = (TileMultipart) t;
|
||||
if (tile.partList().isEmpty() || !client.hasDynamicParts()) {
|
||||
TileMultipart tile = TileMultipart.class.cast((TileMultipartClient) t);
|
||||
if (tile.partList().isEmpty() || !tile.hasDynamicParts()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -263,6 +263,11 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile {
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/** Stable class-call target for the flag getter generated by the TileMultipartClient runtime interface. */
|
||||
public boolean hasDynamicParts() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Client render hook overridden by generated tiles carrying TileMultipartClient. */
|
||||
public boolean renderStatic(IBlockAccess world, Vector3 position, RenderBlocks renderer) {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user