From ee2a5c199a396af509b7573f9a1a591645c592f3 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Jun 2012 14:46:31 -0400 Subject: [PATCH] Added functionality to specify custom blocks that should not trigger abilities. --- .../config/mods/CustomBlocksConfig.java | 20 +++++++++++++------ .../com/gmail/nossr50/util/BlockChecks.java | 3 +++ src/main/resources/blocks.yml | 14 ++++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java index 3eaa158c6..c86b1761d 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java @@ -30,6 +30,7 @@ public class CustomBlocksConfig extends ModConfigLoader{ public List customOres = new ArrayList(); public List customLogs = new ArrayList(); public List customLeaves = new ArrayList(); + public List customAbilityBlocks = new ArrayList(); public List customItems = new ArrayList(); public List customBlocks = new ArrayList(); @@ -46,6 +47,7 @@ public class CustomBlocksConfig extends ModConfigLoader{ loadBlocks("Herbalism", customHerbalismBlocks); loadBlocks("Mining", customMiningBlocks); loadBlocks("Woodcutting", customWoodcuttingBlocks); + loadBlocks("Ability_Blocks", customAbilityBlocks); } private void loadBlocks(String skillType, List blockList) { @@ -66,20 +68,26 @@ public class CustomBlocksConfig extends ModConfigLoader{ int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1); int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1); + CustomBlock block; + ItemStack itemDrop; + ItemStack blockItem; + if (id == 0) { plugin.getLogger().warning("Missing ID. This block will be skipped."); continue; } + if (skillType == "Ability_Blocks") { + blockItem = new ItemStack(id, 1, (short) 0, data); + blockList.add(blockItem); + continue; + } + if (dropItem && dropID == 0) { plugin.getLogger().warning("Incomplete item drop information. This block will drop itself."); dropItem = false; } - CustomBlock block; - ItemStack itemDrop; - ItemStack blockItem; - if (dropItem) { itemDrop = new ItemStack(dropID, 1, (short) 0, dropData); } @@ -90,10 +98,10 @@ public class CustomBlocksConfig extends ModConfigLoader{ block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id); blockItem = new ItemStack(id, 1, (short) 0, data); - if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { + if (skillType == "Mining" && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { customOres.add(blockItem); } - else if (skillType.equals("Woodcutting")) { + else if (skillType == "Woodcutting") { if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) { customLogs.add(blockItem); } diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 68947aac5..c095d71b5 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -97,6 +97,9 @@ public class BlockChecks { if (block.getTypeId() == Config.getInstance().getRepairAnvilId()) { return false; } + else if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) { + return false; + } else { return true; } diff --git a/src/main/resources/blocks.yml b/src/main/resources/blocks.yml index f41d2cf98..12bb6b656 100644 --- a/src/main/resources/blocks.yml +++ b/src/main/resources/blocks.yml @@ -94,4 +94,16 @@ Woodcutting: Drop_Item_ID: 999 Drop_Item_Data_Value: 0 Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 \ No newline at end of file + Max_Drop_Item_Amount: 1 + +# +# Settings for Custom Ability Blocks +# (These blocks don't trigger abilities) +### +Ability_Blocks: + Block_1: + ID: 999 + Data_Value: 0 + Block_2: + ID: 999 + Data_Value: 0 \ No newline at end of file