Physics engines usually do no conserve energy, there is loss over time. The reason is everything is an approximation. You can however keep the energy close to being constant by correcting the velocity.
So the equation is this:
E=KE+PE
E=0.5*m*v^2 + m*g*h
solved for v
v = sqrt((E-mgh)*2/m)
So the events to correct the velocity so energy is conserved would be:
global number total_energy=0
global number initial_y=0
global number speed=0
global number angleOfMotion=0
Start of layout
--- set initial_y to ball.y
--- set total_energy to ball.physics.mass*10*(480-ball.y)
ball: y<initial_y
--- ball: set y to initial_y
every tick
--- set speed to sqrt((total_energy-ball.physics.mass*10*(480-ball.y))*2/ball.physics.mass)
--- set angleOfMotion to angle(0,0,ball.physics.velocityX,ball.physics.velocityY)
--- ball: physics: set velocity to ( speed*cos(angleOfMotion), speed*sin(angleOfMotion) )