Added removeAll for reactor and rolling machine. Closes #1427

This commit is contained in:
drcrazy 2018-02-02 18:33:14 +03:00
parent dfa35e2652
commit 543a2a7271
3 changed files with 48 additions and 28 deletions

View file

@ -35,7 +35,6 @@ import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.api.reactor.FusionReactorRecipeHelper;
import java.util.ArrayList;
import java.util.List;
@ -55,9 +54,19 @@ public class CTFusionReactor {
@ZenMethod
public static void removeBottomInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveTopInput(iIngredient));
CraftTweakerAPI.apply(new RemoveBottomInput(iIngredient));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output)));
}
@ZenMethod
public static void removeAll() {
CraftTweakerAPI.apply(new RemoveAll());
}
private static class Add implements IAction {
private final FusionReactorRecipe recipe;
@ -76,11 +85,6 @@ public class CTFusionReactor {
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output)));
}
private static class Remove implements IAction {
private final ItemStack output;
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
@ -97,7 +101,6 @@ public class CTFusionReactor {
FusionReactorRecipeHelper.reactorRecipes.remove(recipeType);
break;
}
}
}
@ -133,7 +136,6 @@ public class CTFusionReactor {
}
}
@SuppressWarnings("unused")
private static class RemoveBottomInput implements IAction {
private final IIngredient output;
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
@ -158,4 +160,17 @@ public class CTFusionReactor {
return "Removing Fusion Reactor recipe";
}
}
private static class RemoveAll implements IAction {
@Override
public void apply() {
FusionReactorRecipeHelper.reactorRecipes.clear();
}
@Override
public String describe() {
return "Removing all Fusion Reactor recipes";
}
}
}

View file

@ -24,6 +24,8 @@
package techreborn.compat.crafttweaker;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import gnu.trove.set.TCharSet;
@ -65,6 +67,24 @@ public class CTRollingMachine {
RollingMachineRecipe.instance.getRecipeList().remove(resourceLocation);
}
}
@ZenMethod
public static void removeAll() {
CraftTweakerAPI.apply(new RemoveAll());
}
private static class RemoveAll implements IAction{
@Override
public void apply() {
RollingMachineRecipe.instance.getRecipeList().clear();
}
@Override
public String describe() {
return "Removing all Rolling Machine recipes";
}
}
//Stolen from https://github.com/jaredlll08/MTLib/blob/1.12/src/main/java/com/blamejared/mtlib/helpers/InputHelper.java#L170-L213
//License as seen here: https://github.com/jaredlll08/MTLib/blob/1.12/LICENSE.md (MIT at time of writing)

View file

@ -24,20 +24,15 @@
package techreborn.compat.crafttweaker;
import java.util.ArrayList;
import java.util.List;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.api.recipe.machines.ScrapboxRecipe;
import techreborn.compat.crafttweaker.CTGeneric.Remove;
@ -58,8 +53,8 @@ public class CTScrapbox {
}
@ZenMethod
public static void removeAllRecipes() {
CraftTweakerAPI.apply(new RemoveAll(getMachineName()));
public static void removeAll() {
CraftTweakerAPI.apply(new RemoveAll());
}
public static String getMachineName() {
@ -67,25 +62,15 @@ public class CTScrapbox {
}
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);
}
RecipeHandler.recipeList.removeAll(RecipeHandler.getRecipeClassFromName(Reference.scrapboxRecipe));
}
@Override
public String describe() {
return "Removing all recipies for " + name;
return "Removing all Scrapbox recipies";
}
}
}