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[] oreGenDimensionBlacklist;
public static int[] plantDimensionBlacklist; public static int[] plantDimensionBlacklist;
public static String[] minerExtraWhitelist;
public static String[] minerBlacklist;
public static void defineConfigValues(Configuration config){ public static void defineConfigValues(Configuration config){
for(ConfigCrafting currConf : craftingConfig){ 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(); 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(); 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(); 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.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.ConfigValues;
import ellpeck.actuallyadditions.network.PacketHandler; import ellpeck.actuallyadditions.network.PacketHandler;
import ellpeck.actuallyadditions.network.PacketParticle; import ellpeck.actuallyadditions.network.PacketParticle;
import ellpeck.actuallyadditions.network.gui.IButtonReactor; import ellpeck.actuallyadditions.network.gui.IButtonReactor;
@ -107,6 +108,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
} }
private boolean isMinable(Block block, int meta){ private boolean isMinable(Block block, int meta){
if(!this.isBlacklisted(block)){
if(!this.onlyMineOres){ if(!this.onlyMineOres){
return true; return true;
} }
@ -118,9 +120,33 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
return true; 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; return false;
} }
} }
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;
}
private void shootParticles(int endX, int endY, int endZ){ private void shootParticles(int endX, int endY, int endZ){
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(xCoord, yCoord, zCoord, endX, endY, endZ, new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 96)); PacketHandler.theNetwork.sendToAllAround(new PacketParticle(xCoord, yCoord, zCoord, endX, endY, endZ, new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 96));