I created an axe to do that
its not perfect, had major problems with hugemushroom blocks , here is the code for it
package me.el.LoonTools;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockCocoa;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.BlockHugeMushroom;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockMushroom;
import net.minecraft.block.BlockSand;
import net.minecraft.block.BlockSnow;
import net.minecraft.block.BlockSnowBlock;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.block.BlockVine;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemLumberAxe extends ItemAxe{
public String mat;
public ItemLumberAxe(ToolMaterial material, String materialName) {
super(material);
mat=materialName;
setCreativeTab(CreativeTabs.tabTools);
setUnlocalizedName("lumberaxe"+mat);
setTextureName(LoonTools.modid+":lumberaxe_"+mat);
}
// EXPLODE TREE
byte[] tre= new byte[32000];
byte unchecked=0;
byte needcheck=1;
byte ignore =2;
byte harvest =3;
private boolean setcheck(int x, int y, int z) {
if(x<0 || x>19 || z<0 || z>19 || y<0 || y>79) return false;
int o=x+z*20+y*400;
if (tre[o]==unchecked) tre[o]=needcheck;
return true;
}
public boolean canIgnore(Block bit){
if (bit instanceof BlockAir)return true;
if (bit instanceof BlockGrass)return true;
if (bit instanceof BlockSand)return true;
if (bit instanceof BlockDirt)return true;
if (bit instanceof BlockCocoa)return true;
if (bit instanceof BlockVine)return true;
if (bit instanceof BlockMushroom)return true;
if (bit instanceof BlockSnow)return true;
if (bit instanceof BlockSnowBlock)return true;
if (bit instanceof BlockFlower)return true;
if (bit instanceof BlockTallGrass)return true;
if (bit instanceof BlockDoublePlant)return true;
//LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName());
return false;
}
private int check(World par1World, int x, int y, int z, int xo, int yo,int zo) {
int f=0;
int o=x+z*20+y*400;
if (tre[o]==needcheck){
tre[o]=ignore;
Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom)||(bit instanceof HugeMushroomBlock)){
f=1;
tre[o]=harvest;
//if (bit instanceof BlockLog){
// LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" ");
//}
for(int xb=-1;xb<2;xb++)
for(int yb=-1;yb<2;yb++)
for(int zb=-1;zb<2;zb++)
if (!setcheck(x+xb,y+yb,z+zb))return 3;
}else{
if (!canIgnore(bit)) return 2;
}
}
return f;
}
public int checkTree(World par1World,int xo,int yo,int zo){
boolean f;
for (f=true;f==true;){
f=false;
for (int y=0;y<80;y++)
for(int z=0;z<20;z++)
for(int x=0;x<20;x++){
int r=check(par1World,x,y,z,xo,yo,zo);
if (r==3) return 3;
if (r==2) return 2;
if (r==1) f=true;
}
for (int y=79;y>=0;y--)
for(int z=19;z>=0;z--)
for(int x=19;x>=0;x--){
int r=check(par1World,x,y,z,xo,yo,zo);
if (r==2) return 3;
if (r==2) return 2;
if (r==1) f=true;
}
}
return 1;
}
private int check2(World par1World, int x, int y, int z, int xo, int yo,int zo) {
int f=0;
int o=x+z*20+y*400;
if (tre[o]==needcheck){
tre[o]=ignore;
Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
if (bit instanceof BlockLog){
f=1;
tre[o]=harvest;
//if (bit instanceof BlockLog){
// LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" ");
//}
for(int xb=-1;xb<2;xb++)
for(int yb=-1;yb<2;yb++)
for(int zb=-1;zb<2;zb++)
if (!setcheck(x+xb,y+yb,z+zb))return 3;
}else if (bit instanceof BlockLeavesBase){
}else{
if (!canIgnore(bit)) return 2;
}
}
return f;
}
public int checkTree2(World par1World,int xo,int yo,int zo){
boolean f;
for (f=true;f==true;){
f=false;
for (int y=0;y<80;y++)
for(int z=0;z<20;z++)
for(int x=0;x<20;x++){
int r=check2(par1World,x,y,z,xo,yo,zo);
if (r==3) return 3;
if (r==2) return 2;
if (r==1) f=true;
}
for (int y=79;y>=0;y--)
for(int z=19;z>=0;z--)
for(int x=19;x>=0;x--){
int r=check2(par1World,x,y,z,xo,yo,zo);
if (r==2) return 3;
if (r==2) return 2;
if (r==1) f=true;
}
}
return 1;
}
public void exploadTree(World par1World,int xo,int yo,int zo, EntityPlayer plr){
for (int y=0;y<80;y++)
for(int z=0;z<20;z++)
for(int x=0;x<20;x++){
int o=x+z*20+y*400;
if (tre[o]==harvest){
Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo);
if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)){
bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met);
par1World.setBlockToAir(x+xo, y+yo, z+zo);
}
}
}
}
private void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) {
if (silk){
ItemStack stk;
if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met);
else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met);
else stk = new ItemStack(bit,1,met);
EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk);
entityitem.delayBeforeCanPickup = 10;
wld.spawnEntityInWorld(entityitem);
}else{
bit.harvestBlock(wld, plr, x, y, z, met);
}
wld.setBlockToAir(x, y, z);
}
public void exploadMushroom(World par1World,int xo,int yo,int zo, EntityPlayer plr, boolean silk){
for (int y=0;y<80;y++)
for(int z=0;z<20;z++)
for(int x=0;x<20;x++){
int o=x+z*20+y*400;
if (tre[o]==harvest){
Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo);
if (bit instanceof BlockHugeMushroom){
breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met);
}else{
bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met);
par1World.setBlockToAir(x+xo, y+yo, z+zo);
}
}
}
}
@Override
public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) {
if (!wld.isRemote){
Block bit = wld.getBlock(x, y, z);
boolean silk=EnchantmentHelper.getSilkTouchModifier(plr);
if ((bit instanceof BlockHugeMushroom) || (bit instanceof HugeMushroomBlock)){
for (int n=0;n<32000;n++) tre[n]=unchecked;
int met = wld.getBlockMetadata(x, y, z);
breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met);
wld.setBlockToAir(x,y,z);
tre[2210]=needcheck;
if (checkTree(wld,x-10,y-4,z-10)==1){
exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk);
}
}
if (bit instanceof BlockLog){
//LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" ");
for (int n=0;n<32000;n++) tre[n]=unchecked;
int met = wld.getBlockMetadata(x, y, z);
bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met);
wld.setBlockToAir(x,y,z);
tre[2210]=needcheck;
if (checkTree(wld,x-10,y-4,z-10)==1){
exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr);
}else{
for (int n=0;n<32000;n++) tre[n]=unchecked;
tre[2210]=needcheck;
if (checkTree2(wld,x-10,y-4,z-10)==1){
exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr);
}
}
}
}
return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr);
}
}