/*
 * Copyright  2014 - 2017 | Wurst-Imperium | All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package net.wurstclient.features.mods;

import net.minecraft.block.Block;
import net.wurstclient.compatibility.WMinecraft;
import net.wurstclient.events.listeners.UpdateListener;

@Mod.Info(
	description = "Automatically mines a block as soon as you look at it.",
	name = "AutoMine",
	tags = "AutoBreak, auto mine, auto break",
	help = "Mods/AutoMine")
@Mod.Bypasses
public final class AutoMineMod extends Mod implements UpdateListener
{
	@Override
	public void onEnable()
	{
		mc.gameSettings.keyBindAttack.pressed = false;
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		if(mc.objectMouseOver == null
			|| mc.objectMouseOver.getBlockPos() == null)
			return;
		if(Block.getIdFromBlock(WMinecraft.getWorld()
			.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock()) != 0)
			mc.gameSettings.keyBindAttack.pressed = true;
		else
			mc.gameSettings.keyBindAttack.pressed = false;
		
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
		mc.gameSettings.keyBindAttack.pressed = false;
	}
}

@@ -338,21 +338,33 @@
 t.block.
-Block
+material.Material
 ;%0Aimport
@@ -395,25 +395,21 @@
 bility.W
-Minecraft
+Block
 ;%0Aimport
@@ -759,57 +759,8 @@
 %0A%09%7B%0A
-%09%09mc.gameSettings.keyBindAttack.pressed = false;%0A
 %09%09wu
@@ -811,32 +811,203 @@
 %09%7D%0A%09%0A%09@Override%0A
+%09public void onDisable()%0A%09%7B%0A%09%09wurst.events.remove(UpdateListener.class, this);%0A%09%09%0A%09%09// release attack key%0A%09%09mc.gameSettings.keyBindAttack.pressed = false;%0A%09%7D%0A%09%0A%09@Override%0A
 %09public void onU
@@ -1017,16 +1017,37 @@
 te()%0A%09%7B%0A
+%09%09// check hitResult%0A
 %09%09if(mc.
@@ -1135,179 +1135,175 @@
 ;%0A%09%09
-if(Block.getIdFromBlock(WMinecraft.getWorld()%0A%09%09%09.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock()) != 0)%0A%09%09%09mc.gameSettings.keyBindAttack.pressed = true;%0A%09%09else
+%0A%09%09// if attack key is down but nothing happens, release it for one tick%0A%09%09if(mc.gameSettings.keyBindAttack.pressed%0A%09%09%09&& !mc.playerController.getIsHittingBlock())%0A%09%09%7B
 %0A%09%09%09
@@ -1355,151 +1355,180 @@
 ;%0A%09%09
-%0A
+%09return;%0A%09
 %09%7D%0A%09
+%09
 %0A%09
-@Override%0A%09public void onDisable()%0A%09%7B%0A%09%09wurst.events.remove(UpdateListener.class, this);%0A%09%09mc.gameSettings.keyBindAttack.pressed = false
+%09// press attack key if looking at block%0A%09%09mc.gameSettings.keyBindAttack.pressed = WBlock%0A%09%09%09.getMaterial(mc.objectMouseOver.getBlockPos()) != Material.AIR
 ;%0A%09%7D

Update AutoMineMod