Fix up Integration for Forestry 4.1.0 using only the API
This commit is contained in:
parent
4682dba3e6
commit
28175a9e95
|
@ -45,7 +45,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:dev"
|
||||
compile "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:api"
|
||||
}
|
||||
|
||||
processResources
|
||||
|
|
|
@ -3,4 +3,4 @@ forge.version=10.13.4.1448-1.7.10
|
|||
|
||||
mod.version=0.9.4
|
||||
|
||||
forestry.version=4.0.8.36
|
||||
forestry.version=4.1.0.43
|
||||
|
|
|
@ -5,5 +5,5 @@ public class ModProps {
|
|||
public static final String NAME = "Mod Tweaker 2", name = NAME;
|
||||
public static final String MODID = "modtweaker2", modid = MODID;
|
||||
public static final String VERSION = "0.9.4", version = VERSION;
|
||||
public static final String DEPENDENCIES = "required-after:MineTweaker3;after:Forestry@[4.0.3,);", dependencies = DEPENDENCIES;
|
||||
public static final String DEPENDENCIES = "required-after:MineTweaker3;after:Forestry@[4.1.0,);", dependencies = DEPENDENCIES;
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package modtweaker2.mods.forestry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import modtweaker2.helpers.ReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
|
||||
public class ForestryHelper {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addCarpenterRecipeBox(ItemStack box) {
|
||||
List<ItemStack> recipeBoxes = (ArrayList<ItemStack>) ReflectionHelper.getStaticObject(TileCarpenter.RecipeManager.class, "boxes");
|
||||
|
||||
if(recipeBoxes != null) {
|
||||
recipeBoxes.add(box);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addCarpenterRecipeFluids(Fluid newFluid) {
|
||||
Set<Fluid> recipeFluids = (HashSet<Fluid>) ReflectionHelper.getStaticObject(TileCarpenter.RecipeManager.class, "recipeFluids");
|
||||
|
||||
if(recipeFluids != null) {
|
||||
recipeFluids.add(newFluid);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package modtweaker2.mods.forestry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.recipes.ICraftingProvider;
|
||||
import forestry.api.recipes.IForestryRecipe;
|
||||
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
|
||||
public abstract class ForestryListAddition<T extends IForestryRecipe, C extends ICraftingProvider<T>> extends BaseListAddition<T> {
|
||||
private final C craftingProvider;
|
||||
|
||||
protected ForestryListAddition(String name, C craftingProvider) {
|
||||
super(name, new ArrayList<T>(craftingProvider.recipes()));
|
||||
this.craftingProvider = craftingProvider;
|
||||
}
|
||||
|
||||
protected ForestryListAddition(String name, C craftingProvider, List<T> recipes) {
|
||||
super(name, new ArrayList<T>(craftingProvider.recipes()), recipes);
|
||||
this.craftingProvider = craftingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract String getRecipeInfo(T recipe);
|
||||
|
||||
@Override
|
||||
public final void apply() {
|
||||
for (T recipe : recipes) {
|
||||
if (recipe != null) {
|
||||
if (craftingProvider.addRecipe(recipe)) {
|
||||
successful.add(recipe);
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void undo() {
|
||||
for (T recipe : successful) {
|
||||
if (recipe != null) {
|
||||
if (!craftingProvider.removeRecipe(recipe)) {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package modtweaker2.mods.forestry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.recipes.ICraftingProvider;
|
||||
import forestry.api.recipes.IForestryRecipe;
|
||||
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
|
||||
public abstract class ForestryListRemoval<T extends IForestryRecipe, C extends ICraftingProvider<T>> extends BaseListRemoval<T> {
|
||||
private final C craftingProvider;
|
||||
|
||||
public ForestryListRemoval(String name, C craftingProvider, List<T> recipes) {
|
||||
super(name, new ArrayList<T>(craftingProvider.recipes()), recipes);
|
||||
this.craftingProvider = craftingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract String getRecipeInfo(T recipe);
|
||||
|
||||
@Override
|
||||
public final void apply() {
|
||||
for (T recipe : recipes) {
|
||||
if (recipe != null) {
|
||||
if (craftingProvider.removeRecipe(recipe)) {
|
||||
successful.add(recipe);
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void undo() {
|
||||
for (T recipe : successful) {
|
||||
if (recipe != null) {
|
||||
if (!craftingProvider.addRecipe(recipe)) {
|
||||
LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error restoring %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import static modtweaker2.helpers.InputHelper.toStacks;
|
|||
import static modtweaker2.helpers.InputHelper.toShapedObjects;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,18 +16,20 @@ import minetweaker.api.item.IIngredient;
|
|||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.forestry.ForestryHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.init.Blocks;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.CarpenterRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import modtweaker2.mods.forestry.recipes.DescriptiveRecipe;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileCarpenter.Recipe;
|
||||
import forestry.factory.tiles.TileCarpenter.RecipeManager;
|
||||
|
||||
import forestry.api.recipes.ICarpenterManager;
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
@ZenClass("mods.forestry.Carpenter")
|
||||
public class Carpenter {
|
||||
|
@ -47,7 +48,8 @@ public class Carpenter {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(packagingTime, null, toStack(box), ShapedRecipeCustom.createShapedRecipe(toStack(output), toShapedObjects(ingredients)) )));
|
||||
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false);
|
||||
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,44 +63,27 @@ public class Carpenter {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(packagingTime, toFluid(fluidInput), toStack(box), ShapedRecipeCustom.createShapedRecipe(toStack(output), toShapedObjects(ingredients)) )));
|
||||
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false);
|
||||
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) {
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (ItemStack stack : toStacks(ingredients)) {
|
||||
if (stack != null) {
|
||||
stacks.add(stack);
|
||||
}
|
||||
if (stack == null) {
|
||||
stacks.add(new ItemStack(Blocks.air));
|
||||
}
|
||||
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new Recipe(packagingTime, toFluid(liquid), toStack(ingredient), new ShapedRecipeCustom(3, 3, toStacks(ingredients), toStack(product)))));
|
||||
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toStacks(ingredients), toStack(product), false);
|
||||
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(liquid), toStack(ingredient), craftRecipe)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<Recipe> {
|
||||
private static class Add extends ForestryListAddition<ICarpenterRecipe, ICarpenterManager> {
|
||||
|
||||
public Add(Recipe recipe) {
|
||||
super(Carpenter.name, TileCarpenter.RecipeManager.recipes);
|
||||
public Add(ICarpenterRecipe recipe) {
|
||||
super(Carpenter.name, RecipeManagers.carpenterManager);
|
||||
recipes.add(recipe);
|
||||
|
||||
// The Carpenter has a list of valid Fluids, access them via
|
||||
// Reflection because of private
|
||||
if (recipe.getLiquid() != null)
|
||||
ForestryHelper.addCarpenterRecipeFluids(recipe.getLiquid().getFluid());
|
||||
|
||||
if(!RecipeManager.isBox(recipe.getBox())){
|
||||
ForestryHelper.addCarpenterRecipeBox(recipe.getBox());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingResult());
|
||||
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,15 +97,18 @@ public class Carpenter {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) {
|
||||
List<Recipe> recipes = new LinkedList<Recipe>();
|
||||
List<ICarpenterRecipe> recipes = new LinkedList<ICarpenterRecipe>();
|
||||
|
||||
for(Recipe recipe : RecipeManager.recipes) {
|
||||
if( recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult())) ) {
|
||||
if (liquid != null) {
|
||||
if (matches(liquid, toILiquidStack(recipe.getLiquid())))
|
||||
for(ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) {
|
||||
if (recipe != null) {
|
||||
ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput();
|
||||
if (recipeResult != null && matches(output, toIItemStack(recipeResult))) {
|
||||
if (liquid != null) {
|
||||
if (matches(liquid, toILiquidStack(recipe.getFluidResource())))
|
||||
recipes.add(recipe);
|
||||
} else {
|
||||
recipes.add(recipe);
|
||||
} else {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,15 +120,15 @@ public class Carpenter {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<Recipe> {
|
||||
private static class Remove extends ForestryListRemoval<ICarpenterRecipe, ICarpenterManager> {
|
||||
|
||||
public Remove(List<Recipe> recipes) {
|
||||
super(Carpenter.name, RecipeManager.recipes, recipes);
|
||||
public Remove(List<ICarpenterRecipe> recipes) {
|
||||
super(Carpenter.name, RecipeManagers.carpenterManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingResult());
|
||||
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,16 @@ 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 modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.CentrifugeRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import forestry.api.recipes.ICentrifugeManager;
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.factory.tiles.TileCentrifuge.CentrifugeRecipe;
|
||||
import forestry.factory.tiles.TileCentrifuge.RecipeManager;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
|
||||
@ZenClass("mods.forestry.Centrifuge")
|
||||
|
@ -59,9 +61,9 @@ public class Centrifuge {
|
|||
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<ICentrifugeRecipe> {
|
||||
private static class Add extends ForestryListAddition<ICentrifugeRecipe, ICentrifugeManager> {
|
||||
public Add(ICentrifugeRecipe recipe) {
|
||||
super(Centrifuge.name, RecipeManager.recipes);
|
||||
super(Centrifuge.name, RecipeManagers.centrifugeManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,7 @@ public class Centrifuge {
|
|||
public static void removeRecipe(IIngredient input) {
|
||||
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
|
||||
|
||||
for(ICentrifugeRecipe recipe : RecipeManager.recipes) {
|
||||
for(ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) {
|
||||
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
@ -95,10 +97,10 @@ public class Centrifuge {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<ICentrifugeRecipe> {
|
||||
private static class Remove extends ForestryListRemoval<ICentrifugeRecipe, ICentrifugeManager> {
|
||||
|
||||
public Remove(List<ICentrifugeRecipe> recipes) {
|
||||
super(Centrifuge.name, RecipeManager.recipes, recipes);
|
||||
super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package modtweaker2.mods.forestry.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.getFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||
|
@ -7,7 +8,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
|
|||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -18,18 +18,20 @@ import minetweaker.api.item.IIngredient;
|
|||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.FermenterRecipe;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.factory.tiles.TileFermenter.Recipe;
|
||||
import forestry.factory.tiles.TileFermenter.RecipeManager;
|
||||
import forestry.api.recipes.IFermenterManager;
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
@ZenClass("mods.forestry.Fermenter")
|
||||
public class Fermenter {
|
||||
|
@ -51,87 +53,41 @@ public class Fermenter {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), fermentationValue, fluidOutputModifier, toFluid(fluidOutput), toFluid(fluidInput))));
|
||||
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), fermentationValue, fluidOutputModifier, toFluid(fluidOutput), toFluid(fluidInput))));
|
||||
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<Recipe> {
|
||||
public Add(Recipe recipe) {
|
||||
super(Fermenter.name, RecipeManager.recipes);
|
||||
|
||||
private static class Add extends ForestryListAddition<IFermenterRecipe, IFermenterManager> {
|
||||
public Add(IFermenterRecipe recipe) {
|
||||
super(Fermenter.name, RecipeManagers.fermenterManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
// add liquids to valid input / output
|
||||
for(Recipe recipe : successful) {
|
||||
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
|
||||
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
|
||||
}
|
||||
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
|
||||
// Tidy up valid inputs
|
||||
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
|
||||
boolean found = false;
|
||||
Fluid fluid = iter.next();
|
||||
for(Recipe recipe : list) {
|
||||
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up valid outputs
|
||||
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
|
||||
boolean found = false;
|
||||
Fluid fluid = iter.next();
|
||||
for(Recipe recipe : list) {
|
||||
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.output);
|
||||
public String getRecipeInfo(IFermenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<Recipe> recipes = new LinkedList<Recipe>();
|
||||
List<IFermenterRecipe> recipes = new LinkedList<IFermenterRecipe>();
|
||||
|
||||
for(Recipe recipe : RecipeManager.recipes) {
|
||||
for(IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
|
||||
// check for input items
|
||||
if(recipe != null && recipe.resource != null && matches(input, toIItemStack(recipe.resource))) {
|
||||
if(recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
// check for input liquids
|
||||
if(recipe != null && recipe.resource != null && matches(input, toILiquidStack(recipe.liquid))) {
|
||||
if(recipe != null && recipe.getResource() != null && matches(input, toILiquidStack(recipe.getFluidResource()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
@ -142,61 +98,16 @@ public class Fermenter {
|
|||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<Recipe> {
|
||||
|
||||
public Remove(List<Recipe> recipes) {
|
||||
super(Fermenter.name, RecipeManager.recipes, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
|
||||
// Tidy up valid inputs
|
||||
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
|
||||
boolean found = false;
|
||||
Fluid fluid = iter.next();
|
||||
for(Recipe recipe : list) {
|
||||
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up valid outputs
|
||||
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
|
||||
boolean found = false;
|
||||
Fluid fluid = iter.next();
|
||||
for(Recipe recipe : list) {
|
||||
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
private static class Remove extends ForestryListRemoval<IFermenterRecipe, IFermenterManager> {
|
||||
|
||||
public Remove(List<IFermenterRecipe> recipes) {
|
||||
super(Fermenter.name, RecipeManagers.fermenterManager, recipes);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
// add liquids to valid input / output
|
||||
for(Recipe recipe : successful) {
|
||||
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
|
||||
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
|
||||
}
|
||||
super.undo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.output);
|
||||
protected String getRecipeInfo(IFermenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,17 +15,18 @@ import minetweaker.MineTweakerAPI;
|
|||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.MoistenerRecipe;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.factory.tiles.TileMoistener;
|
||||
import forestry.factory.tiles.TileMoistener.Recipe;
|
||||
import forestry.factory.tiles.TileMoistener.RecipeManager;
|
||||
import forestry.api.recipes.IMoistenerManager;
|
||||
import forestry.api.recipes.IMoistenerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
@ZenClass("mods.forestry.Moistener")
|
||||
public class Moistener {
|
||||
|
@ -44,24 +45,24 @@ public class Moistener {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), toStack(output), timePerItem)));
|
||||
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
|
||||
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), toStack(product), timePerItem)));
|
||||
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<Recipe> {
|
||||
public Add(Recipe recipe) {
|
||||
super(Moistener.name, TileMoistener.RecipeManager.recipes);
|
||||
private static class Add extends ForestryListAddition<IMoistenerRecipe, IMoistenerManager> {
|
||||
public Add(IMoistenerRecipe recipe) {
|
||||
super(Moistener.name, RecipeManagers.moistenerManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.product);
|
||||
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getProduct());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,9 +70,9 @@ public class Moistener {
|
|||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<Recipe> recipes = new LinkedList<Recipe>();
|
||||
for (Recipe recipe : RecipeManager.recipes) {
|
||||
if (recipe != null && recipe.product != null && matches(output, toIItemStack(recipe.product))) {
|
||||
List<IMoistenerRecipe> recipes = new LinkedList<IMoistenerRecipe>();
|
||||
for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) {
|
||||
if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
@ -83,14 +84,14 @@ public class Moistener {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<Recipe> {
|
||||
public Remove(List<Recipe> recipes) {
|
||||
super(Moistener.name, RecipeManager.recipes, recipes);
|
||||
private static class Remove extends ForestryListRemoval<IMoistenerRecipe, IMoistenerManager> {
|
||||
public Remove(List<IMoistenerRecipe> recipes) {
|
||||
super(Moistener.name, RecipeManagers.moistenerManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.product);
|
||||
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getProduct());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,25 +7,25 @@ import static modtweaker2.helpers.InputHelper.toStack;
|
|||
import static modtweaker2.helpers.InputHelper.toStacks;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.recipes.ISqueezerManager;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.SqueezerRecipe;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.factory.tiles.TileSqueezer;
|
||||
import forestry.factory.tiles.TileSqueezer.RecipeManager;
|
||||
import forestry.factory.recipes.ISqueezerRecipe;
|
||||
import forestry.factory.recipes.SqueezerRecipe;
|
||||
|
||||
@ZenClass("mods.forestry.Squeezer")
|
||||
public class Squeezer {
|
||||
|
@ -65,28 +65,12 @@ public class Squeezer {
|
|||
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<ISqueezerRecipe> {
|
||||
private static class Add extends ForestryListAddition<ISqueezerRecipe, ISqueezerManager> {
|
||||
public Add(ISqueezerRecipe recipe) {
|
||||
super(Squeezer.name, TileSqueezer.RecipeManager.recipes);
|
||||
super(Squeezer.name, RecipeManagers.squeezerManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
for (ISqueezerRecipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.addAll(Arrays.asList(recipe.getResources()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (ISqueezerRecipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.removeAll(Arrays.asList(recipe.getResources()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||
|
@ -105,7 +89,7 @@ public class Squeezer {
|
|||
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {
|
||||
List<ISqueezerRecipe> recipes = new LinkedList<ISqueezerRecipe>();
|
||||
|
||||
for (ISqueezerRecipe r : RecipeManager.recipes) {
|
||||
for (ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) {
|
||||
if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) {
|
||||
// optional check for ingredients
|
||||
if (ingredients != null) {
|
||||
|
@ -135,25 +119,9 @@ public class Squeezer {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<ISqueezerRecipe> {
|
||||
private static class Remove extends ForestryListRemoval<ISqueezerRecipe, ISqueezerManager> {
|
||||
public Remove(List<ISqueezerRecipe> recipes) {
|
||||
super(Squeezer.name, TileSqueezer.RecipeManager.recipes, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
for (ISqueezerRecipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.removeAll(Arrays.asList(recipe.getResources()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (ISqueezerRecipe recipe : recipes) {
|
||||
RecipeManager.recipeInputs.addAll(Arrays.asList(recipe.getResources()));
|
||||
}
|
||||
super(Squeezer.name, RecipeManagers.squeezerManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,14 +11,16 @@ import minetweaker.MineTweakerAPI;
|
|||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import modtweaker2.mods.forestry.recipes.StillRecipe;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.factory.tiles.TileStill;
|
||||
import forestry.factory.tiles.TileStill.Recipe;
|
||||
import forestry.factory.tiles.TileStill.RecipeManager;
|
||||
|
||||
import forestry.api.recipes.IStillManager;
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
|
||||
@ZenClass("mods.forestry.Still")
|
||||
public class Still {
|
||||
|
@ -39,7 +41,7 @@ public class Still {
|
|||
fluidOutput.amount(fluidOutput.getAmount() / 100);
|
||||
fluidInput.amount(fluidInput.getAmount() / 100);
|
||||
|
||||
MineTweakerAPI.apply(new Add(new Recipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput))));
|
||||
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput))));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -48,34 +50,18 @@ public class Still {
|
|||
output.amount(output.getAmount() / 100);
|
||||
input.amount(input.getAmount() / 100);
|
||||
|
||||
MineTweakerAPI.apply(new Add(new Recipe(timePerUnit, toFluid(input), toFluid(output))));
|
||||
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<Recipe> {
|
||||
public Add(Recipe recipe) {
|
||||
super("Forestry Still", TileStill.RecipeManager.recipes);
|
||||
private static class Add extends ForestryListAddition<IStillRecipe, IStillManager> {
|
||||
public Add(IStillRecipe recipe) {
|
||||
super("Forestry Still", RecipeManagers.stillManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeFluidInputs.add(recipe.input.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeFluidInputs.remove(recipe.input.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.output);
|
||||
public String getRecipeInfo(IStillRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,12 +75,12 @@ public class Still {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) {
|
||||
List<Recipe> recipes = new LinkedList<Recipe>();
|
||||
List<IStillRecipe> recipes = new LinkedList<IStillRecipe>();
|
||||
|
||||
for (Recipe r : RecipeManager.recipes) {
|
||||
if (r != null && r.output != null && matches(output, toILiquidStack(r.output))) {
|
||||
for (IStillRecipe r : RecipeManagers.stillManager.recipes()) {
|
||||
if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) {
|
||||
if (input != null) {
|
||||
if (matches(input, toILiquidStack(r.input))) {
|
||||
if (matches(input, toILiquidStack(r.getInput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
@ -110,30 +96,14 @@ public class Still {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<Recipe> {
|
||||
public Remove(List<Recipe> recipes) {
|
||||
super(Still.name, RecipeManager.recipes, recipes);
|
||||
private static class Remove extends ForestryListRemoval<IStillRecipe, IStillManager> {
|
||||
public Remove(List<IStillRecipe> recipes) {
|
||||
super(Still.name, RecipeManagers.stillManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Recipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeFluidInputs.remove(recipe.input.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
for (Recipe recipe : recipes) {
|
||||
RecipeManager.recipeFluidInputs.add(recipe.input.getFluid());
|
||||
}
|
||||
public String getRecipeInfo(IStillRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,23 @@ import minetweaker.api.item.IIngredient;
|
|||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import modtweaker2.mods.forestry.recipes.DescriptiveRecipe;
|
||||
import modtweaker2.mods.forestry.recipes.FabricatorRecipe;
|
||||
import modtweaker2.mods.forestry.recipes.FabricatorSmeltingRecipe;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.api.recipes.IFabricatorManager;
|
||||
import forestry.api.recipes.IFabricatorSmeltingManager;
|
||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
import forestry.factory.recipes.FabricatorRecipe;
|
||||
import forestry.factory.tiles.TileFabricator.RecipeManager;
|
||||
import forestry.factory.tiles.TileFabricator.Smelting;
|
||||
|
||||
@ZenClass("mods.forestry.ThermionicFabricator")
|
||||
public class ThermionicFabricator {
|
||||
|
@ -41,14 +47,14 @@ public class ThermionicFabricator {
|
|||
@ZenMethod
|
||||
public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) {
|
||||
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
|
||||
MineTweakerAPI.apply(new AddSmelting(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
|
||||
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
|
||||
MineTweakerAPI.apply(new AddSmelting(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -63,36 +69,38 @@ public class ThermionicFabricator {
|
|||
*/
|
||||
@ZenMethod
|
||||
public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan) {
|
||||
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), ShapedRecipeCustom.createShapedRecipe(toStack(output), toShapedObjects(ingredients)))));
|
||||
IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false);
|
||||
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output) {
|
||||
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), ShapedRecipeCustom.createShapedRecipe(toStack(output), toShapedObjects(ingredients)))));
|
||||
IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false);
|
||||
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe)));
|
||||
}
|
||||
|
||||
/*
|
||||
Implements the actions to add a recipe
|
||||
Since the machine has two crafting Steps, this is a constructors for both
|
||||
*/
|
||||
private static class AddSmelting extends BaseListAddition<Smelting> {
|
||||
private static class AddSmelting extends ForestryListAddition<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||
|
||||
public AddSmelting(Smelting recipe) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings);
|
||||
public AddSmelting(IFabricatorSmeltingRecipe recipe) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Smelting recipe) {
|
||||
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getResource());
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddCast extends BaseListAddition<IFabricatorRecipe> {
|
||||
private static class AddCast extends ForestryListAddition<IFabricatorRecipe, IFabricatorManager> {
|
||||
|
||||
public AddCast(IFabricatorRecipe recipe) {
|
||||
super(ThermionicFabricator.nameCasting, RecipeManager.recipes);
|
||||
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
|
@ -106,9 +114,9 @@ public class ThermionicFabricator {
|
|||
|
||||
@ZenMethod
|
||||
public static void removeSmelting(IIngredient itemInput) {
|
||||
List<Smelting> recipes = new LinkedList<Smelting>();
|
||||
List<IFabricatorSmeltingRecipe> recipes = new LinkedList<IFabricatorSmeltingRecipe>();
|
||||
|
||||
for (Smelting r : RecipeManager.smeltings) {
|
||||
for (IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) {
|
||||
if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
|
@ -125,7 +133,7 @@ public class ThermionicFabricator {
|
|||
public static void removeCast(IIngredient product) {
|
||||
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
||||
|
||||
for (IFabricatorRecipe r : RecipeManager.recipes) {
|
||||
for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) {
|
||||
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
|
@ -143,7 +151,7 @@ public class ThermionicFabricator {
|
|||
public static void removeCasts(IIngredient product) {
|
||||
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
||||
|
||||
for (IFabricatorRecipe r : RecipeManager.recipes) {
|
||||
for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) {
|
||||
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
|
@ -156,20 +164,20 @@ public class ThermionicFabricator {
|
|||
}
|
||||
}
|
||||
|
||||
private static class RemoveSmelting extends BaseListRemoval<Smelting> {
|
||||
public RemoveSmelting(List<Smelting> recipes) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings, recipes);
|
||||
private static class RemoveSmelting extends ForestryListRemoval<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||
public RemoveSmelting(List<IFabricatorSmeltingRecipe> recipes) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Smelting recipe) {
|
||||
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getResource());
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveCasts extends BaseListRemoval<IFabricatorRecipe> {
|
||||
private static class RemoveCasts extends ForestryListRemoval<IFabricatorRecipe, IFabricatorManager> {
|
||||
public RemoveCasts(List<IFabricatorRecipe> recipes) {
|
||||
super(ThermionicFabricator.nameCasting, RecipeManager.recipes, recipes);
|
||||
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
|
||||
public class CarpenterRecipe implements ICarpenterRecipe {
|
||||
|
||||
private final int packagingTime;
|
||||
@Nullable
|
||||
private final FluidStack liquid;
|
||||
@Nullable
|
||||
private final ItemStack box;
|
||||
private final IDescriptiveRecipe internal;
|
||||
|
||||
public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, IDescriptiveRecipe internal) {
|
||||
this.packagingTime = packagingTime;
|
||||
this.liquid = liquid;
|
||||
this.box = box;
|
||||
this.internal = internal;
|
||||
}
|
||||
|
||||
public int getPackagingTime() {
|
||||
return packagingTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack getFluidResource() {
|
||||
return liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDescriptiveRecipe getCraftingGridRecipe() {
|
||||
return internal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
|
||||
public class CentrifugeRecipe implements ICentrifugeRecipe {
|
||||
|
||||
private final int processingTime;
|
||||
private final ItemStack input;
|
||||
private final Map<ItemStack, Float> outputs;
|
||||
|
||||
public CentrifugeRecipe(int processingTime, ItemStack input, Map<ItemStack, Float> outputs) {
|
||||
this.processingTime = processingTime;
|
||||
this.input = input;
|
||||
this.outputs = outputs;
|
||||
|
||||
for (ItemStack item : outputs.keySet()) {
|
||||
if (item == null) {
|
||||
throw new IllegalArgumentException("Tried to register a null product of " + input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessingTime() {
|
||||
return processingTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getProducts(Random random) {
|
||||
List<ItemStack> products = new ArrayList<ItemStack>();
|
||||
|
||||
for (Map.Entry<ItemStack, Float> entry : this.outputs.entrySet()) {
|
||||
float probability = entry.getValue();
|
||||
|
||||
if (probability >= 1.0) {
|
||||
products.add(entry.getKey().copy());
|
||||
} else if (random.nextFloat() < probability) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ItemStack, Float> getAllProducts() {
|
||||
return ImmutableMap.copyOf(outputs);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
|
||||
public class DescriptiveRecipe implements IDescriptiveRecipe {
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final ShapedOreRecipe recipe;
|
||||
private final boolean preserveNBT;
|
||||
|
||||
public DescriptiveRecipe(int width, int height, Object[] ingredients, ItemStack output, boolean preserveNBT) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.recipe = new ShapedOreRecipe(output, ingredients);
|
||||
this.preserveNBT = preserveNBT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return recipe.getRecipeOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getIngredients() {
|
||||
return recipe.getInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preserveNBT() {
|
||||
return preserveNBT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inventoryCrafting, World world) {
|
||||
return recipe.matches(inventoryCrafting, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean matches(IInventory inventoryCrafting, World world) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
|
||||
return recipe.getCraftingResult(inventoryCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return width * height;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
|
||||
public class FabricatorRecipe implements IFabricatorRecipe {
|
||||
|
||||
private final ItemStack plan;
|
||||
private final FluidStack molten;
|
||||
private final IDescriptiveRecipe internal;
|
||||
|
||||
public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, boolean preservesNbt, Object[] ingredients) {
|
||||
this(plan, molten, new DescriptiveRecipe(3, 3, ingredients, result, preservesNbt));
|
||||
}
|
||||
|
||||
public FabricatorRecipe(ItemStack plan, FluidStack molten, IDescriptiveRecipe internal) {
|
||||
this.plan = plan;
|
||||
this.molten = molten;
|
||||
this.internal = internal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean matches(@Nullable ItemStack plan, ItemStack[][] resources) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getIngredients() {
|
||||
return internal.getIngredients();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return internal.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return internal.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preservesNbt() {
|
||||
return internal.preserveNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getPlan() {
|
||||
return plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getLiquid() {
|
||||
return molten;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemStack getCraftingResult(IInventory craftingInventory) {
|
||||
return getRecipeOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return internal.getRecipeOutput();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||
|
||||
public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe {
|
||||
private final ItemStack resource;
|
||||
private final FluidStack product;
|
||||
private final int meltingPoint;
|
||||
|
||||
public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) {
|
||||
if (resource == null) {
|
||||
throw new IllegalArgumentException("Resource cannot be null");
|
||||
}
|
||||
if (molten == null) {
|
||||
throw new IllegalArgumentException("Molten cannot be null");
|
||||
}
|
||||
|
||||
this.resource = resource;
|
||||
this.product = molten;
|
||||
this.meltingPoint = meltingPoint;
|
||||
}
|
||||
|
||||
public ItemStack getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public FluidStack getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public int getMeltingPoint() {
|
||||
return meltingPoint;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
|
||||
public class FermenterRecipe implements IFermenterRecipe {
|
||||
|
||||
private final ItemStack resource;
|
||||
private final int fermentationValue;
|
||||
private final float modifier;
|
||||
private final Fluid output;
|
||||
private final FluidStack fluidResource;
|
||||
|
||||
public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) {
|
||||
if (resource == null) {
|
||||
throw new NullPointerException("Fermenter Resource cannot be null!");
|
||||
}
|
||||
|
||||
if (output == null) {
|
||||
throw new NullPointerException("Fermenter Output cannot be null!");
|
||||
}
|
||||
|
||||
if (fluidResource == null) {
|
||||
throw new NullPointerException("Fermenter Liquid cannot be null!");
|
||||
}
|
||||
|
||||
// assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey"
|
||||
if (fluidResource.getFluid().getName().equals("fluid.honey")) {
|
||||
fluidResource = new FluidStack(FluidRegistry.getFluid("fluid.for.honey"), fluidResource.amount);
|
||||
}
|
||||
|
||||
this.resource = resource;
|
||||
this.fermentationValue = fermentationValue;
|
||||
this.modifier = modifier;
|
||||
this.output = output;
|
||||
this.fluidResource = fluidResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidResource() {
|
||||
return fluidResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFermentationValue() {
|
||||
return fermentationValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.recipes.IMoistenerRecipe;
|
||||
|
||||
public class MoistenerRecipe implements IMoistenerRecipe {
|
||||
|
||||
private final int timePerItem;
|
||||
private final ItemStack resource;
|
||||
private final ItemStack product;
|
||||
|
||||
public MoistenerRecipe(ItemStack resource, ItemStack product, int timePerItem) {
|
||||
this.timePerItem = timePerItem;
|
||||
this.resource = resource;
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public int getTimePerItem() {
|
||||
return timePerItem;
|
||||
}
|
||||
|
||||
public ItemStack getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public ItemStack getProduct() {
|
||||
return product;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
|
||||
public class SqueezerRecipe implements ISqueezerRecipe {
|
||||
|
||||
private final int processingTime;
|
||||
private final ItemStack[] resources;
|
||||
private final FluidStack fluidOutput;
|
||||
private final ItemStack remnants;
|
||||
private final float remnantsChance;
|
||||
|
||||
public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) {
|
||||
this.processingTime = processingTime;
|
||||
this.resources = resources;
|
||||
this.fluidOutput = fluidOutput;
|
||||
this.remnants = remnants;
|
||||
this.remnantsChance = remnantsChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRemnants() {
|
||||
return remnants;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRemnantsChance() {
|
||||
return remnantsChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidOutput() {
|
||||
return fluidOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessingTime() {
|
||||
return processingTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package modtweaker2.mods.forestry.recipes;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
|
||||
public class StillRecipe implements IStillRecipe {
|
||||
private final int timePerUnit;
|
||||
private final FluidStack input;
|
||||
private final FluidStack output;
|
||||
|
||||
public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) {
|
||||
this.timePerUnit = timePerUnit;
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("Still recipes need an input. Input was null.");
|
||||
}
|
||||
if (output == null) {
|
||||
throw new IllegalArgumentException("Still recipes need an output. Output was null.");
|
||||
}
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCyclesPerUnit() {
|
||||
return timePerUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue