Recipe Engine Added, not quite done yet tho.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.recipes.Ingredient;
|
||||
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
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
public class Grind extends CraftHandler
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.recipes.Ingredient;
|
||||
import appeng.recipes.RecipeError;
|
||||
import appeng.recipes.RegistrationError;
|
||||
|
||||
public class Shaped extends CraftHandler
|
||||
{
|
||||
|
||||
private int rows;
|
||||
private int cols;
|
||||
|
||||
List<List<Ingredient>> inputs;
|
||||
Ingredient output;
|
||||
|
||||
@Override
|
||||
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError
|
||||
{
|
||||
if ( output.size() == 1 && output.get( 0 ).size() == 1 )
|
||||
{
|
||||
rows = inputs.size();
|
||||
if ( rows > 0 && inputs.size() <= 3 )
|
||||
{
|
||||
cols = inputs.get( 0 ).size();
|
||||
for (int x = 0; x < inputs.size(); x++)
|
||||
if ( inputs.get( x ).size() != cols )
|
||||
throw new RecipeError( "all rows in a shaped crafting recipe must contain the same number of ingredients." );
|
||||
|
||||
inputs = input;
|
||||
this.output = output.get( 0 ).get( 0 );
|
||||
}
|
||||
else
|
||||
throw new RecipeError( "shaped crafting recpies must have 1-3 rows." );
|
||||
}
|
||||
else
|
||||
throw new RecipeError( "Crafting must produce a single output." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() throws RegistrationError
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.recipes.Ingredient;
|
||||
import appeng.recipes.RecipeError;
|
||||
import appeng.recipes.RegistrationError;
|
||||
|
||||
public class Shapeless extends CraftHandler
|
||||
{
|
||||
|
||||
List<Ingredient> inputs;
|
||||
Ingredient output;
|
||||
|
||||
@Override
|
||||
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError
|
||||
{
|
||||
if ( output.size() == 1 && output.get( 0 ).size() == 1 )
|
||||
{
|
||||
if ( inputs.size() == 1 )
|
||||
{
|
||||
inputs = input.get( 0 );
|
||||
this.output = output.get( 0 ).get( 0 );
|
||||
}
|
||||
else
|
||||
throw new RecipeError( "Shapeless crafting recipes cannot have rows." );
|
||||
}
|
||||
else
|
||||
throw new RecipeError( "Crafting must produce a single output." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() throws RegistrationError
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.recipes.Ingredient;
|
||||
import appeng.recipes.RecipeError;
|
||||
import appeng.recipes.RegistrationError;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Smelt extends CraftHandler
|
||||
{
|
||||
|
||||
Ingredient in;
|
||||
Ingredient out;
|
||||
|
||||
@Override
|
||||
public void setup(List<List<Ingredient>> input, List<List<Ingredient>> output) throws RecipeError
|
||||
{
|
||||
if ( input.size() == 1 && output.size() == 1 )
|
||||
{
|
||||
List<Ingredient> inputList = input.get( 0 );
|
||||
List<Ingredient> outputList = output.get( 0 );
|
||||
if ( inputList.size() == 1 && outputList.size() == 1 )
|
||||
{
|
||||
in = inputList.get( 0 );
|
||||
out = outputList.get( 0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RecipeError( "Smelting recipe can only have a single input and output." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() throws RegistrationError
|
||||
{
|
||||
if ( in.getItemStack().getItem() == null )
|
||||
throw new RegistrationError( in.toString() + ": Smelting Input is not a valid item." );
|
||||
|
||||
if ( out.getItemStack().getItem() == null )
|
||||
throw new RegistrationError( out.toString() + ": Smelting Output is not a valid item." );
|
||||
|
||||
GameRegistry.addSmelting( in.getItemStack(), out.getItemStack(), 0 );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user