From 5f3e8fc748b4e7834a2fde56b466dbf7489d6e50 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 5 May 2016 10:01:15 +0200 Subject: [PATCH] Added a default extra whitelist config option for the Item Repairer Closes #85 --- .../mod/config/ConfigValues.java | 7 ++++-- .../mod/items/ItemDrill.java | 2 +- .../mod/tile/TileEntityItemRepairer.java | 22 ++++++++++++++++++- .../actuallyadditions/mod/util/ModUtil.java | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java index 36608a319..7f56d2ac0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java @@ -25,7 +25,7 @@ public class ConfigValues{ public static String[] mashedFoodCraftingExceptions; public static String[] paxelExtraMiningWhitelist; - public static String[] drillExtraminingWhitelist; + public static String[] drillExtraMiningWhitelist; public static int[] oreGenDimensionBlacklist; public static int[] plantDimensionBlacklist; @@ -33,6 +33,8 @@ public class ConfigValues{ public static String[] minerExtraWhitelist; public static String[] minerBlacklist; + public static String[] repairerExtraWhitelist; + public static boolean lessSound; public static boolean lessParticles; public static boolean lessBlockBreakingEffects; @@ -52,11 +54,12 @@ public class ConfigValues{ crusherRecipeExceptions = config.get(ConfigCategories.OTHER.name, "Crusher Recipe Exceptions", new String[]{"ingotBrick", "ingotBrickNether"}, "The Ingots, Dusts and Ores blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only.").getStringList(); mashedFoodCraftingExceptions = config.get(ConfigCategories.ITEMS_CRAFTING.name, "Mashed Food Crafting Exceptions", new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); paxelExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "AIOT Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); - drillExtraminingWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "Drill Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); + drillExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "Drill Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); oreGenDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "OreGen Dimension Blacklist", new int[0], "The IDs of the dimensions that Actually Additions OreGen (Black Quartz for example) is banned in").getIntList(); plantDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "Plant Blacklist", new int[0], "The IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in").getIntList(); minerExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Extra Whitelist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode.").getStringList(); minerBlacklist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Blacklist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes.").getStringList(); + repairerExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Item Repairer Extra Whitelist", new String[]{"tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver"}, "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable.").getStringList(); lessSound = config.get(ConfigCategories.PERFORMANCE.name, "Less Sound", false, "If blocks in Actually Additions should have less sounds").getBoolean(); lessParticles = config.get(ConfigCategories.PERFORMANCE.name, "Less Particles", false, "If blocks in Actually Additions should have less particles").getBoolean(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 625788ed8..91149e37e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -520,7 +520,7 @@ public class ItemDrill extends ItemEnergy{ private boolean hasExtraWhitelist(Block block){ String name = block.getRegistryName().toString(); if(name != null){ - for(String list : ConfigValues.drillExtraminingWhitelist){ + for(String list : ConfigValues.drillExtraMiningWhitelist){ if(list.equals(name)){ return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java index 580fc3f04..554233eb2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java @@ -12,6 +12,8 @@ package de.ellpeck.actuallyadditions.mod.tile; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyReceiver; +import de.ellpeck.actuallyadditions.mod.config.ConfigValues; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -32,7 +34,25 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I } public static boolean canBeRepaired(ItemStack stack){ - return stack != null && stack.getItem().isRepairable(); + if(stack != null){ + Item item = stack.getItem(); + if(item != null){ + if(item.isRepairable()){ + return true; + } + else{ + String reg = item.getRegistryName().toString(); + if(reg != null){ + for(String strg : ConfigValues.repairerExtraWhitelist){ + if(reg.equals(strg)){ + return true; + } + } + } + } + } + } + return false; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java index 05960ae61..fc92f3d5f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java @@ -21,5 +21,5 @@ public class ModUtil{ public static final String MOD_ID = ActuallyAdditionsAPI.MOD_ID; public static final String NAME = "Actually Additions"; - public static final Logger LOGGER = LogManager.getLogger(MOD_ID); + public static final Logger LOGGER = LogManager.getLogger(NAME); }