pinv = player.getInventory();
hasLimiter = false;

//---------Axes v1.0 - Renounce4-----//
var Axe_ready = 1
var Axe_MagicLow = 0
var Axe_frozenEntities = new Array()
AxeAttack = function() {
	if(Axe_MagicCost < 0) {
		if(magdly >= Math.abs(Axe_MagicCost)) {
			magdly = magdly-Math.abs(Axe_MagicCost)
		}
		else {
			Axe_ready = 0
			Axe_MagicLow = 1
		}
	}
	if(Axe_ready == 1) {
		Axe_ready = 0
		player.swingMainHand()
		var ppos = player.getPosition()
		var plok = player.getLookVec()
		var target = plok.scale(Axe_Range).add(ppos);
		var results = player.rayTrace(ppos, target);
		var hitpos = results[0];
		var block = results[1];
		var ent = results[2];
		if(ent != null && ent.getClassType() != "Painting" && ent.getClassType() != "FallingSand" && ent.getClassType() != "Minecart" && ent.getClassType() != "Boat" && ent.getClassType() != "Item") {
			ent.attackEntityFrom(player,Axe_Damage)
			var evel = ent.getVelocity()
			ent.setVelocity(evel.x*Axe_KnockBack,evel.y,evel.z*Axe_KnockBack)
			evel = ent.getVelocity()
			if(evel.x > (Axe_KnockBack*.38)) {
				ent.setVelocity(evel.x/Axe_KnockBack,evel.y,evel.z/Axe_KnockBack)
			}
			if(evel.x < (Axe_KnockBack*-.38)) {
				ent.setVelocity(evel.x/Axe_KnockBack,evel.y,evel.z/Axe_KnockBack)
			}
			if(evel.z > (Axe_KnockBack*.38)) {
				ent.setVelocity(evel.x/Axe_KnockBack,evel.y,evel.z/Axe_KnockBack)
			}
			if(evel.z < (Axe_KnockBack*-.38)) {
				ent.setVelocity(evel.x/Axe_KnockBack,evel.y,evel.z/Axe_KnockBack)
			}
			if(Axe_MagicCost > 0) {
				if(magdly >= Axe_MagicCost) {
					magdly = magdly-Axe_MagicCost
					var aspectready = 1
				}
				else {
					var aspectready = 0
				}
			}
			else {
				var aspectready = 1
			}
			if(aspectready == 1) {
				ent.setFireLevel(Axe_FireAspect*20)
				if(ent.getStunned() == 0) {
					ent.setStunned(Axe_IceAspect*20)
					Axe_frozenEntities.splice(Axe_frozenEntities.length,0,ent)
				}
			}
		}
		time.sleep(Axe_CoolDown)
		Axe_ready = 1
	}
	if(Axe_MagicLow == 1) {
		Axe_ready = 1
		Axe_MagicLow = 0
	}
}
UpdateAxefrozenEntities = function() {
	for (var i = 0; i < Axe_frozenEntities.length; i++) {
		var hTime = Axe_frozenEntities[i].getHurtTime();
		if (hTime > 0) {
			Axe_frozenEntities[i].setHurtTime(0);
		}
		
		var r = Math.random();
		
		if (r <= 0.05 && Axe_IceAspect > 0) {
			for (var j = 0; j < 10; j++) {
				px = Axe_frozenEntities[i].getPosition().x + ((Math.random() * 0.5) - 0.25);
				py = Axe_frozenEntities[i].getPosition().y + ((Math.random() * 0.5) - 0.25);
				pz = Axe_frozenEntities[i].getPosition().z + ((Math.random() * 0.5) - 0.25);
				
				effect.spawnParticle("snowballpoof", px, py+1, pz, 0.0, 0.0, 0.0);
			}
		}
		
		if (Axe_frozenEntities[i].getStunned() == 0) {
			Axe_frozenEntities.splice(i, 1);
		}
	}
}