attackEntity

fun attackEntity(entity: Entity, swing: SwingMode, keepSprint: Boolean = false)

See also

Minecraft.startAttack