Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -80,31 +80,31 @@ public class DisassembleRecipe implements IRecipe
{
ItemStack hasCell = null;
for ( int x = 0; x < inv.getSizeInventory(); x++ )
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
ItemStack is = inv.getStackInSlot( x );
if ( is != null )
if( is != null )
{
if ( hasCell != null )
if( hasCell != null )
return null;
hasCell = this.getCellOutput( is );
// make sure the storage cell is empty...
if ( hasCell != null )
if( hasCell != null )
{
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
if ( cellInv != null )
if( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( StorageChannel.ITEMS.createList() );
if ( !list.isEmpty() )
if( !list.isEmpty() )
return null;
}
}
hasCell = this.getNonCellOutput( is );
if ( hasCell == null )
if( hasCell == null )
return null;
}
}
@@ -114,9 +114,9 @@ public class DisassembleRecipe implements IRecipe
private ItemStack getCellOutput( ItemStack compared )
{
for ( Map.Entry<IItemDefinition, IItemDefinition> entry : this.cellMappings.entrySet() )
for( Map.Entry<IItemDefinition, IItemDefinition> entry : this.cellMappings.entrySet() )
{
if ( entry.getKey().isSameAs( compared ) )
if( entry.getKey().isSameAs( compared ) )
{
return entry.getValue().maybeStack( 1 ).get();
}
@@ -127,9 +127,9 @@ public class DisassembleRecipe implements IRecipe
private ItemStack getNonCellOutput( ItemStack compared )
{
for ( Map.Entry<IItemDefinition, IItemDefinition> entry : this.nonCellMappings.entrySet() )
for( Map.Entry<IItemDefinition, IItemDefinition> entry : this.nonCellMappings.entrySet() )
{
if ( entry.getKey().isSameAs( compared ) )
if( entry.getKey().isSameAs( compared ) )
{
return entry.getValue().maybeStack( 1 ).get();
}
@@ -59,16 +59,16 @@ public final class FacadeRecipe implements IRecipe
@Nullable
private ItemStack getOutput( IInventory inv, boolean createFacade )
{
if ( inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null )
if( inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null )
{
if ( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) )
if( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) )
{
for ( Item facadeItemDefinition : this.maybeFacade.asSet() )
for( Item facadeItemDefinition : this.maybeFacade.asSet() )
{
final ItemFacade facade = (ItemFacade) facadeItemDefinition;
ItemStack facades = facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade );
if ( facades != null && createFacade )
if( facades != null && createFacade )
facades.stackSize = 4;
return facades;
}
@@ -18,6 +18,7 @@
package appeng.recipes.game;
import java.util.ArrayList;
import java.util.HashMap;
@@ -31,6 +32,7 @@ import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.IIngredient;
public class ShapedRecipe implements IRecipe, IRecipeBakeable
{
@@ -45,22 +47,17 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
private boolean mirrored = true;
private boolean disable = false;
public boolean isEnabled()
{
return !this.disable;
}
public ShapedRecipe(ItemStack result, Object... recipe)
public ShapedRecipe( ItemStack result, Object... recipe )
{
this.output = result.copy();
StringBuilder shape = new StringBuilder();
int idx = 0;
if ( recipe[idx] instanceof Boolean )
if( recipe[idx] instanceof Boolean )
{
this.mirrored = (Boolean) recipe[idx];
if ( recipe[idx + 1] instanceof Object[] )
if( recipe[idx + 1] instanceof Object[] )
{
recipe = (Object[]) recipe[idx + 1];
}
@@ -70,12 +67,12 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
}
}
if ( recipe[idx] instanceof String[] )
if( recipe[idx] instanceof String[] )
{
String[] parts = ((String[]) recipe[idx]);
String[] parts = ( (String[]) recipe[idx] );
idx++;
for (String s : parts)
for( String s : parts )
{
this.width = s.length();
shape.append( s );
@@ -85,7 +82,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
}
else
{
while (recipe[idx] instanceof String)
while( recipe[idx] instanceof String )
{
String s = (String) recipe[idx];
idx++;
@@ -95,10 +92,10 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
}
}
if ( this.width * this.height != shape.length() )
if( this.width * this.height != shape.length() )
{
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
for (Object tmp : recipe)
for( Object tmp : recipe )
{
ret.append( tmp ).append( ", " );
}
@@ -108,19 +105,19 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
for (; idx < recipe.length; idx += 2)
for(; idx < recipe.length; idx += 2 )
{
Character chr = (Character) recipe[idx];
Object in = recipe[idx + 1];
if ( in instanceof IIngredient )
if( in instanceof IIngredient )
{
itemMap.put( chr, in );
}
else
{
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
for (Object tmp : recipe)
for( Object tmp : recipe )
{
ret.append( tmp ).append( ", " );
}
@@ -131,15 +128,45 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
this.input = new Object[this.width * this.height];
int x = 0;
for (char chr : shape.toString().toCharArray())
for( char chr : shape.toString().toCharArray() )
{
this.input[x] = itemMap.get( chr );
x++;
}
}
public boolean isEnabled()
{
return !this.disable;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1)
public boolean matches( InventoryCrafting inv, World world )
{
if( this.disable )
return false;
for( int x = 0; x <= MAX_CRAFT_GRID_WIDTH - this.width; x++ )
{
for( int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - this.height; ++y )
{
if( this.checkMatch( inv, x, y, false ) )
{
return true;
}
if( this.mirrored && this.checkMatch( inv, x, y, true ) )
{
return true;
}
}
}
return false;
}
@Override
public ItemStack getCraftingResult( InventoryCrafting var1 )
{
return this.output.copy();
}
@@ -156,48 +183,23 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
return this.output;
}
@Override
public boolean matches(InventoryCrafting inv, World world)
@SuppressWarnings( "unchecked" )
private boolean checkMatch( InventoryCrafting inv, int startX, int startY, boolean mirror )
{
if ( this.disable )
if( this.disable )
return false;
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - this.width; x++)
for( int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++ )
{
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - this.height; ++y)
{
if ( this.checkMatch( inv, x, y, false ) )
{
return true;
}
if ( this.mirrored && this.checkMatch( inv, x, y, true ) )
{
return true;
}
}
}
return false;
}
@SuppressWarnings("unchecked")
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
if ( this.disable )
return false;
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
{
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
for( int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++ )
{
int subX = x - startX;
int subY = y - startY;
Object target = null;
if ( subX >= 0 && subY >= 0 && subX < this.width && subY < this.height )
if( subX >= 0 && subY >= 0 && subX < this.width && subY < this.height )
{
if ( mirror )
if( mirror )
{
target = this.input[this.width - subX - 1 + subY * this.width];
}
@@ -209,46 +211,46 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
ItemStack slot = inv.getStackInRowAndColumn( x, y );
if ( target instanceof IIngredient )
if( target instanceof IIngredient )
{
boolean matched = false;
try
{
for (ItemStack item : ((IIngredient) target).getItemStackSet())
for( ItemStack item : ( (IIngredient) target ).getItemStackSet() )
{
matched = matched || this.checkItemEquals( item, slot );
}
}
catch (RegistrationError e)
catch( RegistrationError e )
{
// :P
}
catch (MissingIngredientError e)
catch( MissingIngredientError e )
{
// :P
}
if ( !matched )
if( !matched )
{
return false;
}
}
else if ( target instanceof ArrayList )
else if( target instanceof ArrayList )
{
boolean matched = false;
for (ItemStack item : (ArrayList<ItemStack>) target)
for( ItemStack item : (ArrayList<ItemStack>) target )
{
matched = matched || this.checkItemEquals( item, slot );
}
if ( !matched )
if( !matched )
{
return false;
}
}
else if ( target == null && slot != null )
else if( target == null && slot != null )
{
return false;
}
@@ -258,17 +260,16 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
return true;
}
private boolean checkItemEquals(ItemStack target, ItemStack input)
private boolean checkItemEquals( ItemStack target, ItemStack input )
{
if ( input == null && target != null || input != null && target == null )
if( input == null && target != null || input != null && target == null )
{
return false;
}
return (target.getItem() == input.getItem() && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input
.getItemDamage()));
return ( target.getItem() == input.getItem() && ( target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage() ) );
}
public ShapedRecipe setMirrored(boolean mirror)
public ShapedRecipe setMirrored( boolean mirror )
{
this.mirrored = mirror;
return this;
@@ -306,16 +307,15 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
try
{
this.disable = false;
for (Object o : this.input )
for( Object o : this.input )
{
if ( o instanceof IIngredient )
((IIngredient) o).bake();
if( o instanceof IIngredient )
( (IIngredient) o ).bake();
}
}
catch (MissingIngredientError err)
catch( MissingIngredientError err )
{
this.disable = true;
}
}
}
@@ -18,6 +18,7 @@
package appeng.recipes.game;
import java.util.ArrayList;
import net.minecraft.inventory.InventoryCrafting;
@@ -30,31 +31,27 @@ import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.IIngredient;
public class ShapelessRecipe implements IRecipe, IRecipeBakeable
{
private ItemStack output = null;
private final ArrayList<Object> input = new ArrayList<Object>();
private ItemStack output = null;
private boolean disable = false;
public boolean isEnabled()
{
return !this.disable;
}
public ShapelessRecipe(ItemStack result, Object... recipe)
public ShapelessRecipe( ItemStack result, Object... recipe )
{
this.output = result.copy();
for (Object in : recipe)
for( Object in : recipe )
{
if ( in instanceof IIngredient )
if( in instanceof IIngredient )
{
this.input.add( in );
}
else
{
StringBuilder ret = new StringBuilder( "Invalid shapeless ore recipe: " );
for (Object tmp : recipe)
for( Object tmp : recipe )
{
ret.append( tmp ).append( ", " );
}
@@ -64,6 +61,75 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
}
}
public boolean isEnabled()
{
return !this.disable;
}
@SuppressWarnings( "unchecked" )
@Override
public boolean matches( InventoryCrafting var1, World world )
{
if( this.disable )
return false;
ArrayList<Object> required = new ArrayList<Object>( this.input );
for( int x = 0; x < var1.getSizeInventory(); x++ )
{
ItemStack slot = var1.getStackInSlot( x );
if( slot != null )
{
boolean inRecipe = false;
for( Object next : required )
{
boolean match = false;
if( next instanceof IIngredient )
{
try
{
for( ItemStack item : ( (IIngredient) next ).getItemStackSet() )
{
match = match || this.checkItemEquals( item, slot );
}
}
catch( RegistrationError e )
{
// :P
}
catch( MissingIngredientError e )
{
// :P
}
}
if( match )
{
inRecipe = true;
required.remove( next );
break;
}
}
if( !inRecipe )
{
return false;
}
}
}
return required.isEmpty();
}
@Override
public ItemStack getCraftingResult( InventoryCrafting var1 )
{
return this.output.copy();
}
@Override
public int getRecipeSize()
{
@@ -76,74 +142,9 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
return this.output;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1)
private boolean checkItemEquals( ItemStack target, ItemStack input )
{
return this.output.copy();
}
@SuppressWarnings("unchecked")
@Override
public boolean matches(InventoryCrafting var1, World world)
{
if ( this.disable )
return false;
ArrayList<Object> required = new ArrayList<Object>( this.input );
for (int x = 0; x < var1.getSizeInventory(); x++)
{
ItemStack slot = var1.getStackInSlot( x );
if ( slot != null )
{
boolean inRecipe = false;
for (Object next : required)
{
boolean match = false;
if ( next instanceof IIngredient )
{
try
{
for (ItemStack item : ((IIngredient) next).getItemStackSet())
{
match = match || this.checkItemEquals( item, slot );
}
}
catch (RegistrationError e)
{
// :P
}
catch (MissingIngredientError e)
{
// :P
}
}
if ( match )
{
inRecipe = true;
required.remove( next );
break;
}
}
if ( !inRecipe )
{
return false;
}
}
}
return required.isEmpty();
}
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
return (target.getItem() == input.getItem() && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input
.getItemDamage()));
return ( target.getItem() == input.getItem() && ( target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage() ) );
}
/**
@@ -163,13 +164,13 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
try
{
this.disable = false;
for (Object o : this.input )
for( Object o : this.input )
{
if ( o instanceof IIngredient )
((IIngredient) o).bake();
if( o instanceof IIngredient )
( (IIngredient) o ).bake();
}
}
catch (MissingIngredientError e)
catch( MissingIngredientError e )
{
this.disable = true;
}