Fix the incorrect matching algorithm in ShapelessRecipes and ShapelessOreRecipe (#4472)
This commit is contained in:
parent
8eb6ec9cdd
commit
c8efe29d61
|
@ -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<Ingredient> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -409,7 +409,6 @@ public class CraftingHelper {
|
|||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================
|
||||
// INTERNAL
|
||||
//=======================================================
|
||||
|
|
|
@ -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<IRecipe> 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<Ingredient> 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<Ingredient> 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
|
||||
|
|
Loading…
Reference in New Issue