From 5404fc87038997f7e7c53ecb6265b83f4092b5e2 Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 02:00:53 -0500 Subject: [PATCH 1/5] More Mining optimizations --- .../nossr50/listeners/mcBlockListener.java | 6 ++++-- src/main/java/com/gmail/nossr50/m.java | 5 ++++- .../java/com/gmail/nossr50/skills/Mining.java | 18 +++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index da4e99919..f5dc89773 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -76,9 +76,11 @@ public class mcBlockListener implements Listener if(m.shouldBeWatched(block)) { int id = block.getTypeId(); - if (id == 17 || id == 39 || id == 40 || id == 91 || id == 86 || id == 73 || id == 74) { + + //Only needed for blocks that use their block data (wood, pumpkins, etc.) + if (id == 17 || id == 81 || id == 83 || id == 86 || id == 91) plugin.misc.blockWatchList.add(block); - } else { + else { //block.setData((byte) 5); //Change the byte //The following is a method to get around a breakage in 1.1-R2 and onward //it should be removed as soon as functionality to change a block diff --git a/src/main/java/com/gmail/nossr50/m.java b/src/main/java/com/gmail/nossr50/m.java index 7eb16b326..ac1e9fbfa 100644 --- a/src/main/java/com/gmail/nossr50/m.java +++ b/src/main/java/com/gmail/nossr50/m.java @@ -92,7 +92,10 @@ public class m return shouldBeWatched(id); } public static boolean shouldBeWatched(int id) { - return id == 103 || id == 82 || id == 16 || id == 73 || id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24; + return id == 2 || id == 3 || id == 12 || id == 13 || id == 82 || //Excavation + id == 1 || id == 14 || id == 15 || id == 16 || id == 21 || id == 24 || id == 49 || id == 56 || id == 73 || id == 74 || id == 87 || id == 89 || //Mining + id == 17 || id == 37 || id == 38 || id == 39 || id == 40 || id == 81 || id == 83 || id == 86 || id == 91 || id == 103 || id == 106 || id == 111 || //Woodcutting & Herbalism + id == 42; //Anvil } public static int getPowerLevel(Player player) diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 3a7de4260..687564942 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -79,10 +79,10 @@ public class Mining public static void blockProcSimulate(Block block) { Location loc = block.getLocation(); - Material mat = Material.getMaterial(block.getTypeId()); + int id = block.getTypeId(); + Material mat = Material.getMaterial(id); byte damage = 0; ItemStack item = new ItemStack(mat, 1, (byte)0, damage); - int id = block.getTypeId(); if(id != 89 && id != 73 && id != 74 && id != 56 && id != 21 && id != 1 && id != 16) { m.mcDropItem(loc, item); @@ -108,7 +108,7 @@ public class Mining m.mcDropItem(loc, item); } } - //LAPUS + //LAPIS else if(id == 21) { mat = Material.getMaterial(351); @@ -220,11 +220,8 @@ public class Mining */ public static Boolean canBeSuperBroken(Block block) { - int t = block.getTypeId(); - if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15 || t == 112) - return true; - else - return false; + int id = block.getTypeId(); + return id == 1 || id == 14 || id == 15 || id == 16 || id == 21 || id == 24 || id == 49 || id == 56 || id == 73 || id == 74 || id == 87 || id == 89; } public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin) @@ -241,12 +238,11 @@ public class Mining //Pre-processing Location loc = block.getLocation(); - Material mat = Material.getMaterial(block.getTypeId()); + int id = block.getTypeId(); + Material mat = Material.getMaterial(id); int xp = 0; byte damage = 0; ItemStack item = new ItemStack(mat, 1, (byte)0, damage); - int id = block.getTypeId(); - if(id == 1 || id == 24) { From 64e6ea86fd175324427dacfc5f946c3a0647ff20 Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 02:11:01 -0500 Subject: [PATCH 2/5] Readded redstone ores to BlockWatchList. Added vines to BlockWatchList. --- src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index f5dc89773..583cbdd99 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -78,7 +78,7 @@ public class mcBlockListener implements Listener int id = block.getTypeId(); //Only needed for blocks that use their block data (wood, pumpkins, etc.) - if (id == 17 || id == 81 || id == 83 || id == 86 || id == 91) + if (id == 17 || id == 73 || id == 74 || id == 81 || id == 83 || id == 86 || id == 91 || id == 106) plugin.misc.blockWatchList.add(block); else { //block.setData((byte) 5); //Change the byte From 5b3c17619254649970b1b2c2c4ae957e08a7c81f Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 03:28:47 -0500 Subject: [PATCH 3/5] Even more Mining optimizations. --- .../java/com/gmail/nossr50/skills/Mining.java | 178 ++++++++++-------- 1 file changed, 95 insertions(+), 83 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 687564942..a4efad68b 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -89,55 +89,69 @@ public class Mining return; } - //GLOWSTONE - if(id == 89) - { - mat = Material.getMaterial(348); - item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - } - //REDSTONE - else if(id == 73 || id == 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); - if(Math.random() * 10 > 5){ + switch (id){ + //GLOWSTONE + case 89: + mat = Material.getMaterial(348); + item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); - } - } - //LAPIS - else if(id == 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); - } - //DIAMOND - else if(id == 56) - { - mat = Material.getMaterial(264); - item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - } - //STONE - else if(id == 1) - { - mat = Material.getMaterial(4); - item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); - } - //COAL - else if(id == 16) - { - mat = Material.getMaterial(263); - item = new ItemStack(mat, 1, (byte)0, damage); - m.mcDropItem(loc, item); + 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); + 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); + 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); + break; + //DIAMOND + case 56: + mat = Material.getMaterial(264); + item = new ItemStack(mat, 1, (byte)0, damage); + m.mcDropItem(loc, item); + break; + //STONE + case 1: + mat = Material.getMaterial(4); + item = new ItemStack(mat, 1, (byte)0, damage); + m.mcDropItem(loc, item); + break; + //COAL + case 16: + mat = Material.getMaterial(263); + item = new ItemStack(mat, 1, (byte)0, damage); + m.mcDropItem(loc, item); + break; } } @@ -229,11 +243,8 @@ public class Mining PlayerProfile PP = Users.getProfile(player); if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) - { - - } - m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); + if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) + m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } //Pre-processing @@ -244,32 +255,34 @@ public class Mining byte damage = 0; ItemStack item = new ItemStack(mat, 1, (byte)0, damage); - if(id == 1 || id == 24) + //STONE + if(id == 1) { - if(id == 1) + if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5) { - mat = Material.COBBLESTONE; - if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5) - { - xp += LoadProperties.mstone; - blockProcCheck(block, player); - blockProcCheck(block, player); - } - } else - { - mat = Material.SANDSTONE; - if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5) - { - xp += LoadProperties.msandstone; - blockProcCheck(block, player); - blockProcCheck(block, player); - } + xp += LoadProperties.mstone; + blockProcCheck(block, player); + blockProcCheck(block, player); } + mat = Material.getMaterial(4); item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); } + //SANDSTONE + else if(id == 24) + { + if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5) + { + xp += LoadProperties.msandstone; + blockProcCheck(block, player); + blockProcCheck(block, player); + } + m.mcDropItem(loc, item); + player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); + block.setType(Material.AIR); + } //NETHERRACK else if(id == 87) { @@ -278,8 +291,6 @@ public class Mining blockProcCheck(block, player); blockProcCheck(block, player); } - mat = Material.getMaterial(87); - item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); @@ -320,7 +331,6 @@ public class Mining blockProcCheck(block, player); blockProcCheck(block, player); } - item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); @@ -328,15 +338,11 @@ public class Mining //OBSIDIAN else if(id == 49 && m.getTier(player) >= 4) { - if(LoadProperties.toolsLoseDurabilityFromAbilities) - m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ xp += LoadProperties.mobsidian; blockProcCheck(block, player); blockProcCheck(block, player); } - mat = Material.getMaterial(49); - item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); @@ -363,7 +369,6 @@ public class Mining blockProcCheck(block, player); blockProcCheck(block, player); } - item = new ItemStack(mat, 1, (byte)0, damage); m.mcDropItem(loc, item); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); @@ -382,14 +387,13 @@ public class Mining 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); - } player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); } - //LAPUS + //LAPIS else if(id == 21 && m.getTier(player) >= 3){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ xp += LoadProperties.mlapis; @@ -402,14 +406,22 @@ public class Mining 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); player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); block.setType(Material.AIR); } + if(block.getData() != (byte) 5) PP.addXP(SkillType.MINING, xp, player); if(LoadProperties.spoutEnabled) SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); - Skills.XpCheckSkill(SkillType.MINING, player); } } From 0f41381c985b6454b641b69bce8cc7cf5b19ae16 Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 03:45:46 -0500 Subject: [PATCH 4/5] Herbalism double drop updates --- .../com/gmail/nossr50/skills/Herbalism.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index 60eb33063..63765b813 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -213,6 +213,13 @@ public class Herbalism if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM)) { m.mcDropItem(loc, is); + m.mcDropItem(loc, is); + 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); } } } @@ -317,12 +324,23 @@ public class Herbalism if(type == 103) { mat = Material.getMaterial(360); - int slices = (int) ((Math.random() + 3) + (int)(Math.random() * 4)); //drop 3-7 melon slices rather than melon blocks - is = new ItemStack(mat, slices, (byte)0, (byte)0); - - if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM)) + is = new ItemStack(mat, 1, (byte)0, (byte)0); + if(player != null) { - m.mcDropItem(loc, is); + if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM)) + { + m.mcDropItem(loc, is); + m.mcDropItem(loc, is); + m.mcDropItem(loc, is); + 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); + } } PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player); } From e3d04fd940a6d702aa9162b4da4e5493bfb6a2db Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 03:50:39 -0500 Subject: [PATCH 5/5] FIxed variable names in Herbalism.java --- .../java/com/gmail/nossr50/skills/Herbalism.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index 63765b813..d1c00d1c5 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -215,11 +215,11 @@ public class Herbalism m.mcDropItem(loc, is); m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); } } } @@ -333,13 +333,13 @@ public class Herbalism m.mcDropItem(loc, is); m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); if(Math.random() * 10 > 5) - m.mcDropItem(loc, item); + m.mcDropItem(loc, is); } } PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player);