I checked it a long time ago. heres the new code I updated but didnt post:
public static boolean attack(){
ClientPlayerEntity player = Minecraft.getInstance().player;
if ((player == null)) {return false;}
RayTraceResult lookingAt = Minecraft.getInstance().objectMouseOver;
assert lookingAt != null;
System.out.println(lookingAt.getType().toString());
if (lookingAt.getType() == RayTraceResult.Type.BLOCK) {
if (lookingAt.getType().toString() == "a"){
System.out.println("Yeaaa");
}
double x = lookingAt.getHitVec().getX();
double y = lookingAt.getHitVec().getY();
double z = lookingAt.getHitVec().getZ();
net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, Minecraft.getInstance().gameSettings.keyBindAttack, Hand.MAIN_HAND);
if (inputEvent.shouldSwingHand()) {
Minecraft.getInstance().particles.addBlockHitEffects(new BlockPos(x, y, z), (BlockRayTraceResult) lookingAt);
Minecraft.getInstance().player.swingArm(Hand.MAIN_HAND);
}
player.world.getBlockState(new BlockPos(x, y, z))
.getBlock().
harvestBlock(
player.world,
player,
new BlockPos(x, y, z),
player.world.getBlockState(new BlockPos(x, y, z)),
player.world.getTileEntity(new BlockPos(x, y, z)),
player.getHeldItemMainhand()
);
}
return true;
}