mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Merge pull request #72 from gmcferrin/pull-me
More Mining optimizations
This commit is contained in:
commit
3fcfde1697
@ -76,9 +76,11 @@ public class mcBlockListener implements Listener
|
|||||||
if(m.shouldBeWatched(block))
|
if(m.shouldBeWatched(block))
|
||||||
{
|
{
|
||||||
int id = block.getTypeId();
|
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 == 73 || id == 74 || id == 81 || id == 83 || id == 86 || id == 91 || id == 106)
|
||||||
plugin.misc.blockWatchList.add(block);
|
plugin.misc.blockWatchList.add(block);
|
||||||
} else {
|
else {
|
||||||
//block.setData((byte) 5); //Change the byte
|
//block.setData((byte) 5); //Change the byte
|
||||||
//The following is a method to get around a breakage in 1.1-R2 and onward
|
//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
|
//it should be removed as soon as functionality to change a block
|
||||||
|
@ -92,7 +92,10 @@ public class m
|
|||||||
return shouldBeWatched(id);
|
return shouldBeWatched(id);
|
||||||
}
|
}
|
||||||
public static boolean shouldBeWatched(int 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)
|
public static int getPowerLevel(Player player)
|
||||||
|
@ -213,6 +213,13 @@ public class Herbalism
|
|||||||
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
|
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, is);
|
||||||
|
if(Math.random() * 10 > 5)
|
||||||
|
m.mcDropItem(loc, is);
|
||||||
|
if(Math.random() * 10 > 5)
|
||||||
|
m.mcDropItem(loc, is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,12 +324,23 @@ public class Herbalism
|
|||||||
if(type == 103)
|
if(type == 103)
|
||||||
{
|
{
|
||||||
mat = Material.getMaterial(360);
|
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, 1, (byte)0, (byte)0);
|
||||||
is = new ItemStack(mat, slices, (byte)0, (byte)0);
|
if(player != null)
|
||||||
|
|
||||||
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
|
|
||||||
{
|
{
|
||||||
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, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player);
|
PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player);
|
||||||
}
|
}
|
||||||
|
@ -79,65 +79,79 @@ public class Mining
|
|||||||
public static void blockProcSimulate(Block block)
|
public static void blockProcSimulate(Block block)
|
||||||
{
|
{
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
Material mat = Material.getMaterial(block.getTypeId());
|
int id = block.getTypeId();
|
||||||
|
Material mat = Material.getMaterial(id);
|
||||||
byte damage = 0;
|
byte damage = 0;
|
||||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
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) {
|
if(id != 89 && id != 73 && id != 74 && id != 56 && id != 21 && id != 1 && id != 16) {
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//GLOWSTONE
|
switch (id){
|
||||||
if(id == 89)
|
//GLOWSTONE
|
||||||
{
|
case 89:
|
||||||
mat = Material.getMaterial(348);
|
mat = Material.getMaterial(348);
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
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){
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
}
|
break;
|
||||||
}
|
//REDSTONE
|
||||||
//LAPUS
|
case 73:
|
||||||
else if(id == 21)
|
mat = Material.getMaterial(331);
|
||||||
{
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
mat = Material.getMaterial(351);
|
m.mcDropItem(loc, item);
|
||||||
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);
|
m.mcDropItem(loc, item);
|
||||||
m.mcDropItem(loc, item);
|
if(Math.random() * 10 > 5)
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
}
|
break;
|
||||||
//DIAMOND
|
case 74:
|
||||||
else if(id == 56)
|
mat = Material.getMaterial(331);
|
||||||
{
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
mat = Material.getMaterial(264);
|
m.mcDropItem(loc, item);
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
m.mcDropItem(loc, item);
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
}
|
m.mcDropItem(loc, item);
|
||||||
//STONE
|
if(Math.random() * 10 > 5)
|
||||||
else if(id == 1)
|
m.mcDropItem(loc, item);
|
||||||
{
|
break;
|
||||||
mat = Material.getMaterial(4);
|
//LAPIS
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
case 21:
|
||||||
m.mcDropItem(loc, item);
|
mat = Material.getMaterial(351);
|
||||||
}
|
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
|
||||||
//COAL
|
m.mcDropItem(loc, item);
|
||||||
else if(id == 16)
|
m.mcDropItem(loc, item);
|
||||||
{
|
m.mcDropItem(loc, item);
|
||||||
mat = Material.getMaterial(263);
|
m.mcDropItem(loc, item);
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
if(Math.random() * 10 > 5)
|
||||||
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);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +234,8 @@ public class Mining
|
|||||||
*/
|
*/
|
||||||
public static Boolean canBeSuperBroken(Block block)
|
public static Boolean canBeSuperBroken(Block block)
|
||||||
{
|
{
|
||||||
int t = block.getTypeId();
|
int id = 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 id == 1 || id == 14 || id == 15 || id == 16 || id == 21 || id == 24 || id == 49 || id == 56 || id == 73 || id == 74 || id == 87 || id == 89;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin)
|
public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin)
|
||||||
@ -232,48 +243,46 @@ public class Mining
|
|||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||||
{
|
{
|
||||||
if(player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY))
|
if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY))
|
||||||
{
|
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||||
|
|
||||||
}
|
|
||||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Pre-processing
|
//Pre-processing
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
Material mat = Material.getMaterial(block.getTypeId());
|
int id = block.getTypeId();
|
||||||
|
Material mat = Material.getMaterial(id);
|
||||||
int xp = 0;
|
int xp = 0;
|
||||||
byte damage = 0;
|
byte damage = 0;
|
||||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
int id = block.getTypeId();
|
|
||||||
|
|
||||||
|
//STONE
|
||||||
if(id == 1 || id == 24)
|
if(id == 1)
|
||||||
{
|
{
|
||||||
if(id == 1)
|
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
|
||||||
{
|
{
|
||||||
mat = Material.COBBLESTONE;
|
xp += LoadProperties.mstone;
|
||||||
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
|
blockProcCheck(block, player);
|
||||||
{
|
blockProcCheck(block, player);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mat = Material.getMaterial(4);
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
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
|
//NETHERRACK
|
||||||
else if(id == 87)
|
else if(id == 87)
|
||||||
{
|
{
|
||||||
@ -282,8 +291,6 @@ public class Mining
|
|||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
}
|
}
|
||||||
mat = Material.getMaterial(87);
|
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -324,7 +331,6 @@ public class Mining
|
|||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
}
|
}
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -332,15 +338,11 @@ public class Mining
|
|||||||
//OBSIDIAN
|
//OBSIDIAN
|
||||||
else if(id == 49 && m.getTier(player) >= 4)
|
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){
|
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
|
||||||
xp += LoadProperties.mobsidian;
|
xp += LoadProperties.mobsidian;
|
||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
}
|
}
|
||||||
mat = Material.getMaterial(49);
|
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -367,7 +369,6 @@ public class Mining
|
|||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
blockProcCheck(block, player);
|
blockProcCheck(block, player);
|
||||||
}
|
}
|
||||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -386,14 +387,13 @@ public class Mining
|
|||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
|
m.mcDropItem(loc, item);
|
||||||
if(Math.random() * 10 > 5)
|
if(Math.random() * 10 > 5)
|
||||||
{
|
|
||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
}
|
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
//LAPUS
|
//LAPIS
|
||||||
else if(id == 21 && m.getTier(player) >= 3){
|
else if(id == 21 && m.getTier(player) >= 3){
|
||||||
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
|
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
|
||||||
xp += LoadProperties.mlapis;
|
xp += LoadProperties.mlapis;
|
||||||
@ -406,14 +406,22 @@ public class Mining
|
|||||||
m.mcDropItem(loc, item);
|
m.mcDropItem(loc, item);
|
||||||
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);
|
||||||
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.getData() != (byte) 5)
|
if(block.getData() != (byte) 5)
|
||||||
PP.addXP(SkillType.MINING, xp, player);
|
PP.addXP(SkillType.MINING, xp, player);
|
||||||
if(LoadProperties.spoutEnabled)
|
if(LoadProperties.spoutEnabled)
|
||||||
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||||
|
|
||||||
Skills.XpCheckSkill(SkillType.MINING, player);
|
Skills.XpCheckSkill(SkillType.MINING, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user