Allow removal of recipes

For CraftTweaker and such
This commit is contained in:
Nicholas Ignoffo 2017-09-07 22:46:49 -07:00
parent 4c44c871e7
commit dd1dafe3dc
5 changed files with 58 additions and 6 deletions

View file

@ -86,6 +86,24 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar {
addTartaricForge(output, minimumSouls, soulDrain, ingredients.toArray(new Ingredient[0]));
}
public boolean removeBloodAltar(@Nonnull RecipeBloodAltar recipe) {
Preconditions.checkNotNull(recipe, "recipe cannot be null.");
return altarRecipes.remove(recipe);
}
public boolean removeAlchemyTable(@Nonnull RecipeAlchemyTable recipe) {
Preconditions.checkNotNull(recipe, "recipe cannot be null.");
return alchemyRecipes.remove(recipe);
}
public boolean removeTartaricForge(@Nonnull RecipeTartaricForge recipe) {
Preconditions.checkNotNull(recipe, "recipe cannot be null.");
return tartaricForgeRecipes.remove(recipe);
}
@Nullable
public RecipeBloodAltar getBloodAltar(@Nonnull ItemStack input) {
Preconditions.checkNotNull(input, "input cannot be null.");

View file

@ -0,0 +1,34 @@
package WayofTime.bloodmagic.api_impl.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import java.util.List;
public class IngredientTester {
public static boolean compareIngredients(Ingredient ingredient1, Ingredient ingredient2) {
ItemStack[] stacks1 = ingredient1.getMatchingStacks();
ItemStack[] stacks2 = ingredient2.getMatchingStacks();
if (stacks1.length != stacks2.length)
return false;
for (int i = 0; i < stacks1.length; i++)
if (!ItemStack.areItemStacksEqualUsingNBTShareTag(stacks1[i], stacks2[i]))
return false;
return true;
}
public static boolean compareIngredients(List<Ingredient> ingredients1, List<Ingredient> ingredients2) {
if (ingredients1.size() != ingredients2.size())
return false;
for (int i = 0; i < ingredients1.size(); i++)
if (!compareIngredients(ingredients1.get(i), ingredients2.get(i)))
return false;
return true;
}
}

View file

@ -67,8 +67,8 @@ public class RecipeAlchemyTable {
if (syphon != that.syphon) return false;
if (ticks != that.ticks) return false;
if (minimumTier != that.minimumTier) return false;
if (!input.equals(that.input)) return false;
return ItemStack.areItemStacksEqual(output, that.output);
if (!IngredientTester.compareIngredients(input, that.input)) return false;
return ItemStack.areItemStacksEqualUsingNBTShareTag(output, that.output);
}
@Override

View file

@ -80,8 +80,8 @@ public class RecipeBloodAltar {
if (minimumTier != that.minimumTier) return false;
if (syphon != that.syphon) return false;
if (drainRate != that.drainRate) return false;
if (!input.equals(that.input)) return false;
return ItemStack.areItemStacksEqual(output, that.output);
if (!IngredientTester.compareIngredients(input, that.input)) return false;
return ItemStack.areItemStacksEqualUsingNBTShareTag(output, that.output);
}
@Override

View file

@ -60,8 +60,8 @@ public class RecipeTartaricForge {
if (minimumSouls != that.minimumSouls) return false;
if (soulDrain != that.soulDrain) return false;
if (!input.equals(that.input)) return false;
return ItemStack.areItemStacksEqual(output, that.output);
if (!IngredientTester.compareIngredients(input, that.input)) return false;
return ItemStack.areItemStacksEqualUsingNBTShareTag(output, that.output);
}
@Override