2014-02-25 06:33:31 +01:00
|
|
|
package appeng.recipes;
|
|
|
|
|
2014-03-10 03:11:29 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.api.AEApi;
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
public class AEItemResolver implements ISubItemResolver
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
2014-03-10 03:11:29 +01:00
|
|
|
public Object resolveItemByName(String nameSpace, String itemName)
|
2014-02-25 06:33:31 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
if ( nameSpace.equals( AppEng.modid ) )
|
|
|
|
{
|
2014-03-10 03:11:29 +01:00
|
|
|
if ( itemName.equals( "CableGlass" ) )
|
|
|
|
{
|
|
|
|
return new ResolverResultSet( "CableGlass", AEApi.instance().parts().partCableGlass.allStacks( 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "CableGlass." ) )
|
|
|
|
{
|
|
|
|
return cableItem( AEApi.instance().parts().partCableGlass, itemName.substring( itemName.indexOf( "." ) + 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.equals( "CableCovered" ) )
|
|
|
|
{
|
|
|
|
return new ResolverResultSet( "CableCovered", AEApi.instance().parts().partCableCovered.allStacks( 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "CableCovered." ) )
|
|
|
|
{
|
|
|
|
return cableItem( AEApi.instance().parts().partCableCovered, itemName.substring( itemName.indexOf( "." ) + 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.equals( "CableSmart" ) )
|
|
|
|
{
|
|
|
|
return new ResolverResultSet( "CableSmart", AEApi.instance().parts().partCableSmart.allStacks( 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "CableSmart." ) )
|
|
|
|
{
|
|
|
|
return cableItem( AEApi.instance().parts().partCableSmart, itemName.substring( itemName.indexOf( "." ) + 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.equals( "CableDense" ) )
|
|
|
|
{
|
|
|
|
return new ResolverResultSet( "CableDense", AEApi.instance().parts().partCableDense.allStacks( 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "CableDense." ) )
|
|
|
|
{
|
|
|
|
return cableItem( AEApi.instance().parts().partCableDense, itemName.substring( itemName.indexOf( "." ) + 1 ) );
|
|
|
|
}
|
|
|
|
|
2014-02-25 06:33:31 +01:00
|
|
|
if ( itemName.startsWith( "ItemCrystalSeed." ) )
|
|
|
|
{
|
|
|
|
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Certus" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Certus );
|
2014-02-25 06:33:31 +01:00
|
|
|
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Nether" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Nether );
|
2014-02-25 06:33:31 +01:00
|
|
|
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Fluix" ) )
|
2014-03-10 03:11:29 +01:00
|
|
|
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Fluix );
|
2014-03-09 22:39:30 +01:00
|
|
|
|
|
|
|
return null;
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "ItemMaterial." ) )
|
|
|
|
{
|
|
|
|
String materialName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
|
|
|
MaterialType mt = MaterialType.valueOf( materialName );
|
2014-05-06 19:08:48 +02:00
|
|
|
//itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
2014-03-28 02:27:19 +01:00
|
|
|
if ( mt.damageValue >= 0 )
|
2014-05-06 19:08:48 +02:00
|
|
|
return new ResolverResult( "ItemMultiMaterial", mt.damageValue );
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( itemName.startsWith( "ItemPart." ) )
|
|
|
|
{
|
|
|
|
String partName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
|
|
|
PartType pt = PartType.valueOf( partName );
|
2014-05-06 19:08:48 +02:00
|
|
|
//itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
2014-05-06 07:16:29 +02:00
|
|
|
int dVal = ItemMultiPart.instance.getDamageByType( pt );
|
2014-03-28 02:27:19 +01:00
|
|
|
if ( dVal >= 0 )
|
2014-05-06 19:08:48 +02:00
|
|
|
return new ResolverResult( "ItemMultiPart", dVal );
|
2014-02-25 06:33:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-03-10 03:11:29 +01:00
|
|
|
private Object cableItem(AEColoredItemDefinition partType, String substring)
|
|
|
|
{
|
|
|
|
AEColor col = AEColor.Transparent;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
col = AEColor.valueOf( substring );
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
col = AEColor.Transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|