Refactoring
Type-safety Minor performance improvements
This commit is contained in:
@@ -18,7 +18,9 @@
|
||||
|
||||
package appeng.recipes;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
@@ -39,7 +41,7 @@ public class AEItemResolver implements ISubItemResolver
|
||||
public Object resolveItemByName(String nameSpace, String itemName)
|
||||
{
|
||||
|
||||
if ( nameSpace.equals( AppEng.modid ) )
|
||||
if ( nameSpace.equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
if ( itemName.startsWith( "PaintBall." ) )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.recipes;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -25,6 +26,9 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
@@ -32,7 +36,6 @@ import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Ingredient implements IIngredient
|
||||
{
|
||||
@@ -183,7 +186,7 @@ public class Ingredient implements IIngredient
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return nameSpace + ":" + itemName + ":" + meta;
|
||||
return nameSpace + ':' + itemName + ':' + meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.recipes;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -29,8 +30,14 @@ import java.util.Map.Entry;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import appeng.recipes.handlers.IWebsiteSerializer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
@@ -47,14 +54,9 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.items.materials.ItemMultiMaterial;
|
||||
import appeng.items.misc.ItemCrystalSeed;
|
||||
import appeng.items.parts.ItemMultiPart;
|
||||
import appeng.recipes.handlers.IWebsiteSerializer;
|
||||
import appeng.recipes.handlers.OreRegistration;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
public class RecipeHandler implements IRecipeHandler
|
||||
{
|
||||
|
||||
@@ -203,7 +205,7 @@ public class RecipeHandler implements IRecipeHandler
|
||||
String rew = ws.getPattern( this );
|
||||
if ( rew != null && rew.length() > 0 )
|
||||
{
|
||||
out.putNextEntry( new ZipEntry( realName + "_" + offset + ".txt" ) );
|
||||
out.putNextEntry( new ZipEntry( realName + '_' + offset + ".txt" ) );
|
||||
offset++;
|
||||
out.write( rew.getBytes() );
|
||||
}
|
||||
@@ -245,15 +247,15 @@ public class RecipeHandler implements IRecipeHandler
|
||||
// :P
|
||||
}
|
||||
|
||||
return i.getNameSpace() + ":" + i.getItemName();
|
||||
return i.getNameSpace() + ':' + i.getItemName();
|
||||
}
|
||||
|
||||
public String getName(ItemStack is) throws RecipeError
|
||||
{
|
||||
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() );
|
||||
String realName = id.modId + ":" + id.name;
|
||||
String realName = id.modId + ':' + id.name;
|
||||
|
||||
if ( !id.modId.equals( AppEng.modid ) && !id.modId.equals( "minecraft" ) )
|
||||
if ( !id.modId.equals( AppEng.MOD_ID ) && !id.modId.equals( "minecraft" ) )
|
||||
throw new RecipeError( "Not applicable for website" );
|
||||
|
||||
if ( is.getItem() == AEApi.instance().items().itemCrystalSeed.item() )
|
||||
@@ -321,12 +323,12 @@ public class RecipeHandler implements IRecipeHandler
|
||||
else if ( is.getItem() instanceof ItemMultiMaterial )
|
||||
{
|
||||
realName = realName.replace( "ItemMultiMaterial", "ItemMaterial" );
|
||||
realName += "." + ((ItemMultiMaterial) is.getItem()).getTypeByStack( is ).name();
|
||||
realName += '.' + ((ItemMultiMaterial) is.getItem()).getTypeByStack( is ).name();
|
||||
}
|
||||
else if ( is.getItem() instanceof ItemMultiPart )
|
||||
{
|
||||
realName = realName.replace( "ItemMultiPart", "ItemPart" );
|
||||
realName += "." + ((ItemMultiPart) is.getItem()).getTypeByStack( is ).name();
|
||||
realName += '.' + ((ItemMultiPart) is.getItem()).getTypeByStack( is ).name();
|
||||
}
|
||||
else if ( is.getItemDamage() > 0 )
|
||||
realName += "." + is.getItemDamage();
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
@@ -67,7 +69,7 @@ public class Grind implements ICraftHandler, IWebsiteSerializer
|
||||
@Override
|
||||
public String getPattern( RecipeHandler h ) {
|
||||
return "grind\n"+
|
||||
h.getName(pro_input)+"\n"+
|
||||
h.getName(pro_input)+ '\n' +
|
||||
h.getName(pro_output[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
@@ -117,17 +119,17 @@ public class Inscribe implements ICraftHandler, IWebsiteSerializer
|
||||
@Override
|
||||
public String getPattern(RecipeHandler h)
|
||||
{
|
||||
String o = "inscriber " + output.getQty() + "\n";
|
||||
String o = "inscriber " + output.getQty() + '\n';
|
||||
|
||||
o += h.getName( output ) + "\n";
|
||||
o += h.getName( output ) + '\n';
|
||||
|
||||
if ( plateA != null )
|
||||
o += h.getName( plateA )+"\n";
|
||||
o += h.getName( plateA )+ '\n';
|
||||
|
||||
o += h.getName(imprintable);
|
||||
|
||||
if ( plateB != null )
|
||||
o += "\n"+h.getName( plateB );
|
||||
o += '\n' +h.getName( plateB );
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
@@ -31,7 +35,6 @@ import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
import appeng.recipes.game.ShapedRecipe;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Shaped implements ICraftHandler, IWebsiteSerializer
|
||||
{
|
||||
@@ -86,7 +89,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
||||
for (int x = 0; x < cols; x++)
|
||||
{
|
||||
if ( inputs.get( y ).get( x ).isAir() )
|
||||
row.append( " " );
|
||||
row.append( ' ' );
|
||||
else
|
||||
{
|
||||
row.append( first );
|
||||
@@ -136,9 +139,9 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
||||
@Override
|
||||
public String getPattern(RecipeHandler h)
|
||||
{
|
||||
String o = "shaped " + output.getQty() + " " + cols + "x" + rows + "\n";
|
||||
String o = "shaped " + output.getQty() + ' ' + cols + 'x' + rows + '\n';
|
||||
|
||||
o += h.getName( output ) + "\n";
|
||||
o += h.getName( output ) + '\n';
|
||||
|
||||
for (int y = 0; y < rows; y++)
|
||||
for (int x = 0; x < cols; x++)
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
@@ -31,7 +35,6 @@ import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
import appeng.recipes.game.ShapelessRecipe;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
||||
{
|
||||
@@ -100,9 +103,9 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
||||
@Override
|
||||
public String getPattern(RecipeHandler h)
|
||||
{
|
||||
StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + "\n" );
|
||||
StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + '\n' );
|
||||
|
||||
o.append( h.getName( output ) ).append( "\n" );
|
||||
o.append( h.getName( output ) ).append( '\n' );
|
||||
|
||||
for (int y = 0; y < inputs.size(); y++)
|
||||
{
|
||||
@@ -119,11 +122,11 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
||||
|
||||
if ( y + 1 == this.inputs.size() )
|
||||
{
|
||||
o.append( "\n" );
|
||||
o.append( '\n' );
|
||||
}
|
||||
else
|
||||
{
|
||||
o.append( " " );
|
||||
o.append( ' ' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,13 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RecipeError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
@@ -28,7 +32,6 @@ import appeng.api.recipes.ICraftHandler;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Smelt implements ICraftHandler, IWebsiteSerializer
|
||||
{
|
||||
@@ -72,8 +75,8 @@ public class Smelt implements ICraftHandler, IWebsiteSerializer
|
||||
|
||||
@Override
|
||||
public String getPattern( RecipeHandler h ) {
|
||||
return "smelt "+out.getQty()+"\n"+
|
||||
h.getName(out)+"\n"+
|
||||
return "smelt "+out.getQty()+ '\n' +
|
||||
h.getName(out)+ '\n' +
|
||||
h.getName(in);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user