From 9748d86c0cfb01e3fcbb3cbac4c6b83692a01a3e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 2 Jul 2015 11:44:41 +0200 Subject: [PATCH] Added Config Options for Crusher Recipes --- .../config/ConfigCategories.java | 3 ++- .../config/ConfigValues.java | 6 ++++- .../config/values/ConfigCrafting.java | 25 +++++++++++++++++-- .../crafting/CrusherCrafting.java | 24 ++++++++---------- .../recipe/CrusherRecipeAutoRegistry.java | 11 ++++++-- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java index dc14d923a..d0e2f7c99 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java @@ -13,7 +13,8 @@ public enum ConfigCategories{ POTION_RING_CRAFTING("ring crafting"), OTHER("other"), FLUIDS("fluids"), - DRILL_VALUES("drill values"); + DRILL_VALUES("drill values"), + CRUSHER_RECIPES("crusher recipes"); public final String name; diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java index 6c77a8f53..f6358d6ef 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java @@ -13,10 +13,12 @@ public class ConfigValues{ public static ConfigFloatValues[] floatConfig = ConfigFloatValues.values(); public static ConfigBoolValues[] boolConfig = ConfigBoolValues.values(); + public static String[] crusherRecipeExceptions; + public static void defineConfigValues(Configuration config){ for(ConfigCrafting currConf : craftingConfig){ - currConf.currentValue = config.getBoolean(currConf.name, currConf.category, currConf.defaultValue, "If the Crafting Recipe for the "+currConf.name+" is Enabled"); + currConf.currentValue = config.getBoolean(currConf.name, currConf.category, currConf.defaultValue, "If the " + currConf.extraText + "Crafting Recipe for the "+currConf.name+" is Enabled"); } for(ConfigIntValues currConf : intConfig){ currConf.currentValue = config.getInt(currConf.name, currConf.category, currConf.defaultValue, currConf.min, currConf.max, currConf.desc); @@ -27,5 +29,7 @@ public class ConfigValues{ for(ConfigBoolValues currConf : boolConfig){ currConf.currentValue = config.getBoolean(currConf.name, currConf.category, currConf.defaultValue, currConf.desc); } + + crusherRecipeExceptions = config.getStringList("Crusher Recipe Exceptions", ConfigCategories.CRUSHER_RECIPES.name, new String[]{"ingotBrick", "ingotBrickNether"}, "The Ingots, Dusts and Ores blacklisted from being auto-registered by the Crusher. This list uses OreDictionary Names of the Inputs only."); } } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java index ee1dacf8d..24c33ca0a 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java @@ -107,11 +107,23 @@ public enum ConfigCrafting{ ENERVATOR("Enervator", ConfigCategories.BLOCKS_CRAFTING), QUARTZ("Black Quartz in a Crafting Table (as a Backup if there's no Ores to be found anywhere)", ConfigCategories.ITEMS_CRAFTING), - LAMPS("Lamps", ConfigCategories.BLOCKS_CRAFTING); + LAMPS("Lamps", ConfigCategories.BLOCKS_CRAFTING), + + REDSTONE("Redstone Ore -> Redstone", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + LAPIS("Lapis Ore -> Lapis", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + COAL("Coal -> Coal Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + COAL_BLOCKS("Coal Block -> Coal Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + COBBLESTONE("Cobblestone -> Sand", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + GRAVEL("Gravel -> Flint", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + STONE("Stone -> Cobblestone", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + RICE_SUGAR("Rice -> Sugar", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + IRON("Iron Ore -> Iron Dust + Gold Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"); public final String name; public final String category; public final boolean defaultValue; + public final String extraText; public boolean currentValue; @@ -119,10 +131,19 @@ public enum ConfigCrafting{ this(name, category, true); } - ConfigCrafting(String name, ConfigCategories category, boolean defaultValue){ + ConfigCrafting(String name, ConfigCategories category, String extraText){ + this(name, category, extraText, true); + } + + ConfigCrafting(String name, ConfigCategories category, String extraText, boolean defaultValue){ this.name = name; this.category = category.name; this.defaultValue = defaultValue; + this.extraText = extraText + " "; + } + + ConfigCrafting(String name, ConfigCategories category, boolean defaultValue){ + this(name, category, "", defaultValue); } public boolean isEnabled(){ diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java index c0e9a5600..448b66538 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java @@ -1,5 +1,6 @@ package ellpeck.actuallyadditions.crafting; +import ellpeck.actuallyadditions.config.values.ConfigCrafting; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheDusts; import ellpeck.actuallyadditions.items.metalists.TheFoods; @@ -16,18 +17,18 @@ public class CrusherCrafting{ public static void init(){ ModUtil.LOGGER.info("Initializing Crusher Recipes..."); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 10)); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.lapis_ore), new ItemStack(InitItems.itemDust, 12, TheDusts.LAPIS.ordinal())); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Items.coal), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal())); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.coal_block), new ItemStack(InitItems.itemDust, 9, TheDusts.COAL.ordinal())); + if(ConfigCrafting.REDSTONE.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 10)); + if(ConfigCrafting.LAPIS.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.lapis_ore), new ItemStack(InitItems.itemDust, 12, TheDusts.LAPIS.ordinal())); + if(ConfigCrafting.COAL.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Items.coal), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal())); + if(ConfigCrafting.COAL_BLOCKS.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.coal_block), new ItemStack(InitItems.itemDust, 9, TheDusts.COAL.ordinal())); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.sand)); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint)); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone)); - CrusherRecipeManualRegistry.registerRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.sugar, 2)); + if(ConfigCrafting.COBBLESTONE.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.sand)); + if(ConfigCrafting.GRAVEL.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint)); + if(ConfigCrafting.STONE.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone)); + if(ConfigCrafting.RICE_SUGAR.isEnabled()) CrusherRecipeManualRegistry.registerRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.sugar, 2)); - CrusherRecipeManualRegistry.registerRecipe("oreNickel", "dustNickel", "dustPlatinum", 15, 2, 1); - CrusherRecipeManualRegistry.registerRecipe("oreIron", "dustIron", "dustGold", 20, 2, 1); + if(ConfigCrafting.NICKEL.isEnabled()) CrusherRecipeManualRegistry.registerRecipe("oreNickel", "dustNickel", "dustPlatinum", 15, 2, 1); + if(ConfigCrafting.IRON.isEnabled()) CrusherRecipeManualRegistry.registerRecipe("oreIron", "dustIron", "dustGold", 20, 2, 1); CrusherRecipeAutoRegistry.searchCases.add(new SearchCase("oreNether", 6)); CrusherRecipeAutoRegistry.searchCases.add(new SearchCase("orePoor", 4, "nugget")); @@ -36,9 +37,6 @@ public class CrusherCrafting{ CrusherRecipeAutoRegistry.searchCases.add(new SearchCase("ingot", 1)); CrusherRecipeAutoRegistry.searchCases.add(new SearchCase("ore", 2)); - CrusherRecipeAutoRegistry.exceptions.add("ingotBrick"); - CrusherRecipeAutoRegistry.exceptions.add("ingotBrickNether"); - CrusherRecipeAutoRegistry.registerFinally(); } } diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/CrusherRecipeAutoRegistry.java b/src/main/java/ellpeck/actuallyadditions/recipe/CrusherRecipeAutoRegistry.java index 0049ad575..8d4c1e905 100644 --- a/src/main/java/ellpeck/actuallyadditions/recipe/CrusherRecipeAutoRegistry.java +++ b/src/main/java/ellpeck/actuallyadditions/recipe/CrusherRecipeAutoRegistry.java @@ -1,5 +1,6 @@ package ellpeck.actuallyadditions.recipe; +import ellpeck.actuallyadditions.config.ConfigValues; import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; @@ -7,7 +8,6 @@ import java.util.ArrayList; public class CrusherRecipeAutoRegistry{ public static ArrayList searchCases = new ArrayList(); - public static ArrayList exceptions = new ArrayList(); public static class SearchCase{ @@ -26,11 +26,18 @@ public class CrusherRecipeAutoRegistry{ } } + private static boolean hasException(String name){ + for(String except : ConfigValues.crusherRecipeExceptions){ + if(except.equals(name)) return true; + } + return false; + } + public static void registerFinally(){ String[] names = OreDictionary.getOreNames(); for(String inputName : names){ - if(!exceptions.contains(inputName)){ + if(!hasException(inputName)){ int resultAmount = 1; String inputNameWithoutPrefix = null; String replacer = null;