fix: modified mods.forestry.Centrifuge for newest Version of Forestry API

new file:   libs/forestry_1.7.10-3.6.1.18-dev.jar
modified:   src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java
This commit is contained in:
Tobias Wohlfarth 2015-06-29 17:05:15 +02:00
parent 634c222921
commit 4126c64792
2 changed files with 51 additions and 17 deletions

Binary file not shown.

View file

@ -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<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++;
public static void addRecipe(WeightedItemStack[] output, int timePerItem, IItemStack ingredient) {
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
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<ItemStack, Float> products = new HashMap<ItemStack, Float>();
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)";
}
}
}