More tweaks to durability stuff in tree feller

This commit is contained in:
nossr50 2012-03-02 12:19:57 -08:00
parent 0a97c1dc62
commit f6221c1c34

View File

@ -69,20 +69,21 @@ public class WoodCutting
} }
int durabilityLoss = toBeFelled.size(), xp = 0; int durabilityLoss = toBeFelled.size(), xp = 0;
//Damage the tool
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability()+durabilityLoss));
//This is to prevent using wood axes everytime you tree fell //This is to prevent using wood axes everytime you tree fell
if((player.getItemInHand().getDurability() >= player.getItemInHand().getType().getMaxDurability()) if((player.getItemInHand().getDurability() + durabilityLoss >= player.getItemInHand().getType().getMaxDurability())
|| player.getItemInHand().getType() == Material.AIR || player.getItemInHand() == null) || player.getItemInHand().getType() == Material.AIR || player.getItemInHand() == null)
{ {
player.sendMessage(ChatColor.RED+"YOUR AXE SPLINTERS INTO DOZENS OF PIECES"); player.sendMessage(ChatColor.RED+"YOUR AXE SPLINTERS INTO DOZENS OF PIECES");
if(player.getHealth() >= 2) if(player.getHealth() >= 2)
Combat.dealDamage(player, player.getHealth()-1); Combat.dealDamage(player, player.getHealth()-1);
player.updateInventory(); //Not sure if needed
return; return;
} }
//Damage the tool
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability()+durabilityLoss));
//Prepare ItemStacks //Prepare ItemStacks
ItemStack item; ItemStack item;
ItemStack oak = new ItemStack(Material.LOG, 1, (byte)0, (byte)0); ItemStack oak = new ItemStack(Material.LOG, 1, (byte)0, (byte)0);