From 31fc8e7bfa0407392b6bd1b2067c0c6a3143531a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 27 Dec 2015 16:09:17 +0100 Subject: [PATCH] Miner Whitelist and Blacklist config --- .../config/ConfigValues.java | 5 +++ .../tile/TileEntityMiner.java | 42 +++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java index a694bf64d..b3c13e3bb 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java @@ -30,6 +30,9 @@ public class ConfigValues{ public static int[] oreGenDimensionBlacklist; public static int[] plantDimensionBlacklist; + public static String[] minerExtraWhitelist; + public static String[] minerBlacklist; + public static void defineConfigValues(Configuration config){ for(ConfigCrafting currConf : craftingConfig){ @@ -48,5 +51,7 @@ public class ConfigValues{ 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(); } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityMiner.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityMiner.java index f54589f2e..d7a4f01e3 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityMiner.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityMiner.java @@ -15,6 +15,7 @@ import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.network.PacketHandler; import ellpeck.actuallyadditions.network.PacketParticle; import ellpeck.actuallyadditions.network.gui.IButtonReactor; @@ -107,19 +108,44 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR } private boolean isMinable(Block block, int meta){ - if(!this.onlyMineOres){ - return true; + if(!this.isBlacklisted(block)){ + if(!this.onlyMineOres){ + return true; + } + else{ + int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); + for(int id : ids){ + String name = OreDictionary.getOreName(id); + if(name.startsWith("ore") || name.startsWith("denseore")){ + return true; + } + } + + String reg = Block.blockRegistry.getNameForObject(block); + if(reg != null && !reg.isEmpty()){ + for(String string : ConfigValues.minerExtraWhitelist){ + if(reg.equals(string)){ + return true; + } + } + } + + return false; + } } - else{ - int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); - for(int id : ids){ - String name = OreDictionary.getOreName(id); - if(name.startsWith("ore") || name.startsWith("denseore")){ + return false; + } + + private boolean isBlacklisted(Block block){ + String reg = Block.blockRegistry.getNameForObject(block); + if(reg != null && !reg.isEmpty()){ + for(String string : ConfigValues.minerBlacklist){ + if(reg.equals(string)){ return true; } } - return false; } + return false; } private void shootParticles(int endX, int endY, int endZ){