Website Recipe Update.

This commit is contained in:
AlgorithmX2 2014-07-15 12:02:12 -05:00
parent 8c0658d3de
commit 137549f8fa
4 changed files with 66 additions and 21 deletions

View file

@ -103,6 +103,8 @@ public class Ingredient implements IIngredient
}
else
throw new RecipeError( input + " : Needs at least Namespace and Name." );
handler.data.knownItem.add( toString() );
}
@Override
@ -171,7 +173,7 @@ public class Ingredient implements IIngredient
}
if ( set.length == 0 )
throw new MissingIngredientError( toString() + " - ore dictionary could not be resolved to any items." );
throw new MissingIngredientError( getItemName() + " - ore dictionary could not be resolved to any items." );
return set;
}

View file

@ -11,6 +11,8 @@ import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.google.common.collect.HashMultimap;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingIngredientError;
@ -133,37 +135,50 @@ public class RecipeHandler implements IRecipeHandler
{
ZipOutputStream out = new ZipOutputStream( new FileOutputStream( "recipes.zip" ) );
HashMultimap<String, IWebsiteSeralizer> combined = HashMultimap.create();
for (String s : data.knownItem)
{
try
{
try {
Ingredient i = new Ingredient( this, s, 1 );
for (ItemStack is : i.getItemStackSet())
{
String realName = getName( is );
List<IWebsiteSeralizer> recipes = findRecipe( is );
if ( !recipes.isEmpty() )
combined.putAll(realName, recipes);
}
} catch (RecipeError e1) {
} catch (MissedIngredientSet e1) {
} catch (RegistrationError e1) {
} catch (MissingIngredientError e1) {
}
}
for ( String realName : combined.keySet() )
{
int offset = 0;
String realName = getName( is );
for (IWebsiteSeralizer ws : recipes)
for ( IWebsiteSeralizer ws : combined.get(realName) )
{
String rew = ws.getPattern( this );
if ( rew != null && rew.length() > 0 )
{
out.putNextEntry( new ZipEntry( realName + "_" + offset + ".txt" ) );
offset++;
out.write( ws.getPattern( this ).getBytes() );
out.write( rew.getBytes() );
}
}
}
}
catch (Throwable t)
{
// :P
}
}
out.close();
}
catch (FileNotFoundException e1)
{
@ -256,7 +271,7 @@ public class RecipeHandler implements IRecipeHandler
switch (is.getItemDamage())
{
case 1:
realName = realName.replace( "blockCraftingUnit", "blockCraftingAccelerator" );
realName = realName.replace( "Unit", "Accelerator" );
break;
default:
}
@ -585,7 +600,6 @@ public class RecipeHandler implements IRecipeHandler
if ( gi != null )
return gi.copy( qty );
data.knownItem.add( v );
try
{
return new Ingredient( this, v, qty );

View file

@ -93,6 +93,21 @@ public class Shaped implements ICraftHandler, IWebsiteSeralizer
@Override
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError
{
for (int y = 0; y < rows; y++)
for (int x = 0; x < cols; x++)
{
IIngredient i = inputs.get( y ).get( x );
if ( !i.isAir() )
{
for ( ItemStack r : i.getItemStackSet() )
{
if ( Platform.isSameItemPrecise( r, reqOutput) )
return false;
}
}
}
return Platform.isSameItemPrecise( output.getItemStack(), reqOutput );
}

View file

@ -60,6 +60,20 @@ public class Shapeless implements ICraftHandler, IWebsiteSeralizer
@Override
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
for ( int y = 0; y < inputs.size(); y++ )
{
IIngredient i = inputs.get(y);
if ( !i.isAir() )
{
for ( ItemStack r : i.getItemStackSet() )
{
if ( Platform.isSameItemPrecise( r, reqOutput) )
return false;
}
}
}
return Platform.isSameItemPrecise( output.getItemStack(),reqOutput );
}