From fa41ae06094fd4a50e7c771d3265f2595310dcd2 Mon Sep 17 00:00:00 2001 From: Algent Date: Fri, 4 Sep 2026 00:32:48 +0200 Subject: [PATCH] refactor: port micro occlusion client to Java --- JAVA_MIGRATION.md | 5 +-- JAVA_MIGRATION_HANDOFF.md | 33 ++++++++++--------- JAVA_MIGRATION_MANUAL_CHECKS.md | 2 +- docs/migration/HISTORY.md | 27 +++++++++++++++ .../microblock/TMicroOcclusion.scala | 6 ++-- .../TMicroOcclusionClientLogic.java | 12 +++++++ 6 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 src/main/scala/codechicken/microblock/TMicroOcclusionClientLogic.java diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index 089e349..68d922f 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -25,8 +25,9 @@ No trustworthy tool will produce a maintainable Java port automatically. A decom Work continues on `algent/java`. The low-coupling queue, core part/tile types, registries, handlers, factories, placement/render helpers, both generators and all built-in tile traits are Java. Common, face, corner, edge, post, -hollow and occlusion microblock traits retain Scala inheritance/bridge declarations over Java behavior. The next -bounded target is `TMicroOcclusionClient`: lifecycle handling and render-state updates in `TMicroOcclusion.scala`. +hollow and occlusion microblock traits retain Scala inheritance/state/super declarations over Java behavior, +including client bounds/mask updates. The next bounded target is `StackAnalyser` constructor initialization; +retain the coordinated Scala class/companion/models and characterize initialization before extraction. Java-trait rewriting and compiler startup also delegate to Java helpers. Abstract Java mixins and Java-path side-only filtering are complete; multiple Scala-trait inheritance still needs its metadata. Retain trait state/accessor/super bridges and the compiler/signature/analyser model shells. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index d63be12..7e2d5bc 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -16,22 +16,23 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes ## Current state and next target -**386 plain-JVM tests and 234 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **223 Java -files and 9 Scala files / 784 nonblank Scala lines**. The packaged inventory has 443 classes. +**392 plain-JVM tests and 235 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java +files and 9 Scala files / 782 nonblank Scala lines**. The packaged inventory has 444 classes. -Latest bounded target: `TMicroOcclusion` delegates its occlusion and edge/corner rules to `TMicroOcclusionLogic.java`. -Scala retains inheritance metadata, `$class` and the short-circuiting super bridge. Characterization was committed -first as `c709759`: frozen Scala forwarders pin super/type-guard order, repeated getters, signed overflow, -material short-circuits, virtual edge/corner delegation and failures. Forge tests generated face/corner/edge pairs -with matching and different materials. Clean checks preserve all 442 original class/member APIs, all 17 -ScalaSignature payloads, 3,721 unrelated method bodies and all 116 generated dumps. The Java helper is the sole -added class; no originals are removed. Evidence: `run/migration-micro-occlusion-trait-reference/`. +Latest bounded target: `TMicroOcclusionClient` delegates bounds copying and mask updates to +`TMicroOcclusionClientLogic.java`. Scala retains inheritance metadata, mutable state/accessors and the three +lifecycle super/recalc bridges. Characterization was committed first as `d69d12b`: frozen Scala forwarders pin +super/recalc order, argument identity, virtual copying, mask replacement and partial publication on failure. +Forge exercises live Stone/Glass neighbors through the hollow client probe and real factories. Clean checks +preserve all 443 original class/member APIs, all 17 ScalaSignature payloads, 3,725 unrelated method bodies and +all 116 generated dumps. Only the Java helper is added. Evidence: `run/migration-micro-occlusion-client-reference/`. -**Next: port `TMicroOcclusionClient` in `microblock/TMicroOcclusion.scala`.** Characterize lifecycle super/recalc -ordering, packet propagation, render-bounds copying, mask updates and failures before extraction. Retain the -`JMicroShrinkRender` declaration, Scala inheritance metadata and state/accessor/super bridges as needed. -The external ProjectRed Scala-trait fixture and ScalaSignature model bridges remain required; compiler changes -stay separate. Actual client generation, GPU output and full-pack checks remain manual. +**Next: extract `StackAnalyser` constructor initialization to its existing Java helper.** Characterize receiver +and parameter slot setup, virtual `pushL` ordering, malformed descriptors and duplicate exception-handler +precedence before editing. Keep the Scala class/companion/models, field initialization and default-argument +bridges; this is an initialization extraction, not a full shell replacement or opcode algorithm fix. +The external ProjectRed Scala-trait fixture and ScalaSignature model bridges remain required. Actual client +generation, GPU output and full-pack checks remain manual. Remaining Scala units: @@ -39,10 +40,10 @@ Remaining Scala units: | --- | --- | | `multipart/asm/ASMMixinCompiler.scala` | Retained nested models, construction callbacks and Scala entry-point shell | | `multipart/asm/ScalaSignature.scala` | Named models, primitive/erased bridges and five generic inner-construction branches | -| `multipart/asm/StackAnalyser.scala` | Class/companion/model shell over Java `StackAnalyserLogic` | +| `multipart/asm/StackAnalyser.scala` | Class/companion/models over Java `StackAnalyserLogic`; initialization and model queries remain Scala | | `microblock/MicroblockTraits.scala`, `FaceMicroblockTraits.scala`, `CornerMicroblockTraits.scala`, `EdgeMicroblockTraits.scala` | Nine retained state/inheritance/bridge shells over Java implementation, including post lifecycle/super dispatch | | `microblock/HollowMicroblockTraits.scala` | Hollow server/client inheritance, initializer and super shells over Java behavior | -| `microblock/TMicroOcclusion.scala` | Occlusion inheritance/super shell and remaining client lifecycle/state implementation | +| `microblock/TMicroOcclusion.scala` | Occlusion/client inheritance, state/accessor and lifecycle/super shells over Java behavior | Both generators, both registries, core tile/part classes, ordinary microblock helpers/factories, handlers, networking, placement/render helpers and built-in tile traits are Java. The low-risk queue and immediate consumer gate are diff --git a/JAVA_MIGRATION_MANUAL_CHECKS.md b/JAVA_MIGRATION_MANUAL_CHECKS.md index d061881..82ee2b8 100644 --- a/JAVA_MIGRATION_MANUAL_CHECKS.md +++ b/JAVA_MIGRATION_MANUAL_CHECKS.md @@ -43,7 +43,7 @@ Lamp Cover**, **Hollow Inverted White Lamp Cover**, **Inverted White Lamp Nook** | [ ] | Saw **Stone**, **Glass** and a ProjectRed **Inverted White Lamp** into face covers; place them on all six faces beside other microblocks, then inspect their inventory renders | Opaque covers retain their outer face while internal faces follow the shrink mask; transparent covers use the shrunk bounds, and inventory renders show the complete shape without missing or doubled faces | `FaceMicroblockClient.render` / `FaceMicroblockTraitLogic.render` | | [ ] | Saw **Stone**, **Glass** and a ProjectRed **Inverted White Lamp** into strip/post shapes; place crossing posts on all three axes between face covers, then add and remove neighbours | Compare both split segments with the reference, including the second segment's use of physical bounds; removal resets the split without stale geometry or missing sections | `PostMicroblockClient.recalcBounds` / `PostMicroblockClientLogic` / `shrinkFace` / `shrinkPost` | | [ ] | Run connected AE2 **ME Glass Cable**, **ME Covered Cable** and **ME Dense Smart Cable**, plus ProjectRed **Framed Red Alloy Wire**, through hollow stone/glass covers on all six faces | 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` / `HollowMicroblockClientLogic` | -| [ ] | 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` | +| [ ] | Place touching **Stone Cover**, **Glass Cover**, corner/edge counterparts and ProjectRed **Inverted White Lamp** microblocks at mixed sizes; add/remove neighbours, then rejoin the server | Intersections choose the same winner, opaque covered faces stay masked, and every surviving segment refreshes without gaps or stale bounds | `MicroOcclusion` / `TMicroOcclusionClient` / `TMicroOcclusionClientLogic` | 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 diff --git a/docs/migration/HISTORY.md b/docs/migration/HISTORY.md index dd45af0..ab763c5 100644 --- a/docs/migration/HISTORY.md +++ b/docs/migration/HISTORY.md @@ -1239,3 +1239,30 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m - Next: `TMicroOcclusionClient`; characterize lifecycle super/recalc ordering, packet propagation, bounds copying, mask updates and failures. Retain `JMicroShrinkRender` and required Scala metadata/state/super bridges. Actual client generation, GPU drawing and full-pack checks remain on the existing manual checklist. + +### 2026-09-04 — Micro occlusion client state updates + +- Committed six JVM and one Forge characterization tests first as `d69d12b`, against untouched production code. + Frozen Scala 2.11.5 forwarders compiled under Java 8 pin the three real superclass predecessors, virtual recalc + dispatch, exact part/packet identity (including null), super/recalc failure order and predecessor state changes. + Bounds tests cover virtual copying before traversal, mask replacement, clipping, fresh copies on repeated + updates, null/copy failures and partially clipped bounds with the old mask after traversal failure. Forge uses + the existing hollow client probe with real Stone/Glass materials and factory bounds, checking priority, + opacity, neighbor resizing/removal and physical-bounds immutability. +- Extracted render-state updates to package-private `TMicroOcclusionClientLogic.java`. Scala retains + `JMicroShrinkRender`, trait inheritance metadata, mutable state/accessors, initialization and lifecycle bridges. + Java source cannot call the synthetic Scala super accessors directly; those three super calls and subsequent + virtual recalculation calls retain identical instructions and dispatch. The helper still calls the bounds setter + and getter separately before mask publication. No compiler algorithm change or new effective divergence. +- Evidence in ignored `run/migration-micro-occlusion-client-reference/` includes reference source/jar, frozen + fixture compilation, reports and 116 generated dumps. Normal and clean checks after stopping Gradle preserve + all 443 original class/member APIs, all 17 ScalaSignature payloads, 3,725 unrelated method bodies and all 116 + generated names/hashes. Only the Java helper is added: 443 -> 444 packaged classes. Formatting, checkstyle, + build and Forge pass with 392 JVM / 235 Forge tests and zero failures/errors/skips. The forced Scala compilation + guard and all five packaged `@Mod` versions remain verified. Sources total 224 Java files and 9 Scala files / + 782 nonblank Scala lines. +- Next: extract `StackAnalyser` constructor initialization after characterizing receiver/parameter slot setup, + virtual `pushL` order, malformed descriptors and duplicate exception-handler precedence. Retain its coordinated + Scala shell/models; keep opcode fixes separate. The client manual row now names Stone/Glass covers and + ProjectRed Inverted White Lamp microblocks, including a server rejoin. Headless probes do not establish actual + client generation, GPU output or full-pack correctness; those checks remain unrecorded release gates. diff --git a/src/main/scala/codechicken/microblock/TMicroOcclusion.scala b/src/main/scala/codechicken/microblock/TMicroOcclusion.scala index 36d7cac..12c380b 100644 --- a/src/main/scala/codechicken/microblock/TMicroOcclusion.scala +++ b/src/main/scala/codechicken/microblock/TMicroOcclusion.scala @@ -31,10 +31,8 @@ trait TMicroOcclusionClient extends TMicroOcclusion with JMicroShrinkRender { recalcBounds() } - def recalcBounds() { - renderBounds = getBounds.copy - renderMask = MicroOcclusion$.MODULE$.recalcBounds(this, renderBounds) - } + def recalcBounds(): Unit = + TMicroOcclusionClientLogic.recalcBounds(this) override def getPriorityClass = 0 } diff --git a/src/main/scala/codechicken/microblock/TMicroOcclusionClientLogic.java b/src/main/scala/codechicken/microblock/TMicroOcclusionClientLogic.java new file mode 100644 index 0000000..f82002e --- /dev/null +++ b/src/main/scala/codechicken/microblock/TMicroOcclusionClientLogic.java @@ -0,0 +1,12 @@ +package codechicken.microblock; + +/** Render-state updates behind the retained Scala state accessors and lifecycle super bridges. */ +final class TMicroOcclusionClientLogic { + + private TMicroOcclusionClientLogic() {} + + static void recalcBounds(TMicroOcclusionClient part) { + part.renderBounds_$eq(part.getBounds().copy()); + part.renderMask_$eq(MicroOcclusion$.MODULE$.recalcBounds(part, part.renderBounds())); + } +}