Some performance or memory optimizations
Replaced String concat in loops with StringBuilder (performance) Replaced for with keySet + Map.get() through for with entrySet (perf) Changed inner classes to static classes, mostly struct like (memory)
This commit is contained in:
@@ -57,9 +57,10 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
||||
throw new RegistrationError( "Error while adding shapeless recipe." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
|
||||
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
|
||||
for (IIngredient i : inputs)
|
||||
{
|
||||
@@ -74,26 +75,27 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Platform.isSameItemPrecise( output.getItemStack(),reqOutput );
|
||||
|
||||
return Platform.isSameItemPrecise( output.getItemStack(), reqOutput );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPattern( RecipeHandler h) {
|
||||
String o = "shapeless "+output.getQty()+"\n";
|
||||
public String getPattern(RecipeHandler h)
|
||||
{
|
||||
StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + "\n" );
|
||||
|
||||
o += h.getName(output)+"\n";
|
||||
|
||||
for ( int y = 0; y < inputs.size(); y++ )
|
||||
o.append( h.getName( output ) + "\n" );
|
||||
|
||||
for (int y = 0; y < inputs.size(); y++)
|
||||
{
|
||||
IIngredient i = inputs.get(y);
|
||||
IIngredient i = inputs.get( y );
|
||||
if ( i.isAir() )
|
||||
o += "air"+( y +1 == inputs.size() ? "\n" : " " );
|
||||
o.append( "air" + (y + 1 == inputs.size() ? "\n" : " ") );
|
||||
else
|
||||
o += h.getName(i)+( y +1 == inputs.size() ? "\n" : " " );
|
||||
o.append( h.getName( i ) + (y + 1 == inputs.size() ? "\n" : " ") );
|
||||
}
|
||||
|
||||
return o.trim();
|
||||
|
||||
return o.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user