From 5092c1dab7c959bf7895ee2691bfc864a96e8994 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 13 Sep 2015 16:41:49 +0200 Subject: [PATCH] Added special Whitelist Config for Paxels and the Drill --- .../actuallyadditions/config/ConfigValues.java | 5 +++++ .../actuallyadditions/items/ItemDrill.java | 15 +++++++++++++-- .../items/tools/ItemAllToolAA.java | 15 +++++++++++++-- .../assets/actuallyadditions/lang/en_US.lang | 4 ++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java index 140330e28..ebbe4ed7b 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java @@ -29,6 +29,9 @@ public class ConfigValues{ public static String[] oreMagnetExceptions; public static String[] oreMagnetExtraWhitelist; + public static String[] paxelExtraMiningWhitelist; + public static String[] drillExtraminingWhitelist; + public static void defineConfigValues(Configuration config){ for(ConfigCrafting currConf : craftingConfig){ @@ -48,5 +51,7 @@ public class ConfigValues{ 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."); oreMagnetExtraWhitelist = config.getStringList("Ore Magnet Extra Whitelist", ConfigCategories.MACHINE_VALUES.name, new String[]{"rftools:dimensionalShardBlock"}, "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."); + paxelExtraMiningWhitelist = config.getStringList("AIOT Extra Whitelist", ConfigCategories.TOOL_VALUES.name, new String[]{"TConstruct:GravelOre"}, "By default, the AIOT 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."); + drillExtraminingWhitelist = config.getStringList("Drill Extra Whitelist", ConfigCategories.TOOL_VALUES.name, 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."); } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java index ac8c16efb..d47e1b9c0 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java @@ -15,6 +15,7 @@ import com.google.common.collect.Multimap; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.config.values.ConfigFloatValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.inventory.GuiHandler; @@ -401,14 +402,24 @@ public class ItemDrill extends ItemEnergy implements INameableItem{ return true; } + private boolean hasExtraWhitelist(Block block){ + String name = Block.blockRegistry.getNameForObject(block); + if(name != null){ + for(String list : ConfigValues.drillExtraminingWhitelist){ + if(list.equals(name)) return true; + } + } + return false; + } + @Override public float getDigSpeed(ItemStack stack, Block block, int meta){ - return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) ? (block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.getEfficiencyFromUpgrade(stack) : 1.0F) : 0.0F; + return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) ? (this.hasExtraWhitelist(block) || block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.getEfficiencyFromUpgrade(stack) : 1.0F) : 0.0F; } @Override public boolean canHarvestBlock(Block block, ItemStack stack){ - return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? ToolMaterial.EMERALD.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 1) : ToolMaterial.EMERALD.getHarvestLevel() >= 1) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 2)))); + return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? ToolMaterial.EMERALD.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 1) : ToolMaterial.EMERALD.getHarvestLevel() >= 1) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 2) : ToolMaterial.EMERALD.getHarvestLevel() >= 2)))); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java b/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java index df828494c..47da093d9 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java @@ -14,6 +14,7 @@ import com.google.common.collect.Sets; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.util.INameableItem; import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.block.Block; @@ -50,14 +51,24 @@ public class ItemAllToolAA extends ItemTool implements INameableItem{ this.setMaxDamage(this.getMaxDamage()*4); } + private boolean hasExtraWhitelist(Block block){ + String name = Block.blockRegistry.getNameForObject(block); + if(name != null){ + for(String list : ConfigValues.paxelExtraMiningWhitelist){ + if(list.equals(name)) return true; + } + } + return false; + } + @Override public float getDigSpeed(ItemStack stack, Block block, int meta){ - return block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.efficiencyOnProperMaterial : 1.0F; + return this.hasExtraWhitelist(block) || block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.efficiencyOnProperMaterial : 1.0F; } @Override public boolean canHarvestBlock(Block block, ItemStack stack){ - return block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2))); + return this.hasExtraWhitelist(block) || block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2))); } @Override diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index c5df4bb44..8796fe32a 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -405,7 +405,7 @@ booklet.actuallyadditions.chapter.treasureChest.text.1=Treasure Chests booklet.actuallyadditions.chapter.breaker.name=Breakers and Placers booklet.actuallyadditions.chapter.breaker.text.1=The Breaker... well.. it breaks blocks in front of it. That's about it. It can be oriented in every direction like a Piston. booklet.actuallyadditions.chapter.breaker.text.2=The Placer... well... it places blocks in front of it. That's about it. It can be oriented in every direction like a Piston. -booklet.actuallyadditions.chapter.breaker.text.3=The Liquid Placer places blocks that correspond to the liquid you put in via a bucket or pipe in via a pipe. Needs 1000mb to place one block. -booklet.actuallyadditions.chapter.breaker.text.4=The Liquid Collector will collect liquid blocks in front of it and convert them to 1000mb of fluid. That's the equivalent of a filled bucket. +booklet.actuallyadditions.chapter.breaker.text.3=The Liquid Placer places blocks that correspond to the liquid you put in via a bucket or pipe in via a pipe. Needs 1000mB to place one block. +booklet.actuallyadditions.chapter.breaker.text.4=The Liquid Collector will collect liquid blocks in front of it and convert them to 1000mB of fluid. That's the equivalent of a filled bucket. booklet.actuallyadditions.chapter.phantomfaces.name=Phantomfaces