for(var i = 0; i < spawnedEntities.length; i++) 
{
    var ent = spawnedEntities[i];
    if(ent.isAlive()) 
	{
        //OPTIONAL:
        ent.texture = "/ice/" + ent.getClassType() + ".png"
        //ENDOPTIONAL
        if (ent.getImmuneToFire()) 
        {
            ent.setImmuneToFire(false);
        }
        var target = ent.getEntitiesWithinRange(2);
        for(var j = 0; j < target.length; j++) 
		{
            var entj = target[j];
            if (entj.getClassType() == "Player") 
			{
                                player.setStunned(10)
                                effect.setOverlay("ice.png");
			}   
		}
		Epos = ent.getPosition();
		for(var k = 0; k < 10; k++)
		{
			effect.spawnParticle("reddust", Epos.x + Math.random() - 0.5, Epos.y + Math.random(), Epos.z + Math.random() - 0.5, -1, 1, 1);
			effect.spawnParticle("snowballpoof", Epos.x + Math.random() - 0.5, Epos.y + Math.random(), Epos.z + Math.random() - 0.5, 0, 0, 0);
		}
		if(!ent.isBurning())
		{
			ent.heal(4);
		}
	}
}

if(player.getStunned() == 0 || player.getHealth() == 0)
{
	if(effect.getOverlay() == "ice.png")
	{
		effect.clearOverlay();
	}
}
