88import static modtweaker2 .helpers .InputHelper .toShapedObjects ;
99import static modtweaker2 .helpers .StackHelper .matches ;
1010
11- import java .util .ArrayList ;
1211import java .util .LinkedList ;
1312import java .util .List ;
1413
1716import minetweaker .api .item .IItemStack ;
1817import minetweaker .api .liquid .ILiquidStack ;
1918import modtweaker2 .helpers .LogHelper ;
20- import modtweaker2 .mods .forestry .ForestryHelper ;
21- import modtweaker2 .utils .BaseListAddition ;
22- import modtweaker2 .utils .BaseListRemoval ;
23- import net .minecraft .init .Blocks ;
19+ import modtweaker2 .mods .forestry .ForestryListAddition ;
20+ import modtweaker2 .mods .forestry .ForestryListRemoval ;
21+ import modtweaker2 .mods .forestry .recipes .CarpenterRecipe ;
2422import net .minecraft .item .ItemStack ;
23+
24+ import modtweaker2 .mods .forestry .recipes .DescriptiveRecipe ;
2525import stanhebben .zenscript .annotations .Optional ;
2626import stanhebben .zenscript .annotations .ZenClass ;
2727import stanhebben .zenscript .annotations .ZenMethod ;
28- import forestry .core .recipes .ShapedRecipeCustom ;
29- import forestry .factory .tiles .TileCarpenter ;
30- import forestry .factory .tiles .TileCarpenter .Recipe ;
31- import forestry .factory .tiles .TileCarpenter .RecipeManager ;
28+
29+ import forestry .api .recipes .ICarpenterManager ;
30+ import forestry .api .recipes .ICarpenterRecipe ;
31+ import forestry .api .recipes .IDescriptiveRecipe ;
32+ import forestry .api .recipes .RecipeManagers ;
3233
3334@ ZenClass ("mods.forestry.Carpenter" )
3435public class Carpenter {
@@ -47,7 +48,8 @@ public class Carpenter {
4748 */
4849 @ ZenMethod
4950 public static void addRecipe (IItemStack output , IIngredient [][] ingredients , int packagingTime , @ Optional IItemStack box ) {
50- MineTweakerAPI .apply (new Add (new Recipe (packagingTime , null , toStack (box ), ShapedRecipeCustom .createShapedRecipe (toStack (output ), toShapedObjects (ingredients )) )));
51+ IDescriptiveRecipe craftRecipe = new DescriptiveRecipe (3 , 3 , toShapedObjects (ingredients ), toStack (output ), false );
52+ MineTweakerAPI .apply (new Add (new CarpenterRecipe (packagingTime , null , toStack (box ), craftRecipe )));
5153 }
5254
5355 /**
@@ -61,44 +63,27 @@ public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int
6163 */
6264 @ ZenMethod
6365 public static void addRecipe (IItemStack output , IIngredient [][] ingredients , ILiquidStack fluidInput , int packagingTime , @ Optional IItemStack box ) {
64- MineTweakerAPI .apply (new Add (new Recipe (packagingTime , toFluid (fluidInput ), toStack (box ), ShapedRecipeCustom .createShapedRecipe (toStack (output ), toShapedObjects (ingredients )) )));
66+ IDescriptiveRecipe craftRecipe = new DescriptiveRecipe (3 , 3 , toShapedObjects (ingredients ), toStack (output ), false );
67+ MineTweakerAPI .apply (new Add (new CarpenterRecipe (packagingTime , toFluid (fluidInput ), toStack (box ), craftRecipe )));
6568 }
6669
6770 @ Deprecated
6871 @ ZenMethod
6972 public static void addRecipe (int packagingTime , ILiquidStack liquid , IItemStack [] ingredients , IItemStack ingredient , IItemStack product ) {
70- ArrayList <ItemStack > stacks = new ArrayList <ItemStack >();
71- for (ItemStack stack : toStacks (ingredients )) {
72- if (stack != null ) {
73- stacks .add (stack );
74- }
75- if (stack == null ) {
76- stacks .add (new ItemStack (Blocks .air ));
77- }
78-
79- }
80- MineTweakerAPI .apply (new Add (new Recipe (packagingTime , toFluid (liquid ), toStack (ingredient ), new ShapedRecipeCustom (3 , 3 , toStacks (ingredients ), toStack (product )))));
73+ IDescriptiveRecipe craftRecipe = new DescriptiveRecipe (3 , 3 , toStacks (ingredients ), toStack (product ), false );
74+ MineTweakerAPI .apply (new Add (new CarpenterRecipe (packagingTime , toFluid (liquid ), toStack (ingredient ), craftRecipe )));
8175 }
8276
83- private static class Add extends BaseListAddition < Recipe > {
77+ private static class Add extends ForestryListAddition < ICarpenterRecipe , ICarpenterManager > {
8478
85- public Add (Recipe recipe ) {
86- super (Carpenter .name , TileCarpenter . RecipeManager . recipes );
79+ public Add (ICarpenterRecipe recipe ) {
80+ super (Carpenter .name , RecipeManagers . carpenterManager );
8781 recipes .add (recipe );
88-
89- // The Carpenter has a list of valid Fluids, access them via
90- // Reflection because of private
91- if (recipe .getLiquid () != null )
92- ForestryHelper .addCarpenterRecipeFluids (recipe .getLiquid ().getFluid ());
93-
94- if (!RecipeManager .isBox (recipe .getBox ())){
95- ForestryHelper .addCarpenterRecipeBox (recipe .getBox ());
96- }
9782 }
9883
9984 @ Override
100- protected String getRecipeInfo (Recipe recipe ) {
101- return LogHelper .getStackDescription (recipe .getCraftingResult ());
85+ protected String getRecipeInfo (ICarpenterRecipe recipe ) {
86+ return LogHelper .getStackDescription (recipe .getCraftingGridRecipe (). getRecipeOutput ());
10287 }
10388 }
10489
@@ -112,15 +97,18 @@ protected String getRecipeInfo(Recipe recipe) {
11297 */
11398 @ ZenMethod
11499 public static void removeRecipe (IIngredient output , @ Optional IIngredient liquid ) {
115- List <Recipe > recipes = new LinkedList <Recipe >();
100+ List <ICarpenterRecipe > recipes = new LinkedList <ICarpenterRecipe >();
116101
117- for (Recipe recipe : RecipeManager .recipes ) {
118- if ( recipe != null && recipe .getCraftingResult () != null && matches (output , toIItemStack (recipe .getCraftingResult ())) ) {
119- if (liquid != null ) {
120- if (matches (liquid , toILiquidStack (recipe .getLiquid ())))
102+ for (ICarpenterRecipe recipe : RecipeManagers .carpenterManager .recipes ()) {
103+ if (recipe != null ) {
104+ ItemStack recipeResult = recipe .getCraftingGridRecipe ().getRecipeOutput ();
105+ if (recipeResult != null && matches (output , toIItemStack (recipeResult ))) {
106+ if (liquid != null ) {
107+ if (matches (liquid , toILiquidStack (recipe .getFluidResource ())))
108+ recipes .add (recipe );
109+ } else {
121110 recipes .add (recipe );
122- } else {
123- recipes .add (recipe );
111+ }
124112 }
125113 }
126114 }
@@ -132,15 +120,15 @@ public static void removeRecipe(IIngredient output, @Optional IIngredient liquid
132120 }
133121 }
134122
135- private static class Remove extends BaseListRemoval < Recipe > {
123+ private static class Remove extends ForestryListRemoval < ICarpenterRecipe , ICarpenterManager > {
136124
137- public Remove (List <Recipe > recipes ) {
138- super (Carpenter .name , RecipeManager . recipes , recipes );
125+ public Remove (List <ICarpenterRecipe > recipes ) {
126+ super (Carpenter .name , RecipeManagers . carpenterManager , recipes );
139127 }
140128
141129 @ Override
142- protected String getRecipeInfo (Recipe recipe ) {
143- return LogHelper .getStackDescription (recipe .getCraftingResult ());
130+ protected String getRecipeInfo (ICarpenterRecipe recipe ) {
131+ return LogHelper .getStackDescription (recipe .getCraftingGridRecipe (). getRecipeOutput ());
144132 }
145133 }
146134}
0 commit comments