Miner Whitelist and Blacklist config

This commit is contained in:
Ellpeck 2015-12-27 16:09:17 +01:00
parent 317bfa1de5
commit 31fc8e7bfa
2 changed files with 39 additions and 8 deletions

View file

@ -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();
}
}

View file

@ -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){