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-25 06:33:31 +01:00
|
|
|
package appeng.recipes;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-03-10 03:11:29 +01:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IDefinitions;
|
|
|
|
import appeng.api.definitions.IItems;
|
|
|
|
import appeng.api.definitions.IParts;
|
2014-02-25 06:33:31 +01:00
|
|
|
import appeng.api.recipes.ISubItemResolver;
|
2014-03-10 03:11:29 +01:00
|
|
|
import appeng.api.recipes.ResolverResult;
|
|
|
|
import appeng.api.recipes.ResolverResultSet;
|
|
|
|
import appeng.api.util.AEColor;
|
|
|
|
import appeng.api.util.AEColoredItemDefinition;
|
2014-02-25 06:33:31 +01:00
|
|
|
import appeng.core.AppEng;
|
2014-08-03 01:09:41 +02:00
|
|
|
import appeng.items.materials.ItemMultiMaterial;
|
2014-02-25 06:33:31 +01:00
|
|
|
import appeng.items.materials.MaterialType;
|
|
|
|
import appeng.items.misc.ItemCrystalSeed;
|
2014-05-06 07:16:29 +02:00
|
|
|
import appeng.items.parts.ItemMultiPart;
|
2014-02-25 06:33:31 +01:00
|
|
|
import appeng.items.parts.PartType;
|
2017-04-12 16:10:13 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-02-25 06:33:31 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2014-02-25 06:33:31 +01:00
|
|
|
public class AEItemResolver implements ISubItemResolver
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public Object resolveItemByName( final String nameSpace, final String itemName )
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( nameSpace.equals( AppEng.MOD_ID ) )
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
final IDefinitions definitions = AEApi.instance().definitions();
|
|
|
|
final IItems items = definitions.items();
|
|
|
|
final IParts parts = definitions.parts();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "PaintBall." ) )
|
2014-07-11 22:07:16 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.paintBall( items.coloredPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), false );
|
2014-07-11 22:07:16 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "LumenPaintBall." ) )
|
2014-07-11 22:07:16 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.paintBall( items.coloredLumenPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), true );
|
2014-07-11 22:07:16 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equals( "CableGlass" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return new ResolverResultSet( "CableGlass", parts.cableGlass().allStacks( 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "CableGlass." ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.cableItem( parts.cableGlass(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equals( "CableCovered" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return new ResolverResultSet( "CableCovered", parts.cableCovered().allStacks( 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "CableCovered." ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.cableItem( parts.cableCovered(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equals( "CableSmart" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return new ResolverResultSet( "CableSmart", parts.cableSmart().allStacks( 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "CableSmart." ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.cableItem( parts.cableSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equals( "CableDense" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return new ResolverResultSet( "CableDense", parts.cableDense().allStacks( 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "CableDense." ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.cableItem( parts.cableDense(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "ItemCrystalSeed." ) )
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Certus" ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-05-08 23:37:09 +02:00
|
|
|
return ItemCrystalSeed.getResolver( ItemCrystalSeed.CERTUS );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Nether" ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-07-22 16:00:18 +02:00
|
|
|
return ItemCrystalSeed.getResolver( ItemCrystalSeed.NETHER );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Fluix" ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-07-22 16:00:18 +02:00
|
|
|
return ItemCrystalSeed.getResolver( ItemCrystalSeed.FLUIX );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-03-09 22:39:30 +01:00
|
|
|
|
|
|
|
return null;
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "ItemMaterial." ) )
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final String materialName = itemName.substring( itemName.indexOf( '.' ) + 1 );
|
|
|
|
final MaterialType mt = MaterialType.valueOf( materialName );
|
2014-06-17 05:44:17 +02:00
|
|
|
// itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
2015-10-08 15:42:42 +02:00
|
|
|
if( mt.getItemInstance() == ItemMultiMaterial.instance && mt.getDamageValue() >= 0 && mt.isRegistered() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return new ResolverResult( "ItemMultiMaterial", mt.getDamageValue() );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( itemName.startsWith( "ItemPart." ) )
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final String partName = itemName.substring( itemName.indexOf( '.' ) + 1 );
|
|
|
|
final PartType pt = PartType.valueOf( partName );
|
2014-06-17 05:44:17 +02:00
|
|
|
// itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
2015-09-25 23:10:56 +02:00
|
|
|
final int dVal = ItemMultiPart.instance.getDamageByType( pt );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dVal >= 0 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-05-06 19:08:48 +02:00
|
|
|
return new ResolverResult( "ItemMultiPart", dVal );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private Object paintBall( final AEColoredItemDefinition partType, final String substring, final boolean lumen )
|
2014-07-11 22:07:16 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
AEColor col;
|
2014-07-11 22:07:16 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
col = AEColor.valueOf( substring );
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final Throwable t )
|
2014-07-11 22:07:16 +02:00
|
|
|
{
|
|
|
|
col = AEColor.Transparent;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( col == AEColor.Transparent )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-07-11 22:07:16 +02:00
|
|
|
return null;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-07-29 04:52:17 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemStack is = partType.stack( col, 1 );
|
2015-01-03 02:53:14 +01:00
|
|
|
return new ResolverResult( "ItemPaintBall", ( lumen ? 20 : 0 ) + is.getItemDamage() );
|
2014-07-11 22:07:16 +02:00
|
|
|
}
|
2014-07-29 04:52:17 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
private Object cableItem( final AEColoredItemDefinition partType, final String substring )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
AEColor col;
|
2014-03-10 03:11:29 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
col = AEColor.valueOf( substring );
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final Throwable t )
|
2014-03-10 03:11:29 +01:00
|
|
|
{
|
|
|
|
col = AEColor.Transparent;
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemStack is = partType.stack( col, 1 );
|
2014-05-06 19:08:48 +02:00
|
|
|
return new ResolverResult( "ItemMultiPart", is.getItemDamage() );
|
2014-03-10 03:11:29 +01:00
|
|
|
}
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|