2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-02-10 04:16:36 +01:00
|
|
|
package appeng.recipes.handlers;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-02-10 04:16:36 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
2015-12-24 02:07:03 +01:00
|
|
|
|
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
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-21 02:29:41 +02:00
|
|
|
public class Smelt implements ICraftHandler, IWebsiteSerializer
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private IIngredient in;
|
|
|
|
private IIngredient out;
|
2014-02-10 04:16:36 +01:00
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public void setup( final List<List<IIngredient>> input, final List<List<IIngredient>> output ) throws RecipeError
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( input.size() == 1 && output.size() == 1 )
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
2015-09-30 14:24:40 +02:00
|
|
|
final List<IIngredient> inputList = input.get( 0 );
|
|
|
|
final List<IIngredient> outputList = output.get( 0 );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( inputList.size() == 1 && outputList.size() == 1 )
|
2014-02-10 04:16:36 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.in = inputList.get( 0 );
|
|
|
|
this.out = outputList.get( 0 );
|
2014-02-10 04:16:36 +01:00
|
|
|
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
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.in.getItemStack().getItem() == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
throw new RegistrationError( this.in.toString() + ": Smelting Input is not a valid item." );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-10 04:16:36 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.out.getItemStack().getItem() == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
throw new RegistrationError( this.out.toString() + ": Smelting Output is not a valid item." );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-10 04:16:36 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
GameRegistry.addSmelting( this.in.getItemStack(), this.out.getItemStack(), 0 );
|
2014-02-10 04:16:36 +01:00
|
|
|
}
|
|
|
|
|
2014-03-05 20:34:56 +01:00
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public String getPattern( final RecipeHandler h )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
2016-01-01 02:02:05 +01:00
|
|
|
return "smelt " + this.out.getQty() + '\n' + h.getName( this.out ) + '\n' + h.getName( this.in );
|
2014-03-05 20:34:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public boolean canCraft( final ItemStack reqOutput ) throws RegistrationError, MissingIngredientError
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
2016-11-04 09:27:52 +01:00
|
|
|
return Platform.itemComparisons().isSameItem( this.out.getItemStack(), reqOutput );
|
2014-03-05 20:34:56 +01:00
|
|
|
}
|
2014-02-10 04:16:36 +01:00
|
|
|
}
|