var scriptName = "gommenoslow";
var scriptAuthor = "apexCode with MANY help of Nvaros (thank you <3)";
var scriptVersion = 2.1;

var i = 0;

var noslow = moduleManager.getModule("noslow");

var test = new Boolean("false");

var test2 = new Boolean("false");

var test3 = new Boolean("false");

var test4 = new Boolean("false");

var killaura = moduleManager.getModule("killaura");

var height;

var sneak = moduleManager.getModule("sneak");


function gommenoslow() {
	
	var blocknoslow = value.createBoolean("BlockNoSlow", true);
	var ongroundfastdelay = value.createInteger("OnGroundFastDelay", 7, 1, 25);
	var ongroundslowdownforward = value.createFloat("OnGroundSlowDownForward", 0.55, 0.2, 1.0);
	var ongroundslowdownstrafe = value.createFloat("OnGroundSlowDownStrafe", 0.55, 0.2, 1.0);
	var smartblock = value.createBoolean("SmartBlock", true);
	var smartblockhurttime = value.createInteger("SmartBlockHurttime", 5, 0, 10);
	var autosneak = value.createBoolean("AutoSneak", true);
	var pushvelo = value.createBoolean("PushVelo", false);
	
    this.getName = function() {
        return "gommenoslow";
    }
    this.getDescription = function() {
        return "gommenoslow";
    }
    this.getCategory = function() {
        return "Misc"; 
    }
    this.onEnable = function() {
		
		if (mc.thePlayer.onGround) {
			height = mc.thePlayer.posY;
		}
		
    }
    this.onDisable = function() {
		
    }
	
	this.addValues = function(values) {
		values.add(blocknoslow);
        values.add(ongroundfastdelay);
		values.add(ongroundslowdownforward);
		values.add(ongroundslowdownstrafe);
		values.add(smartblock);
		values.add(pushvelo);
		values.add(smartblockhurttime);
		values.add(autosneak);
    }
	
	
    this.onUpdate = function() {
		
		
		//workaround for the nofall breaking the fallDistance
		
		if (mc.thePlayer.onGround && mc.thePlayer.fallDistance < 0) {
			mc.thePlayer.fallDistance = 0
		}
		
		//var height
		
		if (mc.thePlayer.onGround) {
			height = mc.thePlayer.posY;
		}	
		
		
		//sneak
		
		if (autosneak.get()) {
			if ((mc.thePlayer.fallDistance > 0) && (mc.thePlayer.posY < height + 0.256) && (!mc.thePlayer.isInWater()) || mc.thePlayer.onGround) {
				sneak.setState(false);
				sneak.getValue("mode").set("Vanilla");
			}else if (!mc.thePlayer.onGround) {
				sneak.setState(true);
			}
		}
		
		
		//noslowdown for food and bow while jumping
		
		if ((!mc.thePlayer.isInWater) && (mc.thePlayer.fallDistance > 0 && mc.thePlayer.posY < height + 0.2001) || (mc.thePlayer.onGround)) {
			if (i > 1) {
				mc.thePlayer.setSprinting(false);
			}
			noslow.getValue("ConsumeForwardMultiplier").set(0.54);
			noslow.getValue("ConsumeStrafeMultiplier").set(0.50);
			noslow.getValue("BowForwardMultiplier").set(0.54);
			noslow.getValue("BowStrafeMultiplier").set(0.50);
		}else if (!mc.thePlayer.onGround) {
			noslow.getValue("ConsumeForwardMultiplier").set(1);
			noslow.getValue("ConsumeStrafeMultiplier").set(1);
			noslow.getValue("BowForwardMultiplier").set(1);
			noslow.getValue("BowStrafeMultiplier").set(1);
		}
		

		//hurttime smartblock
		
		if (smartblock.get()){
			if (mc.thePlayer.hurtTime > smartblockhurttime.get()) {
				killaura.getValue("AutoBlock").set(false);
			}else{
				killaura.getValue("AutoBlock").set(true);
			}
		}
		
		
		//block-noslow
		
		if (blocknoslow.get()){
			
			
			if ((test == true) || (mc.thePlayer.hurtTime > 5) && (pushvelo.get())) {
					noslow.getValue("Packet").set(false);
					noslow.getValue("BlockForwardMultiplier").set (1);
					noslow.getValue("BlockStrafeMultiplier").set (1);
					test = false;
					test3 = false;
			}
			
		
			if (i < ongroundfastdelay.get()) {
				if ((mc.thePlayer.fallDistance > 0) && (mc.thePlayer.posY < height + 0.256) && (!mc.thePlayer.isInWater()) && (mc.thePlayer.posY > height - 0.6) || (mc.thePlayer.onGround && test4 == true)) {
					noslow.getValue("Packet").set(true);
					noslow.getValue("BlockForwardMultiplier").set (1);
					noslow.getValue("BlockStrafeMultiplier").set (1);
					test3 = true;
					test4 = false;
				}else if ((!mc.thePlayer.onGround) && (test3 == true)) {
					test = true;
					test4 = true;
					
				}
			}
		
		
			if ((mc.thePlayer.onGround) && (!mc.thePlayer.isInWater())) {
			
				if (test2 == true) {
				i++;
				}
			
				if (i == ongroundfastdelay.get()) {
					noslow.getValue("Packet").set(false);
					noslow.getValue("BlockForwardMultiplier").set (ongroundslowdownforward.get());
					noslow.getValue("BlockStrafeMultiplier").set (ongroundslowdownstrafe.get());
					mc.thePlayer.setSprinting(false);
					test2 = false;
					test3 = true;
					test4 = false;
					i = 0;
				}
			
			}else if (!mc.thePlayer.onGround) {
				test2 = true;
				i = 0;
			}
		}
	}
}


var gommenoslow = new gommenoslow();
var gommenoslowClient;


function onLoad() {}

function onEnable() {
    gommenoslowClient = moduleManager.registerModule(gommenoslow);
}

function onDisable() {
    moduleManager.unregisterModule(gommenoslowClient);
}