2014-02-10 04:16:36 +01:00
|
|
|
package appeng.recipes.handlers;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
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-10 04:16:36 +01:00
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
public class Smelt implements ICraftHandler, IWebsiteSeralizer
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
IIngredient in;
|
|
|
|
IIngredient out;
|
2014-02-10 04:16:36 +01:00
|
|
|
|
|
|
|
@Override
|
2014-02-20 00:33:36 +01:00
|
|
|
public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
|
|
|
if ( input.size() == 1 && output.size() == 1 )
|
|
|
|
{
|
2014-02-20 00:33:36 +01:00
|
|
|
List<IIngredient> inputList = input.get( 0 );
|
|
|
|
List<IIngredient> outputList = output.get( 0 );
|
2014-02-10 04:16:36 +01:00
|
|
|
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
|
2014-02-11 00:15:43 +01:00
|
|
|
public void register() throws RegistrationError, MissingIngredientError
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
@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"+
|
2014-03-09 04:35:53 +01:00
|
|
|
h.getName(out)+"\n"+
|
|
|
|
h.getName(in);
|
2014-03-05 20:34:56 +01:00
|
|
|
}
|
2014-02-10 04:16:36 +01:00
|
|
|
}
|