/*
 * 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.commands;

import net.minecraft.network.play.client.CPacketPlayer.Position;
import net.wurstclient.compatibility.WConnection;
import net.wurstclient.compatibility.WMinecraft;
import net.wurstclient.utils.MiscUtils;

@Cmd.Info(description = "Applies the given amount of damage.",
	name = "damage",
	syntax = {"<amount>"},
	help = "Commands/damage")
public final class DamageCmd extends Cmd
{
	@Override
	public void execute(String[] args) throws CmdError
	{
		if(args.length == 0)
			syntaxError();
		
		// check amount
		if(!MiscUtils.isInteger(args[0]))
			syntaxError("Amount must be a number.");
		int dmg = Integer.parseInt(args[0]);
		if(dmg < 1)
			error("Amount must be at least 1.");
		if(dmg > 40)
			error("Amount must be at most 20.");
		
		// check gamemode
		if(WMinecraft.getPlayer().capabilities.isCreativeMode)
			error("Cannot damage in creative mode.");
		
		double posX = WMinecraft.getPlayer().posX;
		double posY = WMinecraft.getPlayer().posY;
		double posZ = WMinecraft.getPlayer().posZ;
		
		// apply damage
		for(int i = 0; i < 80 + 20 * (dmg - 1D); ++i)
		{
			WConnection
				.sendPacket(new Position(posX, posY + 0.049D, posZ, false));
			WConnection.sendPacket(new Position(posX, posY, posZ, false));
		}
		WConnection.sendPacket(new Position(posX, posY, posZ, true));
	}
}

@@ -373,17 +373,8 @@
 ayer
-.Position
 ;%0Aim
@@ -1396,13 +1396,8 @@
 tion
-%0A%09%09%09%09
 .sen
@@ -1396,36 +1396,55 @@
 tion.sendPacket(
-new 
+%0A%09%09%09%09new CPacketPlayer.
 Position(posX, p
@@ -1490,36 +1490,55 @@
 tion.sendPacket(
-new 
+%0A%09%09%09%09new CPacketPlayer.
 Position(posX, p
@@ -1566,32 +1566,36 @@
 %09%7D%0A%09%09WConnection
+%0A%09%09%09
 .sendPacket(new 
@@ -1594,16 +1594,30 @@
 ket(new 
+CPacketPlayer.
 Position

Update DamageCmd