From e1644d3c08e432047b6996e14d8c695d99863270 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 5 Mar 2012 23:29:05 -0500 Subject: [PATCH] Changed Blast Mining & Mining to use the same drop function. --- .../com/gmail/nossr50/skills/BlastMining.java | 63 ++------------ .../java/com/gmail/nossr50/skills/Mining.java | 82 ++++++++++--------- 2 files changed, 51 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/BlastMining.java index 3358a33dd..9ac8ea70c 100644 --- a/src/main/java/com/gmail/nossr50/skills/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/BlastMining.java @@ -22,7 +22,6 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -37,56 +36,6 @@ import com.gmail.nossr50.datatypes.SkillType; public class BlastMining{ - public static void explosionBlockDrops(Block block, Location loc) - { - int id = block.getTypeId(); - ItemStack item = new ItemStack(id, 1); - - switch (id){ - //GLOWSTONE - case 89: - item = new ItemStack(348, 1); - m.mcDropItems(loc, item, 2); - m.mcRandomDropItems(loc, item, 50, 2); - break; - //REDSTONE - case 73: - item = new ItemStack(331, 1); - m.mcDropItems(loc, item, 4); - m.mcRandomDropItem(loc, item, 50); - break; - case 74: - item = new ItemStack(331, 1); - m.mcDropItems(loc, item, 4); - m.mcRandomDropItem(loc, item, 50); - break; - //LAPIS - case 21: - item = new ItemStack(351, 1, (byte)0,(byte)0x4); - m.mcDropItems(loc, item, 4); - m.mcRandomDropItems(loc, item, 50, 4); - break; - //DIAMOND - case 56: - item = new ItemStack(264, 1); - m.mcDropItem(loc, item); - break; - //STONE - case 1: - item = new ItemStack(4, 1); - m.mcDropItem(loc, item); - break; - //COAL - case 16: - item = new ItemStack(263, 1); - m.mcDropItem(loc, item); - break; - default: - m.mcDropItem(loc, item); - break; - } - } - public static List explosionYields(List ores, List debris, float yield, float oreBonus, float debrisReduction, Location location, int extraDrops) { Iterator iterator2 = ores.iterator(); @@ -97,13 +46,17 @@ public class BlastMining{ if((float)Math.random() < (yield + oreBonus)) { blocksDropped.add(temp); - explosionBlockDrops(temp, location); + Mining.miningDrops(temp); if(extraDrops == 2) + { blocksDropped.add(temp); - explosionBlockDrops(temp, location); + Mining.miningDrops(temp); + } if(extraDrops == 3) + { blocksDropped.add(temp); - explosionBlockDrops(temp, location); + Mining.miningDrops(temp); + } } } @@ -114,7 +67,7 @@ public class BlastMining{ { Block temp = iterator3.next(); if((float)Math.random() < (yield - debrisReduction)) - explosionBlockDrops(temp, location); + Mining.miningDrops(temp); } } return blocksDropped; diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 2aa0f9614..dbdb2ed9a 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -38,51 +38,55 @@ import com.gmail.nossr50.datatypes.SkillType; public class Mining { - public static void blockProcSimulate(Block block, Player player) + public static void miningDrops(Block block) { - Location loc = block.getLocation(); + Location loc = block.getLocation(); Material type = block.getType(); ItemStack item = new ItemStack(type, 1); - //Drop natural block with Silk Touch - if(player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)){ + switch (type) + { + case COAL_ORE: + item = new ItemStack(Material.COAL, 1, (byte)0, (byte)0x0); m.mcDropItem(loc, item); - return; - } - - switch (type){ - case GLOWSTONE: - item = new ItemStack(Material.GLOWSTONE_DUST, 1); - m.mcDropItems(loc, item, 2); - m.mcRandomDropItems(loc, item, 50, 2); - break; - case GLOWING_REDSTONE_ORE: - case REDSTONE_ORE: - item = new ItemStack(Material.REDSTONE, 1); - m.mcDropItems(loc, item, 4); - m.mcRandomDropItem(loc, item, 50); - break; - case LAPIS_ORE: - item = new ItemStack(Material.INK_SACK, 1, (byte)0, (byte)0x4); - m.mcDropItems(loc, item, 4); - m.mcRandomDropItems(loc, item, 50, 4); - break; - case DIAMOND_ORE: - item = new ItemStack(Material.DIAMOND, 1); - m.mcDropItem(loc, item); - break; - case STONE: - item = new ItemStack(Material.COBBLESTONE, 1); - m.mcDropItem(loc, item); - break; - case COAL_ORE: - item = new ItemStack(Material.COAL, 1, (byte)0, (byte)0x0); - m.mcDropItem(loc, item); - break; - default: - m.mcDropItem(loc, item); - break; + break; + case DIAMOND_ORE: + item = new ItemStack(Material.DIAMOND, 1); + m.mcDropItem(loc, item); + break; + case GLOWING_REDSTONE_ORE: + case REDSTONE_ORE: + item = new ItemStack(Material.REDSTONE, 1); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItem(loc, item, 50); + break; + case GLOWSTONE: + item = new ItemStack(Material.GLOWSTONE_DUST, 1); + m.mcDropItems(loc, item, 2); + m.mcRandomDropItems(loc, item, 50, 2); + break; + case LAPIS_ORE: + item = new ItemStack(Material.INK_SACK, 1, (byte)0, (byte)0x4); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItems(loc, item, 50, 4); + break; + case STONE: + item = new ItemStack(Material.COBBLESTONE, 1); + m.mcDropItem(loc, item); + break; + default: + m.mcDropItem(loc, item); + break; } + } + + public static void blockProcSimulate(Block block, Player player) + { + //Drop natural block with Silk Touch + if(player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) + m.mcDropItem(block.getLocation(), new ItemStack(block.getType(), 1)); + else + miningDrops(block); } public static void blockProcCheck(Block block, Player player)