Files
ModTweaker/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java
T
jaredlll08 ec562b62ea This closes #17 and closes #58, I tested and it worked using the script given
Also changes like all packages
inb4 "jared changes a package name in ModTweaker2 breaking compatability
with everything" drama tweet.
2015-02-20 23:57:32 +02:00

79 lines
2.1 KiB
Java

package modtweaker2.mods.forestry.handlers;
import java.util.HashMap;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineCentrifuge.Recipe;
import forestry.factory.gadgets.MachineCentrifuge.RecipeManager;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
@ZenClass("mods.forestry.Centrifuge")
public class Centrifuge {
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
// products.put(toStack(output[0]), chances[0]);
int i = 0;
for (IItemStack product : output) {
products.put(toStack(product), chances[i]);
i++;
}
MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStack(itemInput), products)));
}
@ZenMethod
public static void removeRecipe(IItemStack itemInput) {
MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(itemInput)));
}
/*
Implements the actions to add the recipe
*/
private static class Add extends BaseListAddition {
public Add(Recipe recipe) {
super("Forestry Centrifuge", RecipeManager.recipes, recipe);
}
@Override
public String getRecipeInfo() {
return " Input:" + ((Recipe) recipe).resource.getDisplayName();
}
}
/*
Implements the actions to remove the recipe
*/
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack input) {
super("Forestry Centrifuge", RecipeManager.recipes, input);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.matches(stack)) {
recipe = r;
RecipeManager.recipes.remove(r);
break;
}
}
}
@Override
public String getRecipeInfo() {
return " Input:" + stack.getDisplayName();
}
}
}