fix: register all requested microblock metadata variants

This commit is contained in:
Algent committed 2026-09-14 16:50:33 +02:00
1 parent 4e0d7a684e
commit 74eb0ea7ba
4 files changed
+23 -4

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ audit, before extending this list.
| Area | Difference and consequence |
| --- | --- |
| Raw microblock recipe material lookup | Skips `MissingMicroMaterial`, whose recovery item is stone, so sawing stone selects the real stone material. Existing missing-material microblocks retain their recovery behavior. This fixes a pre-existing Scala bug. |
| `BlockMicroMaterial.createAndRegister(Block, Seq, String)` | Registers every supplied metadata value instead of only zero, including dark-oak logs and leaves and their legacy-name remaps. This fixes a pre-existing Scala bug; material IDs are rebuilt through the existing registry mapping. |
| `IDWriter` before `setMax` | `read`/`write` throw `IllegalStateException` instead of `NullPointerException`. Uninitialized use is unsupported. |
| `PacketScheduler` invalid `maskWidth` | Throws `IllegalArgumentException` instead of `scala.MatchError`. Valid widths remain 1, 2, 4 and 8. |
| `NormalOcclusionTest.apply(Traversable, Traversable)` | Materializes both inputs into Java lists before testing instead of nested Scala `forall`. Finite, side-effect-free collections give the same result; eager traversal can change side effects, failure timing and termination for unusual inputs. |
@@ -360,9 +360,9 @@ class DefaultContentFunctionalTest {
add(expectedNames, expectedRemaps, Blocks.cobblestone, "minecraft:cobblestone", 0);
add(expectedNames, expectedRemaps, Blocks.planks, "minecraft:planks", 5);
add(expectedNames, expectedRemaps, Blocks.log, "minecraft:log", 3);
add(expectedNames, expectedRemaps, Blocks.log2, "minecraft:log2", 0, "tile.log2");
add(expectedNames, expectedRemaps, Blocks.log2, "minecraft:log2", 1, "tile.log2");
add(expectedNames, expectedRemaps, Blocks.leaves, "minecraft:leaves", 3);
add(expectedNames, expectedRemaps, Blocks.leaves2, "minecraft:leaves2", 0, "tile.leaves2");
add(expectedNames, expectedRemaps, Blocks.leaves2, "minecraft:leaves2", 1, "tile.leaves2");
add(expectedNames, expectedRemaps, Blocks.sponge, "minecraft:sponge", 0);
add(expectedNames, expectedRemaps, Blocks.glass, "minecraft:glass", 0);
add(expectedNames, expectedRemaps, Blocks.lapis_block, "minecraft:lapis_block", 0);
@@ -419,7 +419,7 @@ class DefaultContentFunctionalTest {
}
}
assertEquals(119, expectedNames.size());
assertEquals(121, expectedNames.size());
assertEquals(expectedNames, actualNames);
assertEquals(expectedRemaps, materialRemaps());
}
@@ -7,6 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
@@ -17,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import org.junit.jupiter.api.Test;
import codechicken.microblock.BlockMicroMaterial;
import codechicken.microblock.ItemMicroPart;
import codechicken.microblock.MicroMaterialRegistry;
import codechicken.microblock.MicroRecipe;
@@ -41,6 +43,22 @@ class MicroRecipeFunctionalTest {
assertMicro(MicroRecipe.getCraftingResult(crafting), 2, 0, 2, material);
}
@Test
void cuttingDarkOakLogsAndLeavesRetainsTheirMetadata() {
for (Block block : new Block[] { Blocks.log2, Blocks.leaves2 }) {
String name = BlockMicroMaterial.materialKey(block, 1);
assertTrue(MicroMaterialRegistry.getMaterial(name) instanceof BlockMicroMaterial);
int material = MicroMaterialRegistry.materialID(name);
InventoryCrafting crafting = grid();
crafting.setInventorySlotContents(0, new ItemStack(new TestSaw(100)));
crafting.setInventorySlotContents(3, new ItemStack(block, 1, 1));
assertMicro(MicroRecipe.getCraftingResult(crafting), 2, 0, 4, material);
ItemStack restored = MicroRecipe.create(1, 0, 8, material);
assertSame(Item.getItemFromBlock(block), restored.getItem());
assertEquals(1, restored.getItemDamage());
}
}
@Test
void recipeMetadataMaterialLookupAndCreationRoundTrip() {
int material = glassMaterial();
@@ -53,7 +53,7 @@ public final class BlockMicroMaterial$ {
}
public void createAndRegister(Block block, Seq<Object> meta, String oldName) {
createAndRegister(block, 0, materialKey(block), oldName);
createAndRegister(block, meta, materialKey(block), oldName);
}
public void createAndRegister(Block block, Seq<Object> meta, String name, String oldName) {