Allow removal of recipes
For CraftTweaker and such
This commit is contained in:
parent
4c44c871e7
commit
dd1dafe3dc
|
@ -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.");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue