Added an extra Whitelist for the Ore Magnet.

For stuff which isn't OreDictionaried.
People know what I'm talking about.
This commit is contained in:
Ellpeck 2015-08-14 19:25:01 +02:00
parent d29c8116e5
commit 90f330fd97
2 changed files with 33 additions and 10 deletions

View file

@ -15,7 +15,9 @@ public class ConfigValues{
public static String[] crusherRecipeExceptions; public static String[] crusherRecipeExceptions;
public static String[] mashedFoodCraftingExceptions; public static String[] mashedFoodCraftingExceptions;
public static String[] oreMagnetExceptions; public static String[] oreMagnetExceptions;
public static String[] oreMagnetExtraWhitelist;
public static void defineConfigValues(Configuration config){ public static void defineConfigValues(Configuration config){
@ -35,5 +37,6 @@ public class ConfigValues{
crusherRecipeExceptions = config.getStringList("Crusher Recipe Exceptions", ConfigCategories.CRUSHER_RECIPES.name, 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."); crusherRecipeExceptions = config.getStringList("Crusher Recipe Exceptions", ConfigCategories.CRUSHER_RECIPES.name, 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.");
mashedFoodCraftingExceptions = config.getStringList("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING.name, 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."); mashedFoodCraftingExceptions = config.getStringList("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING.name, 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.");
oreMagnetExceptions = config.getStringList("Ore Magnet Exceptions", ConfigCategories.MACHINE_VALUES.name, new String[0], "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want any Ore not to be pulled up by the Magnet, put its ORE DICTIONARY name here."); oreMagnetExceptions = config.getStringList("Ore Magnet Exceptions", ConfigCategories.MACHINE_VALUES.name, new String[0], "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want any Ore not to be pulled up by the Magnet, put its ORE DICTIONARY name here.");
oreMagnetExtraWhitelist = config.getStringList("Ore Magnet Extra Whitelist", ConfigCategories.MACHINE_VALUES.name, new String[0], "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want anything else to be pulled up by the Magnet, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.");
} }
} }

View file

@ -89,21 +89,18 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z); Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z); int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
if(block != null && !block.isAir(worldObj, xCoord+x, y, zCoord+z) && !block.hasTileEntity(meta) && block.getBlockHardness(worldObj, xCoord+x, y, zCoord+z) >= 0.0F && ((block.getMaterial() != null && block.getMaterial().isToolNotRequired()) || (block.getHarvestTool(meta) == null || (block.getHarvestTool(meta).equals("pickaxe") && block.getHarvestLevel(meta) <= 3)))){ if(block != null && !block.isAir(worldObj, xCoord+x, y, zCoord+z) && !block.hasTileEntity(meta) && block.getBlockHardness(worldObj, xCoord+x, y, zCoord+z) >= 0.0F && ((block.getMaterial() != null && block.getMaterial().isToolNotRequired()) || (block.getHarvestTool(meta) == null || (block.getHarvestTool(meta).equals("pickaxe") && block.getHarvestLevel(meta) <= 3)))){
//Check Whitelist
if(this.hasExtraWhitelist(block)){
this.removeBlock(x, y, z, block, meta, toPlaceY);
return;
}
//Check Ores
int[] oreIDs = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); int[] oreIDs = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
for(int ID : oreIDs){ for(int ID : oreIDs){
String oreName = OreDictionary.getOreName(ID); String oreName = OreDictionary.getOreName(ID);
//Is the block an ore according to the OreDictionary? //Is the block an ore according to the OreDictionary?
if(oreName.substring(0, 3).equals("ore") && !this.hasException(oreName)){ if(oreName.substring(0, 3).equals("ore") && !this.hasException(oreName)){
//Remove the Block this.removeBlock(x, y, z, block, meta, toPlaceY);
worldObj.setBlockToAir(xCoord+x, y, zCoord+z);
worldObj.playAuxSFX(2001, xCoord+x, y, zCoord+z, Block.getIdFromBlock(block)+(meta << 12));
//Set the Block at the Top again
worldObj.setBlock(xCoord+x, yCoord+toPlaceY, zCoord+z, block, meta, 2);
worldObj.playSoundEffect((double)xCoord+x+0.5D, (double)yCoord+toPlaceY+0.5D, (double)zCoord+z+0.5D, block.stepSound.func_150496_b(), (block.stepSound.getVolume()+1.0F)/2.0F, block.stepSound.getPitch()*0.8F);
//Extract oil
this.tank.drain(oilUsePerTick, true);
return; return;
} }
} }
@ -130,6 +127,19 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
} }
} }
private void removeBlock(int x, int y, int z, Block block, int meta, int toPlaceY){
//Remove the Block
worldObj.setBlockToAir(xCoord+x, y, zCoord+z);
worldObj.playAuxSFX(2001, xCoord+x, y, zCoord+z, Block.getIdFromBlock(block)+(meta << 12));
//Set the Block at the Top again
worldObj.setBlock(xCoord+x, yCoord+toPlaceY, zCoord+z, block, meta, 2);
worldObj.playSoundEffect((double)xCoord+x+0.5D, (double)yCoord+toPlaceY+0.5D, (double)zCoord+z+0.5D, block.stepSound.func_150496_b(), (block.stepSound.getVolume()+1.0F)/2.0F, block.stepSound.getPitch()*0.8F);
//Extract oil
this.tank.drain(oilUsePerTick, true);
}
private boolean hasException(String name){ private boolean hasException(String name){
for(String except : ConfigValues.oreMagnetExceptions){ for(String except : ConfigValues.oreMagnetExceptions){
if(except.equals(name)) return true; if(except.equals(name)) return true;
@ -137,6 +147,16 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
return false; return false;
} }
private boolean hasExtraWhitelist(Block block){
String name = Block.blockRegistry.getNameForObject(block);
if(name != null){
for(String list : ConfigValues.oreMagnetExtraWhitelist){
if(list.equals(name)) return true;
}
}
return false;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){ public int getEnergyScaled(int i){
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();