diff --git a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java.patch b/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java.patch index cc918d8fa8..df082d02b7 100644 --- a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java.patch +++ b/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java.patch @@ -32,7 +32,48 @@ } return nonnulllist; -@@ -136,7 +130,6 @@ +@@ -61,7 +55,8 @@ + + public boolean func_77569_a(InventoryCrafting p_77569_1_, World p_77569_2_) + { +- List list = Lists.newArrayList(this.field_77579_b); ++ int ingredientCount = 0; ++ net.minecraft.client.util.RecipeItemHelper recipeItemHelper = new net.minecraft.client.util.RecipeItemHelper(); + + for (int i = 0; i < p_77569_1_.func_174923_h(); ++i) + { +@@ -71,27 +66,13 @@ + + if (!itemstack.func_190926_b()) + { +- boolean flag = false; +- +- for (Ingredient ingredient : list) +- { +- if (ingredient.apply(itemstack)) +- { +- flag = true; +- list.remove(ingredient); +- break; +- } +- } +- +- if (!flag) +- { +- return false; +- } ++ ++ingredientCount; ++ recipeItemHelper.func_194112_a(itemstack); + } + } + } + +- return list.isEmpty(); ++ return ingredientCount == this.field_77579_b.size() && recipeItemHelper.func_194116_a(this, null); + } + + public ItemStack func_77572_b(InventoryCrafting p_77572_1_) +@@ -136,7 +117,6 @@ return nonnulllist; } diff --git a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java index 1650adda0f..f4479c2e61 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java +++ b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java @@ -409,7 +409,6 @@ public class CraftingHelper { } - //======================================================= // INTERNAL //======================================================= diff --git a/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java index 42c554a9d0..56d9485da2 100644 --- a/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java +++ b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java @@ -19,11 +19,11 @@ package net.minecraftforge.oredict; -import java.util.Iterator; +import java.util.List; import net.minecraft.block.Block; +import net.minecraft.client.util.RecipeItemHelper; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -31,13 +31,13 @@ import net.minecraft.util.JsonUtils; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.registries.IForgeRegistryEntry; import javax.annotation.Nonnull; +import com.google.common.collect.Lists; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; @@ -90,38 +90,22 @@ public class ShapelessOreRecipe extends IForgeRegistryEntry.Impl implem public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1){ return output.copy(); } @Override - public boolean matches(@Nonnull InventoryCrafting var1, @Nonnull World world) + public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world) { - NonNullList required = NonNullList.create(); - required.addAll(input); + int ingredientCount = 0; + RecipeItemHelper recipeItemHelper = new RecipeItemHelper(); - for (int x = 0; x < var1.getSizeInventory(); x++) + for (int i = 0; i < inv.getSizeInventory(); ++i) { - ItemStack slot = var1.getStackInSlot(x); - - if (!slot.isEmpty()) + ItemStack itemstack = inv.getStackInSlot(i); + if (!itemstack.isEmpty()) { - boolean inRecipe = false; - Iterator req = required.iterator(); - - while (req.hasNext()) - { - if (req.next().apply(slot)) - { - inRecipe = true; - req.remove(); - break; - } - } - - if (!inRecipe) - { - return false; - } + ++ingredientCount; + recipeItemHelper.accountStack(itemstack); } } - return required.isEmpty(); + return ingredientCount == this.input.size() && recipeItemHelper.canCraft(this, null); } @Override