Applying collisions and physics to a processing 3 project

I’ve been working on a simulation project which has a cannon and 2 towers of blocks which must collide with each other in a way that causes movement(however rotation is not required, just displacement and gravity)
I’ve been trying to use this processing script I wrote: https://pastebin.com/g1T0U7YN
to do just that, but when the blocks fall, they stack on top of each other, but the console says that collision is detected, what’s wrong with my collision?
Relevant excerpt:

  void drawblock() {
    for (int i=0; i<blocks.size(); i++) {
      block sb=blocks.get(i);
      if (sb.by<by+25&&sb.by+25>by&&(sb.bx+25>bx||cbs.get(0).cx>bx)) {
        //left
        println("left");
      }
      if (sb.by<by+25&&sb.by+25>by&&(sb.bx<bx+25||cbs.get(0).cx>bx)) {
        //right
        println("right");
      }
      if (sb.bx+25>bx&&sb.bx<bx+25&&(sb.by+25>by||cbs.get(0).cx>bx)) {
        //top
        println("top");
      }
      if (sb.bx+25>bx&&sb.bx<bx+25&&(sb.by<by||cbs.get(0).cx>bx)) {
        //bottom
        println("bottom");
      } else {
        if (by<400) {
          VelD+=.98;
          by+=VelD;
        }
      }
    }

-Jake T.