2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
2015-05-16 20:48:32 +02:00
|
|
|
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
2014-11-14 12:02:52 +01:00
|
|
|
*
|
|
|
|
* 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-03-18 18:54:57 +01:00
|
|
|
package appeng.recipes.handlers;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-03-18 18:54:57 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-12-24 02:07:03 +01:00
|
|
|
|
2014-03-18 18:54:57 +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;
|
|
|
|
import appeng.core.AELog;
|
2015-05-16 20:48:32 +02:00
|
|
|
import appeng.integration.IntegrationRegistry;
|
2014-07-24 00:26:23 +02:00
|
|
|
import appeng.integration.IntegrationType;
|
2014-03-18 18:54:57 +01:00
|
|
|
import appeng.integration.abstraction.IFZ;
|
|
|
|
import appeng.recipes.RecipeHandler;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-21 02:29:41 +02:00
|
|
|
public class GrindFZ implements ICraftHandler, IWebsiteSerializer
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private IIngredient pro_input;
|
|
|
|
private IIngredient[] pro_output;
|
2014-03-18 18:54:57 +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-03-18 18:54:57 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( input.size() == 1 && output.size() == 1 )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
2015-09-30 14:24:40 +02:00
|
|
|
final int outs = output.get( 0 ).size();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( input.get( 0 ).size() == 1 && outs == 1 )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.pro_input = input.get( 0 ).get( 0 );
|
|
|
|
this.pro_output = output.get( 0 ).toArray( new IIngredient[outs] );
|
2014-03-18 18:54:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-10-01 11:41:52 +02:00
|
|
|
throw new RecipeError( "Grind must have a single input, and single output." );
|
2014-03-18 18:54:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void register() throws RegistrationError, MissingIngredientError
|
|
|
|
{
|
2015-05-16 20:48:32 +02:00
|
|
|
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.FZ ) )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
2015-09-30 14:24:40 +02:00
|
|
|
final IFZ fz = (IFZ) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.FZ );
|
|
|
|
for( final ItemStack is : this.pro_input.getItemStackSet() )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
fz.grinderRecipe( is, this.pro_output[0].getItemStack() );
|
2014-03-18 18:54:57 +01:00
|
|
|
}
|
2015-09-30 14:24:40 +02:00
|
|
|
catch( final java.lang.RuntimeException err )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
|
|
|
AELog.info( "FZ not happy - " + err.getMessage() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public String getPattern( final RecipeHandler h )
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return null;
|
2014-03-18 18:54:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
2014-03-18 18:54:57 +01:00
|
|
|
{
|
2016-11-04 09:27:52 +01:00
|
|
|
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
2014-03-18 18:54:57 +01:00
|
|
|
}
|
|
|
|
}
|