@@ -31,6 +31,11 @@ public static void addShaped(IItemStack output, IIngredient[][] inputs) {
3131 ModTweaker .LATE_ADDITIONS .add (new AddShaped (output , inputs ));
3232 }
3333
34+ @ ZenMethod
35+ public static void addShapedFixed (IItemStack output , IIngredient [][] inputs ) {
36+ ModTweaker .LATE_ADDITIONS .add (new AddShapedFixed (output , inputs ));
37+ }
38+
3439 @ ZenMethod
3540 public static void addShapeless (IItemStack output , IIngredient [] inputs ) {
3641 ModTweaker .LATE_ADDITIONS .add (new AddShapeless (output , inputs ));
@@ -41,6 +46,11 @@ public static void removeShaped(IItemStack output, @Optional IIngredient[][] ing
4146 ModTweaker .LATE_REMOVALS .add (new RemoveShaped (output , ingredients ));
4247 }
4348
49+ @ ZenMethod
50+ public static void removeShapedFixed (IItemStack output , @ Optional IIngredient [][] ingredients ) {
51+ ModTweaker .LATE_REMOVALS .add (new RemoveShapedFixed (output , ingredients ));
52+ }
53+
4454 @ ZenMethod
4555 public static void removeShapeless (IItemStack output , @ Optional IIngredient [] ingredients ) {
4656 ModTweaker .LATE_REMOVALS .add (new RemoveShapeless (output , ingredients ));
@@ -73,6 +83,18 @@ protected String getRecipeInfo() {
7383 }
7484 }
7585
86+ public static class AddShapedFixed extends AddShaped {
87+
88+ public AddShapedFixed (IItemStack output , IIngredient [][] ingredients ) {
89+ super (output , ingredients );
90+ }
91+
92+ @ Override
93+ public void apply () {
94+ AnvilRecipes .addSteelShapedRecipe (new ResourceLocation ("crafttweaker" , this .name ), InputHelper .toStack (output ), toShapedAnvilObjectsFixed (ingredients ));
95+ }
96+ }
97+
7698 public static class AddShapeless extends BaseAction {
7799
78100 private final IItemStack output ;
@@ -96,6 +118,33 @@ protected String getRecipeInfo() {
96118 }
97119
98120 public static Object [] toShapedAnvilObjects (IIngredient [][] ingredients ) {
121+ if (ingredients == null )
122+ return null ;
123+ else {
124+ ArrayList prep = new ArrayList ();
125+ char chr = 'a' ;
126+ for (int y = 0 ; y < 4 ; y ++) {
127+ StringBuilder matrix = new StringBuilder ();
128+ for (int x = 0 ; x < 4 ; x ++) {
129+ if (x < ingredients .length && ingredients [x ] != null && y < ingredients [x ].length ) {
130+ if (ingredients [x ][y ] != null ) {
131+ prep .add (chr );
132+ prep .add (InputHelper .toObject (ingredients [x ][y ]));
133+ matrix .append (chr );
134+ chr ++;
135+ } else {
136+ matrix .append (' ' );
137+ }
138+ }
139+ }
140+ if (matrix .length () > 0 )
141+ prep .add (y , matrix .toString ());
142+ }
143+ return prep .toArray ();
144+ }
145+ }
146+
147+ public static Object [] toShapedAnvilObjectsFixed (IIngredient [][] ingredients ) {
99148 if (ingredients == null )
100149 return null ;
101150 else {
@@ -159,6 +208,32 @@ protected String getRecipeInfo() {
159208 }
160209 }
161210
211+ public static class RemoveShapedFixed extends RemoveShaped {
212+
213+ protected RemoveShapedFixed (IItemStack output , IIngredient [][] ingredients ) {
214+ super (output , ingredients );
215+ }
216+
217+ @ Override
218+ public void apply () {
219+ if (ingredients != null ) {
220+ IRecipe removal = new ShapedAnvilRecipe (new ResourceLocation ("crafttweaker" , this .name ), InputHelper .toStack (output ), toShapedAnvilObjectsFixed (ingredients ));
221+ for (Iterator <IRecipe > iterator = AnvilCraftingManager .ANVIL_CRAFTING .iterator (); iterator .hasNext (); ) {
222+ IRecipe recipe = iterator .next ();
223+ if (recipe .getRecipeOutput ().isItemEqual (removal .getRecipeOutput ()) && removal .getIngredients ().equals (recipe .getIngredients ()))
224+ iterator .remove ();
225+ }
226+ } else {
227+ for (Iterator <IRecipe > iterator = AnvilCraftingManager .ANVIL_CRAFTING .iterator (); iterator .hasNext (); ) {
228+ IRecipe recipe = iterator .next ();
229+ if (recipe .getRecipeOutput ().isItemEqual (InputHelper .toStack (output ))) {
230+ iterator .remove ();
231+ }
232+ }
233+ }
234+ }
235+ }
236+
162237 public static class RemoveShapeless extends BaseAction {
163238
164239 private final IItemStack output ;
0 commit comments