refactor: port missing micro material

Preserve the singleton ABI, client stripping, and placeholder registration.
This commit is contained in:
Algent committed 2026-08-31 19:12:26 +02:00
1 parent e1ca4fba53
commit 9a8bbfd7a7
9 files changed
+224 -67

No files matched your search

+8
View File
@@ -804,3 +804,11 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec
reference. Only the unreferenced compiler-generated `$$anonfun$1` closure disappeared.
- All 174 plain-JVM tests and all 91 Java 8 Forge dedicated-server tests pass. The next medium-risk target is
`MissingMicroMaterial.scala`; its real icon/render paths remain client-manual work.
- Characterized `MissingMicroMaterial` against untouched Scala. Three plain-JVM cases freeze the exact facade and
companion surfaces, `MODULE$`, inert material values, interface defaults and all client-only boundaries. One Forge
case freezes side stripping and the exact singleton registered under the missing-material name and ID.
- Ported the singleton to a Java facade/companion pair and changed both Scala object-value uses to name `MODULE$`
explicitly. The placeholder key, stone item, sound, strength, resistance and missing-texture render pipeline are
unchanged; only the actual client rendering remains manual.
- All 177 plain-JVM and all 92 Java 8 Forge dedicated-server tests pass. This inert singleton is not a meaningful
focused performance target; `DefaultContent.scala` is the next medium-risk target.
+39
View File
@@ -2041,3 +2041,42 @@ other Java-authored Scala-style setters in this migration, newly recompiled Scal
- Java 8 Forge dedicated-server suite: 91 tests, 0 failures, 0 errors.
- Raw `javap` comparison confirms identical callable public names/descriptors for all three retained types. The sole
class-list removal is the unreferenced compiler closure above.
## 2026-08-31 — MissingMicroMaterial Java port
The unresolved-material placeholder is now a Java static facade plus a Java companion singleton implementing
`IMicroMaterial`. `DefaultContent` and `ItemMicroPart` name `MissingMicroMaterial$.MODULE$` explicitly where Scala
previously supplied the object value implicitly.
### Observable behavior
No known runtime divergence. The registered key remains `forgemicroblock:missing`; the material remains opaque,
non-luminous, strength 1, cutter strength 0, stone-sounding, explosion resistance 6, and supplies a one-item stone
stack. It still inherits render-pass-zero and solid behavior from the Java `IMicroMaterial` defaults.
On the client, icon loading still asks the proxy renderer for its safe null icon. Breaking returns that icon and face
rendering still applies its `IconTransformation`, lighting and render pipeline in the same order. On a dedicated
server Forge strips the three client methods from both singleton types and the client-only icon field from the
companion before `DefaultContent` registers it.
### ABI and source compatibility
`MissingMicroMaterial` retains its exact 12 public static methods. `MissingMicroMaterial$` retains `MODULE$`,
implements `IMicroMaterial`, and retains the matching 12 public instance methods. Both types keep `@SideOnly(CLIENT)`
on `loadIcons`, `getBreakingIcon` and `renderMicroFace`; neither class is itself side-only. Both jars emit exactly
`MissingMicroMaterial.class` and `MissingMicroMaterial$.class`, and no audited shipping consumer references either
type.
Accepted classfile-only differences are removed Scala signature/marker attributes, a private constructor on the
facade, removal of the companion's private Scala `icon` getter/setter, and a class initializer without Scala's
`ACC_PUBLIC` flag. None is a callable public member. Recompiled Scala source that passes the singleton as a value must
use `MissingMicroMaterial$.MODULE$`; static calls retain their original names and descriptors.
### Validation
- `MissingMicroMaterialCharacterizationTest`: 3 plain-JVM tests, unchanged from the Scala baseline.
- `MissingMicroMaterialFunctionalTest`: 1 Forge test, unchanged from the Scala baseline.
- Complete plain-JVM suite: 177 tests, 0 failures, 0 errors.
- Java 8 Forge dedicated-server suite: 92 tests, 0 failures, 0 errors.
- Raw `javap` comparison confirms identical callable public names/descriptors and the emitted class list is unchanged.
- Missing-texture icon loading and face rendering require a client and remain on the manual checklist.
+15 -10
View File
@@ -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`. 100 commits including the incremental-version build fix and separate
characterization and port commits for `MultipartSaveLoad`.
Branch: `algent/java`. Base: `master`. 102 commits including the incremental-version build fix and separate
characterization and port commits for `MissingMicroMaterial`.
## The one rule that matters
@@ -67,7 +67,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: **174 plain-JVM tests and 91 Java 8 Forge dedicated-server tests passing.** The ignored local server
Current baseline: **177 plain-JVM tests and 92 Java 8 Forge dedicated-server tests passing.** The ignored local server
EULA is accepted in this checkout.
### ABI diff against the reference
@@ -243,7 +243,7 @@ All eight load-bearing `$class` helpers from the inventory, both registries, and
`TRedstoneTile`, `TTileChangeTile`, `TFluidHandlerTile`, `TIInventoryTile`/`JInventoryTile`, `TileMultipartClient`, and
`TRandomDisplayTickTile` Java-trait ports, plus `MultipartCompatiblity`/`MCPCCompatModule`, `MultipartMod`,
`MultipartEventHandler`, `MicroblockMod`, `MicroblockEventHandler`, and the complete `MicroblockPH`/
`MicroblockCPH`/`MicroblockSPH` packet-handler unit, plus `MultipartSaveLoad`.
`MicroblockCPH`/`MicroblockSPH` packet-handler unit, plus `MultipartSaveLoad` and `MissingMicroMaterial`.
Plus the six marker interfaces: `TSlottedPart`, `IRandomDisplayTick`, `INeighborTileChange`, `TRandomUpdateTick`,
`ISidedHollowConnect`, `IMicroMaterialRender`, plus `MultipartHelper`, `TileCache`, `PacketScheduler` and the `ControlKeyModifer` pair.
@@ -258,7 +258,7 @@ across the port. It is also where the two shim constraints in the gotchas list w
`rayTraceAll`'s index production is now characterized, closing the gap the read-path cleanup left: the index written
into `ExtendedMOP.data` is what `reduceMOP` hands back to every click, activate, harvest and pick block.
110 Java files, 31 Scala files, ~4,919 Scala lines left (non-blank; that is the metric this figure has always used).
112 Java files, 30 Scala files, ~4,871 Scala lines left (non-blank; that is the metric this figure has always used).
## What is left, and in what order
@@ -377,18 +377,23 @@ ProjectRed's `MODULE$`/`loadingWorld` linkage, and dedicated Forge tests cover r
converter precedence/deletion and saved multipart reconstruction. Only the compiler-generated `$$anonfun$1`
class disappeared; the downstream inventory contains no reference to it.
`MissingMicroMaterial` is now Java. Its static facade and load-bearing companion retain all 12 public methods, exact
descriptors, `MODULE$`, `IMicroMaterial`, and the three client-only boundaries. Three plain-JVM tests freeze its raw
shape and inert values; one Forge test proves that `DefaultContent` registers the same singleton after client methods
and state are stripped on a dedicated server. The missing-texture render path remains client-manual.
**Medium.** The `handler` packages on both sides, `ItemMicroPart`,
`MicroblockPlacement`, `PlacementGrids`, `BlockMicroMaterial`, `MissingMicroMaterial`, `ConfigContent`,
`MicroblockPlacement`, `PlacementGrids`, `BlockMicroMaterial`, `ConfigContent`,
`DefaultContent`.
**Phase 5 is complete.** There are no Scala files left in `multipart/scalatraits/`. The client pair required the first
narrow generator relaxation: Java-trait parent linearization, explicit field-accessor recognition, and exclusion of
transient runtime caches from generated copying.
Take `microblock/MissingMicroMaterial.scala` next. At 48 nonblank lines it is the smallest remaining non-ASM unit in
the medium-risk queue, and existing registry tests already cover much of its inherited behavior. Before changing it,
freeze the exact facade/companion surface, `IMicroMaterial` method descriptors, client-only method stripping and the
singleton registered by `DefaultContent`; keep actual icon/render behavior on the client manual checklist.
Take `microblock/DefaultContent.scala` next. At 55 nonblank lines it is the smallest remaining unit named in the
medium-risk queue. Freeze the exact facade/companion surface and the complete ordered built-in class/material
registration result before changing it; retain the existing remaps and exact `MissingMicroMaterial$.MODULE$`
registration. Keep the characterization and port commits separate.
**Phase 6/7, last.** `Microblock` and the microblock shape hierarchy, `MicroblockGenerator`, `MultipartGenerator`, and
all of `multipart/asm/`. The ASM subsystem should be last; freeze generated-class fixtures before touching it.
+1
View File
@@ -18,6 +18,7 @@ release that includes those ports.
| Reload client resources after placing several microblock materials | The texture atlas reloads every material icon without missing textures | `MicroblockEventHandler.postTextureStitch` |
| Look at a saw in inventory and in hand | The saw item renders with its custom transform | `ItemSaw` `IItemRenderer` |
| Place microblocks of several materials, including glass | Transparent materials render in the correct pass and are not opaque | `IMicroMaterial.canRenderInPass` |
| Load a saved microblock whose material is no longer installed | The part remains present and renders the magenta/black missing texture instead of becoming material ID 0 | `MissingMicroMaterial` |
| Change a mixed multipart tile containing static and dynamically rendered parts | Static parts remain in the block render, dynamic parts remain in the TESR pass, and neither disappears after a part update | `TileMultipartClient` render caches |
| Watch a multipart torch long enough to emit display particles | Only parts implementing `IRandomDisplayTick` emit particles, with no duplicate or missing callbacks | `TRandomDisplayTickTile.randomDisplayTick` |
@@ -55,6 +55,6 @@ object DefaultContent {
MicroMaterialRegistry.remapName(oldKey(mycelium), materialKey(mycelium))
registerMaterial(new TopMicroMaterial(mycelium), materialKey(mycelium))
registerMaterial(MissingMicroMaterial, MissingMicroMaterial.key)
registerMaterial(MissingMicroMaterial$.MODULE$, MissingMicroMaterial.key())
}
}
@@ -136,7 +136,7 @@ object ItemMicroPart {
MicroMaterialRegistry.getMaterial(
stack.getTagCompound.getString("mat")
) match {
case null => MissingMicroMaterial
case null => MissingMicroMaterial$.MODULE$
case mat => mat
}
}
@@ -0,0 +1,91 @@
package codechicken.microblock;
import net.minecraft.block.Block;
import net.minecraft.block.Block.SoundType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import codechicken.lib.render.uv.IconTransformation;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial;
import codechicken.microblock.handler.MicroblockProxy$;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public final class MissingMicroMaterial$ implements IMicroMaterial {
public static final MissingMicroMaterial$ MODULE$ = new MissingMicroMaterial$();
private final String key = "forgemicroblock:missing";
@SideOnly(Side.CLIENT)
private IIcon icon;
private MissingMicroMaterial$() {}
public String key() {
return key;
}
@Override
@SideOnly(Side.CLIENT)
public void loadIcons() {
icon = MicroblockProxy$.MODULE$.renderBlocks().getIconSafe(null);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingIcon(int side) {
return icon;
}
@Override
@SideOnly(Side.CLIENT)
public void renderMicroFace(Vector3 pos, int pass, Cuboid6 bounds) {
MaterialRenderHelper$.MODULE$.start(pos, pass, new IconTransformation(icon)).lighting().render();
}
@Override
public boolean isTransparent() {
return false;
}
@Override
public int getLightValue() {
return 0;
}
@Override
public float getStrength(EntityPlayer player) {
return 1f;
}
@Override
public String getLocalizedName() {
return "Missing Material";
}
@Override
public ItemStack getItem() {
return new ItemStack(Blocks.stone);
}
@Override
public int getCutterStrength() {
return 0;
}
@Override
public SoundType getSound() {
return Block.soundTypeStone;
}
@Override
public float explosionResistance(Entity entity) {
return 6f;
}
}
@@ -0,0 +1,68 @@
package codechicken.microblock;
import net.minecraft.block.Block.SoundType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public final class MissingMicroMaterial {
private MissingMicroMaterial() {}
public static String key() {
return MissingMicroMaterial$.MODULE$.key();
}
@SideOnly(Side.CLIENT)
public static void loadIcons() {
MissingMicroMaterial$.MODULE$.loadIcons();
}
@SideOnly(Side.CLIENT)
public static IIcon getBreakingIcon(int side) {
return MissingMicroMaterial$.MODULE$.getBreakingIcon(side);
}
@SideOnly(Side.CLIENT)
public static void renderMicroFace(Vector3 pos, int pass, Cuboid6 bounds) {
MissingMicroMaterial$.MODULE$.renderMicroFace(pos, pass, bounds);
}
public static boolean isTransparent() {
return MissingMicroMaterial$.MODULE$.isTransparent();
}
public static int getLightValue() {
return MissingMicroMaterial$.MODULE$.getLightValue();
}
public static float getStrength(EntityPlayer player) {
return MissingMicroMaterial$.MODULE$.getStrength(player);
}
public static String getLocalizedName() {
return MissingMicroMaterial$.MODULE$.getLocalizedName();
}
public static ItemStack getItem() {
return MissingMicroMaterial$.MODULE$.getItem();
}
public static int getCutterStrength() {
return MissingMicroMaterial$.MODULE$.getCutterStrength();
}
public static SoundType getSound() {
return MissingMicroMaterial$.MODULE$.getSound();
}
public static float explosionResistance(Entity entity) {
return MissingMicroMaterial$.MODULE$.explosionResistance(entity);
}
}
@@ -1,55 +0,0 @@
package codechicken.microblock
import codechicken.lib.render.uv.IconTransformation
import codechicken.lib.vec.{Cuboid6, Vector3}
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
import codechicken.microblock.handler.MicroblockProxy
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.Block
import net.minecraft.block.Block.SoundType
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraft.util.IIcon
/** Stand-in for a material whose name could not be resolved at load time.
* Renders the vanilla missing texture (magenta/black checkerboard) and behaves
* inertly. Resolving an unknown name to this placeholder keeps microblocks
* from silently becoming material id 0 (Blood Rune in GTNH).
*/
object MissingMicroMaterial extends IMicroMaterial {
val key = "forgemicroblock:missing"
@SideOnly(Side.CLIENT)
private var icon: IIcon = _
@SideOnly(Side.CLIENT)
override def loadIcons(): Unit = {
icon = MicroblockProxy.renderBlocks.getIconSafe(null)
}
@SideOnly(Side.CLIENT)
override def getBreakingIcon(side: Int): IIcon = icon
@SideOnly(Side.CLIENT)
override def renderMicroFace(
pos: Vector3,
pass: Int,
bounds: Cuboid6
): Unit = {
MaterialRenderHelper
.start(pos, pass, new IconTransformation(icon))
.lighting()
.render()
}
override def isTransparent: Boolean = false
override def getLightValue: Int = 0
override def getStrength(player: EntityPlayer): Float = 1f
override def getLocalizedName: String = "Missing Material"
override def getItem: ItemStack = new ItemStack(Blocks.stone)
override def getCutterStrength: Int = 0
override def getSound: SoundType = Block.soundTypeStone
override def explosionResistance(entity: Entity): Float = 6f
}