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
@@ -18,6 +18,7 @@
package appeng.integration.modules;
import java.util.Arrays;
import java.util.List;
@@ -51,89 +52,68 @@ import appeng.integration.IIntegrationModule;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModule, RecipeProvider, StackInfoSource, RecipeGenerator
{
public static CraftGuide instance;
private final Slot[] shapelessCraftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ),
new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ),
new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] shapelessCraftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ), new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ), new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] craftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ).drawOwnBackground(),
new ItemSlot( 21, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 3, 16, 16 ).drawOwnBackground(),
new ItemSlot( 3, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 21, 16, 16 ).drawOwnBackground(),
new ItemSlot( 39, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 3, 39, 16, 16 ).drawOwnBackground(),
new ItemSlot( 21, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 39, 16, 16 ).drawOwnBackground(),
new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
private final Slot[] craftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 3, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 3, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
private final Slot[] smallCraftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ).drawOwnBackground(),
new ItemSlot( 30, 12, 16, 16 ).drawOwnBackground(), new ItemSlot( 12, 30, 16, 16 ).drawOwnBackground(),
new ItemSlot( 30, 30, 16, 16 ).drawOwnBackground(), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
private final Slot[] smallCraftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ).drawOwnBackground(), new ItemSlot( 30, 12, 16, 16 ).drawOwnBackground(), new ItemSlot( 12, 30, 16, 16 ).drawOwnBackground(), new ItemSlot( 30, 30, 16, 16 ).drawOwnBackground(), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
private final Slot[] craftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ),
new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ),
new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] craftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ), new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ), new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] smallCraftingSlots = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ), new ItemSlot( 30, 12, 16, 16 ), new ItemSlot( 12, 30, 16, 16 ),
new ItemSlot( 30, 30, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] smallCraftingSlots = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ), new ItemSlot( 30, 12, 16, 16 ), new ItemSlot( 12, 30, 16, 16 ), new ItemSlot( 30, 30, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] furnaceSlots = new ItemSlot[] { new ItemSlot( 13, 21, 16, 16 ),
new ItemSlot( 50, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
private final Slot[] furnaceSlots = new ItemSlot[] { new ItemSlot( 13, 21, 16, 16 ), new ItemSlot( 50, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
RecipeGenerator parent;
@Override
public String getInfo(ItemStack itemStack)
public String getInfo( ItemStack itemStack )
{
// :P
return null;
}
RecipeGenerator parent;
@Override
public void generateRecipes(RecipeGenerator generator)
public void generateRecipes( RecipeGenerator generator )
{
this.parent = generator;
RecipeTemplate craftingTemplate;
RecipeTemplate smallCraftingTemplate;
if ( uristqwerty.CraftGuide.CraftGuide.newerBackgroundStyle )
if( uristqwerty.CraftGuide.CraftGuide.newerBackgroundStyle )
{
craftingTemplate = generator.createRecipeTemplate( this.craftingSlotsOwnBackground, null );
smallCraftingTemplate = generator.createRecipeTemplate( this.smallCraftingSlotsOwnBackground, null );
}
else
{
craftingTemplate = new DefaultRecipeTemplate( this.craftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
DynamicTexture.instance( "recipe_backgrounds" ), 1, 1, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 1,
79, 58 ) );
craftingTemplate = new DefaultRecipeTemplate( this.craftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 1, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 1, 79, 58 ) );
smallCraftingTemplate = new DefaultRecipeTemplate( this.smallCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
DynamicTexture.instance( "recipe_backgrounds" ), 1, 61, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 61,
79, 58 ) );
smallCraftingTemplate = new DefaultRecipeTemplate( this.smallCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 61, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 61, 79, 58 ) );
}
RecipeTemplate shapelessTemplate = new DefaultRecipeTemplate( this.shapelessCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
DynamicTexture.instance( "recipe_backgrounds" ), 1, 121, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 121,
79, 58 ) );
RecipeTemplate shapelessTemplate = new DefaultRecipeTemplate( this.shapelessCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 121, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 121, 79, 58 ) );
RecipeTemplate furnaceTemplate = new DefaultRecipeTemplate( this.furnaceSlots, new ItemStack( Blocks.furnace ), new TextureClip(
DynamicTexture.instance( "recipe_backgrounds" ), 1, 181, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 181,
79, 58 ) );
RecipeTemplate furnaceTemplate = new DefaultRecipeTemplate( this.furnaceSlots, new ItemStack( Blocks.furnace ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 181, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 181, 79, 58 ) );
this.addCraftingRecipes( craftingTemplate, smallCraftingTemplate, shapelessTemplate, this );
this.addGrinderRecipes( furnaceTemplate, this );
this.addInscriberRecipes( furnaceTemplate, this );
}
private void addCraftingRecipes(RecipeTemplate template, RecipeTemplate templateSmall, RecipeTemplate templateShapeless, RecipeGenerator generator)
private void addCraftingRecipes( RecipeTemplate template, RecipeTemplate templateSmall, RecipeTemplate templateShapeless, RecipeGenerator generator )
{
List recipes = CraftingManager.getInstance().getRecipeList();
int errCount = 0;
for (Object o : recipes)
for( Object o : recipes )
{
try
{
@@ -141,11 +121,11 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
Object[] items = generator.getCraftingRecipe( recipe, true );
if ( items.length == 5 )
if( items.length == 5 )
{
generator.addRecipe( templateSmall, items );
}
else if ( recipe instanceof ShapelessRecipe )
else if( recipe instanceof ShapelessRecipe )
{
generator.addRecipe( templateShapeless, items );
}
@@ -154,13 +134,11 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
generator.addRecipe( template, items );
}
}
catch (Exception e)
catch( Exception e )
{
if ( errCount >= 5 )
if( errCount >= 5 )
{
CraftGuideLog
.log( "CraftGuide DefaultRecipeProvider: Stack trace limit reached, further stack traces from this invocation will not be logged to the console. They will still be logged to (.minecraft)/config/CraftGuide/CraftGuide.log",
true );
CraftGuideLog.log( "CraftGuide DefaultRecipeProvider: Stack trace limit reached, further stack traces from this invocation will not be logged to the console. They will still be logged to (.minecraft)/config/CraftGuide/CraftGuide.log", true );
errCount = -1;
}
else
@@ -174,83 +152,80 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
}
}
private void addGrinderRecipes(RecipeTemplate template, RecipeGenerator generator)
private void addGrinderRecipes( RecipeTemplate template, RecipeGenerator generator )
{
}
private void addInscriberRecipes(RecipeTemplate template, RecipeGenerator generator)
private void addInscriberRecipes( RecipeTemplate template, RecipeGenerator generator )
{
}
@Override
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType)
public RecipeTemplate createRecipeTemplate( Slot[] slots, ItemStack craftingType )
{
return this.parent.createRecipeTemplate( slots, craftingType );
}
@Override
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY,
int backgroundSelectedX, int backgroundSelectedY)
public RecipeTemplate createRecipeTemplate( Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, int backgroundSelectedX, int backgroundSelectedY )
{
return this.parent.createRecipeTemplate( slots, craftingType, backgroundTexture, backgroundX, backgroundY, backgroundSelectedX, backgroundSelectedY );
}
@Override
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY,
String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY)
public RecipeTemplate createRecipeTemplate( Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY )
{
return this.parent.createRecipeTemplate( slots, craftingType, backgroundTexture, backgroundX, backgroundY, backgroundSelectedTexture, backgroundSelectedX,
backgroundSelectedY );
return this.parent.createRecipeTemplate( slots, craftingType, backgroundTexture, backgroundX, backgroundY, backgroundSelectedTexture, backgroundSelectedX, backgroundSelectedY );
}
@Override
public void addRecipe(RecipeTemplate template, Object[] crafting)
public void addRecipe( RecipeTemplate template, Object[] crafting )
{
this.parent.addRecipe( template, crafting );
}
@Override
public void addRecipe(CraftGuideRecipe recipe, ItemStack craftingType)
public void addRecipe( CraftGuideRecipe recipe, ItemStack craftingType )
{
this.parent.addRecipe( recipe, craftingType );
}
@Override
public void setDefaultTypeVisibility(ItemStack type, boolean visible)
public void setDefaultTypeVisibility( ItemStack type, boolean visible )
{
this.parent.setDefaultTypeVisibility( type, visible );
}
@Override
public Object[] getCraftingRecipe(IRecipe recipe)
public Object[] getCraftingRecipe( IRecipe recipe )
{
return this.getCraftingRecipe( recipe, true );
}
Object[] getCraftingShapelessRecipe(List items, ItemStack recipeOutput)
Object[] getCraftingShapelessRecipe( List items, ItemStack recipeOutput )
{
Object[] output = new Object[10];
for (int i = 0; i < items.size(); i++)
for( int i = 0; i < items.size(); i++ )
{
output[i] = items.get( i );
if ( output[i] instanceof ItemStack[] )
if( output[i] instanceof ItemStack[] )
output[i] = Arrays.asList( (ItemStack[]) output[i] );
if ( output[i] instanceof IIngredient )
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ((IIngredient) output[i]).getItemStackSet() );
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch (RegistrationError ignored)
catch( RegistrationError ignored )
{
}
catch (MissingIngredientError ignored)
catch( MissingIngredientError ignored )
{
}
@@ -261,67 +236,31 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
return output;
}
Object[] getCraftingShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput)
{
Object[] output = new Object[10];
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int i = y * 3 + x;
output[i] = items[y * width + x];
if ( output[i] instanceof ItemStack[] )
output[i] = Arrays.asList( (ItemStack[]) output[i] );
if ( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ((IIngredient) output[i]).getItemStackSet() );
}
catch (RegistrationError ignored)
{
}
catch (MissingIngredientError ignored)
{
}
}
}
}
output[9] = recipeOutput;
return output;
}
Object[] getSmallShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput)
Object[] getSmallShapedRecipe( int width, int height, Object[] items, ItemStack recipeOutput )
{
Object[] output = new Object[5];
for (int y = 0; y < height; y++)
for( int y = 0; y < height; y++ )
{
for (int x = 0; x < width; x++)
for( int x = 0; x < width; x++ )
{
int i = y * 2 + x;
output[i] = items[y * width + x];
if ( output[i] instanceof ItemStack[] )
if( output[i] instanceof ItemStack[] )
output[i] = Arrays.asList( (ItemStack[]) output[i] );
if ( output[i] instanceof IIngredient )
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ((IIngredient) output[i]).getItemStackSet() );
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch (RegistrationError ignored)
catch( RegistrationError ignored )
{
}
catch (MissingIngredientError ignored)
catch( MissingIngredientError ignored )
{
}
@@ -333,14 +272,50 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
return output;
}
private Object toCG(ItemStack[] itemStackSet)
Object[] getCraftingShapedRecipe( int width, int height, Object[] items, ItemStack recipeOutput )
{
Object[] output = new Object[10];
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
int i = y * 3 + x;
output[i] = items[y * width + x];
if( output[i] instanceof ItemStack[] )
output[i] = Arrays.asList( (ItemStack[]) output[i] );
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
}
output[9] = recipeOutput;
return output;
}
private Object toCG( ItemStack[] itemStackSet )
{
List<ItemStack> list = Arrays.asList( itemStackSet );
for (int x = 0; x < list.size(); x++)
for( int x = 0; x < list.size(); x++ )
{
list.set( x, list.get( x ).copy() );
if ( list.get( x ).stackSize == 0 )
if( list.get( x ).stackSize == 0 )
list.get( x ).stackSize = 1;
}
@@ -348,20 +323,20 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
}
@Override
public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid)
public Object[] getCraftingRecipe( IRecipe recipe, boolean allowSmallGrid )
{
if ( recipe instanceof ShapelessRecipe )
if( recipe instanceof ShapelessRecipe )
{
List items = ReflectionHelper.getPrivateValue( ShapelessRecipe.class, (ShapelessRecipe) recipe, "input" );
return this.getCraftingShapelessRecipe( items, recipe.getRecipeOutput() );
}
else if ( recipe instanceof ShapedRecipe )
else if( recipe instanceof ShapedRecipe )
{
int width = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "width" );
int height = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "height" );
Object[] items = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "input" );
if ( allowSmallGrid && width < 3 && height < 3 )
if( allowSmallGrid && width < 3 && height < 3 )
{
return this.getSmallShapedRecipe( width, height, items, recipe.getRecipeOutput() );
}
@@ -369,7 +344,6 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
{
return this.getCraftingShapedRecipe( width, height, items, recipe.getRecipeOutput() );
}
}
return null;
@@ -386,5 +360,4 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
{
}
}