Add wildcard support to entire recipe system
This commit is contained in:
parent
47fd7799ff
commit
06b806e871
3 changed files with 19 additions and 12 deletions
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||
|
||||
import mekanism.api.infuse.InfusionInput;
|
||||
import mekanism.api.infuse.InfusionOutput;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
|
@ -92,9 +93,11 @@ public final class RecipeHandler
|
|||
{
|
||||
for(Map.Entry entry : recipes.entrySet())
|
||||
{
|
||||
if(((InfusionInput)entry.getKey()).inputStack.isItemEqual(infusion.inputStack) && infusion.inputStack.stackSize >= ((InfusionInput)entry.getKey()).inputStack.stackSize)
|
||||
InfusionInput input = (InfusionInput)entry.getKey();
|
||||
|
||||
if(StackUtils.equalsWildcard(input.inputStack, infusion.inputStack) && infusion.inputStack.stackSize >= input.inputStack.stackSize)
|
||||
{
|
||||
if(infusion.infusionType == ((InfusionInput)entry.getKey()).infusionType)
|
||||
if(infusion.infusionType == input.infusionType)
|
||||
{
|
||||
if(stackDecrease)
|
||||
{
|
||||
|
@ -123,11 +126,13 @@ public final class RecipeHandler
|
|||
{
|
||||
for(Map.Entry entry : recipes.entrySet())
|
||||
{
|
||||
if(((ItemStack)entry.getKey()).isItemEqual(itemstack) && itemstack.stackSize >= ((ItemStack)entry.getKey()).stackSize)
|
||||
ItemStack stack = (ItemStack)entry.getKey();
|
||||
|
||||
if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize)
|
||||
{
|
||||
if(stackDecrease)
|
||||
{
|
||||
itemstack.stackSize -= ((ItemStack)entry.getKey()).stackSize;
|
||||
itemstack.stackSize -= stack.stackSize;
|
||||
}
|
||||
|
||||
return ((ItemStack)entry.getValue()).copy();
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public final class StackUtils
|
||||
{
|
||||
|
@ -41,6 +42,11 @@ public final class StackUtils
|
|||
return stack1.itemID != stack2.itemID;
|
||||
}
|
||||
|
||||
public static boolean equalsWildcard(ItemStack wild, ItemStack check)
|
||||
{
|
||||
return wild.itemID == check.itemID && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage());
|
||||
}
|
||||
|
||||
public static List<ItemStack> even(ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
|
|
@ -106,7 +106,10 @@ public class MekanismGenerators implements IModule
|
|||
try {
|
||||
for(ItemStack ore : OreDictionary.getOres("treeSapling"))
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(BioFuel, 2));
|
||||
if(ore.getItemDamage() == 0 || ore.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE), new ItemStack(BioFuel, 2));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
@ -153,13 +156,6 @@ public class MekanismGenerators implements IModule
|
|||
RecipeHandler.addCrusherRecipe(new ItemStack(Item.potato), new ItemStack(BioFuel, 4));
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Item.carrot), new ItemStack(BioFuel, 4));
|
||||
|
||||
try {
|
||||
for(int i = 0; i < BlockLeaves.LEAF_TYPES.length; i++)
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Block.sapling, 1, i), new ItemStack(BioFuel, 2));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
|
||||
InfuseRegistry.registerInfuseObject(new ItemStack(BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue