From d6917fdc5b6c5b0b3a45337728b504a7fb8bee9b Mon Sep 17 00:00:00 2001 From: thatsIch Date: Wed, 1 Oct 2014 11:07:13 +0200 Subject: [PATCH] Use StringBuilder to its fullest Linearized append logic --- .../appeng/recipes/game/ShapedRecipe.java | 4 ++-- .../appeng/recipes/game/ShapelessRecipe.java | 2 +- .../appeng/recipes/handlers/Shapeless.java | 20 ++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/appeng/recipes/game/ShapedRecipe.java b/src/main/java/appeng/recipes/game/ShapedRecipe.java index ac698482..6bef1053 100644 --- a/src/main/java/appeng/recipes/game/ShapedRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapedRecipe.java @@ -79,7 +79,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " ); for (Object tmp : recipe) { - ret.append( tmp + ", " ); + ret.append( tmp ).append( ", " ); } ret.append( output ); throw new RuntimeException( ret.toString() ); @@ -101,7 +101,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " ); for (Object tmp : recipe) { - ret.append( tmp + ", " ); + ret.append( tmp ).append( ", " ); } ret.append( output ); throw new RuntimeException( ret.toString() ); diff --git a/src/main/java/appeng/recipes/game/ShapelessRecipe.java b/src/main/java/appeng/recipes/game/ShapelessRecipe.java index e7bec013..3c6638f5 100644 --- a/src/main/java/appeng/recipes/game/ShapelessRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapelessRecipe.java @@ -38,7 +38,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable StringBuilder ret = new StringBuilder( "Invalid shapeless ore recipe: " ); for (Object tmp : recipe) { - ret.append( tmp + ", " ); + ret.append( tmp ).append( ", " ); } ret.append( output ); throw new RuntimeException( ret.toString() ); diff --git a/src/main/java/appeng/recipes/handlers/Shapeless.java b/src/main/java/appeng/recipes/handlers/Shapeless.java index 5c0b6f52..b1d4ff35 100644 --- a/src/main/java/appeng/recipes/handlers/Shapeless.java +++ b/src/main/java/appeng/recipes/handlers/Shapeless.java @@ -84,15 +84,29 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer { StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + "\n" ); - o.append( h.getName( output ) + "\n" ); + o.append( h.getName( output ) ).append( "\n" ); for (int y = 0; y < inputs.size(); y++) { IIngredient i = inputs.get( y ); + if ( i.isAir() ) - o.append( "air" + (y + 1 == inputs.size() ? "\n" : " ") ); + { + o.append( "air" ); + } else - o.append( h.getName( i ) + (y + 1 == inputs.size() ? "\n" : " ") ); + { + o.append( h.getName( i ) ); + } + + if ( y + 1 == this.inputs.size() ) + { + o.append( "\n" ); + } + else + { + o.append( " " ); + } } return o.toString().trim();