This commit is contained in:
AlgorithmX2
2014-06-02 19:32:51 -05:00
3 changed files with 83 additions and 52 deletions
@@ -48,14 +48,11 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
CachedShapedRecipe recipe = null;
if ( (irecipe instanceof ShapedRecipe) ) if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( recipe != null )
{ {
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
recipe.computeVisuals(); recipe.computeVisuals();
this.arecipes.add( recipe ); arecipes.add( recipe );
} }
} }
} }
@@ -70,16 +67,13 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) if ( (irecipe instanceof ShapedRecipe) )
{ {
CachedShapedRecipe recipe = null; if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( recipe != null )
{ {
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
recipe.computeVisuals(); recipe.computeVisuals();
this.arecipes.add( recipe ); arecipes.add( recipe );
} }
} }
} }
@@ -90,17 +84,18 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
CachedShapedRecipe recipe = null;
if ( (irecipe instanceof ShapedRecipe) ) if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.getItem() )) )
{ {
recipe.computeVisuals(); CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( recipe.contains( recipe.ingredients, ingredient ) )
if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
{ {
recipe.setIngredientPermutation( recipe.ingredients, ingredient ); recipe.computeVisuals();
this.arecipes.add( recipe ); if ( recipe.contains( recipe.ingredients, ingredient ) )
{
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
arecipes.add( recipe );
}
} }
} }
} }
@@ -127,12 +122,12 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
{ {
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if ( renderer != null ) if ( renderer != null )
{
return renderer; return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if ( positioner == null ) if ( positioner == null )
return null; return null;
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner ); return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
} }
@@ -141,9 +136,8 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
{ {
IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if ( handler != null ) if ( handler != null )
{
return handler; return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
} }
@@ -48,12 +48,9 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
CachedShapelessRecipe recipe = null;
if ( (irecipe instanceof ShapelessRecipe) ) if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( recipe != null )
{ {
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
recipe.computeVisuals(); recipe.computeVisuals();
this.arecipes.add( recipe ); this.arecipes.add( recipe );
} }
@@ -70,16 +67,13 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) if ( (irecipe instanceof ShapelessRecipe) )
{ {
CachedShapelessRecipe recipe = null; if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( recipe != null )
{ {
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
recipe.computeVisuals(); recipe.computeVisuals();
this.arecipes.add( recipe ); arecipes.add( recipe );
} }
} }
} }
@@ -90,17 +84,18 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) for (IRecipe irecipe : allrecipes)
{ {
CachedShapelessRecipe recipe = null;
if ( (irecipe instanceof ShapelessRecipe) ) if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.getItem() )) )
{ {
recipe.computeVisuals(); CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( recipe.contains( recipe.ingredients, ingredient ) )
if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
{ {
recipe.setIngredientPermutation( recipe.ingredients, ingredient ); recipe.computeVisuals();
this.arecipes.add( recipe ); if ( recipe.contains( recipe.ingredients, ingredient ) )
{
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
this.arecipes.add( recipe );
}
} }
} }
} }
@@ -127,12 +122,12 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
{ {
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if ( renderer != null ) if ( renderer != null )
{
return renderer; return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if ( positioner == null ) if ( positioner == null )
return null; return null;
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner ); return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
} }
@@ -141,9 +136,8 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
{ {
IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if ( handler != null ) if ( handler != null )
{
return handler; return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
} }
@@ -200,9 +194,8 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
public void computeVisuals() public void computeVisuals()
{ {
for (PositionedStack p : this.ingredients) for (PositionedStack p : this.ingredients)
{
p.generatePermutations(); p.generatePermutations();
}
this.result.generatePermutations(); this.result.generatePermutations();
} }
} }
+47 -3
View File
@@ -1,13 +1,16 @@
package appeng.items.tools.powered.powersink; package appeng.items.tools.powered.powersink;
import ic2.api.item.IElectricItemManager; import ic2.api.item.IElectricItemManager;
import ic2.api.item.ISpecialElectricItem;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.config.PowerUnits; import appeng.api.config.PowerUnits;
import appeng.transformer.annotations.integration.Interface; import appeng.transformer.annotations.integration.Interface;
import appeng.transformer.annotations.integration.InterfaceList;
@Interface(iface = "ic2.api.item.IElectricItemManager", iname = "IC2") @InterfaceList(value = { @Interface( iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2"), @Interface( iface = "ic2.api.item.IElectricItemManager", iname = "IC2")} )
public class IC2 extends AERootPoweredItem implements IElectricItemManager public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
{ {
public IC2(Class c, String subname) { public IC2(Class c, String subname) {
@@ -17,7 +20,13 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager
@Override @Override
public int charge(ItemStack is, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) public int charge(ItemStack is, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{ {
return amount - ((int) injectExternalPower( PowerUnits.EU, is, amount, simulate )); int addedAmt = amount;
int limit = getTransferLimit( is );
if ( ! ignoreTransferLimit && amount > limit )
addedAmt = limit;
return addedAmt - ((int) injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ));
} }
@Override @Override
@@ -62,4 +71,39 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager
return null; return null;
} }
@Override
public boolean canProvideEnergy(ItemStack itemStack) {
return false;
}
@Override
public Item getChargedItem(ItemStack itemStack) {
return itemStack.getItem();
}
@Override
public Item getEmptyItem(ItemStack itemStack) {
return itemStack.getItem();
}
@Override
public int getMaxCharge(ItemStack itemStack) {
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) );
}
@Override
public int getTier(ItemStack itemStack) {
return 1;
}
@Override
public int getTransferLimit(ItemStack itemStack) {
return Math.max( 32, getMaxCharge(itemStack)/ 200 );
}
@Override
public IElectricItemManager getManager(ItemStack itemStack) {
return this;
}
} }