Recipe API Update.

This commit is contained in:
AlgorithmX2
2014-02-19 17:33:36 -06:00
parent 85b053f6b5
commit bea8f2cc07
26 changed files with 292 additions and 203 deletions
+1 -1
Submodule api updated: 5eac4a9b50...7834e09f34
+1 -8
View File
@@ -12,14 +12,12 @@ import appeng.api.networking.IGridBlock;
import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartHelper;
import appeng.api.recipes.IRecipeHandler;
import appeng.api.storage.IStorageHelper; import appeng.api.storage.IStorageHelper;
import appeng.core.api.ApiPart; import appeng.core.api.ApiPart;
import appeng.core.api.ApiStorage; import appeng.core.api.ApiStorage;
import appeng.core.features.registries.RegistryContainer; import appeng.core.features.registries.RegistryContainer;
import appeng.me.GridConnection; import appeng.me.GridConnection;
import appeng.me.GridNode; import appeng.me.GridNode;
import appeng.recipes.RecipeHandler;
import appeng.util.Platform; import appeng.util.Platform;
public class Api implements IAppEngApi public class Api implements IAppEngApi
@@ -34,6 +32,7 @@ public class Api implements IAppEngApi
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry(); // private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
private RegistryContainer rc = new RegistryContainer(); private RegistryContainer rc = new RegistryContainer();
private ApiStorage storageHelper = new ApiStorage(); private ApiStorage storageHelper = new ApiStorage();
public ApiPart partHelper = new ApiPart(); public ApiPart partHelper = new ApiPart();
private Materials materials = new Materials(); private Materials materials = new Materials();
@@ -97,10 +96,4 @@ public class Api implements IAppEngApi
return new GridConnection( a, b, ForgeDirection.UNKNOWN ); return new GridConnection( a, b, ForgeDirection.UNKNOWN );
} }
@Override
public IRecipeHandler createNewRecipeHandler()
{
return new RecipeHandler();
}
} }
+21 -21
View File
@@ -63,28 +63,28 @@ public class AppEng
private IntegrationRegistry integrationModules = new IntegrationRegistry( new Object[] { private IntegrationRegistry integrationModules = new IntegrationRegistry( new Object[] {
/** /**
* Display Name, ModID ClassPostFix * Side, Display Name, ModID ClassPostFix
*/ */
IntegrationSide.BOTH, "Industrial Craft 2", "IC2", "IC2", // IC2 IntegrationSide.BOTH, "Industrial Craft 2", "IC2", "IC2", // IC2
IntegrationSide.BOTH, "Railcraft", "Railcraft", "RC", // RC //IntegrationSide.BOTH, "Railcraft", "Railcraft", "RC", // RC
IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE", // TE //IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE", // TE
IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft", // MC //IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft", // MC
IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC", // BC IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC", // BC
IntegrationSide.BOTH, "BuildCraft Power", null, "MJ", // BC IntegrationSide.BOTH, "BuildCraft Power", null, "MJ", // BC
IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT", // GT //IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT", // GT
IntegrationSide.BOTH, "Universal Electricity", null, "UE", // UE //IntegrationSide.BOTH, "Universal Electricity", null, "UE", // UE
IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP", // LP //IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP", // LP
// IntegrationSide.CLIENT, "Inventory Tweaks", "", "InvTweaks", // IntegrationSide.CLIENT, "Inventory Tweaks", "", "InvTweaks", // InvTweaks
// IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR", // MFR // IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR", // MFR
IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU", // DSU IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU", // DSU
IntegrationSide.BOTH, "Better Storage", "betterstorage", "BS", // BS //IntegrationSide.BOTH, "Better Storage", "betterstorage", "BS", // BS
IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ //IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ
IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry //IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry
IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK //IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK
IntegrationSide.CLIENT, "Not Enought Items", "NotEnoughItems", "NEI", // Not //IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila
// Eneough //IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI
// Items //IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" // FMP
IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" } ); });
public boolean isIntegrationEnabled(String Name) public boolean isIntegrationEnabled(String Name)
{ {
+13
View File
@@ -15,6 +15,7 @@ import appeng.api.definitions.Blocks;
import appeng.api.definitions.Items; import appeng.api.definitions.Items;
import appeng.api.definitions.Materials; import appeng.api.definitions.Materials;
import appeng.api.definitions.Parts; import appeng.api.definitions.Parts;
import appeng.api.features.IRecipeHandlerRegistry;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.networking.IGridCacheRegistry; import appeng.api.networking.IGridCacheRegistry;
import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.energy.IEnergyGrid;
@@ -113,6 +114,11 @@ import appeng.me.storage.AEExternalHandler;
import appeng.recipes.RecipeHandler; import appeng.recipes.RecipeHandler;
import appeng.recipes.Recipes.ShapedRecipe; import appeng.recipes.Recipes.ShapedRecipe;
import appeng.recipes.Recipes.ShapelessRecipe; import appeng.recipes.Recipes.ShapelessRecipe;
import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.Pureify;
import appeng.recipes.handlers.Shaped;
import appeng.recipes.handlers.Shapeless;
import appeng.recipes.handlers.Smelt;
import appeng.recipes.loader.ConfigLoader; import appeng.recipes.loader.ConfigLoader;
import appeng.recipes.loader.JarLoader; import appeng.recipes.loader.JarLoader;
import appeng.recipes.ores.OreDictionaryHandler; import appeng.recipes.ores.OreDictionaryHandler;
@@ -143,6 +149,13 @@ public class Registration
public void PreInit(FMLPreInitializationEvent event) public void PreInit(FMLPreInitializationEvent event)
{ {
IRecipeHandlerRegistry recipeRegistery = AEApi.instance().registries().recipes();
recipeRegistery.addNewCraftHandler("grind", Grind.class);
recipeRegistery.addNewCraftHandler("shaped", Shaped.class);
recipeRegistery.addNewCraftHandler("shapeless", Shapeless.class);
recipeRegistery.addNewCraftHandler("smelt", Smelt.class);
recipeRegistery.addNewCraftHandler("pureify", Pureify.class);
RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" ); RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" );
RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" ); RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" );
@@ -0,0 +1,39 @@
package appeng.core.features.registries;
import java.util.HashMap;
import appeng.api.features.IRecipeHandlerRegistry;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler;
import appeng.core.AELog;
import appeng.recipes.RecipeHandler;
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry{
HashMap<String,Class<? extends ICraftHandler>> handlers = new HashMap<String, Class<? extends ICraftHandler >>();
@Override
public void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler) {
handlers.put(name.toLowerCase(), handler);
}
@Override
public ICraftHandler getCraftHandlerFor(String name) {
Class<? extends ICraftHandler> clz= handlers.get(name);
if ( clz == null ) return null;
try {
return clz.newInstance();
} catch (Throwable e) {
AELog.severe("Error Caused when trying to construct "+clz.getName());
AELog.error(e);
handlers.put(name, null); // clear it..
return null;
}
}
@Override
public IRecipeHandler createNewRecipehandler() {
return new RecipeHandler();
}
}
@@ -5,6 +5,7 @@ import appeng.api.features.ILocateableRegistry;
import appeng.api.features.IMatterCannonAmmoRegistry; import appeng.api.features.IMatterCannonAmmoRegistry;
import appeng.api.features.IP2PTunnelRegistry; import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.features.IPlayerRegistry; import appeng.api.features.IPlayerRegistry;
import appeng.api.features.IRecipeHandlerRegistry;
import appeng.api.features.IRegistryContainer; import appeng.api.features.IRegistryContainer;
import appeng.api.features.ISpecialComparisonRegistry; import appeng.api.features.ISpecialComparisonRegistry;
import appeng.api.features.IWirelessTermRegistery; import appeng.api.features.IWirelessTermRegistery;
@@ -27,6 +28,7 @@ public class RegistryContainer implements IRegistryContainer
private MovableTileRegistry MoveableReg = new MovableTileRegistry(); private MovableTileRegistry MoveableReg = new MovableTileRegistry();
private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry(); private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
private PlayerRegistry playerreg = new PlayerRegistry(); private PlayerRegistry playerreg = new PlayerRegistry();
private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
@Override @Override
public IWirelessTermRegistery wireless() public IWirelessTermRegistery wireless()
@@ -94,4 +96,9 @@ public class RegistryContainer implements IRegistryContainer
return playerreg; return playerreg;
} }
@Override
public IRecipeHandlerRegistry recipes() {
return recipeReg;
}
} }
+7 -1
View File
@@ -1,10 +1,16 @@
package appeng.integration; package appeng.integration;
public class BaseModule { public abstract class BaseModule implements IIntegrationModule {
protected void TestClass( Class clz ) protected void TestClass( Class clz )
{ {
clz.isInstance(this); clz.isInstance(this);
} }
@Override
public abstract void Init() throws Throwable;
@Override
public abstract void PostInit() throws Throwable;
} }
-6
View File
@@ -1,6 +0,0 @@
package appeng.integration.abstraction;
public interface IUE
{
}
+1 -3
View File
@@ -13,10 +13,8 @@ import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IFacadePart; import appeng.api.parts.IFacadePart;
import appeng.facade.FacadePart; import appeng.facade.FacadePart;
import appeng.integration.BaseModule; import appeng.integration.BaseModule;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.IBC; import appeng.integration.abstraction.IBC;
import appeng.integration.modules.helpers.BCPipeHandler; import appeng.integration.modules.helpers.BCPipeHandler;
import appeng.integration.modules.helpers.MJPerdition;
import buildcraft.BuildCraftEnergy; import buildcraft.BuildCraftEnergy;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
@@ -28,7 +26,7 @@ import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TileGenericPipe;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms;
public class BC extends BaseModule implements IIntegrationModule, IBC public class BC extends BaseModule implements IBC
{ {
public static BC instance; public static BC instance;
+60
View File
@@ -0,0 +1,60 @@
package appeng.integration.modules;
import java.util.List;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.event.FMLInterModComms;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import appeng.block.AEBaseBlock;
import appeng.core.AppEng;
import appeng.integration.BaseModule;
public class Waila extends BaseModule implements IWailaDataProvider {
public static void yourRegistrationMethod(IWailaRegistrar registrar)
{
registrar.registerHeadProvider( (Waila)AppEng.instance.getIntegration("Waila"), AEBaseBlock.class);
registrar.registerBodyProvider( (Waila)AppEng.instance.getIntegration("Waila"), AEBaseBlock.class);
registrar.registerTailProvider( (Waila)AppEng.instance.getIntegration("Waila"), AEBaseBlock.class);
}
@Override
public void Init() throws Throwable {
TestClass( IWailaDataProvider.class );
TestClass( IWailaRegistrar.class );
FMLInterModComms.sendMessage("Waila", "register", "mcp.mobius.waila_demo.ProviderDemo.callbackRegister");
}
@Override
public void PostInit() throws Throwable {
// :P
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
currenttip.add("AE2 Says Hi");
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
-24
View File
@@ -1,24 +0,0 @@
package appeng.integration.modules.dead;
import appeng.integration.IIntegrationModule;
public class UE implements IIntegrationModule
{
public static UE instance;
@Override
public void Init()
{
// TODO Auto-generated method stub
}
@Override
public void PostInit()
{
// TODO Auto-generated method stub
}
}
+33 -2
View File
@@ -6,13 +6,17 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.IIngredient;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.items.materials.MaterialType; import appeng.items.materials.MaterialType;
import appeng.items.parts.ItemPart; import appeng.items.parts.ItemPart;
import appeng.items.parts.PartType; import appeng.items.parts.PartType;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
public class Ingredient public class Ingredient implements IIngredient
{ {
final public boolean isAir; final public boolean isAir;
@@ -106,6 +110,7 @@ public class Ingredient
throw new RecipeError( input + " : Needs at least Namespace and Name." ); throw new RecipeError( input + " : Needs at least Namespace and Name." );
} }
@Override
public ItemStack getItemStack() throws RegistrationError, MissingIngredientError public ItemStack getItemStack() throws RegistrationError, MissingIngredientError
{ {
if ( isAir ) if ( isAir )
@@ -150,7 +155,8 @@ public class Ingredient
return nameSpace + ":" + itemName + ":" + meta; return nameSpace + ":" + itemName + ":" + meta;
} }
public ItemStack[] getSet() throws RegistrationError, MissingIngredientError @Override
public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError
{ {
if ( nameSpace.equalsIgnoreCase( "oreDictionary" ) ) if ( nameSpace.equalsIgnoreCase( "oreDictionary" ) )
{ {
@@ -171,4 +177,29 @@ public class Ingredient
return new ItemStack[] { getItemStack() }; return new ItemStack[] { getItemStack() };
} }
@Override
public String getNameSpace() {
return nameSpace;
}
@Override
public String getItemName() {
return itemName;
}
@Override
public int getDamageValue() {
return meta;
}
@Override
public int getQty() {
return qty;
}
@Override
public boolean isAir() {
return isAir;
}
} }
-11
View File
@@ -1,11 +0,0 @@
package appeng.recipes;
public class MissingIngredientError extends Exception {
private static final long serialVersionUID = -998858343831371697L;
public MissingIngredientError(String n) {
super( n );
}
}
+2 -2
View File
@@ -4,13 +4,13 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import appeng.recipes.handlers.CraftHandler; import appeng.api.recipes.ICraftHandler;
public class RecipeData public class RecipeData
{ {
final public HashMap<String, String> aliases = new HashMap<String, String>(); final public HashMap<String, String> aliases = new HashMap<String, String>();
final public List<CraftHandler> Handlers = new LinkedList<CraftHandler>(); final public List<ICraftHandler> Handlers = new LinkedList<ICraftHandler>();
public boolean crash = true; public boolean crash = true;
public boolean erroronmissing = true; public boolean erroronmissing = true;
-12
View File
@@ -1,12 +0,0 @@
package appeng.recipes;
public class RecipeError extends Exception
{
private static final long serialVersionUID = -6602870588617670262L;
public RecipeError(String n) {
super( n );
}
}
+21 -24
View File
@@ -6,10 +6,16 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.features.IRecipeHandlerRegistry;
import appeng.api.recipes.ICraftHandler;
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.AELog; import appeng.core.AELog;
import appeng.recipes.handlers.CraftHandler;
import appeng.recipes.handlers.Grind; import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.OreRegistration; import appeng.recipes.handlers.OreRegistration;
import appeng.recipes.handlers.Pureify; import appeng.recipes.handlers.Pureify;
@@ -31,7 +37,7 @@ public class RecipeHandler implements IRecipeHandler
data = parent.data; data = parent.data;
} }
private void addCrafting(CraftHandler ch) private void addCrafting(ICraftHandler ch)
{ {
data.Handlers.add( ch ); data.Handlers.add( ch );
} }
@@ -42,7 +48,7 @@ public class RecipeHandler implements IRecipeHandler
HashMap<Class, Integer> processed = new HashMap<Class, Integer>(); HashMap<Class, Integer> processed = new HashMap<Class, Integer>();
try try
{ {
for (CraftHandler ch : data.Handlers) for (ICraftHandler ch : data.Handlers)
{ {
try try
{ {
@@ -206,6 +212,8 @@ public class RecipeHandler implements IRecipeHandler
{ {
try try
{ {
IRecipeHandlerRegistry cr = AEApi.instance().registries().recipes();
if ( tokens.isEmpty() ) if ( tokens.isEmpty() )
return; return;
@@ -226,7 +234,7 @@ public class RecipeHandler implements IRecipeHandler
List<String> pre = tokens.subList( 0, split - 1 ); List<String> pre = tokens.subList( 0, split - 1 );
List<String> post = tokens.subList( split, tokens.size() ); List<String> post = tokens.subList( split, tokens.size() );
List<List<Ingredient>> inputs = parseLines( pre ); List<List<IIngredient>> inputs = parseLines( pre );
if ( inputs.size() >= 1 && post.size() == 1 ) if ( inputs.size() >= 1 && post.size() == 1 )
{ {
@@ -240,11 +248,11 @@ public class RecipeHandler implements IRecipeHandler
List<String> pre = tokens.subList( 0, split - 1 ); List<String> pre = tokens.subList( 0, split - 1 );
List<String> post = tokens.subList( split, tokens.size() ); List<String> post = tokens.subList( split, tokens.size() );
List<List<Ingredient>> inputs = parseLines( pre ); List<List<IIngredient>> inputs = parseLines( pre );
if ( inputs.size() == 1 && inputs.get( 0 ).size() > 0 && post.size() == 1 ) if ( inputs.size() == 1 && inputs.get( 0 ).size() > 0 && post.size() == 1 )
{ {
CraftHandler ch = new OreRegistration( inputs.get( 0 ), post.get( 0 ) ); ICraftHandler ch = new OreRegistration( inputs.get( 0 ), post.get( 0 ) );
addCrafting( ch ); addCrafting( ch );
} }
else else
@@ -255,21 +263,10 @@ public class RecipeHandler implements IRecipeHandler
List<String> pre = tokens.subList( 0, split - 1 ); List<String> pre = tokens.subList( 0, split - 1 );
List<String> post = tokens.subList( split, tokens.size() ); List<String> post = tokens.subList( split, tokens.size() );
List<List<Ingredient>> inputs = parseLines( pre ); List<List<IIngredient>> inputs = parseLines( pre );
List<List<Ingredient>> outputs = parseLines( post ); List<List<IIngredient>> outputs = parseLines( post );
CraftHandler ch = null; ICraftHandler ch = cr.getCraftHandlerFor(operation);
if ( operation.equals( "shaped" ) )
ch = new Shaped();
else if ( operation.equals( "shapeless" ) )
ch = new Shapeless();
else if ( operation.equals( "smelt" ) )
ch = new Smelt();
else if ( operation.equals( "pureify" ) )
ch = new Pureify();
else if ( operation.equals( "grind" ) )
ch = new Grind();
if ( ch != null ) if ( ch != null )
{ {
@@ -325,10 +322,10 @@ public class RecipeHandler implements IRecipeHandler
tokens.clear(); tokens.clear();
} }
private List<List<Ingredient>> parseLines(List<String> subList) throws RecipeError private List<List<IIngredient>> parseLines(List<String> subList) throws RecipeError
{ {
List<List<Ingredient>> out = new LinkedList<List<Ingredient>>(); List<List<IIngredient>> out = new LinkedList<List<IIngredient>>();
List<Ingredient> cList = new LinkedList<Ingredient>(); List<IIngredient> cList = new LinkedList<IIngredient>();
boolean hasQty = false; boolean hasQty = false;
int qty = 1; int qty = 1;
@@ -341,7 +338,7 @@ public class RecipeHandler implements IRecipeHandler
throw new RecipeError( "Qty found with no item." ); throw new RecipeError( "Qty found with no item." );
if ( !cList.isEmpty() ) if ( !cList.isEmpty() )
out.add( cList ); out.add( cList );
cList = new LinkedList<Ingredient>(); cList = new LinkedList<IIngredient>();
} }
else else
{ {
-12
View File
@@ -1,12 +0,0 @@
package appeng.recipes;
public class RegistrationError extends Exception
{
private static final long serialVersionUID = -6602870588617670263L;
public RegistrationError(String n) {
super( n );
}
}
-21
View File
@@ -1,21 +0,0 @@
package appeng.recipes.handlers;
import java.util.List;
import appeng.recipes.Ingredient;
import appeng.recipes.MissingIngredientError;
import appeng.recipes.RecipeError;
import appeng.recipes.RegistrationError;
public class CraftHandler
{
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError
{
}
public void register() throws RegistrationError, MissingIngredientError
{
}
}
+22 -1
View File
@@ -1,6 +1,27 @@
package appeng.recipes.handlers; package appeng.recipes.handlers;
public class Grind extends CraftHandler import java.util.List;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
public class Grind implements ICraftHandler
{ {
@Override
public void setup(List<List<IIngredient>> input,
List<List<IIngredient>> output) throws RecipeError {
// TODO Auto-generated method stub
}
@Override
public void register() throws RegistrationError, MissingIngredientError {
// TODO Auto-generated method stub
}
} }
+16 -8
View File
@@ -4,17 +4,19 @@ import java.util.List;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import appeng.recipes.Ingredient; import appeng.api.exceptions.MissingIngredientError;
import appeng.recipes.MissingIngredientError; import appeng.api.exceptions.RecipeError;
import appeng.recipes.RegistrationError; import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
public class OreRegistration extends CraftHandler public class OreRegistration implements ICraftHandler
{ {
List<Ingredient> inputs; List<IIngredient> inputs;
String name; String name;
public OreRegistration(List<Ingredient> in, String out) { public OreRegistration(List<IIngredient> in, String out) {
inputs = in; inputs = in;
name = out; name = out;
} }
@@ -22,12 +24,18 @@ public class OreRegistration extends CraftHandler
@Override @Override
public void register() throws RegistrationError, MissingIngredientError public void register() throws RegistrationError, MissingIngredientError
{ {
for (Ingredient i : inputs) for (IIngredient i : inputs)
{ {
for (ItemStack is : i.getSet()) for (ItemStack is : i.getItemStackSet())
{ {
OreDictionary.registerOre( name, is ); OreDictionary.registerOre( name, is );
} }
} }
} }
@Override
public void setup(List<List<IIngredient>> input,
List<List<IIngredient>> output) throws RecipeError {
}
} }
+12 -11
View File
@@ -2,24 +2,25 @@ package appeng.recipes.handlers;
import java.util.List; import java.util.List;
import appeng.recipes.Ingredient; import appeng.api.exceptions.MissingIngredientError;
import appeng.recipes.MissingIngredientError; import appeng.api.exceptions.RecipeError;
import appeng.recipes.RecipeError; import appeng.api.exceptions.RegistrationError;
import appeng.recipes.RegistrationError; import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
public class Pureify extends CraftHandler public class Pureify implements ICraftHandler
{ {
Ingredient in; IIngredient in;
Ingredient out; IIngredient out;
@Override @Override
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
{ {
if ( input.size() == 1 && output.size() == 1 ) if ( input.size() == 1 && output.size() == 1 )
{ {
List<Ingredient> inputList = input.get( 0 ); List<IIngredient> inputList = input.get( 0 );
List<Ingredient> outputList = output.get( 0 ); List<IIngredient> outputList = output.get( 0 );
if ( inputList.size() == 1 && outputList.size() == 1 ) if ( inputList.size() == 1 && outputList.size() == 1 )
{ {
in = inputList.get( 0 ); in = inputList.get( 0 );
@@ -33,7 +34,7 @@ public class Pureify extends CraftHandler
@Override @Override
public void register() throws RegistrationError, MissingIngredientError public void register() throws RegistrationError, MissingIngredientError
{ {
if ( in.getSet() == null ) if ( in.getItemStackSet() == null )
throw new RegistrationError( in.toString() + ": Pureify Input is not a valid item." ); throw new RegistrationError( in.toString() + ": Pureify Input is not a valid item." );
if ( out.getItemStack().getItem() == null ) if ( out.getItemStack().getItem() == null )
+12 -11
View File
@@ -4,25 +4,26 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.recipes.Ingredient;
import appeng.recipes.MissingIngredientError;
import appeng.recipes.RecipeError;
import appeng.recipes.RegistrationError;
import appeng.recipes.Recipes.ShapedRecipe; import appeng.recipes.Recipes.ShapedRecipe;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
public class Shaped extends CraftHandler public class Shaped implements ICraftHandler
{ {
private int rows; private int rows;
private int cols; private int cols;
List<List<Ingredient>> inputs; List<List<IIngredient>> inputs;
Ingredient output; IIngredient output;
@Override @Override
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
{ {
if ( output.size() == 1 && output.get( 0 ).size() == 1 ) if ( output.size() == 1 && output.get( 0 ).size() == 1 )
{ {
@@ -48,20 +49,20 @@ public class Shaped extends CraftHandler
public void register() throws RegistrationError, MissingIngredientError public void register() throws RegistrationError, MissingIngredientError
{ {
char first = 'A'; char first = 'A';
List<Object> args = new ArrayList(); List<Object> args = new ArrayList<Object>();
for (int y = 0; y < rows; y++) for (int y = 0; y < rows; y++)
{ {
String row = ""; String row = "";
for (int x = 0; x < cols; x++) for (int x = 0; x < cols; x++)
{ {
if ( inputs.get( y ).get( x ).isAir ) if ( inputs.get( y ).get( x ).isAir() )
row = row + " "; row = row + " ";
else else
{ {
row = row + first; row = row + first;
args.add( first ); args.add( first );
args.add( inputs.get( y ).get( x ).getSet() ); args.add( inputs.get( y ).get( x ).getItemStackSet() );
first++; first++;
} }
+12 -11
View File
@@ -4,22 +4,23 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.recipes.Ingredient;
import appeng.recipes.MissingIngredientError;
import appeng.recipes.RecipeError;
import appeng.recipes.RegistrationError;
import appeng.recipes.Recipes.ShapelessRecipe; import appeng.recipes.Recipes.ShapelessRecipe;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
public class Shapeless extends CraftHandler public class Shapeless implements ICraftHandler
{ {
List<Ingredient> inputs; List<IIngredient> inputs;
Ingredient output; IIngredient output;
@Override @Override
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
{ {
if ( output.size() == 1 && output.get( 0 ).size() == 1 ) if ( output.size() == 1 && output.get( 0 ).size() == 1 )
{ {
@@ -38,9 +39,9 @@ public class Shapeless extends CraftHandler
@Override @Override
public void register() throws RegistrationError, MissingIngredientError public void register() throws RegistrationError, MissingIngredientError
{ {
List<Object> args = new ArrayList(); List<Object> args = new ArrayList<Object>();
for (Ingredient i : inputs) for (IIngredient i : inputs)
args.add( i.getSet() ); args.add( i.getItemStackSet() );
ItemStack outIS = output.getItemStack(); ItemStack outIS = output.getItemStack();
+11 -10
View File
@@ -2,25 +2,26 @@ package appeng.recipes.handlers;
import java.util.List; import java.util.List;
import appeng.recipes.Ingredient; import appeng.api.exceptions.MissingIngredientError;
import appeng.recipes.MissingIngredientError; import appeng.api.exceptions.RecipeError;
import appeng.recipes.RecipeError; import appeng.api.exceptions.RegistrationError;
import appeng.recipes.RegistrationError; import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
public class Smelt extends CraftHandler public class Smelt implements ICraftHandler
{ {
Ingredient in; IIngredient in;
Ingredient out; IIngredient out;
@Override @Override
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
{ {
if ( input.size() == 1 && output.size() == 1 ) if ( input.size() == 1 && output.size() == 1 )
{ {
List<Ingredient> inputList = input.get( 0 ); List<IIngredient> inputList = input.get( 0 );
List<Ingredient> outputList = output.get( 0 ); List<IIngredient> outputList = output.get( 0 );
if ( inputList.size() == 1 && outputList.size() == 1 ) if ( inputList.size() == 1 && outputList.size() == 1 )
{ {
in = inputList.get( 0 ); in = inputList.get( 0 );
+1 -1
View File
@@ -12,7 +12,7 @@ public class OreDictionaryHandler
public static final OreDictionaryHandler instance = new OreDictionaryHandler(); public static final OreDictionaryHandler instance = new OreDictionaryHandler();
private List<IOreListener> ol = new ArrayList(); private List<IOreListener> ol = new ArrayList<IOreListener>();
/** /**
* Just limit what items are sent to the final listeners, I got sick of strange items showing up... * Just limit what items are sent to the final listeners, I got sick of strange items showing up...
-2
View File
@@ -7,8 +7,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import scala.collection.ViewMkString;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;