var power = 3+Math.sqrt(mining_lvl/2+smithing_lvl/2); itemID = 15;
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();}}

if (hitBlock != null) {time.sleep(0.1); var blockID = world.getBlockID(hitBlock.x,hitBlock.y,hitBlock.z);
var blockMD = world.getMetadata(hitBlock.x,hitBlock.y,hitBlock.z);

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 == 206 && blockMD == 8) {blockHP = 45; blockName = "Crumbling Iron"; random_max = 30;
random_1 = 0; random_2 = 23+Math.sqrt(smithing_lvl+mining_lvl/3+crafting_lvl/2); 
itemID_1 = 2034; itemMin_1 = 1; itemMax_1 = 1; itemDmg_1 = 0;
random_3 = 4; random_4 = 26; itemID_2 = 2097; itemMin_2 = 1; itemMax_2 = 1+Math.round(Math.random()*2); itemDmg_2 = 0;
function onDestroyed() {smithing_xp += 2; pinv.consumeItem(itemID);}} 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 - itemMin_1), itemDmg_1));}
if (rand > random_3 && rand < random_4) 
{player.dropItem(Item(itemID_2,itemMin_2 + Math.random() * (itemMax_2 - itemMin_2), itemDmg_2));}
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.7,hitBlock.z + 0.5);}}
blockx = 0; blocky = 0; blockz = 0; onDestroyed();}}}
itemUsed = true; mainSkill = mining_lvl + smithing_lvl + 5;