Use StringBuilder to its fullest

Linearized append logic
This commit is contained in:
thatsIch 2014-10-01 11:07:13 +02:00
parent e1627734b1
commit d6917fdc5b
3 changed files with 20 additions and 6 deletions

View file

@ -79,7 +79,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " ); StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
for (Object tmp : recipe) for (Object tmp : recipe)
{ {
ret.append( tmp + ", " ); ret.append( tmp ).append( ", " );
} }
ret.append( output ); ret.append( output );
throw new RuntimeException( ret.toString() ); throw new RuntimeException( ret.toString() );
@ -101,7 +101,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " ); StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
for (Object tmp : recipe) for (Object tmp : recipe)
{ {
ret.append( tmp + ", " ); ret.append( tmp ).append( ", " );
} }
ret.append( output ); ret.append( output );
throw new RuntimeException( ret.toString() ); throw new RuntimeException( ret.toString() );

View file

@ -38,7 +38,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
StringBuilder ret = new StringBuilder( "Invalid shapeless ore recipe: " ); StringBuilder ret = new StringBuilder( "Invalid shapeless ore recipe: " );
for (Object tmp : recipe) for (Object tmp : recipe)
{ {
ret.append( tmp + ", " ); ret.append( tmp ).append( ", " );
} }
ret.append( output ); ret.append( output );
throw new RuntimeException( ret.toString() ); throw new RuntimeException( ret.toString() );

View file

@ -84,15 +84,29 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
{ {
StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + "\n" ); 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++) for (int y = 0; y < inputs.size(); y++)
{ {
IIngredient i = inputs.get( y ); IIngredient i = inputs.get( y );
if ( i.isAir() ) if ( i.isAir() )
o.append( "air" + (y + 1 == inputs.size() ? "\n" : " ") ); {
o.append( "air" );
}
else 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(); return o.toString().trim();