diff --git a/libs/forestry_1.7.10-3.5.0.471-unstable-dev.jar b/libs/forestry_1.7.10-3.6.1.18-dev.jar similarity index 54% rename from libs/forestry_1.7.10-3.5.0.471-unstable-dev.jar rename to libs/forestry_1.7.10-3.6.1.18-dev.jar index f1488d9..b3ef155 100644 Binary files a/libs/forestry_1.7.10-3.5.0.471-unstable-dev.jar and b/libs/forestry_1.7.10-3.6.1.18-dev.jar differ diff --git a/src/main/java/modtweaker2/helpers/StackHelper.java b/src/main/java/modtweaker2/helpers/StackHelper.java index c558a91..2702254 100644 --- a/src/main/java/modtweaker2/helpers/StackHelper.java +++ b/src/main/java/modtweaker2/helpers/StackHelper.java @@ -70,7 +70,7 @@ public class StackHelper { } // Check for Botania special flowers - if(ingredient.getItems() != null && Botania.isSubtile(toStack(itemStack))) { + if(ingredient.getItems() != null && TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(toStack(itemStack))) { for(IItemStack item : ingredient.getItems()) { if(areEqual(toStack(item), toStack(itemStack))) { return true; diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java index fef05f4..dbf3d7e 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java @@ -7,17 +7,20 @@ import static modtweaker2.helpers.StackHelper.matches; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; import modtweaker2.helpers.LogHelper; 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; @@ -28,39 +31,68 @@ 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))); } - private static class Add extends BaseListAddition { + /** + * 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 + @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))); + } - public Add(Recipe recipe) { + private static class Add extends BaseListAddition { + + public Add(ICentrifugeRecipe recipe) { super(Centrifuge.name, RecipeManager.recipes); recipes.add(recipe); } @Override - protected String getRecipeInfo(Recipe recipe) { - return LogHelper.getStackDescription(recipe.resource); + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod + /** + * Removes a recipe for the Centrifuge + * + * @param ingredient item input + */ + @ZenMethod public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); + List recipes = new LinkedList(); - for(Recipe recipe : RecipeManager.recipes) { - if(recipe != null && matches(input, toIItemStack(recipe.resource))) { + for(ICentrifugeRecipe recipe : RecipeManager.recipes) { + if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) { recipes.add(recipe); } } @@ -72,15 +104,15 @@ public class Centrifuge { } } - private static class Remove extends BaseListRemoval { + private static class Remove extends BaseListRemoval { - public Remove(List recipes) { + public Remove(List recipes) { super(Centrifuge.name, RecipeManager.recipes, recipes); } @Override - protected String getRecipeInfo(Recipe recipe) { - return LogHelper.getStackDescription(recipe.resource); + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); } } }