improved: Forestry Squeezer - bring back the addRecipe variant without itemOutput
This commit is contained in:
parent
9a431f4d40
commit
27cc26335c
|
@ -1,6 +1,5 @@
|
|||
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.InputHelper.toIItemStack;
|
||||
|
@ -33,6 +32,19 @@ public class Squeezer {
|
|||
public static final String name = "Forestry Squeezer";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Adds a recipe without additional item output
|
||||
*
|
||||
* @param fluidOutput recipe fluid amount
|
||||
* @param ingredients recipe ingredients
|
||||
* @param timePerItem time per crafting operation
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) {
|
||||
MineTweakerAPI.apply(new Add( new Recipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0) ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipe with additional item output
|
||||
*
|
||||
|
@ -43,20 +55,13 @@ public class Squeezer {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, int timePerItem) {
|
||||
MineTweakerAPI.apply(new Add( new Recipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), (int) itemOutput.getPercent()) ));
|
||||
//TODO: this should definitiv solved somehow better
|
||||
MachineSqueezer.RecipeManager.recipeFluids.add(getFluid(fluidOutput));
|
||||
MachineSqueezer.RecipeManager.recipeInputs.addAll(Arrays.asList(toStacks(ingredients)));
|
||||
MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), (int) itemOutput.getPercent())));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@Deprecated
|
||||
public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance)));
|
||||
|
||||
//TODO: this should definitiv solved somehow better
|
||||
MachineSqueezer.RecipeManager.recipeFluids.add(getFluid(liquid));
|
||||
MachineSqueezer.RecipeManager.recipeInputs.addAll(Arrays.asList(toStacks(resources)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<Recipe> {
|
||||
|
@ -65,6 +70,22 @@ public class Squeezer {
|
|||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.addAll(Arrays.asList(recipe.resources));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.removeAll(Arrays.asList(recipe.resources));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.liquid);
|
||||
|
@ -111,7 +132,6 @@ public class Squeezer {
|
|||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, liquid.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<Recipe> {
|
||||
|
@ -122,8 +142,18 @@ public class Squeezer {
|
|||
|
||||
@Override
|
||||
public void apply() {
|
||||
|
||||
super.apply();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.removeAll(Arrays.asList(recipe.resources));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.addAll(Arrays.asList(recipe.resources));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue