refactor: port face microblock logic to Java

Retain Scala trait declarations and helper bridges for inherited mixin registration and existing consumers.
This commit is contained in:
Algent committed 2026-09-03 21:43:37 +02:00
1 parent dc845bc91e
commit cfde82235a
7 files changed
+94 -55

No files matched your search

+6 -6
View File
@@ -24,12 +24,12 @@ No trustworthy tool will produce a maintainable Java port automatically. A decom
## Current status
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. Five generated microblock trait
implementations and the compiler/signature/analyser compatibility shells remain Scala. `MicroblockTraits.scala`
retains three inheritance/bridge declarations over Java behavior. Composite generation, Java-trait rewriting and
compiler startup also delegate to Java helpers. Abstract Java mixins and Java-path side-only filtering are complete;
placement/render helpers, both generators and all built-in tile traits are Java. Four generated microblock trait
implementations and the compiler/signature/analyser compatibility shells remain Scala. `MicroblockTraits.scala` and
`FaceMicroblockTraits.scala` retain inheritance/bridge declarations over Java behavior. Composite generation,
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. The next bounded target is the implementation in
`microblock/FaceMicroblockTraits.scala`. Retain the ScalaSignature path-dependent model bridges.
`microblock/CornerMicroblockTraits.scala`. Retain the ScalaSignature path-dependent model bridges.
Start with [JAVA_MIGRATION_HANDOFF.md](JAVA_MIGRATION_HANDOFF.md) for the exact source/test baseline, workflow and
Java-source limitations. Read both the [ABI inventory](JAVA_MIGRATION_ABI_INVENTORY.md) and
@@ -365,7 +365,7 @@ cache remain reference-identical; pass-through-interface coverage remains green.
### Phase 6 — Convert multipart core and microblocks
Status: core code, factories, ordinary helpers and common microblock trait behavior are Java. Five generated trait
Status: core code, factories, ordinary helpers and common/face microblock trait behavior are Java. Four generated trait
implementations remain. Extract their behavior while retaining Scala declarations where multiple-trait inheritance
still needs signature metadata; abstract Java mixins and side filtering alone do not replace that metadata. The
following gates continue to apply to those remaining units; completed per-type evidence is in the history.
+5 -1
View File
@@ -512,7 +512,11 @@ invisible Java annotations, including method dispatch, field state and construct
`MicroblockTraitsCharacterizationTest` executes a frozen concrete Scala consumer through all three common microblock
helper bridges, covering slots, partial-box list behavior, material/render routing and particles. Its Forge companion
covers generated common microblocks; the runtime interfaces used by Extra Utilities, ForgeRelocationFMP and GuideNH
remain intact. Full downstream mixed tiles and client-side selection remain Phase 7 integration cases.
remain intact. `FaceMicroblockTraitsCharacterizationTest` additionally executes a frozen Scala face-client forwarder
and checks every emitted face for all masks/slots, including material reuse and repeated virtual slot lookup between
opaque draws. Its Forge companion pins generated face bounds and solidity. The `FaceMicroblockClient` interface
tested by Extra Utilities' connected-texture renderer remains intact. Full downstream mixed tiles and client-side
selection remain Phase 7 integration cases.
With these gates, the source audit is actionable: the port can simplify internals freely where no listed observation
changes, while each externally observed behavior has a named consumer and a focused way to prove compatibility.
+17 -16
View File
@@ -16,23 +16,23 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
## Current state and next target
**340 plain-JVM tests and 213 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **215 Java
files and 9 Scala files / 1,170 nonblank Scala lines**. The packaged inventory has 438 classes.
**345 plain-JVM tests and 216 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **216 Java
files and 9 Scala files / 1,144 nonblank Scala lines**. The packaged inventory has 439 classes.
Latest bounded target: `MicroblockTraits.scala` delegates its eight remaining implementation methods to
`MicroblockTraitLogic.java`; its particle callbacks already delegated to Java. The three Scala trait declarations,
inheritance metadata and `$class` bridges remain. Characterization was committed first as `d6eb56b`, including a
frozen concrete Scala consumer compiled against the unchanged jar. It exercises initialization, slots, immutable
partial-box views, virtual class/material/render dispatch and particle evaluation order. Forge covers generated common
microblocks and the existing server-side failure when a client fallback reaches the stripped `Block.getIcon`.
Clean verification after stopping Gradle matches all 437 original class/member APIs, all 17 ScalaSignature payloads,
3,674 non-target method bodies and all 116 generated dump names/hashes. Only the package-private Java helper is added.
Local evidence is in `run/migration-microblock-traits-reference/`; `clean` preserves this ignored directory.
Latest bounded target: `FaceMicroblockTraits.scala` delegates rendering, bounds lookup and solidity to
`FaceMicroblockTraitLogic.java`. The two Scala trait declarations, inheritance metadata, `$class` bridges and existing
singleton accessor remain. Characterization was committed first as `dc845bc`, including a frozen Scala
face-client consumer. It pins exact emitted faces for all six slots/64 masks, negative passes, repeated slot lookup,
material caching and missing-material failure timing. Forge covers all 42 supported face shapes, signed-index errors,
null/live-replaced bounds and solidity dispatch. Clean verification after stopping Gradle matches all 438 original
class/member APIs, all 17 ScalaSignature payloads, 3,688 non-target method bodies and all 116 generated dump names/hashes.
Only the package-private helper is added. Local evidence is in `run/migration-face-traits-reference/`; `clean`
preserves this ignored directory.
**Next: port the implementation in `microblock/FaceMicroblockTraits.scala`.** Characterize bounds/shape indexing,
material solidity, negative-pass rendering, transparent/opaque face masks and generated dispatch before conversion.
Retain the Scala declarations where inheritance metadata is still required. Keep the external ProjectRed Scala-trait
fixture green and retain the ScalaSignature path-dependent model bridges; compiler changes stay separate.
**Next: port the implementation in `microblock/CornerMicroblockTraits.scala`.** Characterize shape packing with the
seven-slot offset, signed byte/index behavior, live bounds lookup, class identity and generated dispatch before
conversion. Retain the Scala declarations where inheritance metadata is still required. Keep the external ProjectRed
Scala-trait fixture green and retain the ScalaSignature path-dependent model bridges; compiler changes stay separate.
Remaining Scala units:
@@ -42,7 +42,8 @@ Remaining Scala units:
| `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` |
| `microblock/MicroblockTraits.scala` | Three retained inheritance/bridge shells over Java implementation |
| `microblock/FaceMicroblockTraits.scala`, `CornerMicroblockTraits.scala`, `EdgeMicroblockTraits.scala`, `HollowMicroblockTraits.scala`, `TMicroOcclusion.scala` | Generated trait implementations; port in dependency order while preserving inheritance metadata |
| `microblock/FaceMicroblockTraits.scala` | Two retained inheritance/bridge shells over Java implementation |
| `microblock/CornerMicroblockTraits.scala`, `EdgeMicroblockTraits.scala`, `HollowMicroblockTraits.scala`, `TMicroOcclusion.scala` | Generated trait implementations; port in dependency order while preserving inheritance metadata |
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
+1
View File
@@ -40,6 +40,7 @@ Lamp Cover**, **Hollow Inverted White Lamp Cover**, **Inverted White Lamp Nook**
| [ ] | Start a client with 3D saws enabled, inspect all three saw tiers and the microblock item, then repeat with Angelica installed | Each renderer is registered once, saw models use the correct tier, microblock icons load, client packets register, and the Angelica hook initializes without errors | `MicroblockProxy_clientImpl.init` / `postInit` |
| [ ] | Render several block micro-materials with Angelica shaders enabled, then render an unrelated block | Each face receives the matching block/meta shader material and the override is reset after the microblock draw | `MaterialRenderHelper.blockAndMeta` / `render` |
| [ ] | Inspect face, hollow, edge and corner microblocks in inventory and as dropped entities | Every size/material combination uses the correct localized name and centered shape/material render | `ItemMicroPart` / `ItemMicroPartRenderer` / `MicroblockRender.renderItem` |
| [ ] | 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` |
| [ ] | Place crossing posts of different sizes/transparency beside face covers, then add and remove neighbours | Post segments shrink and split at intersections without missing sections or stale render bounds | `PostMicroblockClient.recalcBounds` / `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.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` |
+22
View File
@@ -1058,3 +1058,25 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
`@Mod` versions remain verified. Sources total 215 Java files and 9 Scala files / 1,170 nonblank Scala lines.
Next: `microblock/FaceMicroblockTraits.scala` implementation, with characterization before conversion. GPU rendering
and full client selection remain on the manual checklist.
### 2026-09-03 — Face microblock trait implementation
- Committed five JVM and three Forge characterization tests first as `dc845bc`. The frozen Scala 2.11.5 face-client
consumer was compiled under Java 8 against the untouched jar. Tests verify actual emitted face indices, position,
pass and bounds for all six slots and 64 masks; negative-pass bypass; material caching and repeated virtual slot
evaluation between opaque draws; and null-material failure timing. Forge pins all 42 valid shape bounds, the
existing signed-byte indexing failures, null entries/live replacement of the public bounds array, singleton
identity and material solidity independent of the side argument.
- Moved rendering, bounds lookup and solidity to package-private `FaceMicroblockTraitLogic.java`. The Scala
declarations, inheritance metadata, `$class` helpers and singleton accessor remain; Extra Utilities' runtime
face-client type check and the external Scala registration path are preserved. No compiler algorithm or existing
behavior was changed, and no new divergence entry is needed.
- Saved the pre-port jar/source, reports and 116 generated dumps in ignored `run/migration-face-traits-reference/`.
Clean verification preserves all 438 original class/member APIs, all 17 ScalaSignature payloads and 3,688 non-target
method bodies. All 116 generated names and SHA-256 hashes match; only the new helper increases the jar inventory
to 439 classes. Formatting, checkstyle, build and Forge pass normally and after stopping Gradle for a clean rebuild:
345 JVM / 216 Forge tests, zero failures/errors/skips. The forced Scala-compilation guard and all five packaged
`@Mod` versions remain verified. Sources total 216 Java files and 9 Scala files / 1,144 nonblank Scala lines.
- Added a manual face-cover check using Stone, Glass and ProjectRed Inverted White Lamp materials. Headless tests
prove per-face dispatch, not GPU output. Next: `microblock/CornerMicroblockTraits.scala` implementation, characterized
before conversion.
@@ -0,0 +1,37 @@
package codechicken.microblock;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial;
/** Face behavior behind the retained Scala inheritance metadata and helper bridges. */
final class FaceMicroblockTraitLogic {
private FaceMicroblockTraitLogic() {}
static void render(FaceMicroblockClient part, Vector3 pos, int pass) {
if (pass < 0) {
MicroblockRender.renderCuboid(pos, ((Microblock) part).getIMaterial(), pass, part.getBounds(), 0);
} else if (((Microblock) part).isTransparent()) {
MicroblockRender.renderCuboid(
pos,
((Microblock) part).getIMaterial(),
pass,
part.renderBounds(),
part.renderMask());
} else {
IMicroMaterial material = ((Microblock) part).getIMaterial();
MicroblockRender
.renderCuboid(pos, material, pass, part.renderBounds(), part.renderMask() | 1 << part.getSlot());
MicroblockRender.renderCuboid(pos, material, pass, Cuboid6.full, ~(1 << part.getSlot()));
}
}
static Cuboid6 getBounds(FaceMicroblock part) {
return FaceMicroClass.aBounds()[((Microblock) part).shape()];
}
static boolean solid(FaceMicroblock part, int side) {
return ((Microblock) part).getIMaterial().isSolid();
}
}
@@ -1,44 +1,18 @@
package codechicken.microblock
import codechicken.lib.vec.{Cuboid6, Vector3}
import codechicken.lib.vec.Vector3
import codechicken.multipart.TFacePart
// Retain Scala inheritance metadata and helper bridges for generated and external mixins.
trait FaceMicroblockClient extends CommonMicroblockClient {
override def render(pos: Vector3, pass: Int) {
if (pass < 0)
MicroblockRender.renderCuboid(pos, getIMaterial, pass, getBounds, 0)
else if (isTransparent)
MicroblockRender.renderCuboid(
pos,
getIMaterial,
pass,
renderBounds,
renderMask
)
else {
val mat = getIMaterial
MicroblockRender.renderCuboid(
pos,
mat,
pass,
renderBounds,
renderMask | 1 << getSlot
)
MicroblockRender.renderCuboid(
pos,
mat,
pass,
Cuboid6.full,
~(1 << getSlot)
)
}
}
override def render(pos: Vector3, pass: Int) =
FaceMicroblockTraitLogic.render(this, pos, pass)
}
trait FaceMicroblock extends CommonMicroblock with TFacePart {
def microClass = FaceMicroClass$.MODULE$
def getBounds = FaceMicroClass.aBounds()(shape)
def getBounds = FaceMicroblockTraitLogic.getBounds(this)
override def solid(side: Int) = getIMaterial.isSolid
override def solid(side: Int) = FaceMicroblockTraitLogic.solid(this, side)
}