diff --git a/docs/migration/DIVERGENCES.md b/docs/migration/DIVERGENCES.md index bc1b617..c9fe111 100644 --- a/docs/migration/DIVERGENCES.md +++ b/docs/migration/DIVERGENCES.md @@ -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. | diff --git a/src/functionalTest/java/codechicken/multipart/test/DefaultContentFunctionalTest.java b/src/functionalTest/java/codechicken/multipart/test/DefaultContentFunctionalTest.java index fe9bb78..7b4247a 100644 --- a/src/functionalTest/java/codechicken/multipart/test/DefaultContentFunctionalTest.java +++ b/src/functionalTest/java/codechicken/multipart/test/DefaultContentFunctionalTest.java @@ -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()); } diff --git a/src/functionalTest/java/codechicken/multipart/test/MicroRecipeFunctionalTest.java b/src/functionalTest/java/codechicken/multipart/test/MicroRecipeFunctionalTest.java index fa3a837..5f8dbb5 100644 --- a/src/functionalTest/java/codechicken/multipart/test/MicroRecipeFunctionalTest.java +++ b/src/functionalTest/java/codechicken/multipart/test/MicroRecipeFunctionalTest.java @@ -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(); diff --git a/src/main/scala/codechicken/microblock/BlockMicroMaterial$.java b/src/main/scala/codechicken/microblock/BlockMicroMaterial$.java index 5bdad4e..e56c23a 100644 --- a/src/main/scala/codechicken/microblock/BlockMicroMaterial$.java +++ b/src/main/scala/codechicken/microblock/BlockMicroMaterial$.java @@ -53,7 +53,7 @@ public final class BlockMicroMaterial$ { } public void createAndRegister(Block block, Seq meta, String oldName) { - createAndRegister(block, 0, materialKey(block), oldName); + createAndRegister(block, meta, materialKey(block), oldName); } public void createAndRegister(Block block, Seq meta, String name, String oldName) {