diff --git a/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java index 4c11ead132..8659d976a7 100644 --- a/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java +++ b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java @@ -106,6 +106,9 @@ public class ShapedOreRecipe extends IForgeRegistryEntry.Impl implement return false; } + /** + * Based on {@link net.minecraft.item.crafting.ShapedRecipes#checkMatch(InventoryCrafting, int, int, boolean)} + */ protected boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) @@ -114,7 +117,7 @@ public class ShapedOreRecipe extends IForgeRegistryEntry.Impl implement { int subX = x - startX; int subY = y - startY; - Ingredient target = null; + Ingredient target = Ingredient.EMPTY; if (subX >= 0 && subY >= 0 && subX < width && subY < height) { @@ -126,11 +129,11 @@ public class ShapedOreRecipe extends IForgeRegistryEntry.Impl implement { target = input.get(subX + subY * width); } - - if (!target.apply(inv.getStackInRowAndColumn(x, y))) - { - return false; - } + } + + if (!target.apply(inv.getStackInRowAndColumn(x, y))) + { + return false; } } } diff --git a/src/test/java/net/minecraftforge/debug/RecipeTestMod.java b/src/test/java/net/minecraftforge/debug/RecipeTestMod.java new file mode 100644 index 0000000000..ee77914798 --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/RecipeTestMod.java @@ -0,0 +1,30 @@ +package net.minecraftforge.debug; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.ShapedOreRecipe; + +@Mod(modid = "recipetest", version = "1.0", acceptableRemoteVersions = "*") +public class RecipeTestMod +{ + @Mod.EventHandler + public void preinit(FMLPreInitializationEvent event) + { + ResourceLocation location1 = new ResourceLocation("recipetest", "dirt"); + ShapedOreRecipe recipe1 = new ShapedOreRecipe(location1, new ItemStack(Blocks.DIAMOND_BLOCK), "DDD", 'D', new ItemStack(Blocks.DIRT)); + recipe1.setRegistryName(location1); + GameRegistry.register(recipe1); + + ResourceLocation location2 = new ResourceLocation("recipetest", "stone"); + CraftingHelper.ShapedPrimer primer1 = CraftingHelper.parseShaped("SSS", 'S', new ItemStack(Blocks.IRON_BLOCK)); + ShapedRecipes recipe2 = new ShapedRecipes(location2.getResourcePath(), primer1.width, primer1.height, primer1.input, new ItemStack(Blocks.GOLD_BLOCK)); + recipe2.setRegistryName(location2); + GameRegistry.register(recipe2); + } +}