title: Entity is not rendering properly in my game
body: <p>Recently, I have been developing a game(I am a beginner, but it is organized).
  My problem is that I have added a tree(Static Entity) in my game and I have made an entity manager to render it properly by using a comparator.The code for it can be seen below.</p>
  <pre><code>public class EntityManager {
  
      private Handler handler;
      private Player player;
      private ArrayList&lt;Entity&gt; entities;
      private Comparator&lt;Entity&gt; renderSorter = new Comparator&lt;Entity&gt;() {
  
          @Override
          public int compare(Entity a, Entity b) {
              if(a.getY() + a.getHeight() &lt; b.getY() + b.getHeight()) { 
                  return -1;
              }
              return 1;
          }
          
      };
      
      public EntityManager(Handler handler, Player player) {
          this.handler = handler;
          this.player = player;
          entities = new ArrayList&lt;Entity&gt;();
          addEntity(player);
      }
          
      public void tick() {
          Iterator&lt;Entity&gt; it = entities.iterator();
          
          while(it.hasNext()) {
              Entity e = it.next();
              e.tick();
              //if(!e.active)
                  //it.remove();
          }
          entities.sort(renderSorter);
      }
          
      public void render(Graphics g) {
          for(Entity e : entities) {
              e.render(g);
          }
          //player.postRender(g);
      }
      
      public void addEntity(Entity e) {
          entities.add(e);
      }
  </code></pre>
  <p>Although the tree is rendering properly like this<a href="https://i.stack.imgur.com/QTt3R.png" rel="nofollow noreferrer">Tree rendering behind the player</a></p>
  <p>But a new entity that I added (a Rock) is not rendering properly, like this<a href="https://i.stack.imgur.com/gIaBl.png" rel="nofollow noreferrer">rock rendering in front of player</a></p>
  <p>I don't know why this is happening , or if this is a bug.
  if you want any other details, or source code then please tell.
  Thank you</p>