itemID = 292; breakSpeech = "Wow I worked so hard I didn't even noticed that"; repair = 3;
if (pinv.getCurrentItem() != null)
{if (pinv.getCurrentItem().itemID == itemID) {var ent = pinv.getCurrentItem(); player.swingMainHand();}}
if (pinv.getOffhandItem() != null) 
{if (pinv.getOffhandItem().itemID == itemID) {var ent = pinv.getOffhandItem(); player.swingOffHand();}}
var power = 5;

if (ent.damage >= 250) {pinv.consumeItem(itemID); chat.print(breakSpeech);}

if (hitBlock != null) {var blockID = world.getBlockID(hitBlock.x,hitBlock.y,hitBlock.z);
var blockMD = world.getMetadata(hitBlock.x,hitBlock.y,hitBlock.z);
if (hitBlock != null && blockID == 206 && blockMD == 8)
{ent.damage = Math.max(ent.damage-repair,0); if (timing > 16) {sound.playSoundUI("sound.Repairing"); timing = 0;}}

if (hitBlock.x != blockx || hitBlock.y != blocky || hitBlock.z != blockz) 
{blockx = hitBlock.x; blocky = hitBlock.y; blockz = hitBlock.z; blockHP = 0;
var blockID = world.getBlockID(hitBlock.x,hitBlock.y,hitBlock.z);
if (blockID == 2) {blockHP = 30; blockName = "Dirt"; random_max = 30;
random_1 = 0; random_2 = 25; itemID_1 = 3; itemMin_1 = 1; itemMax_1 = 1; itemDmg_1 = 0;
random_3 = 0; random_4 = 0; itemID_2 = 0; itemMin_2 = 0; itemMax_2 = 0; itemDmg_2 = 0;
random_5 = 0; random_6 = 0; itemID_3 = 0; itemMin_3 = 0; itemMax_3 = 0; itemDmg_3 = 0;
random_7 = 0; random_8 = 0; itemID_4 = 0; itemMin_4 = 0; itemMax_4 = 0; itemDmg_4 = 0;
random_9 = 0; random_10 = 0; itemID_5 = 0; itemMin_5 = 0; itemMax_5 = 0; itemDmg_5 = 0;} blockMaxHP = blockHP;}

else {blockHP = Math.max(blockHP-power,0);
if (blockHP == 0 && blockMaxHP > 0) 
{var rand = Math.floor(Math.random() * random_max);
    if (rand > random_1 && rand < random_2) 
	{player.dropItem(Item(itemID_1,itemMin_1 + Math.random() * itemMax_1, itemDmg_1));}
    if (rand > random_3 && rand < random_4) 
	{player.dropItem(Item(itemID_2,itemMin_2 + Math.random() * itemMax_2, itemDmg_2));}
    if (rand > random_5 && rand < random_6) 
	{player.dropItem(Item(itemID_3,itemMin_3 + Math.random() * itemMax_3, itemDmg_3));}
    if (rand > random_7 && rand < random_8) 
	{player.dropItem(Item(itemID_4,itemMin_4 + Math.random() * itemMax_4, itemDmg_4));}
    if (rand > random_9 && rand < random_10) 
	{player.dropItem(Item(itemID_5,itemMin_5 + Math.random() * itemMax_5, itemDmg_5));}
itemSearch = player.getEntitiesWithinRange(0.5);
    for (var i = 0; i < itemSearch.length; i++) 
	{	var ent1 = itemSearch[i]; 
		if (ent1.getClassType() == "Item") 
		{ent1 = ent1.setPosition(hitBlock.x + 0.5,hitBlock.y + 0.5,hitBlock.z + 0.5);}
	}
world.setBlockID(hitBlock.x,hitBlock.y,hitBlock.z,0);}}

}