Basic reformat, hit once, hope never again
This commit is contained in:
+79
-78
@@ -18,7 +18,8 @@
|
||||
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,6 +47,7 @@ import appeng.core.AEConfig;
|
||||
import appeng.recipes.game.ShapelessRecipe;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
@@ -56,28 +58,16 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
public void loadCraftingRecipes( String outputId, Object... results )
|
||||
{
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return NEIClientUtils.translate( "recipe.shapeless" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (this.getClass() == NEIAEShapelessRecipeHandler.class) )
|
||||
if( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIAEShapelessRecipeHandler.class ) )
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe recipe : recipes)
|
||||
for( IRecipe recipe : recipes )
|
||||
{
|
||||
if ( (recipe instanceof ShapelessRecipe) )
|
||||
if( ( recipe instanceof ShapelessRecipe ) )
|
||||
{
|
||||
if ( ((ShapelessRecipe) recipe).isEnabled() )
|
||||
if( ( (ShapelessRecipe) recipe ).isEnabled() )
|
||||
{
|
||||
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
|
||||
cachedRecipe.computeVisuals();
|
||||
@@ -93,14 +83,14 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
public void loadCraftingRecipes( ItemStack result )
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe recipe : recipes)
|
||||
for( IRecipe recipe : recipes )
|
||||
{
|
||||
if ( (recipe instanceof ShapelessRecipe) )
|
||||
if( ( recipe instanceof ShapelessRecipe ) )
|
||||
{
|
||||
if ( ((ShapelessRecipe) recipe).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( recipe.getRecipeOutput(), result ) )
|
||||
if( ( (ShapelessRecipe) recipe ).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( recipe.getRecipeOutput(), result ) )
|
||||
{
|
||||
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
|
||||
cachedRecipe.computeVisuals();
|
||||
@@ -111,19 +101,19 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
public void loadUsageRecipes( ItemStack ingredient )
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe recipe : recipes)
|
||||
for( IRecipe recipe : recipes )
|
||||
{
|
||||
if ( (recipe instanceof ShapelessRecipe) )
|
||||
if( ( recipe instanceof ShapelessRecipe ) )
|
||||
{
|
||||
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
|
||||
|
||||
if ( ((ShapelessRecipe) recipe).isEnabled() && cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) )
|
||||
if( ( (ShapelessRecipe) recipe ).isEnabled() && cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) )
|
||||
{
|
||||
cachedRecipe.computeVisuals();
|
||||
if ( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
|
||||
if( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
|
||||
{
|
||||
cachedRecipe.setIngredientPermutation( cachedRecipe.ingredients, ingredient );
|
||||
this.arecipes.add( cachedRecipe );
|
||||
@@ -146,105 +136,116 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return (super.hasOverlay( gui, container, recipe )) || ((this.isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
|
||||
{
|
||||
return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
|
||||
{
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
|
||||
if ( renderer != null )
|
||||
if( renderer != null )
|
||||
return renderer;
|
||||
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
|
||||
if ( positioner == null )
|
||||
if( positioner == null )
|
||||
return null;
|
||||
|
||||
return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
|
||||
{
|
||||
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
|
||||
if ( handler != null )
|
||||
if( handler != null )
|
||||
return handler;
|
||||
|
||||
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe)
|
||||
public boolean isRecipe2x2( int recipe )
|
||||
{
|
||||
for (PositionedStack stack : this.getIngredientStacks( recipe ))
|
||||
for( PositionedStack stack : this.getIngredientStacks( recipe ) )
|
||||
{
|
||||
if ( (stack.relx > 43) || (stack.rely > 24) )
|
||||
if( ( stack.relx > 43 ) || ( stack.rely > 24 ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return NEIClientUtils.translate( "recipe.shapeless" );
|
||||
}
|
||||
|
||||
public class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public final ArrayList<PositionedStack> ingredients;
|
||||
public final PositionedStack result;
|
||||
|
||||
public CachedShapelessRecipe(ShapelessRecipe recipe) {
|
||||
public CachedShapelessRecipe( ShapelessRecipe recipe )
|
||||
{
|
||||
this.result = new PositionedStack( recipe.getRecipeOutput(), 119, 24 );
|
||||
this.ingredients = new ArrayList<PositionedStack>();
|
||||
this.setIngredients( recipe.getInput().toArray() );
|
||||
}
|
||||
|
||||
public void setIngredients(Object[] items)
|
||||
{
|
||||
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
if ( items.length > (y * 3 + x) )
|
||||
{
|
||||
IIngredient ing = (IIngredient) items[(y * 3 + x)];
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack[] is = ing.getItemStackSet();
|
||||
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : ing.getItemStackSet(), 25 + x * 18,
|
||||
6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
catch (RegistrationError ignored)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return this.getCycledIngredients( NEIAEShapelessRecipeHandler.this.cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return this.getCycledIngredients( NEIAEShapelessRecipeHandler.this.cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
public void setIngredients( Object[] items )
|
||||
{
|
||||
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
if( items.length > ( y * 3 + x ) )
|
||||
{
|
||||
IIngredient ing = (IIngredient) items[( y * 3 + x )];
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack[] is = ing.getItemStackSet();
|
||||
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : ing.getItemStackSet(), 25 + x * 18, 6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
catch( RegistrationError ignored )
|
||||
{
|
||||
|
||||
}
|
||||
catch( MissingIngredientError ignored )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
for( PositionedStack p : this.ingredients )
|
||||
p.generatePermutations();
|
||||
|
||||
this.result.generatePermutations();
|
||||
|
||||
Reference in New Issue
Block a user