Changed Blast Mining & Mining to use the same drop function.

This commit is contained in:
GJ 2012-03-05 23:29:05 -05:00
parent 36a706b7b6
commit e1644d3c08
2 changed files with 51 additions and 94 deletions

View File

@ -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<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, Location location, int extraDrops)
{
Iterator<Block> 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;

View File

@ -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)