Website Recipe Exporter.
This commit is contained in:
parent
040e948d8e
commit
e8ec768d4c
13 changed files with 257 additions and 11 deletions
|
@ -48,7 +48,7 @@ public enum AEFeature
|
||||||
|
|
||||||
DuplicateItems("Misc", false), Profiler("Services", false), VersionChecker("Services"), Debug("Misc", false), Creative("Misc"),
|
DuplicateItems("Misc", false), Profiler("Services", false), VersionChecker("Services"), Debug("Misc", false), Creative("Misc"),
|
||||||
|
|
||||||
Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false),
|
Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc",false),
|
||||||
|
|
||||||
inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting");
|
inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting");
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package appeng.recipes;
|
package appeng.recipes;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
|
|
||||||
|
@ -18,4 +20,6 @@ public class RecipeData
|
||||||
public boolean exceptions = true;
|
public boolean exceptions = true;
|
||||||
public boolean erroronmissing = true;
|
public boolean erroronmissing = true;
|
||||||
|
|
||||||
|
public Set<String> knownItem = new HashSet();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
package appeng.recipes;
|
package appeng.recipes;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
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 appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.exceptions.MissingIngredientError;
|
import appeng.api.exceptions.MissingIngredientError;
|
||||||
|
@ -15,7 +25,12 @@ import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
import appeng.api.recipes.IRecipeHandler;
|
import appeng.api.recipes.IRecipeHandler;
|
||||||
import appeng.api.recipes.IRecipeLoader;
|
import appeng.api.recipes.IRecipeLoader;
|
||||||
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.items.materials.ItemMaterial;
|
||||||
|
import appeng.items.parts.ItemPart;
|
||||||
|
import appeng.recipes.handlers.IWebsiteSeralizer;
|
||||||
import appeng.recipes.handlers.OreRegistration;
|
import appeng.recipes.handlers.OreRegistration;
|
||||||
|
|
||||||
public class RecipeHandler implements IRecipeHandler
|
public class RecipeHandler implements IRecipeHandler
|
||||||
|
@ -37,6 +52,28 @@ public class RecipeHandler implements IRecipeHandler
|
||||||
data.Handlers.add( ch );
|
data.Handlers.add( ch );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IWebsiteSeralizer> findRecipe( ItemStack output )
|
||||||
|
{
|
||||||
|
List<IWebsiteSeralizer> out = new LinkedList<IWebsiteSeralizer>();
|
||||||
|
|
||||||
|
for ( ICraftHandler ch : data.Handlers )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( ch instanceof IWebsiteSeralizer && ch.canCraft(output))
|
||||||
|
{
|
||||||
|
out.add((IWebsiteSeralizer)ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable t )
|
||||||
|
{
|
||||||
|
AELog.error(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerHandlers()
|
public void registerHandlers()
|
||||||
{
|
{
|
||||||
|
@ -89,6 +126,81 @@ 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) )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("recipes.zip"));
|
||||||
|
|
||||||
|
for ( String s : data.knownItem )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Ingredient i = new Ingredient( this, s, 1 );
|
||||||
|
for ( ItemStack is : i.getItemStackSet() )
|
||||||
|
{
|
||||||
|
List<IWebsiteSeralizer> recipes = findRecipe(is);
|
||||||
|
if ( !recipes.isEmpty() )
|
||||||
|
{
|
||||||
|
int offset =0;
|
||||||
|
String realName = getName(is);
|
||||||
|
|
||||||
|
for ( IWebsiteSeralizer ws : recipes )
|
||||||
|
{
|
||||||
|
out.putNextEntry(new ZipEntry(realName+"_"+offset+".txt"));
|
||||||
|
offset++;
|
||||||
|
out.write(ws.getPattern(this).getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Throwable t )
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e1) {
|
||||||
|
AELog.error(e1);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
AELog.error(e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName( IIngredient i )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getName( i.getItemStack() );
|
||||||
|
}
|
||||||
|
catch (Throwable t )
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
|
|
||||||
|
return i.getNameSpace()+":"+i.getItemName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName(ItemStack is) {
|
||||||
|
|
||||||
|
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(is.getItem());
|
||||||
|
String realName = id.modId+":"+id.name;
|
||||||
|
|
||||||
|
if ( is.getItem() instanceof ItemMaterial )
|
||||||
|
realName += ":"+( (ItemMaterial)is.getItem() ).getType(is).name();
|
||||||
|
else if ( is.getItem() instanceof ItemPart )
|
||||||
|
realName += ":"+( (ItemPart)is.getItem() ).getTypeByStack(is).name();
|
||||||
|
else if ( is.getItemDamage() > 0 )
|
||||||
|
realName += ":"+is.getItemDamage();
|
||||||
|
|
||||||
|
return realName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String alias(String in)
|
public String alias(String in)
|
||||||
|
@ -380,8 +492,11 @@ 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 );
|
||||||
return new Ingredient( this, v, qty );
|
return new Ingredient( this, v, qty );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,4 +514,5 @@ public class RecipeHandler implements IRecipeHandler
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package appeng.recipes.Recipes;
|
package appeng.recipes.game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
|
@ -1,4 +1,4 @@
|
||||||
package appeng.recipes.Recipes;
|
package appeng.recipes.game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
|
@ -9,8 +9,10 @@ import appeng.api.exceptions.RecipeError;
|
||||||
import appeng.api.exceptions.RegistrationError;
|
import appeng.api.exceptions.RegistrationError;
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class Grind implements ICraftHandler
|
public class Grind implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
IIngredient pro_input;
|
IIngredient pro_input;
|
||||||
|
@ -39,4 +41,16 @@ public class Grind implements ICraftHandler
|
||||||
AEApi.instance().registries().grinder().addRecipe( is, pro_output[0].getItemStack(), 8 );
|
AEApi.instance().registries().grinder().addRecipe( is, pro_output[0].getItemStack(), 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( pro_output[0].getItemStack(),output );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h ) {
|
||||||
|
return "grind\n"+
|
||||||
|
h.getName(pro_input)+"\n"+
|
||||||
|
h.getName(pro_output[0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
9
recipes/handlers/IWebsiteSeralizer.java
Normal file
9
recipes/handlers/IWebsiteSeralizer.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package appeng.recipes.handlers;
|
||||||
|
|
||||||
|
import appeng.recipes.RecipeHandler;
|
||||||
|
|
||||||
|
public interface IWebsiteSeralizer {
|
||||||
|
|
||||||
|
String getPattern( RecipeHandler han );
|
||||||
|
|
||||||
|
}
|
|
@ -10,8 +10,10 @@ import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.integration.abstraction.IIC2;
|
import appeng.integration.abstraction.IIC2;
|
||||||
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class Macerator implements ICraftHandler
|
public class Macerator implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
IIngredient pro_input;
|
IIngredient pro_input;
|
||||||
|
@ -44,4 +46,16 @@ public class Macerator implements ICraftHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( pro_output[0].getItemStack(),output );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h ) {
|
||||||
|
return "macerator\n"+
|
||||||
|
h.getName(pro_input)+"\n"+
|
||||||
|
h.getName(pro_output[0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,10 @@ public class OreRegistration implements ICraftHandler
|
||||||
List<List<IIngredient>> output) throws RecipeError {
|
List<List<IIngredient>> output) throws RecipeError {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@ import appeng.api.exceptions.RecipeError;
|
||||||
import appeng.api.exceptions.RegistrationError;
|
import appeng.api.exceptions.RegistrationError;
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||||
|
|
||||||
public class Pulverizer implements ICraftHandler
|
public class Pulverizer implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
IIngredient pro_input;
|
IIngredient pro_input;
|
||||||
|
@ -49,4 +51,17 @@ public class Pulverizer implements ICraftHandler
|
||||||
FMLInterModComms.sendMessage( "ThermalExpansion", "PulverizerRecipe", toSend );
|
FMLInterModComms.sendMessage( "ThermalExpansion", "PulverizerRecipe", toSend );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( pro_output[0].getItemStack(),output );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h ) {
|
||||||
|
return "pulverizer\n"+
|
||||||
|
h.getName(pro_input)+"\n"+
|
||||||
|
h.getName(pro_output[0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,12 @@ import appeng.api.exceptions.RegistrationError;
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.recipes.Recipes.ShapedRecipe;
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.recipes.game.ShapedRecipe;
|
||||||
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
public class Shaped implements ICraftHandler
|
public class Shaped implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
private int rows;
|
private int rows;
|
||||||
|
@ -87,4 +89,29 @@ public class Shaped implements ICraftHandler
|
||||||
throw new RegistrationError( "Error while adding shaped recipe." );
|
throw new RegistrationError( "Error while adding shaped recipe." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( output.getItemStack(),reqOutput );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h ) {
|
||||||
|
String o = "shaped "+output.getQty()+"\n";
|
||||||
|
|
||||||
|
o += h.getName(output)+"\n";
|
||||||
|
|
||||||
|
for ( int y = 0; y < rows; y++ )
|
||||||
|
for ( int x= 0; x< cols; x++ )
|
||||||
|
{
|
||||||
|
IIngredient i = inputs.get(y).get(x);
|
||||||
|
if ( i.isAir() )
|
||||||
|
o += "air"+( x +1 == cols ? "\n" : " " );
|
||||||
|
else
|
||||||
|
o += h.getName(i)+( x +1 == cols ? "\n" : " " );
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.trim();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,12 @@ import appeng.api.exceptions.RegistrationError;
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.recipes.Recipes.ShapelessRecipe;
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.recipes.game.ShapelessRecipe;
|
||||||
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
public class Shapeless implements ICraftHandler
|
public class Shapeless implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
List<IIngredient> inputs;
|
List<IIngredient> inputs;
|
||||||
|
@ -55,4 +57,28 @@ public class Shapeless implements ICraftHandler
|
||||||
throw new RegistrationError( "Erro while adding shapeless recipe." );
|
throw new RegistrationError( "Erro while adding shapeless recipe." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( output.getItemStack(),reqOutput );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h) {
|
||||||
|
String o = "shapeless "+output.getQty()+"\n";
|
||||||
|
|
||||||
|
o += h.getName(output)+"\n";
|
||||||
|
|
||||||
|
for ( int y = 0; y < inputs.size(); y++ )
|
||||||
|
{
|
||||||
|
IIngredient i = inputs.get(y);
|
||||||
|
if ( i.isAir() )
|
||||||
|
o += "air"+( y +1 == inputs.size() ? "\n" : " " );
|
||||||
|
else
|
||||||
|
o += h.getName(i)+( y +1 == inputs.size() ? "\n" : " " );
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.trim();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,18 @@ package appeng.recipes.handlers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import appeng.api.exceptions.MissingIngredientError;
|
import appeng.api.exceptions.MissingIngredientError;
|
||||||
import appeng.api.exceptions.RecipeError;
|
import appeng.api.exceptions.RecipeError;
|
||||||
import appeng.api.exceptions.RegistrationError;
|
import appeng.api.exceptions.RegistrationError;
|
||||||
import appeng.api.recipes.ICraftHandler;
|
import appeng.api.recipes.ICraftHandler;
|
||||||
import appeng.api.recipes.IIngredient;
|
import appeng.api.recipes.IIngredient;
|
||||||
|
import appeng.recipes.RecipeHandler;
|
||||||
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
public class Smelt implements ICraftHandler
|
public class Smelt implements ICraftHandler, IWebsiteSeralizer
|
||||||
{
|
{
|
||||||
|
|
||||||
IIngredient in;
|
IIngredient in;
|
||||||
|
@ -44,4 +48,15 @@ public class Smelt implements ICraftHandler
|
||||||
GameRegistry.addSmelting( in.getItemStack(), out.getItemStack(), 0 );
|
GameRegistry.addSmelting( in.getItemStack(), out.getItemStack(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
|
||||||
|
return Platform.isSameItemPrecise( out.getItemStack(),reqOutput );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPattern( RecipeHandler h ) {
|
||||||
|
return "smelt "+out.getQty()+"\n"+
|
||||||
|
h.getName(in)+"\n"+
|
||||||
|
h.getName(out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue