mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
- Revised base classes for IUndoableAction - Reordered lots of code, so stuck actions should be less frequent - Added wildcard support to many "remove" methods - Started working on exist & duplicate checks
83 lines
2.8 KiB
Java
83 lines
2.8 KiB
Java
package modtweaker2.mods.forestry.handlers;
|
|
|
|
import static modtweaker2.helpers.InputHelper.getFluid;
|
|
import static modtweaker2.helpers.InputHelper.toFluid;
|
|
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
|
import static modtweaker2.helpers.StackHelper.matches;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
import minetweaker.MineTweakerAPI;
|
|
import minetweaker.api.liquid.ILiquidStack;
|
|
import modtweaker2.helpers.InputHelper;
|
|
import modtweaker2.helpers.LogHelper;
|
|
import modtweaker2.utils.BaseListAddition;
|
|
import modtweaker2.utils.BaseListRemoval;
|
|
import stanhebben.zenscript.annotations.ZenClass;
|
|
import stanhebben.zenscript.annotations.ZenMethod;
|
|
import forestry.factory.gadgets.MachineStill;
|
|
import forestry.factory.gadgets.MachineStill.Recipe;
|
|
import forestry.factory.gadgets.MachineStill.RecipeManager;
|
|
|
|
@ZenClass("mods.forestry.Still")
|
|
public class Still {
|
|
|
|
public static final String name = "Forestry Still";
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ZenMethod
|
|
public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) {
|
|
output.amount(output.getAmount() / 100);
|
|
input.amount(input.getAmount() / 100);
|
|
|
|
MineTweakerAPI.apply(new Add(new Recipe(timePerUnit, toFluid(input), toFluid(output))));
|
|
MachineStill.RecipeManager.recipeFluidInputs.add(getFluid(input));
|
|
MachineStill.RecipeManager.recipeFluidOutputs.add(getFluid(output));
|
|
}
|
|
|
|
private static class Add extends BaseListAddition<Recipe> {
|
|
public Add(Recipe recipe) {
|
|
super("Forestry Still", MachineStill.RecipeManager.recipes);
|
|
recipes.add(recipe);
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeInfo(Recipe recipe) {
|
|
return InputHelper.getStackDescription(recipe.output);
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ZenMethod
|
|
public static void removeRecipe(ILiquidStack output, ILiquidStack input) {
|
|
List<Recipe> recipes = new LinkedList<Recipe>();
|
|
|
|
for (Recipe r : RecipeManager.recipes) {
|
|
if (r != null && r.output != null && matches(output, toILiquidStack(r.output))) {
|
|
recipes.add(r);
|
|
}
|
|
}
|
|
|
|
if(!recipes.isEmpty()) {
|
|
MineTweakerAPI.apply(new Remove(recipes));
|
|
} else {
|
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, output.toString()));
|
|
}
|
|
}
|
|
|
|
private static class Remove extends BaseListRemoval<Recipe> {
|
|
public Remove(List<Recipe> recipes) {
|
|
super(Still.name, RecipeManager.recipes, recipes);
|
|
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeInfo(Recipe recipe) {
|
|
return InputHelper.getStackDescription(recipe.output);
|
|
}
|
|
}
|
|
}
|