From c80d8118e06d5e952a41c52efd7536631f985e45 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 11 Aug 2014 20:02:50 +0200 Subject: [PATCH] Add defaults for the whitelisted tools. Also allow mod-wide whitelisting, for stuff like Redstone Armory. --- .../reference/Config.java | 28 +++++++++++++------ .../tweaks/IguanaTweaks.java | 16 +++++++++-- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java index 5e2d4a3..4acf2fb 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java @@ -72,6 +72,7 @@ public class Config { // allowed tools that should not be nerfed public static List allowedTools = new LinkedList(); + public static Set allowedModTools = new HashSet(); // debug public static boolean showDebugXP; @@ -197,15 +198,17 @@ public class Config { //repairAmountMultiplier = configfile.getFloat("repairAmountMultiplier", CATEGORY_Tweaks, 1.0f, 0.01f, 9.99f, "A factor that is multiplied onto the amount a tool is repaired. (0.5 = half durability restored per repair, 2.0 = twice as much durability restored per repair)"); /** Allowed tools for nerfed vanilla tools **/ - configfile.setCategoryComment(CATEGORY_AllowedTools, "Tweak Module: This category allows you to specify which tools ARE STILL USABLE if the option to disable non-TConstsruct tools is enabled.\nYou can use * as a wildcard if you want to enable all items of a mod. For example minecraft:* would enable all vanilla tools."); + configfile.setCategoryComment(CATEGORY_AllowedTools, "Tweak Module: This category allows you to specify which tools ARE STILL USABLE if the option to disable non-TConstsruct tools is enabled."); { - String[] axes = configfile.getStringList("axes", CATEGORY_AllowedTools, new String[0], "Axes that shall remain useful"); - String[] picks = configfile.getStringList("pickaxes", CATEGORY_AllowedTools, new String[0], "Pickaxes that shall remain useful"); - String[] shovels = configfile.getStringList("shovels", CATEGORY_AllowedTools, new String[0], "Shovels that shall remain useful"); - String[] swords = configfile.getStringList("swords", CATEGORY_AllowedTools, new String[0], "Swords that shall remain useful"); - String[] bows = configfile.getStringList("bows", CATEGORY_AllowedTools, new String[0], "bows that shall remain useful"); - String[] hoes = configfile.getStringList("hoes", CATEGORY_AllowedTools, new String[0], "Hoes that shall remain useful"); - String[] other = configfile.getStringList("unspecified", CATEGORY_AllowedTools, new String[0], "Other tools. I'll be honest, the category doesn't matter, they're just for readability :P"); + String[] axes = configfile.getStringList("axes", CATEGORY_AllowedTools, defaultAllowedAxes, "Axes that shall remain useful"); + String[] picks = configfile.getStringList("pickaxes", CATEGORY_AllowedTools, defaultAllowedPicks, "Pickaxes that shall remain useful"); + String[] shovels = configfile.getStringList("shovels", CATEGORY_AllowedTools, defaultAllowedShovel, "Shovels that shall remain useful"); + String[] swords = configfile.getStringList("swords", CATEGORY_AllowedTools, defaultAllowedSwords, "Swords that shall remain useful"); + String[] bows = configfile.getStringList("bows", CATEGORY_AllowedTools, defaultAllowedBows, "bows that shall remain useful"); + String[] hoes = configfile.getStringList("hoes", CATEGORY_AllowedTools, defaultAllowedHoes, "Hoes that shall remain useful"); + String[] other = configfile.getStringList("unspecified", CATEGORY_AllowedTools, defaultAllowedOther, "Other tools. I'll be honest, the category doesn't matter, they're just for readability :P"); + + allowedModTools.addAll(Arrays.asList(configfile.getStringList("mods", CATEGORY_AllowedTools, defaultAllowMod, "Here you can enter a mod-id to whitelist ALL itesm of this mod."))); allowedTools.addAll(Arrays.asList(picks)); allowedTools.addAll(Arrays.asList(axes)); @@ -323,4 +326,13 @@ public class Config { sync(); } + + private static String[] defaultAllowedPicks = new String[]{"Botania:terraPick", "Botania:glassPick", "Steamcraft:steamDrill"}; + private static String[] defaultAllowedAxes = new String[]{"Steamcraft:steamAxe"}; + private static String[] defaultAllowedShovel = new String[]{"Steamcraft:steamShovel"}; + private static String[] defaultAllowedHoes = new String[]{}; + private static String[] defaultAllowedSwords = new String[]{"Botania:terraSword", "Botania:enderDagger"}; + private static String[] defaultAllowedBows = new String[]{}; + private static String[] defaultAllowedOther = new String[]{"ThermalExpansion:tool.battleWrenchInvar", "ThermalExpansion:tool.sickleInvar"}; + private static String[] defaultAllowMod = new String[]{"RedstoneArsenal", "ExtraUtilities", "witchery", "AWWayofTime"}; } diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java index ccaaa4a..60659ea 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java @@ -13,8 +13,7 @@ import mantle.pulsar.pulse.Handler; import mantle.pulsar.pulse.Pulse; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.item.*; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; @@ -243,5 +242,18 @@ public class IguanaTweaks { if(o != null) toolWhitelist.add((Item)o); } + + // mod-wide enabling + for(Object identifier : Item.itemRegistry.getKeys()) + { + String mod = identifier.toString().split(":")[0]; // should always be non-null... I think + if(Config.allowedModTools.contains(mod)) + { + // get the item + Object item = Item.itemRegistry.getObject(identifier); + if(item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemSword || item instanceof ItemBow) + toolWhitelist.add((Item)item); + } + } } }