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:
parent
634c222921
commit
4126c64792
2 changed files with 51 additions and 17 deletions
BIN
libs/forestry_1.7.10-3.6.1.18-dev.jar
Normal file
BIN
libs/forestry_1.7.10-3.6.1.18-dev.jar
Normal file
Binary file not shown.
|
@ -4,36 +4,69 @@ import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.item.WeightedItemStack;
|
||||||
|
import minetweaker.mc1710.item.MCItemStack;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.utils.BaseListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.utils.BaseListRemoval;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
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;
|
import forestry.factory.gadgets.MachineCentrifuge.RecipeManager;
|
||||||
|
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Centrifuge")
|
@ZenClass("mods.forestry.Centrifuge")
|
||||||
public class 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
|
@ZenMethod
|
||||||
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
|
public static void addRecipe(WeightedItemStack[] output, int timePerItem, IItemStack ingredient) {
|
||||||
HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
|
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||||
// products.put(toStack(output[0]), chances[0]);
|
for (WeightedItemStack product : output) {
|
||||||
int i = 0;
|
products.put(toStack(product.getStack()), product.getChance());
|
||||||
for (IItemStack product : output) {
|
|
||||||
products.put(toStack(product), chances[i]);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
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
|
@ZenMethod
|
||||||
public static void removeRecipe(IItemStack itemInput) {
|
@Deprecated
|
||||||
MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(itemInput)));
|
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 {
|
private static class Add extends BaseListAddition {
|
||||||
|
|
||||||
public Add(Recipe recipe) {
|
public Add(ICentrifugeRecipe recipe) {
|
||||||
super("Forestry Centrifuge", RecipeManager.recipes, recipe);
|
super("Forestry Centrifuge", RecipeManager.recipes, recipe);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo() {
|
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 {
|
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);
|
super("Forestry Centrifuge", RecipeManager.recipes, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
for (Recipe r : RecipeManager.recipes) {
|
for (ICentrifugeRecipe r : RecipeManager.recipes) {
|
||||||
if (r.matches(stack)) {
|
if (r.getInput() == stack) {
|
||||||
recipes.add(r);
|
recipes.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +105,7 @@ public class Centrifuge {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo() {
|
public String getRecipeInfo() {
|
||||||
return " Input:" + stack.getDisplayName();
|
return " " + new MCItemStack(stack) + " (Input)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue