Hey,
I just started modding Minecraft. I want to create a pickaxe, which - on rightclick - harvests more than one block. Unfortunately I encountered two problems. The main problem is that the blocks get set to air, but you are still colliding with them. If I leave the world and rejoin, the blocks are reset to what they were before (dirt, stone, whatever). The second problem is that the block, the player is hovering over with his mouse, doesn't become air.
Could you maybe take a look at my code (this is only for the player looking south)? I don't see any mistake, but maybe you do.
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World w, EntityPlayer player)
{
Minecraft mc = Minecraft.getMinecraft();
int x1;
int y1;
int z1;
int damage = 0;
if(mc.objectMouseOver != null)
{
x1 = mc.objectMouseOver.blockX;
y1 = mc.objectMouseOver.blockY;
z1 = mc.objectMouseOver.blockZ;
if((MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3) == 0)
{
for(int xvar = x1-1; xvar < x1+2; xvar++)
{
for(int yvar = y1-1; yvar < y1+2; yvar++)
{
for(int zvar = z1; zvar < z1+4; zvar++)
{
Block block = w.getBlock(xvar, yvar, zvar);
if(!block.isAir(w, xvar, yvar, zvar) && block.canHarvestBlock(player, w.getBlockMetadata(xvar, yvar, zvar)) && block.getMaterial() != Material.water && block.getMaterial() != Material.lava)
{
block.harvestBlock(w, player, xvar, yvar, zvar, w.getBlockMetadata(xvar, yvar, zvar));
w.setBlockToAir(xvar, yvar, zvar);
player.addExhaustion(-0.025F);
damage+=5;
}
}
}
}
par1ItemStack.damageItem(damage, player);
return par1ItemStack;
}