diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index b21414e..0667db0 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -820,3 +820,14 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec overload behavior are unchanged. - All 178 plain-JVM and all 94 Java 8 Forge dedicated-server tests pass. Pre-init-only registration is not a meaningful focused performance target; `GrassMicroMaterial.scala` is the next material unit. +- Characterized `GrassMicroMaterial` and `TopMicroMaterial` against untouched Scala. Five plain-JVM cases freeze both + constructors, the grass overlay accessor used by UtilitiesInExcess, the top default-argument facade/companion, + common-side boundaries and horizontal/side UV plus colour-pipeline routing. One Forge case freezes their registered + blocks/meta and the exact surface left on a dedicated server. +- Ported both classes and the default-argument companion directly to Java. Grass keeps its uncoloured base side pass, + coloured top and height-adjusted side overlay; `TopMicroMaterial` keeps coloured horizontal faces and translated + side UVs. All three emitted binary names and every callable public descriptor match the Scala reference. +- A clean compile was required to evict the deleted Scala classes before the unchanged characterization could test the + Java implementation. All 183 plain-JVM and all 95 Java 8 Forge dedicated-server tests pass. The render path retains + the same per-side transformation work, so no separate performance claim is made; `multipart/handler/proxies.scala` + is the next medium-risk target. diff --git a/JAVA_MIGRATION_DIVERGENCES.md b/JAVA_MIGRATION_DIVERGENCES.md index 71d4e30..a6f1fe2 100644 --- a/JAVA_MIGRATION_DIVERGENCES.md +++ b/JAVA_MIGRATION_DIVERGENCES.md @@ -2116,3 +2116,43 @@ callable member. - Complete plain-JVM suite: 178 tests, 0 failures, 0 errors. - Java 8 Forge dedicated-server suite: 94 tests, 0 failures, 0 errors. - Raw `javap` comparison confirms identical callable public names/descriptors and the emitted class list is unchanged. + +## 2026-08-31 — Grass and top micro-material Java port + +The grass-specific material and the top-texture material are now separate Java classes. The Scala-generated +default-argument companion for `TopMicroMaterial` is retained as a small Java singleton because compiled Scala callers +can address it even though no source object existed. + +### Observable behavior + +No known runtime divergence. Grass still renders its ordinary texture without tint on the bottom and sides, tints the +top, and adds the biome-coloured grass overlay only to side faces. The overlay UV still shifts by +`bounds.max.y - 1`, and non-inventory passes still compute light coordinates before either layer. Top materials still +use their ordinary icons on the two horizontal faces and the same height-adjusted UV on all four sides. Both coloured +paths retain lighting and Angelica's block/meta shader override calls. + +The pipeline characterization observes the actual UV and colour operations with an empty vertex range, so it freezes +branch routing without requiring a GL context. Actual grass/mycelium icons, biome tint and rendered pixels still need +the client checklist. + +### ABI and source compatibility + +`GrassMicroMaterial` retains its public no-argument constructor, four public methods, private `sideIconT` field and +non-final `BlockMicroMaterial` subclass shape. Its `sideIconT()` getter remains directly compatible with the audited +UtilitiesInExcess renderer. `TopMicroMaterial` retains its `(Block, int)` constructor, static +`$lessinit$greater$default$2()` method, render override and non-final superclass shape. `TopMicroMaterial$` retains its +public final singleton class, `MODULE$` field and instance default getter. + +Both jars emit exactly `GrassMicroMaterial.class`, `TopMicroMaterial.class` and `TopMicroMaterial$.class`. Accepted +classfile-only differences are removed Scala signature/marker attributes and the companion class initializer without +Scala's `ACC_PUBLIC` flag. A class initializer is JVM-only and is not callable consumer API. The same fields and +methods remain common-side and therefore survive dedicated-server stripping, matching the reference. + +### Validation + +- `GrassMicroMaterialCharacterizationTest`: 5 plain-JVM tests, unchanged from the Scala baseline. +- `GrassMicroMaterialFunctionalTest`: 1 Forge test, unchanged from the Scala baseline. +- Complete plain-JVM suite: 183 tests, 0 failures, 0 errors. +- Java 8 Forge dedicated-server suite: 95 tests, 0 failures, 0 errors. +- A clean build followed by raw `javap` comparison confirms identical callable public names/descriptors and emitted + classes. The clean step is material: Zinc otherwise retained and packaged the deleted Scala class files. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index 1b1d623..bec4375 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -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`. 104 commits including the incremental-version build fix and separate -characterization and port commits for `DefaultContent`. +Branch: `algent/java`. Base: `master`. 106 commits including the incremental-version build fix and separate +characterization and port commits for `GrassMicroMaterial`/`TopMicroMaterial`. ## The one rule that matters @@ -67,7 +67,7 @@ awk -F'"' '/ 1) { + UVTransformation overlay = (UVTransformation) new UVTranslation(0, bounds.max.y - 1) + .$plus$plus(sideIconT()); + MaterialRenderHelper$.MODULE$.start(pos, pass, overlay).blockColour(getColour(pass)).lighting() + .blockAndMeta(block(), meta()).render(); + } + } +} diff --git a/src/main/scala/codechicken/microblock/GrassMicroMaterial.scala b/src/main/scala/codechicken/microblock/GrassMicroMaterial.scala deleted file mode 100644 index ec77d5b..0000000 --- a/src/main/scala/codechicken/microblock/GrassMicroMaterial.scala +++ /dev/null @@ -1,63 +0,0 @@ -package codechicken.microblock - -import codechicken.lib.vec.{Cuboid6, Vector3} -import net.minecraft.block.Block -import codechicken.lib.render.CCRenderState -import net.minecraft.block.BlockGrass -import net.minecraft.init.Blocks -import codechicken.lib.render.uv.{UVTranslation, IconTransformation} -import codechicken.lib.render.BlockRenderer.BlockFace - -class GrassMicroMaterial extends BlockMicroMaterial(Blocks.grass, 0) { - var sideIconT: IconTransformation = _ - - override def loadIcons() { - super.loadIcons() - sideIconT = new IconTransformation(BlockGrass.getIconSideOverlay) - } - - override def renderMicroFace(pos: Vector3, pass: Int, bounds: Cuboid6) { - val face = CCRenderState.instance().model.asInstanceOf[BlockFace] - if (pass != -1) - face.computeLightCoords() - - if (face.side == 1) - MaterialRenderHelper - .start(pos, pass, icont) - .blockColour(getColour(pass)) - .lighting() - .blockAndMeta(block, meta) - .render() - else - MaterialRenderHelper.start(pos, pass, icont).lighting().render() - - if (face.side > 1) - MaterialRenderHelper - .start(pos, pass, new UVTranslation(0, bounds.max.y - 1) ++ sideIconT) - .blockColour(getColour(pass)) - .lighting() - .blockAndMeta(block, meta) - .render() - } -} - -class TopMicroMaterial($block: Block, $meta: Int = 0) - extends BlockMicroMaterial($block, $meta) { - override def renderMicroFace(pos: Vector3, pass: Int, bounds: Cuboid6) { - val face = CCRenderState.instance().model.asInstanceOf[BlockFace] - if (face.side <= 1) - MaterialRenderHelper - .start(pos, pass, icont) - .blockColour(getColour(pass)) - .lighting() - .blockAndMeta(block, meta) - .render() - else - MaterialRenderHelper - .start(pos, pass, new UVTranslation(0, bounds.max.y - 1) ++ icont) - .blockColour(getColour(pass)) - .lighting() - .blockAndMeta(block, meta) - .render() - } -} diff --git a/src/main/scala/codechicken/microblock/TopMicroMaterial$.java b/src/main/scala/codechicken/microblock/TopMicroMaterial$.java new file mode 100644 index 0000000..e53e780 --- /dev/null +++ b/src/main/scala/codechicken/microblock/TopMicroMaterial$.java @@ -0,0 +1,12 @@ +package codechicken.microblock; + +public final class TopMicroMaterial$ { + + public static final TopMicroMaterial$ MODULE$ = new TopMicroMaterial$(); + + private TopMicroMaterial$() {} + + public int $lessinit$greater$default$2() { + return 0; + } +} diff --git a/src/main/scala/codechicken/microblock/TopMicroMaterial.java b/src/main/scala/codechicken/microblock/TopMicroMaterial.java new file mode 100644 index 0000000..856a7bc --- /dev/null +++ b/src/main/scala/codechicken/microblock/TopMicroMaterial.java @@ -0,0 +1,33 @@ +package codechicken.microblock; + +import net.minecraft.block.Block; + +import codechicken.lib.render.BlockRenderer.BlockFace; +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.uv.UVTransformation; +import codechicken.lib.render.uv.UVTranslation; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Vector3; + +public class TopMicroMaterial extends BlockMicroMaterial { + + public static int $lessinit$greater$default$2() { + return TopMicroMaterial$.MODULE$.$lessinit$greater$default$2(); + } + + public TopMicroMaterial(Block block, int meta) { + super(block, meta); + } + + @Override + public void renderMicroFace(Vector3 pos, int pass, Cuboid6 bounds) { + BlockFace face = (BlockFace) CCRenderState.instance().model; + UVTransformation icons = icont(); + if (face.side > 1) { + icons = (UVTransformation) new UVTranslation(0, bounds.max.y - 1).$plus$plus(icons); + } + + MaterialRenderHelper$.MODULE$.start(pos, pass, icons).blockColour(getColour(pass)).lighting() + .blockAndMeta(block(), meta()).render(); + } +}