Add removeAll() to all machines in crafttweaker, closes #1389

This commit is contained in:
modmuss50 2017-12-29 12:33:05 +00:00
parent 602cfebc38
commit 57f3e43ec5
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82

View file

@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import reborncore.common.util.ItemUtils;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.recipe.BaseRecipe;
import java.util.ArrayList;
@ -124,4 +125,31 @@ public class CTGeneric {
}
}
public static class RemoveAll implements IAction {
List<BaseRecipe> removedRecipes = new ArrayList<BaseRecipe>();
private final String name;
public RemoveAll(String machineName) {
this.name = machineName;
}
@Override
public void apply() {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(name)) {
removedRecipes.add((BaseRecipe) recipeType);
RecipeHandler.recipeList.remove(recipeType);
}
}
@Override
public String describe() {
return "Removing all recipes from " + name;
}
}
@ZenMethod
public static void removeAll(){
CraftTweakerAPI.apply(new RemoveAll(getMachineName()));
}
}