Reconcile broken code.

This commit is contained in:
AlgorithmX2
2014-03-05 23:52:25 -06:00
parent 3f05965a06
commit b62166bd08
4 changed files with 75 additions and 71 deletions
+2 -2
View File
@@ -124,8 +124,8 @@ import appeng.me.storage.AEExternalHandler;
import appeng.parts.PartPlacement; import appeng.parts.PartPlacement;
import appeng.recipes.AEItemResolver; import appeng.recipes.AEItemResolver;
import appeng.recipes.RecipeHandler; import appeng.recipes.RecipeHandler;
import appeng.recipes.Recipes.ShapedRecipe; import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.Recipes.ShapelessRecipe; import appeng.recipes.game.ShapelessRecipe;
import appeng.recipes.handlers.Grind; import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.Macerator; import appeng.recipes.handlers.Macerator;
import appeng.recipes.handlers.Pulverizer; import appeng.recipes.handlers.Pulverizer;
+60 -57
View File
@@ -11,11 +11,7 @@ import java.util.Map.Entry;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError; import appeng.api.exceptions.RecipeError;
@@ -32,6 +28,8 @@ import appeng.items.materials.ItemMaterial;
import appeng.items.parts.ItemPart; import appeng.items.parts.ItemPart;
import appeng.recipes.handlers.IWebsiteSeralizer; import appeng.recipes.handlers.IWebsiteSeralizer;
import appeng.recipes.handlers.OreRegistration; import appeng.recipes.handlers.OreRegistration;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
public class RecipeHandler implements IRecipeHandler public class RecipeHandler implements IRecipeHandler
{ {
@@ -52,28 +50,28 @@ public class RecipeHandler implements IRecipeHandler
data.Handlers.add( ch ); data.Handlers.add( ch );
} }
public List<IWebsiteSeralizer> findRecipe( ItemStack output ) public List<IWebsiteSeralizer> findRecipe(ItemStack output)
{ {
List<IWebsiteSeralizer> out = new LinkedList<IWebsiteSeralizer>(); List<IWebsiteSeralizer> out = new LinkedList<IWebsiteSeralizer>();
for ( ICraftHandler ch : data.Handlers ) for (ICraftHandler ch : data.Handlers)
{ {
try try
{ {
if ( ch instanceof IWebsiteSeralizer && ch.canCraft(output)) if ( ch instanceof IWebsiteSeralizer && ((IWebsiteSeralizer) ch).canCraft( output ) )
{ {
out.add((IWebsiteSeralizer)ch); out.add( (IWebsiteSeralizer) ch );
} }
} }
catch (Throwable t ) catch (Throwable t)
{ {
AELog.error(t); AELog.error( t );
} }
} }
return out; return out;
} }
@Override @Override
public void registerHandlers() public void registerHandlers()
{ {
@@ -126,81 +124,86 @@ public class RecipeHandler implements IRecipeHandler
{ {
AELog.info( "Recipes Loading: " + e.getKey().getSimpleName() + ": " + e.getValue() + " loaded." ); AELog.info( "Recipes Loading: " + e.getKey().getSimpleName() + ": " + e.getValue() + " loaded." );
} }
if ( AEConfig.instance.isFeatureEnabled( AEFeature.WebsiteRecipes ) )
if ( AEConfig.instance.isFeatureEnabled(AEFeature.WebsiteRecipes) )
{ {
try { try
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("recipes.zip")); {
ZipOutputStream out = new ZipOutputStream( new FileOutputStream( "recipes.zip" ) );
for ( String s : data.knownItem )
for (String s : data.knownItem)
{ {
try try
{ {
Ingredient i = new Ingredient( this, s, 1 ); Ingredient i = new Ingredient( this, s, 1 );
for ( ItemStack is : i.getItemStackSet() ) for (ItemStack is : i.getItemStackSet())
{ {
List<IWebsiteSeralizer> recipes = findRecipe(is); List<IWebsiteSeralizer> recipes = findRecipe( is );
if ( !recipes.isEmpty() ) if ( !recipes.isEmpty() )
{ {
int offset =0; int offset = 0;
String realName = getName(is); String realName = getName( is );
for ( IWebsiteSeralizer ws : recipes ) for (IWebsiteSeralizer ws : recipes)
{ {
out.putNextEntry(new ZipEntry(realName+"_"+offset+".txt")); out.putNextEntry( new ZipEntry( realName + "_" + offset + ".txt" ) );
offset++; offset++;
out.write(ws.getPattern(this).getBytes()); out.write( ws.getPattern( this ).getBytes() );
} }
} }
} }
} }
catch( Throwable t ) catch (Throwable t)
{ {
// :P // :P
} }
} }
out.close(); out.close();
} catch (FileNotFoundException e1) {
AELog.error(e1);
} catch (IOException e1) {
AELog.error(e1);
} }
catch (FileNotFoundException e1)
{
AELog.error( e1 );
}
catch (IOException e1)
{
AELog.error( e1 );
}
} }
} }
public String getName( IIngredient i ) public String getName(IIngredient i)
{ {
try try
{ {
return getName( i.getItemStack() ); return getName( i.getItemStack() );
} }
catch (Throwable t ) catch (Throwable t)
{ {
// :P // :P
} }
return i.getNameSpace()+":"+i.getItemName(); return i.getNameSpace() + ":" + i.getItemName();
} }
public String getName(ItemStack is) { public String getName(ItemStack is)
{
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(is.getItem());
String realName = id.modId+":"+id.name; UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() );
String realName = id.modId + ":" + id.name;
if ( is.getItem() instanceof ItemMaterial ) if ( is.getItem() instanceof ItemMaterial )
realName += ":"+( (ItemMaterial)is.getItem() ).getType(is).name(); realName += ":" + ((ItemMaterial) is.getItem()).getType( is ).name();
else if ( is.getItem() instanceof ItemPart ) else if ( is.getItem() instanceof ItemPart )
realName += ":"+( (ItemPart)is.getItem() ).getTypeByStack(is).name(); realName += ":" + ((ItemPart) is.getItem()).getTypeByStack( is ).name();
else if ( is.getItemDamage() > 0 ) else if ( is.getItemDamage() > 0 )
realName += ":"+is.getItemDamage(); realName += ":" + is.getItemDamage();
return realName; return realName;
} }
public String alias(String in) public String alias(String in)
@@ -492,10 +495,10 @@ public class RecipeHandler implements IRecipeHandler
private IIngredient findIngrident(String v, int qty) throws RecipeError private IIngredient findIngrident(String v, int qty) throws RecipeError
{ {
GroupIngredient gi = data.groups.get( v ); GroupIngredient gi = data.groups.get( v );
if ( gi != null ) if ( gi != null )
return gi.copy( qty ); return gi.copy( qty );
data.knownItem.add( v ); data.knownItem.add( v );
return new Ingredient( this, v, qty ); return new Ingredient( this, v, qty );
} }
+9 -3
View File
@@ -1,9 +1,15 @@
package appeng.recipes.handlers; package appeng.recipes.handlers;
import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.recipes.RecipeHandler; import appeng.recipes.RecipeHandler;
public interface IWebsiteSeralizer { public interface IWebsiteSeralizer
{
String getPattern(RecipeHandler han);
boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError;
String getPattern( RecipeHandler han );
} }
+4 -9
View File
@@ -34,14 +34,9 @@ public class OreRegistration implements ICraftHandler
} }
@Override @Override
public void setup(List<List<IIngredient>> input, public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
List<List<IIngredient>> output) throws RecipeError { {
} }
@Override
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
return false;
}
} }