Cables now work in Recipes.
Added Ingredient Resolver Sets. Shrunk MC Chest Battery.
This commit is contained in:
parent
dfd24a6756
commit
d5748eb804
8 changed files with 191 additions and 16 deletions
|
@ -62,4 +62,13 @@ public class ColoredItemDefinition implements AEColoredItemDefinition
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] allStacks(int stackSize)
|
||||
{
|
||||
ItemStack is[] = new ItemStack[colors.length];
|
||||
for (int x = 0; x < is.length; x++)
|
||||
is[x] = colors[x].stack( 1 );
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import appeng.api.features.IRecipeHandlerRegistry;
|
|||
import appeng.api.recipes.ICraftHandler;
|
||||
import appeng.api.recipes.IRecipeHandler;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.api.recipes.ResolveResult;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
|
||||
|
@ -55,11 +54,11 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResolveResult resolveItem(String nameSpace, String itemName)
|
||||
public Object resolveItem(String nameSpace, String itemName)
|
||||
{
|
||||
for (ISubItemResolver sir : resolvers)
|
||||
{
|
||||
ResolveResult rr = null;
|
||||
Object rr = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package appeng.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.api.recipes.ResolveResult;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.items.misc.ItemCrystalSeed;
|
||||
|
@ -12,19 +17,59 @@ public class AEItemResolver implements ISubItemResolver
|
|||
{
|
||||
|
||||
@Override
|
||||
public ResolveResult resolveItemByName(String nameSpace, String itemName)
|
||||
public Object resolveItemByName(String nameSpace, String itemName)
|
||||
{
|
||||
|
||||
if ( nameSpace.equals( AppEng.modid ) )
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
|
||||
if ( itemName.startsWith( "ItemCrystalSeed." ) )
|
||||
{
|
||||
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Certus" ) )
|
||||
return new ResolveResult( "ItemCrystalSeed", ItemCrystalSeed.Certus );
|
||||
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Certus );
|
||||
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Nether" ) )
|
||||
return new ResolveResult( "ItemCrystalSeed", ItemCrystalSeed.Nether );
|
||||
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Nether );
|
||||
if ( itemName.equalsIgnoreCase( "ItemCrystalSeed.Fluix" ) )
|
||||
return new ResolveResult( "ItemCrystalSeed", ItemCrystalSeed.Fluix );
|
||||
return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Fluix );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -34,7 +79,7 @@ public class AEItemResolver implements ISubItemResolver
|
|||
String materialName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
||||
MaterialType mt = MaterialType.valueOf( materialName );
|
||||
itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
||||
return new ResolveResult( itemName, mt.damageValue );
|
||||
return new ResolverResult( itemName, mt.damageValue );
|
||||
}
|
||||
|
||||
if ( itemName.startsWith( "ItemPart." ) )
|
||||
|
@ -42,11 +87,27 @@ public class AEItemResolver implements ISubItemResolver
|
|||
String partName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
||||
PartType pt = PartType.valueOf( partName );
|
||||
itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
||||
return new ResolveResult( itemName, ItemPart.instance.getDamageByType( pt ) );
|
||||
return new ResolverResult( itemName, ItemPart.instance.getDamageByType( pt ) );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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 );
|
||||
return new ResolverResult( "ItemPart", is.getItemDamage() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ import appeng.api.exceptions.MissingIngredientError;
|
|||
import appeng.api.exceptions.RecipeError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.api.recipes.ResolveResult;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Ingredient implements IIngredient
|
||||
|
@ -25,7 +26,7 @@ public class Ingredient implements IIngredient
|
|||
|
||||
final public int qty;
|
||||
|
||||
public Ingredient(RecipeHandler handler, String input, int qty) throws RecipeError {
|
||||
public Ingredient(RecipeHandler handler, String input, int qty) throws RecipeError, MissedIngredientSet {
|
||||
|
||||
// works no matter wat!
|
||||
this.qty = qty;
|
||||
|
@ -60,12 +61,17 @@ public class Ingredient implements IIngredient
|
|||
{
|
||||
try
|
||||
{
|
||||
ResolveResult rr = AEApi.instance().registries().recipes().resolveItem( nameSpace, tmpName );
|
||||
if ( rr != null )
|
||||
Object ro = AEApi.instance().registries().recipes().resolveItem( nameSpace, tmpName );
|
||||
if ( ro instanceof ResolverResult )
|
||||
{
|
||||
ResolverResult rr = (ResolverResult) ro;
|
||||
tmpName = rr.itemName;
|
||||
sel = rr.damageValue;
|
||||
}
|
||||
else if ( ro instanceof ResolverResultSet )
|
||||
{
|
||||
throw new MissedIngredientSet( (ResolverResultSet) ro );
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
|
|
78
recipes/IngredientSet.java
Normal file
78
recipes/IngredientSet.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
package appeng.recipes;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
|
||||
public class IngredientSet implements IIngredient
|
||||
{
|
||||
|
||||
int qty = 0;
|
||||
final String name;
|
||||
final List<ItemStack> items;
|
||||
|
||||
public IngredientSet(ResolverResultSet rr) {
|
||||
name = rr.name;
|
||||
items = rr.results;
|
||||
}
|
||||
|
||||
boolean isInside = false;
|
||||
|
||||
public int getDamageValue()
|
||||
{
|
||||
return OreDictionary.WILDCARD_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
throw new RegistrationError( "Cannot pass group of items to a recipe which desires a single recipe item." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
if ( isInside )
|
||||
return new ItemStack[0];
|
||||
|
||||
List<ItemStack> out = new LinkedList();
|
||||
out.addAll( items );
|
||||
|
||||
if ( out.size() == 0 )
|
||||
throw new MissingIngredientError( toString() + " - group could not be resolved to any items." );
|
||||
|
||||
for (ItemStack is : out)
|
||||
is.stackSize = qty;
|
||||
|
||||
return out.toArray( new ItemStack[out.size()] );
|
||||
}
|
||||
|
||||
public String getNameSpace()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQty()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
15
recipes/MissedIngredientSet.java
Normal file
15
recipes/MissedIngredientSet.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package appeng.recipes;
|
||||
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
|
||||
public class MissedIngredientSet extends Throwable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 2672951714376345807L;
|
||||
final ResolverResultSet rrs;
|
||||
|
||||
public MissedIngredientSet(ResolverResultSet ro) {
|
||||
rrs = ro;
|
||||
}
|
||||
|
||||
}
|
|
@ -539,7 +539,14 @@ public class RecipeHandler implements IRecipeHandler
|
|||
return gi.copy( qty );
|
||||
|
||||
data.knownItem.add( v );
|
||||
return new Ingredient( this, v, qty );
|
||||
try
|
||||
{
|
||||
return new Ingredient( this, v, qty );
|
||||
}
|
||||
catch (MissedIngredientSet grp)
|
||||
{
|
||||
return new IngredientSet( grp.rrs );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNumber(String v)
|
||||
|
|
|
@ -252,9 +252,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
}
|
||||
|
||||
public TileChest() {
|
||||
internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
addNewHandler( new invManger() );
|
||||
|
||||
config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
config.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
config.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
|
Loading…
Reference in a new issue