mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-24 22:24:30 +00:00
- Fixed various crashes if no recipes are removed and the undo method is called (e.g. on /mt reload), adding a null object. - Added option to remove more than 1 recipe with BaseListRemoval - Cleanup of some classes which are extending BaseListRemoval
70 lines
2.2 KiB
Java
70 lines
2.2 KiB
Java
package modtweaker2.mods.thaumcraft.handlers;
|
|
|
|
import static modtweaker2.helpers.InputHelper.toObject;
|
|
import static modtweaker2.helpers.InputHelper.toStack;
|
|
import static modtweaker2.helpers.StackHelper.areEqual;
|
|
import minetweaker.MineTweakerAPI;
|
|
import minetweaker.api.item.IIngredient;
|
|
import minetweaker.api.item.IItemStack;
|
|
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
import modtweaker2.utils.BaseListAddition;
|
|
import modtweaker2.utils.BaseListRemoval;
|
|
import modtweaker2.utils.TweakerPlugin;
|
|
import net.minecraft.item.ItemStack;
|
|
import stanhebben.zenscript.annotations.ZenClass;
|
|
import stanhebben.zenscript.annotations.ZenMethod;
|
|
import thaumcraft.api.ThaumcraftApi;
|
|
import thaumcraft.api.crafting.CrucibleRecipe;
|
|
|
|
@ZenClass("mods.thaumcraft.Crucible")
|
|
public class Crucible {
|
|
@ZenMethod
|
|
public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) {
|
|
if (!TweakerPlugin.hasInit())
|
|
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
|
|
}
|
|
|
|
private static class Add extends BaseListAddition {
|
|
public Add(CrucibleRecipe recipe) {
|
|
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeInfo() {
|
|
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
|
|
}
|
|
}
|
|
|
|
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ZenMethod
|
|
public static void removeRecipe(IItemStack output) {
|
|
if (!TweakerPlugin.hasInit())
|
|
MineTweakerAPI.apply(new Remove(toStack(output)));
|
|
}
|
|
|
|
private static class Remove extends BaseListRemoval {
|
|
public Remove(ItemStack stack) {
|
|
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
|
|
}
|
|
|
|
@Override
|
|
public void apply() {
|
|
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
|
if (o instanceof CrucibleRecipe) {
|
|
CrucibleRecipe r = (CrucibleRecipe) o;
|
|
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
|
|
recipes.add(r);
|
|
}
|
|
}
|
|
}
|
|
super.apply();
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeInfo() {
|
|
return stack.getDisplayName();
|
|
}
|
|
}
|
|
}
|