2013-08-28 08:32:01 +00:00
|
|
|
package thaumcraft.api.crafting;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
2013-10-06 20:38:49 +00:00
|
|
|
import thaumcraft.api.ThaumcraftApiHelper;
|
2013-08-28 08:32:01 +00:00
|
|
|
import thaumcraft.api.aspects.Aspect;
|
|
|
|
import thaumcraft.api.aspects.AspectList;
|
|
|
|
|
2013-10-06 20:38:49 +00:00
|
|
|
public class CrucibleRecipe {
|
2013-08-28 08:32:01 +00:00
|
|
|
|
|
|
|
public ItemStack recipeOutput;
|
|
|
|
public Object catalyst;
|
|
|
|
public AspectList aspects;
|
|
|
|
public String key;
|
|
|
|
|
2013-10-06 20:38:49 +00:00
|
|
|
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
|
2013-08-28 08:32:01 +00:00
|
|
|
recipeOutput = result;
|
|
|
|
this.aspects = tags;
|
|
|
|
this.key = researchKey;
|
2013-10-06 20:38:49 +00:00
|
|
|
this.catalyst = cat;
|
|
|
|
if (cat instanceof String) {
|
|
|
|
this.catalyst = OreDictionary.getOres((String) cat);
|
2013-08-28 08:32:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean matches(AspectList itags, ItemStack cat) {
|
|
|
|
if (catalyst instanceof ItemStack && !cat.isItemEqual((ItemStack) catalyst)) {
|
|
|
|
return false;
|
|
|
|
} else if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
|
2013-10-06 20:38:49 +00:00
|
|
|
if (!ThaumcraftApiHelper.containsMatch(true, ((ArrayList<ItemStack>)catalyst).toArray(new ItemStack[]{}), cat)) return false;
|
2013-08-28 08:32:01 +00:00
|
|
|
}
|
|
|
|
if (itags==null) return false;
|
|
|
|
for (Aspect tag:aspects.getAspects()) {
|
|
|
|
if (itags.getAmount(tag)<aspects.getAmount(tag)) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AspectList removeMatching(AspectList itags) {
|
|
|
|
AspectList temptags = new AspectList();
|
|
|
|
temptags.aspects.putAll(itags.aspects);
|
|
|
|
|
|
|
|
for (Aspect tag:aspects.getAspects()) {
|
|
|
|
temptags.remove(tag, aspects.getAmount(tag));
|
|
|
|
// if (!temptags.remove(tag, aspects.getAmount(tag))) return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
itags = temptags;
|
|
|
|
return itags;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|