Minecraft Velocity setY only works sometimes?

Vo
1

Good evening I have the following problem

Vector dir = target.getVelocity ();

dir.setY (2.0D);

target.setVelocity (dir);

with this code the enemy is to be thrown into the air, but the strange thing happened exactly, but completely random sometimes it sometimes does not happen so why with x and z it always works but why not with y

Co

How do you do dad Event, runnable?