diff --git a/src/main/java/com/gmail/nossr50/m.java b/src/main/java/com/gmail/nossr50/m.java index acf1be427..1310817f0 100644 --- a/src/main/java/com/gmail/nossr50/m.java +++ b/src/main/java/com/gmail/nossr50/m.java @@ -23,7 +23,6 @@ import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; @@ -180,15 +179,21 @@ public class m return true; } - public static void mcDropItem(Location location, int id) + public static void mcDropItems(Location location, ItemStack is, int quantity) { - if(location == null) return; - - Material mat = Material.getMaterial(id); - ItemStack item = new ItemStack(mat, 1, (byte) 0, (byte) 0); - mcDropItem(location, item); + for(int i = 0; i < quantity; i++) + mcDropItem(location, is); + } + public static void mcRandomDropItem(Location location, ItemStack is, int chance) + { + if(Math.random() * 100 < chance) + mcDropItem(location, is); + } + public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity) + { + for(int i = 0; i < quantity; i++) + mcRandomDropItem(location, is, chance); } - public static void mcDropItem(Location location, ItemStack itemStack) { // We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event. McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack); diff --git a/src/main/java/com/gmail/nossr50/skills/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/BlastMining.java index 45bc914c7..605dd0945 100644 --- a/src/main/java/com/gmail/nossr50/skills/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/BlastMining.java @@ -49,56 +49,33 @@ public class BlastMining{ return; } - switch (id) - { + switch (id){ //GLOWSTONE case 89: mat = Material.getMaterial(348); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 2); + m.mcRandomDropItems(loc, item, 50, 2); break; //REDSTONE case 73: mat = Material.getMaterial(331); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItem(loc, item, 50); break; case 74: mat = Material.getMaterial(331); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItem(loc, item, 50); break; //LAPIS case 21: mat = Material.getMaterial(351); item = new ItemStack(mat, 1, (byte)0,(byte)0x4); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItems(loc, item, 50, 4); break; //DIAMOND case 56: @@ -118,7 +95,7 @@ public class BlastMining{ item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); break; - } + } } /* diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index bd6f15c5a..0c9ef1958 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -193,14 +193,8 @@ public class Herbalism { if(herbLevel > 1000 || (Math.random() * 1000 <= herbLevel)) { - m.mcDropItem(loc, is); - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); + m.mcDropItems(loc, is, 2); + m.mcRandomDropItems(loc, is, 50, 3); } } } @@ -310,17 +304,8 @@ public class Herbalism { if(herbLevel > 1000 || (Math.random() * 1000 <= herbLevel)) { - m.mcDropItem(loc, is); - m.mcDropItem(loc, is); - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, is); + m.mcDropItems(loc, is, 3); + m.mcRandomDropItems(loc, is, 50, 4); } } PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player); diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 6ed720af2..1baa36843 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -100,50 +100,28 @@ public class Mining case 89: mat = Material.getMaterial(348); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 2); + m.mcRandomDropItems(loc, item, 50, 2); break; //REDSTONE case 73: mat = Material.getMaterial(331); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItem(loc, item, 50); break; case 74: mat = Material.getMaterial(331); item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItem(loc, item, 50); break; //LAPIS case 21: mat = Material.getMaterial(351); item = new ItemStack(mat, 1, (byte)0,(byte)0x4); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); - if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItems(loc, item, 4); + m.mcRandomDropItems(loc, item, 50, 4); break; //DIAMOND case 56: diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index f9a333a62..109eb7cdb 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -441,7 +441,7 @@ public class Skills Integer x = 0; while(x < plugin.misc.arrowTracker.get(entity)) { - m.mcDropItem(entity.getLocation(), 262); + m.mcDropItem(entity.getLocation(), new ItemStack(262, 1)); x++; } } diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 65c9250f5..4f9c501f9 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -109,9 +109,8 @@ public class WoodCutting Material mat = Material.SAPLING; ItemStack item = new ItemStack(mat, 1, (short)0, (byte)(x.getData()-8)); - //1 in 10 chance to drop sapling - if(Math.random() * 10 > 9) - m.mcDropItem(x.getLocation(), item); + //90% chance to drop sapling + m.mcRandomDropItem(x.getLocation(), item, 90); //Remove the block x.setData((byte) 0);