Use collections methods to add stuff

Remove redundant new String initialization
This commit is contained in:
thatsIch
2014-09-27 23:54:17 +02:00
parent 8a1364146f
commit d37638f4ee
5 changed files with 11 additions and 13 deletions
+3 -3
View File
@@ -1,10 +1,12 @@
package appeng.block; package appeng.block;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import appeng.client.texture.FlippableIcon; import appeng.client.texture.FlippableIcon;
import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -677,9 +679,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
if ( id.removedByPlayer( w, player, x, y, z, false ) ) if ( id.removedByPlayer( w, player, x, y, z, false ) )
{ {
List<ItemStack> l = new ArrayList<ItemStack>(); List<ItemStack> l = Lists.newArrayList(drops);
for (ItemStack iss : drops)
l.add( iss );
Platform.spawnDrops( w, x, y, z, l ); Platform.spawnDrops( w, x, y, z, l );
w.setBlockToAir( x, y, z ); w.setBlockToAir( x, y, z );
} }
+1 -1
View File
@@ -104,7 +104,7 @@ public class ItemRepo
Method b = searchField.getClass().getMethod( "onTextChange", String.class ); Method b = searchField.getClass().getMethod( "onTextChange", String.class );
NEIWord = filter; NEIWord = filter;
a.invoke( searchField, new String( filter ) ); a.invoke( searchField, filter );
b.invoke( searchField, "" ); b.invoke( searchField, "" );
} }
} }
@@ -1,5 +1,6 @@
package appeng.me.helpers; package appeng.me.helpers;
import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -307,8 +308,7 @@ public class AENetworkProxy implements IGridBlock
{ {
EnumSet<GridFlags> flags = EnumSet.noneOf( GridFlags.class ); EnumSet<GridFlags> flags = EnumSet.noneOf( GridFlags.class );
for (GridFlags gf : requireChannel) Collections.addAll( flags, requireChannel );
flags.add( gf );
this.flags = flags; this.flags = flags;
} }
@@ -1,5 +1,6 @@
package appeng.recipes.handlers; package appeng.recipes.handlers;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@@ -76,16 +77,13 @@ public class Inscribe implements ICraftHandler, IWebsiteSerializer
public void register() throws RegistrationError, MissingIngredientError public void register() throws RegistrationError, MissingIngredientError
{ {
if ( imprintable != null ) if ( imprintable != null )
for (ItemStack s : imprintable.getItemStackSet()) Collections.addAll( inputs, imprintable.getItemStackSet() );
inputs.add( s );
if ( plateA != null ) if ( plateA != null )
for (ItemStack s : plateA.getItemStackSet()) Collections.addAll( plates, plateA.getItemStackSet() );
plates.add( s );
if ( plateB != null ) if ( plateB != null )
for (ItemStack s : plateB.getItemStackSet()) Collections.addAll( plates, plateB.getItemStackSet() );
plates.add( s );
InscriberRecipe ir = new InscriberRecipe( imprintable.getItemStackSet(), plateA == null ? null : plateA.getItemStack(), plateB == null ? null InscriberRecipe ir = new InscriberRecipe( imprintable.getItemStackSet(), plateA == null ? null : plateA.getItemStack(), plateB == null ? null
: plateB.getItemStack(), output.getItemStack(), usePlates ); : plateB.getItemStack(), output.getItemStack(), usePlates );
@@ -74,7 +74,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
first++; first++;
} }
} }
args.add( y, new String( row ) ); args.add( y, row );
} }
ItemStack outIS = output.getItemStack(); ItemStack outIS = output.getItemStack();