diff --git a/core/AEConfig.java b/core/AEConfig.java index 054ec21a1..dff97b55f 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -114,6 +114,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo public int colorapplicator_battery = 20000; public int staff_battery = 8000; + public boolean disableColoredCableRecipesInNEI = true; + public boolean updateable = false; final private File myPath; @@ -128,6 +130,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo private void clientSync() { + disableColoredCableRecipesInNEI = get( "Client", "disableColoredCableRecipesInNEI", true ).getBoolean( true ); enableEffects = get( "Client", "enableEffects", true ).getBoolean( true ); useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false ); @@ -152,6 +155,11 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo } + public boolean disableColoredCableRecipesInNEI() + { + return disableColoredCableRecipesInNEI; + } + public String getFilePath() { return myPath.toString(); diff --git a/core/Registration.java b/core/Registration.java index a97f6b3b4..7b2ed1ae4 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -140,7 +140,6 @@ import appeng.parts.PartPlacement; import appeng.recipes.AEItemResolver; import appeng.recipes.RecipeHandler; import appeng.recipes.game.FacadeRecipe; -import appeng.recipes.game.IRecipeBakeable; import appeng.recipes.game.ShapedRecipe; import appeng.recipes.game.ShapelessRecipe; import appeng.recipes.handlers.Crusher; @@ -195,7 +194,6 @@ public class Registration IRecipeHandlerRegistry recipeRegistery = AEApi.instance().registries().recipes(); recipeRegistery.addNewSubItemResolver( new AEItemResolver() ); - recipeRegistery.addNewCraftHandler( "hccrusher", HCCrusher.class ); recipeRegistery.addNewCraftHandler( "mekcrusher", MekCrusher.class ); recipeRegistery.addNewCraftHandler( "mekechamber", MekEnrichment.class ); @@ -693,26 +691,11 @@ public class Registration * Whitelist AE2 */ mr.whiteListTileEntity( AEBaseTile.class ); - - bakeRecipes(); - } - private void bakeRecipes() - { - for ( Object o : CraftingManager.getInstance().getRecipeList() ) - { - if ( o instanceof IRecipeBakeable ) - { - try - { - ( (IRecipeBakeable) o ).bake(); - } - catch (Throwable e) - { - AELog.error( e ); - } - } - } + /** + * initial recipe bake, if ore dictionary changes after this it re-bakes. + */ + OreDictionaryHandler.instance.bakeRecipes(); } private void registerSpatial(boolean force) diff --git a/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java b/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java index 0d6f97d8a..cac381299 100644 --- a/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java +++ b/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java @@ -10,7 +10,12 @@ import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; +import appeng.api.exceptions.MissingIngredientError; +import appeng.api.exceptions.RegistrationError; +import appeng.api.recipes.IIngredient; +import appeng.core.AEConfig; import appeng.recipes.game.ShapedRecipe; +import appeng.util.Platform; import codechicken.nei.NEIClientUtils; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; @@ -87,7 +92,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler if ( (irecipe instanceof ShapedRecipe) ) { CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe ); - + if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) { recipe.computeVisuals(); @@ -123,11 +128,11 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if ( renderer != null ) return renderer; - + IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); if ( positioner == null ) return null; - + return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner ); } @@ -137,7 +142,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if ( handler != null ) return handler; - + return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } @@ -165,15 +170,31 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler public void setIngredients(int width, int height, Object[] items) { + boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if ( items[(y * width + x)] != null ) { - PositionedStack stack = new PositionedStack( items[(y * width + x)], 25 + x * 18, 6 + y * 18, false ); - stack.setMaxSize( 1 ); - this.ingredients.add( stack ); + IIngredient ing = (IIngredient) items[(y * width + x)]; + + try + { + ItemStack[] is = ing.getItemStackSet(); + PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPrefered( is ) : is, 25 + x * 18, 6 + y * 18, false ); + stack.setMaxSize( 1 ); + this.ingredients.add( stack ); + } + catch (RegistrationError e) + { + + } + catch (MissingIngredientError e) + { + + } + } } } diff --git a/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java b/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java index 93752e0fa..1352c0f5d 100644 --- a/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java +++ b/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java @@ -10,7 +10,12 @@ import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; +import appeng.api.exceptions.MissingIngredientError; +import appeng.api.exceptions.RegistrationError; +import appeng.api.recipes.IIngredient; +import appeng.core.AEConfig; import appeng.recipes.game.ShapelessRecipe; +import appeng.util.Platform; import codechicken.nei.NEIClientUtils; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; @@ -87,7 +92,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler if ( (irecipe instanceof ShapelessRecipe) ) { CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe ); - + if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) { recipe.computeVisuals(); @@ -123,11 +128,11 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if ( renderer != null ) return renderer; - + IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); if ( positioner == null ) return null; - + return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner ); } @@ -137,7 +142,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if ( handler != null ) return handler; - + return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } @@ -165,15 +170,32 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler 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) ) { - PositionedStack stack = new PositionedStack( items[(y * 3 + x)], 25 + x * 18, 6 + y * 18, false ); - stack.setMaxSize( 1 ); - this.ingredients.add( stack ); + IIngredient ing = (IIngredient) items[(y * 3 + x)]; + + try + { + ItemStack[] is = ing.getItemStackSet(); + PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPrefered( is ) : ing.getItemStackSet(), 25 + x * 18, + 6 + y * 18, false ); + stack.setMaxSize( 1 ); + this.ingredients.add( stack ); + } + catch (RegistrationError e) + { + + } + catch (MissingIngredientError e) + { + + } + } } } @@ -195,7 +217,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { for (PositionedStack p : this.ingredients) p.generatePermutations(); - + this.result.generatePermutations(); } } diff --git a/recipes/GroupIngredient.java b/recipes/GroupIngredient.java index fffe5ae63..2221f54eb 100644 --- a/recipes/GroupIngredient.java +++ b/recipes/GroupIngredient.java @@ -60,7 +60,7 @@ public class GroupIngredient implements IIngredient { if ( baked != null ) return baked; - + if ( isInside ) return new ItemStack[0]; @@ -114,6 +114,7 @@ public class GroupIngredient implements IIngredient @Override public void bake() throws RegistrationError, MissingIngredientError { + baked = null; baked = getItemStackSet(); } diff --git a/recipes/Ingredient.java b/recipes/Ingredient.java index da4bd9e5e..31d21fed1 100644 --- a/recipes/Ingredient.java +++ b/recipes/Ingredient.java @@ -27,7 +27,7 @@ public class Ingredient implements IIngredient final public int qty; ItemStack[] baked; - + public Ingredient(RecipeHandler handler, String input, int qty) throws RecipeError, MissedIngredientSet { // works no matter wat! @@ -105,8 +105,8 @@ public class Ingredient implements IIngredient } else throw new RecipeError( input + " : Needs at least Namespace and Name." ); - - handler.data.knownItem.add( toString() ); + + handler.data.knownItem.add( toString() ); } @Override @@ -163,7 +163,7 @@ public class Ingredient implements IIngredient { if ( baked != null ) return baked; - + if ( nameSpace.equalsIgnoreCase( "oreDictionary" ) ) { List ores = OreDictionary.getOres( itemName ); @@ -219,7 +219,8 @@ public class Ingredient implements IIngredient @Override public void bake() throws RegistrationError, MissingIngredientError { + baked = null; baked = getItemStackSet(); } - + } diff --git a/recipes/IngredientSet.java b/recipes/IngredientSet.java index 6a8a151fd..4a888eeeb 100644 --- a/recipes/IngredientSet.java +++ b/recipes/IngredientSet.java @@ -17,7 +17,7 @@ public class IngredientSet implements IIngredient final String name; final List items; ItemStack[] baked; - + public IngredientSet(ResolverResultSet rr) { name = rr.name; items = rr.results; @@ -47,7 +47,7 @@ public class IngredientSet implements IIngredient { if ( baked != null ) return baked; - + if ( isInside ) return new ItemStack[0]; @@ -79,11 +79,12 @@ public class IngredientSet implements IIngredient { return false; } - + @Override public void bake() throws RegistrationError, MissingIngredientError { + baked = null; baked = getItemStackSet(); } - + } diff --git a/recipes/ores/OreDictionaryHandler.java b/recipes/ores/OreDictionaryHandler.java index 394212eb5..ed1a2de91 100644 --- a/recipes/ores/OreDictionaryHandler.java +++ b/recipes/ores/OreDictionaryHandler.java @@ -4,7 +4,10 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; import net.minecraftforge.oredict.OreDictionary; +import appeng.core.AELog; +import appeng.recipes.game.IRecipeBakeable; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class OreDictionaryHandler @@ -14,6 +17,8 @@ public class OreDictionaryHandler private List ol = new ArrayList(); + private boolean enableRebaking = false; + /** * Just limit what items are sent to the final listeners, I got sick of strange items showing up... * @@ -33,6 +38,9 @@ public class OreDictionaryHandler for (IOreListener v : ol) v.oreRegistered( event.Name, event.Ore ); } + + if ( enableRebaking ) + bakeRecipes(); } /** @@ -58,4 +66,24 @@ public class OreDictionaryHandler } } + public void bakeRecipes() + { + enableRebaking = true; + + for (Object o : CraftingManager.getInstance().getRecipeList()) + { + if ( o instanceof IRecipeBakeable ) + { + try + { + ((IRecipeBakeable) o).bake(); + } + catch (Throwable e) + { + AELog.error( e ); + } + } + } + } + } diff --git a/util/Platform.java b/util/Platform.java index e92c9d765..cd934d47d 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -80,6 +80,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAETagCompound; import appeng.api.storage.data.IItemList; +import appeng.api.util.AEColor; import appeng.api.util.AEItemDefinition; import appeng.core.AEConfig; import appeng.core.AELog; @@ -1412,7 +1413,7 @@ public class Platform if ( myFluids != null ) { - for (IAEFluidStack is : myFluids.getAvailableItems( AEApi.instance().storage().createFluidList() ) ) + for (IAEFluidStack is : myFluids.getAvailableItems( AEApi.instance().storage().createFluidList() )) { gs.postAlterationOfStoredItems( StorageChannel.FLUIDS, is, src ); } @@ -1692,4 +1693,23 @@ public class Platform return false; } + public static Object findPrefered(ItemStack[] is) + { + for (ItemStack stack : is) + { + if ( AEApi.instance().parts().partCableGlass.sameAs( AEColor.Transparent, stack ) ) + return stack; + + if ( AEApi.instance().parts().partCableCovered.sameAs( AEColor.Transparent, stack ) ) + return stack; + + if ( AEApi.instance().parts().partCableSmart.sameAs( AEColor.Transparent, stack ) ) + return stack; + + if ( AEApi.instance().parts().partCableDense.sameAs( AEColor.Transparent, stack ) ) + return stack; + } + + return is; + } }