2014-02-10 04:16:36 +01:00
|
|
|
package appeng.recipes.handlers;
|
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-02-23 07:55:46 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.api.AEApi;
|
2014-02-20 00:33:36 +01:00
|
|
|
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;
|
2014-03-05 20:34:56 +01:00
|
|
|
import appeng.recipes.RecipeHandler;
|
|
|
|
import appeng.util.Platform;
|
2014-02-20 00:33:36 +01:00
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
public class Grind implements ICraftHandler, IWebsiteSeralizer
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
|
|
|
|
2014-02-23 07:55:46 +01:00
|
|
|
IIngredient pro_input;
|
|
|
|
IIngredient pro_output[];
|
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
@Override
|
2014-02-23 07:55:46 +01:00
|
|
|
public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
|
|
|
|
{
|
|
|
|
if ( input.size() == 1 && output.size() == 1 )
|
|
|
|
{
|
|
|
|
int outs = output.get( 0 ).size();
|
|
|
|
if ( input.get( 0 ).size() == 1 && outs == 1 )
|
|
|
|
{
|
|
|
|
pro_input = input.get( 0 ).get( 0 );
|
|
|
|
pro_output = output.get( 0 ).toArray( new IIngredient[outs] );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new RecipeError( "Grind must have a single input, and single output." );
|
2014-02-20 00:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-23 07:55:46 +01:00
|
|
|
public void register() throws RegistrationError, MissingIngredientError
|
|
|
|
{
|
|
|
|
for (ItemStack is : pro_input.getItemStackSet())
|
|
|
|
AEApi.instance().registries().grinder().addRecipe( is, pro_output[0].getItemStack(), 8 );
|
2014-02-20 00:33:36 +01:00
|
|
|
}
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
@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]);
|
|
|
|
}
|
|
|
|
|
2014-02-10 04:16:36 +01:00
|
|
|
}
|