How to till what side there is a collision on using rectangles.
Get the intersection using the oh so convenient getIntersection method in Rectangle/Rectanle2D. This will give the rectangle that is the intersection of the 2 rectangles.
If the width is less then height, then it is a collision on either the right or left. See whether or not the x vel is positive or negative to find which side.
If the width is greater then height, then you have collision on either the top or bottom. Again, check y vel to see which one.
You can then add the intersection width or height to the player to move them up properly. This will not work for all cases (equal width and height or vel of 0) but is a good starting point.
Rectangle2D rect = this.getIntersection(block.entities.get(i));
if(trect.getWidth() < rect.getHeight())
if(vel.x < 0)
if(vel.y < 0)