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 {
|
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
|
processResources
|
||||||
|
|
|
@ -3,4 +3,4 @@ forge.version=10.13.4.1448-1.7.10
|
||||||
|
|
||||||
mod.version=0.9.4
|
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 NAME = "Mod Tweaker 2", name = NAME;
|
||||||
public static final String MODID = "modtweaker2", modid = MODID;
|
public static final String MODID = "modtweaker2", modid = MODID;
|
||||||
public static final String VERSION = "0.9.4", version = VERSION;
|
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.InputHelper.toShapedObjects;
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -17,18 +16,20 @@ import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.mods.forestry.ForestryHelper;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.recipes.CarpenterRecipe;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import modtweaker2.mods.forestry.recipes.DescriptiveRecipe;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import forestry.core.recipes.ShapedRecipeCustom;
|
|
||||||
import forestry.factory.tiles.TileCarpenter;
|
import forestry.api.recipes.ICarpenterManager;
|
||||||
import forestry.factory.tiles.TileCarpenter.Recipe;
|
import forestry.api.recipes.ICarpenterRecipe;
|
||||||
import forestry.factory.tiles.TileCarpenter.RecipeManager;
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Carpenter")
|
@ZenClass("mods.forestry.Carpenter")
|
||||||
public class Carpenter {
|
public class Carpenter {
|
||||||
|
@ -47,7 +48,8 @@ public class Carpenter {
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box) {
|
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
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box) {
|
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
|
@Deprecated
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) {
|
public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) {
|
||||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toStacks(ingredients), toStack(product), false);
|
||||||
for (ItemStack stack : toStacks(ingredients)) {
|
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(liquid), toStack(ingredient), craftRecipe)));
|
||||||
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)))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<Recipe> {
|
private static class Add extends ForestryListAddition<ICarpenterRecipe, ICarpenterManager> {
|
||||||
|
|
||||||
public Add(Recipe recipe) {
|
public Add(ICarpenterRecipe recipe) {
|
||||||
super(Carpenter.name, TileCarpenter.RecipeManager.recipes);
|
super(Carpenter.name, RecipeManagers.carpenterManager);
|
||||||
recipes.add(recipe);
|
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
|
@Override
|
||||||
protected String getRecipeInfo(Recipe recipe) {
|
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.getCraftingResult());
|
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,15 +97,18 @@ public class Carpenter {
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) {
|
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) {
|
for(ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) {
|
||||||
if( recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult())) ) {
|
if (recipe != null) {
|
||||||
if (liquid != null) {
|
ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput();
|
||||||
if (matches(liquid, toILiquidStack(recipe.getLiquid())))
|
if (recipeResult != null && matches(output, toIItemStack(recipeResult))) {
|
||||||
|
if (liquid != null) {
|
||||||
|
if (matches(liquid, toILiquidStack(recipe.getFluidResource())))
|
||||||
|
recipes.add(recipe);
|
||||||
|
} else {
|
||||||
recipes.add(recipe);
|
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) {
|
public Remove(List<ICarpenterRecipe> recipes) {
|
||||||
super(Carpenter.name, RecipeManager.recipes, recipes);
|
super(Carpenter.name, RecipeManagers.carpenterManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(Recipe recipe) {
|
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.getCraftingResult());
|
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,16 @@ import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.item.WeightedItemStack;
|
import minetweaker.api.item.WeightedItemStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.CentrifugeRecipe;
|
||||||
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.api.recipes.ICentrifugeManager;
|
||||||
import forestry.api.recipes.ICentrifugeRecipe;
|
import forestry.api.recipes.ICentrifugeRecipe;
|
||||||
import forestry.factory.tiles.TileCentrifuge.CentrifugeRecipe;
|
import forestry.api.recipes.RecipeManagers;
|
||||||
import forestry.factory.tiles.TileCentrifuge.RecipeManager;
|
|
||||||
|
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Centrifuge")
|
@ZenClass("mods.forestry.Centrifuge")
|
||||||
|
@ -59,9 +61,9 @@ public class Centrifuge {
|
||||||
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products)));
|
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) {
|
public Add(ICentrifugeRecipe recipe) {
|
||||||
super(Centrifuge.name, RecipeManager.recipes);
|
super(Centrifuge.name, RecipeManagers.centrifugeManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ public class Centrifuge {
|
||||||
public static void removeRecipe(IIngredient input) {
|
public static void removeRecipe(IIngredient input) {
|
||||||
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
|
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()))) {
|
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||||
recipes.add(recipe);
|
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) {
|
public Remove(List<ICentrifugeRecipe> recipes) {
|
||||||
super(Centrifuge.name, RecipeManager.recipes, recipes);
|
super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package modtweaker2.mods.forestry.handlers;
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.getFluid;
|
||||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||||
|
@ -7,7 +8,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,18 +18,20 @@ import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.FermenterRecipe;
|
||||||
import modtweaker2.utils.BaseMapAddition;
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
import modtweaker2.utils.BaseMapRemoval;
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import forestry.api.fuels.FermenterFuel;
|
import forestry.api.fuels.FermenterFuel;
|
||||||
import forestry.api.fuels.FuelManager;
|
import forestry.api.fuels.FuelManager;
|
||||||
import forestry.factory.tiles.TileFermenter.Recipe;
|
import forestry.api.recipes.IFermenterManager;
|
||||||
import forestry.factory.tiles.TileFermenter.RecipeManager;
|
import forestry.api.recipes.IFermenterRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Fermenter")
|
@ZenClass("mods.forestry.Fermenter")
|
||||||
public class Fermenter {
|
public class Fermenter {
|
||||||
|
@ -51,87 +53,41 @@ public class Fermenter {
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) {
|
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
|
@Deprecated
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) {
|
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> {
|
private static class Add extends ForestryListAddition<IFermenterRecipe, IFermenterManager> {
|
||||||
public Add(Recipe recipe) {
|
public Add(IFermenterRecipe recipe) {
|
||||||
super(Fermenter.name, RecipeManager.recipes);
|
super(Fermenter.name, RecipeManagers.fermenterManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public String getRecipeInfo(IFermenterRecipe recipe) {
|
||||||
// add liquids to valid input / output
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IIngredient input) {
|
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
|
// 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);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for input liquids
|
// 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);
|
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()));
|
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) {
|
private static class Remove extends ForestryListRemoval<IFermenterRecipe, IFermenterManager> {
|
||||||
iter.remove();
|
|
||||||
}
|
public Remove(List<IFermenterRecipe> recipes) {
|
||||||
}
|
super(Fermenter.name, RecipeManagers.fermenterManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
protected String getRecipeInfo(IFermenterRecipe recipe) {
|
||||||
// add liquids to valid input / output
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,18 @@ import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.MoistenerRecipe;
|
||||||
import modtweaker2.utils.BaseMapAddition;
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
import modtweaker2.utils.BaseMapRemoval;
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import forestry.api.fuels.FuelManager;
|
import forestry.api.fuels.FuelManager;
|
||||||
import forestry.api.fuels.MoistenerFuel;
|
import forestry.api.fuels.MoistenerFuel;
|
||||||
import forestry.factory.tiles.TileMoistener;
|
import forestry.api.recipes.IMoistenerManager;
|
||||||
import forestry.factory.tiles.TileMoistener.Recipe;
|
import forestry.api.recipes.IMoistenerRecipe;
|
||||||
import forestry.factory.tiles.TileMoistener.RecipeManager;
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Moistener")
|
@ZenClass("mods.forestry.Moistener")
|
||||||
public class Moistener {
|
public class Moistener {
|
||||||
|
@ -44,24 +45,24 @@ public class Moistener {
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) {
|
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
|
@Deprecated
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
|
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> {
|
private static class Add extends ForestryListAddition<IMoistenerRecipe, IMoistenerManager> {
|
||||||
public Add(Recipe recipe) {
|
public Add(IMoistenerRecipe recipe) {
|
||||||
super(Moistener.name, TileMoistener.RecipeManager.recipes);
|
super(Moistener.name, RecipeManagers.moistenerManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo(Recipe recipe) {
|
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.product);
|
return LogHelper.getStackDescription(recipe.getProduct());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +70,9 @@ public class Moistener {
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IIngredient output) {
|
public static void removeRecipe(IIngredient output) {
|
||||||
List<Recipe> recipes = new LinkedList<Recipe>();
|
List<IMoistenerRecipe> recipes = new LinkedList<IMoistenerRecipe>();
|
||||||
for (Recipe recipe : RecipeManager.recipes) {
|
for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) {
|
||||||
if (recipe != null && recipe.product != null && matches(output, toIItemStack(recipe.product))) {
|
if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) {
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,14 +84,14 @@ public class Moistener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<Recipe> {
|
private static class Remove extends ForestryListRemoval<IMoistenerRecipe, IMoistenerManager> {
|
||||||
public Remove(List<Recipe> recipes) {
|
public Remove(List<IMoistenerRecipe> recipes) {
|
||||||
super(Moistener.name, RecipeManager.recipes, recipes);
|
super(Moistener.name, RecipeManagers.moistenerManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo(Recipe recipe) {
|
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.product);
|
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.InputHelper.toStacks;
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ISqueezerManager;
|
||||||
|
import forestry.api.recipes.ISqueezerRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.item.WeightedItemStack;
|
import minetweaker.api.item.WeightedItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.SqueezerRecipe;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
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")
|
@ZenClass("mods.forestry.Squeezer")
|
||||||
public class 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)));
|
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) {
|
public Add(ISqueezerRecipe recipe) {
|
||||||
super(Squeezer.name, TileSqueezer.RecipeManager.recipes);
|
super(Squeezer.name, RecipeManagers.squeezerManager);
|
||||||
recipes.add(recipe);
|
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
|
@Override
|
||||||
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||||
|
@ -105,7 +89,7 @@ public class Squeezer {
|
||||||
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {
|
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {
|
||||||
List<ISqueezerRecipe> recipes = new LinkedList<ISqueezerRecipe>();
|
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()))) {
|
if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) {
|
||||||
// optional check for ingredients
|
// optional check for ingredients
|
||||||
if (ingredients != null) {
|
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) {
|
public Remove(List<ISqueezerRecipe> recipes) {
|
||||||
super(Squeezer.name, TileSqueezer.RecipeManager.recipes, recipes);
|
super(Squeezer.name, RecipeManagers.squeezerManager, 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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,14 +11,16 @@ import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.StillRecipe;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import forestry.factory.tiles.TileStill;
|
|
||||||
import forestry.factory.tiles.TileStill.Recipe;
|
import forestry.api.recipes.IStillManager;
|
||||||
import forestry.factory.tiles.TileStill.RecipeManager;
|
import forestry.api.recipes.IStillRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
|
||||||
@ZenClass("mods.forestry.Still")
|
@ZenClass("mods.forestry.Still")
|
||||||
public class Still {
|
public class Still {
|
||||||
|
@ -39,7 +41,7 @@ public class Still {
|
||||||
fluidOutput.amount(fluidOutput.getAmount() / 100);
|
fluidOutput.amount(fluidOutput.getAmount() / 100);
|
||||||
fluidInput.amount(fluidInput.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
|
@Deprecated
|
||||||
|
@ -48,34 +50,18 @@ public class Still {
|
||||||
output.amount(output.getAmount() / 100);
|
output.amount(output.getAmount() / 100);
|
||||||
input.amount(input.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> {
|
private static class Add extends ForestryListAddition<IStillRecipe, IStillManager> {
|
||||||
public Add(Recipe recipe) {
|
public Add(IStillRecipe recipe) {
|
||||||
super("Forestry Still", TileStill.RecipeManager.recipes);
|
super("Forestry Still", RecipeManagers.stillManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public String getRecipeInfo(IStillRecipe recipe) {
|
||||||
super.apply();
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,12 +75,12 @@ public class Still {
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) {
|
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) {
|
for (IStillRecipe r : RecipeManagers.stillManager.recipes()) {
|
||||||
if (r != null && r.output != null && matches(output, toILiquidStack(r.output))) {
|
if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
if (matches(input, toILiquidStack(r.input))) {
|
if (matches(input, toILiquidStack(r.getInput()))) {
|
||||||
recipes.add(r);
|
recipes.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,30 +96,14 @@ public class Still {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<Recipe> {
|
private static class Remove extends ForestryListRemoval<IStillRecipe, IStillManager> {
|
||||||
public Remove(List<Recipe> recipes) {
|
public Remove(List<IStillRecipe> recipes) {
|
||||||
super(Still.name, RecipeManager.recipes, recipes);
|
super(Still.name, RecipeManagers.stillManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo(Recipe recipe) {
|
public String getRecipeInfo(IStillRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.output);
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
}
|
|
||||||
|
|
||||||
@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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,23 @@ import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import modtweaker2.utils.BaseListAddition;
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
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.Optional;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
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.api.recipes.IFabricatorRecipe;
|
||||||
import forestry.factory.recipes.FabricatorRecipe;
|
|
||||||
import forestry.factory.tiles.TileFabricator.RecipeManager;
|
|
||||||
import forestry.factory.tiles.TileFabricator.Smelting;
|
|
||||||
|
|
||||||
@ZenClass("mods.forestry.ThermionicFabricator")
|
@ZenClass("mods.forestry.ThermionicFabricator")
|
||||||
public class ThermionicFabricator {
|
public class ThermionicFabricator {
|
||||||
|
@ -41,14 +47,14 @@ public class ThermionicFabricator {
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) {
|
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
|
//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
|
@Deprecated
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
|
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
|
//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
|
@ZenMethod
|
||||||
public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan) {
|
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
|
@Deprecated
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output) {
|
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
|
Implements the actions to add a recipe
|
||||||
Since the machine has two crafting Steps, this is a constructors for both
|
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) {
|
public AddSmelting(IFabricatorSmeltingRecipe recipe) {
|
||||||
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings);
|
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo(Smelting recipe) {
|
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.getResource());
|
return LogHelper.getStackDescription(recipe.getResource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AddCast extends BaseListAddition<IFabricatorRecipe> {
|
private static class AddCast extends ForestryListAddition<IFabricatorRecipe, IFabricatorManager> {
|
||||||
|
|
||||||
public AddCast(IFabricatorRecipe recipe) {
|
public AddCast(IFabricatorRecipe recipe) {
|
||||||
super(ThermionicFabricator.nameCasting, RecipeManager.recipes);
|
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager);
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +114,9 @@ public class ThermionicFabricator {
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeSmelting(IIngredient itemInput) {
|
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()))) {
|
if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
|
||||||
recipes.add(r);
|
recipes.add(r);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +133,7 @@ public class ThermionicFabricator {
|
||||||
public static void removeCast(IIngredient product) {
|
public static void removeCast(IIngredient product) {
|
||||||
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
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()))) {
|
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||||
recipes.add(r);
|
recipes.add(r);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +151,7 @@ public class ThermionicFabricator {
|
||||||
public static void removeCasts(IIngredient product) {
|
public static void removeCasts(IIngredient product) {
|
||||||
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
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()))) {
|
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||||
recipes.add(r);
|
recipes.add(r);
|
||||||
}
|
}
|
||||||
|
@ -156,20 +164,20 @@ public class ThermionicFabricator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RemoveSmelting extends BaseListRemoval<Smelting> {
|
private static class RemoveSmelting extends ForestryListRemoval<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||||
public RemoveSmelting(List<Smelting> recipes) {
|
public RemoveSmelting(List<IFabricatorSmeltingRecipe> recipes) {
|
||||||
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings, recipes);
|
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeInfo(Smelting recipe) {
|
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||||
return LogHelper.getStackDescription(recipe.getResource());
|
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) {
|
public RemoveCasts(List<IFabricatorRecipe> recipes) {
|
||||||
super(ThermionicFabricator.nameCasting, RecipeManager.recipes, recipes);
|
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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