refactor: port MicroMaterialRegistry to Java

Replaces MicroMaterialRegistry.scala with a Java registry, its companion
singleton and the two nested interfaces. Both nested interfaces are
descriptor-identical to the reference and MODULE$ keeps every instance
method ProjRed links against. Ten jars reference this type and three more
reach it reflectively, so the surface was checked member by member rather
than by descriptor count.

getIdMap keeps its scala.Tuple2 array because extrautilities links against
it, so the registry still stores tuples internally. readIDMap moves from
scala.collection.Seq to java.util.List, which no jar references; the one
in-repo caller moved from mkString to String.join. That clears one of the
five Scala-typed descriptors the inventory identified.

Three removals, all verified unreferenced: the mangled public accessors
Scala emitted so its closure classes could reach private state,
IMicroMaterial$class, and the MissingMicroMaterial forwarders for the two
members it does not override. The last of those was caught by the
characterization failing to compile, not by inspection.

IMicroMaterial's loadIcons, canRenderInPass and isSolid become real Java
defaults, so implementors can inherit rather than restate them. Eleven
anonfun classes are gone.

Validated with 73 plain-JVM tests passing against both the Scala baseline
and the port, a clean build, and the Java 8 Forge dedicated-server suite,
which exercises setupIDMap and calcMaxCuttingStrength during real startup.
This commit is contained in:
Algent committed 2026-08-14 22:08:30 +02:00
1 parent dc758d4310
commit edd6136354
6 files changed
+463 -261

No files matched your search

@@ -0,0 +1,100 @@
package codechicken.microblock;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MovingObjectPosition;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.packet.PacketCustom;
import codechicken.microblock.MicroMaterialRegistry.IMicroHighlightRenderer;
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial;
import scala.Tuple2;
/**
* Scala companion singleton. Retained because compiled Scala consumers read MODULE$ and call these instance methods.
*/
public final class MicroMaterialRegistry$ {
public static final MicroMaterialRegistry$ MODULE$ = new MicroMaterialRegistry$();
private MicroMaterialRegistry$() {}
public void registerMaterial(IMicroMaterial material, String name) {
MicroMaterialRegistry.registerMaterial(material, name);
}
public void replaceMaterial(IMicroMaterial material, String name) {
MicroMaterialRegistry.replaceMaterial(material, name);
}
public void registerHighlightRenderer(IMicroHighlightRenderer handler) {
MicroMaterialRegistry.registerHighlightRenderer(handler);
}
public void remapName(String oldName, String newName) {
MicroMaterialRegistry.remapName(oldName, newName);
}
public void setupIDMap() {
MicroMaterialRegistry.setupIDMap();
}
public int getMissingId() {
return MicroMaterialRegistry.getMissingId();
}
public void calcMaxCuttingStrength() {
MicroMaterialRegistry.calcMaxCuttingStrength();
}
public void loadIcons() {
MicroMaterialRegistry.loadIcons();
}
public int getMaxCuttingStrength() {
return MicroMaterialRegistry.getMaxCuttingStrength();
}
public void writeIDMap(PacketCustom packet) {
MicroMaterialRegistry.writeIDMap(packet);
}
public List<String> readIDMap(PacketCustom packet) {
return MicroMaterialRegistry.readIDMap(packet);
}
public void writeMaterialID(MCDataOutput data, int id) {
MicroMaterialRegistry.writeMaterialID(data, id);
}
public int readMaterialID(MCDataInput data) {
return MicroMaterialRegistry.readMaterialID(data);
}
public String materialName(int id) {
return MicroMaterialRegistry.materialName(id);
}
public int materialID(String name) {
return MicroMaterialRegistry.materialID(name);
}
public IMicroMaterial getMaterial(String name) {
return MicroMaterialRegistry.getMaterial(name);
}
public IMicroMaterial getMaterial(int id) {
return MicroMaterialRegistry.getMaterial(id);
}
public Tuple2<String, IMicroMaterial>[] getIdMap() {
return MicroMaterialRegistry.getIdMap();
}
public boolean renderHighlight(EntityPlayer player, MovingObjectPosition hit, CommonMicroClass mcrClass, int size,
int material) {
return MicroMaterialRegistry.renderHighlight(player, hit, mcrClass, size, material);
}
}