Skip to content

Instantly share code, notes, and snippets.

@RainWarrior
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RainWarrior/9107341 to your computer and use it in GitHub Desktop.
Save RainWarrior/9107341 to your computer and use it in GitHub Desktop.
val oreDictList = OreDictionary.getOreNames
for {
toolType <- ToolType.values
autodetectValues = configurationSettings.getAutodetectBlocksList(toolType)
if configurationSettings.getAutodetectBlocksToggle(toolType)
oreDictEntry <- oreDictList
autodetectValue <- autodetectValues
if !autodetectValue.isEmpty() && oreDictEntry.startsWith(autodetectValue)
itemStacks = OreDictionary.getOres(oreDictEntry)
item <- itemStacks
if item.getItem.instanceOf[ItemBlock]
} {
val blockName = Item.itemRegistry.getNameForObject(item.getItem)
configurationSettings.addBlockToWhitelist(toolType, new BlockID(blockName, item.getItemDamage))
try {
// Some mods raise an exception when calling getDisplayName on blocks.
MinerLogger debug s"Adding $blockName/${item.getItemDamage} (${item.getDisplayName}) to block whitelist for $toolType ($autoDetectValue:$oreDictEntry)"
}
catch {
case e: Exception =>
// Left over from 1.5/1.6 where some mods were throwing exceptions on item.getDisplayName()
// I just changed id => mod in 1.7
logger error s"ERROR while looking at block with name $blockName. This is a bug with the respective mod."
logger catching e
}
}
configurationSettings.saveConfigs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment