mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-27 15:43:06 +00:00
Fix up Integration for Forestry 4.1.0 using only the API
This commit is contained in:
1 parent
4682dba3e6
commit
28175a9e95
22 files changed
+758
-353
No files matched your search
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user