mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Fix the incorrect matching algorithm in ShapelessRecipes and ShapelessOreRecipe (#4472)
This commit is contained in:
1 parent
8eb6ec9cdd
commit
c8efe29d61
3 files changed
+54
-30
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user