diff --git a/libs/forestry_1.7.10-3.6.1.18-dev.jar b/libs/forestry_1.7.10-3.6.1.18-dev.jar new file mode 100644 index 0000000..b3ef155 Binary files /dev/null and b/libs/forestry_1.7.10-3.6.1.18-dev.jar differ diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java index d28c222..8ab4e37 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java @@ -4,36 +4,69 @@ import static modtweaker2.helpers.InputHelper.toStack; import java.util.HashMap; import java.util.List; +import java.util.Map; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; +import minetweaker.mc1710.item.MCItemStack; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import forestry.factory.gadgets.MachineCentrifuge.Recipe; +import forestry.api.recipes.ICentrifugeRecipe; +import forestry.factory.gadgets.MachineCentrifuge.CentrifugeRecipe; import forestry.factory.gadgets.MachineCentrifuge.RecipeManager; @ZenClass("mods.forestry.Centrifuge") public class Centrifuge { + /** + * Adds a recipe for the Centrifuge + * + * @param output List of items to produce with associated chance + * @param timePerItem time per item to process + * @param ingredient item input + */ @ZenMethod - public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) { - HashMap products = new HashMap(); - // products.put(toStack(output[0]), chances[0]); - int i = 0; - for (IItemStack product : output) { - products.put(toStack(product), chances[i]); - i++; + public static void addRecipe(WeightedItemStack[] output, int timePerItem, IItemStack ingredient) { + Map products = new HashMap(); + for (WeightedItemStack product : output) { + products.put(toStack(product.getStack()), product.getChance()); } - MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStack(itemInput), products))); + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products))); } + /** + * Adds a recipe for the Centrifuge + * + * @param output List of items to produce + * @param output List of percentages to produce a item (same order as in item list) + * @param timePerItem time per item to process + * @param itemInput item input + */ @ZenMethod - public static void removeRecipe(IItemStack itemInput) { - MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(itemInput))); + @Deprecated + public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) { + Map products = new HashMap(); + int i = 0; + for (IItemStack product : output) { + products.put(toStack(product), ((float) chances[i] / 100)); + i++; + } + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products))); + } + + /** + * Removes a recipe for the Centrifuge + * + * @param ingredient item input + */ + @ZenMethod + public static void removeRecipe(IItemStack ingredient) { + MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(ingredient))); } /* @@ -41,12 +74,12 @@ public class Centrifuge { */ private static class Add extends BaseListAddition { - public Add(Recipe recipe) { + public Add(ICentrifugeRecipe recipe) { super("Forestry Centrifuge", RecipeManager.recipes, recipe); } @Override public String getRecipeInfo() { - return " Input:" + ((Recipe) recipe).resource.getDisplayName(); + return " " + new MCItemStack(((ICentrifugeRecipe) recipe).getInput()) + " (Input)"; } } @@ -55,14 +88,15 @@ public class Centrifuge { */ private static class Remove extends BaseListRemoval { - public Remove(List list, ItemStack input) { + public Remove(@SuppressWarnings("rawtypes") List list, ItemStack input) { super("Forestry Centrifuge", RecipeManager.recipes, input); } + @SuppressWarnings("unchecked") @Override public void apply() { - for (Recipe r : RecipeManager.recipes) { - if (r.matches(stack)) { + for (ICentrifugeRecipe r : RecipeManager.recipes) { + if (r.getInput() == stack) { recipes.add(r); } } @@ -71,7 +105,7 @@ public class Centrifuge { @Override public String getRecipeInfo() { - return " Input:" + stack.getDisplayName(); + return " " + new MCItemStack(stack) + " (Input)"; } } }