fix: exclude missing placeholder from raw material recipes

This commit is contained in:
Algent committed 2026-09-14 16:49:47 +02:00
1 parent e2122ad822
commit 4e0d7a684e
3 files changed
+17

No files matched your search

@@ -29,6 +29,18 @@ import scala.Tuple3;
*/
class MicroRecipeFunctionalTest {
@Test
void cuttingStoneUsesTheRealMaterialInsteadOfTheMissingPlaceholder() {
int material = MicroMaterialRegistry.materialID("minecraft:stone");
InventoryCrafting crafting = grid();
crafting.setInventorySlotContents(0, new ItemStack(new TestSaw(100)));
crafting.setInventorySlotContents(3, new ItemStack(Blocks.stone));
assertEquals(material, MicroRecipe.findMaterial(crafting.getStackInSlot(3)));
assertMicro(MicroRecipe.getCraftingResult(crafting), 2, 0, 4, material);
crafting.setInventorySlotContents(3, MicroRecipe.getCraftingResult(crafting));
assertMicro(MicroRecipe.getCraftingResult(crafting), 2, 0, 2, material);
}
@Test
void recipeMetadataMaterialLookupAndCreationRoundTrip() {
int material = glassMaterial();
@@ -220,6 +220,10 @@ public final class MicroRecipe$ implements IRecipe {
public int findMaterial(ItemStack item) {
for (Tuple2<String, IMicroMaterial> entry : MicroMaterialRegistry.getIdMap()) {
// The recovery placeholder exposes stone, but must never win a raw-material recipe lookup.
if (entry._2() == MissingMicroMaterial$.MODULE$) {
continue;
}
ItemStack materialItem = entry._2().getItem();
if (Objects.equals(item.getItem(), materialItem.getItem())
&& item.getItemDamage() == materialItem.getItemDamage()