Program: 7260
Project: 7260
Buggy source:
public void update(GameContainer container,StateBasedGame game,int delta){
  if (Main.KEYDOWN[Input.KEY_Q] && !blockSelected) {
    inventory.prev();
    blockSelected=true;
  }
  if (Main.KEYDOWN[Input.KEY_E] && !blockSelected) {
    inventory.next();
    blockSelected=true;
  }
  if (!Main.KEYDOWN[Input.KEY_Q] && !Main.KEYDOWN[Input.KEY_E] && blockSelected) {
    blockSelected=false;
  }
  if (Main.KEYDOWN[Input.KEY_UP] || Main.KEYDOWN[Input.KEY_W] || Main.KEYDOWN[Input.KEY_SPACE]) {
    if (character.grounded) {
      character.applyForce(0,-Main.GU * 1600f);
    }
  }
  if (Main.KEYDOWN[Input.KEY_LEFT] || Main.KEYDOWN[Input.KEY_A]) {
    character.applyForce(-Main.GU * 200,0);
  }
  if (Main.KEYDOWN[Input.KEY_RIGHT] || Main.KEYDOWN[Input.KEY_D]) {
    character.applyForce(Main.GU * 200,0);
  }
  if (Main.MOUSEDOWN[0]) {
    Block out=inventory.peek();
    fireVector.set(Main.MOUSEX + character.gameworld.viewport.getX() - character.boundingBox.getCenterX(),Main.MOUSEY + character.gameworld.viewport.getY() - character.boundingBox.getCenterY());
    fireVector.normalise();
    fireVector.scale(Main.GU * 6);
    if (out != null && character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type == Block.EMPTY) {
      inventory.pop();
      character.gameworld.terrain.fillCell(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY(),out);
    }
  }
  if (Main.MOUSEDOWN[1]) {
    fireVector.set(Main.MOUSEX + character.gameworld.viewport.getX() - character.boundingBox.getCenterX(),Main.MOUSEY + character.gameworld.viewport.getY() - character.boundingBox.getCenterY());
    fireVector.normalise();
    fireVector.scale(Main.GU * 6);
switch (character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type) {
case ROCK:
case RUBBER:
case WATER:
      inventory.push(character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type);
case EARTH:
    character.gameworld.terrain.emptyCell(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY());
  break;
default :
break;
}
}
if (character.body.getPosition().getY() > Main.GU * 48 + character.gameworld.getViewportPosition().getY()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.getViewportPosition().getX(),character.body.getPosition().getY() - Main.GU * 48));
}
if (character.body.getPosition().getY() < Main.GU * 16 + character.gameworld.getViewportPosition().getY()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.getViewportPosition().getX(),character.body.getPosition().getY() - Main.GU * 16));
}
if (character.body.getPosition().getX() > Main.GU * 100 + character.gameworld.getViewportPosition().getX()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.body.getPosition().getX() - Main.GU * 100,character.gameworld.getViewportPosition().getY()));
}
if (character.body.getPosition().getX() < Main.GU * 16 + character.gameworld.getViewportPosition().getX()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.body.getPosition().getX() - Main.GU * 16,character.gameworld.getViewportPosition().getY()));
}
if (character.grounded) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.getViewportPosition().getX(),character.body.getPosition().getY() - Main.GU * 48));
}
}

Fixed version (ground truth):
public void update(GameContainer container,StateBasedGame game,int delta){
  if (Main.KEYDOWN[Input.KEY_Q] && !blockSelected) {
    inventory.prev();
    blockSelected=true;
  }
  if (Main.KEYDOWN[Input.KEY_E] && !blockSelected) {
    inventory.next();
    blockSelected=true;
  }
  if (!Main.KEYDOWN[Input.KEY_Q] && !Main.KEYDOWN[Input.KEY_E] && blockSelected) {
    blockSelected=false;
  }
  if (Main.KEYDOWN[Input.KEY_UP] || Main.KEYDOWN[Input.KEY_W] || Main.KEYDOWN[Input.KEY_SPACE]) {
    if (character.grounded) {
      character.applyForce(0,-Main.GU * 1600f);
    }
  }
  if (Main.KEYDOWN[Input.KEY_LEFT] || Main.KEYDOWN[Input.KEY_A]) {
    character.applyForce(-Main.GU * 200,0);
  }
  if (Main.KEYDOWN[Input.KEY_RIGHT] || Main.KEYDOWN[Input.KEY_D]) {
    character.applyForce(Main.GU * 200,0);
  }
  if (Main.MOUSEDOWN[0]) {
    Block out=inventory.peek();
    fireVector.set(Main.MOUSEX + character.gameworld.viewport.getX() - character.boundingBox.getCenterX(),Main.MOUSEY + character.gameworld.viewport.getY() - character.boundingBox.getCenterY());
    fireVector.normalise();
    fireVector.scale(Main.GU * 6);
    if (out != null && character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type == Block.EMPTY) {
      inventory.pop();
      character.gameworld.terrain.fillCell(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY(),out);
    }
  }
  if (Main.MOUSEDOWN[1]) {
    fireVector.set(Main.MOUSEX + character.gameworld.viewport.getX() - character.boundingBox.getCenterX(),Main.MOUSEY + character.gameworld.viewport.getY() - character.boundingBox.getCenterY());
    fireVector.normalise();
    fireVector.scale(Main.GU * 6);
switch (character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type) {
case ROCK:
case RUBBER:
case WATER:
      inventory.push(character.gameworld.terrain.getLeaf(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY()).type);
case EARTH:
    character.gameworld.terrain.emptyCell(character.boundingBox.getCenterX() + fireVector.getX(),character.boundingBox.getCenterY() + fireVector.getY());
  break;
default :
break;
}
}
if (character.body.getPosition().getY() > Main.GU * 48 + character.gameworld.getViewportPosition().getY()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.getViewportPosition().getX(),character.body.getPosition().getY() - Main.GU * 48));
}
if (character.body.getPosition().getY() < Main.GU * 16 + character.gameworld.getViewportPosition().getY()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.getViewportPosition().getX(),character.body.getPosition().getY() - Main.GU * 16));
}
if (character.body.getPosition().getX() > Main.GU * 100 + character.gameworld.getViewportPosition().getX()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.body.getPosition().getX() - Main.GU * 100,character.gameworld.getViewportPosition().getY()));
}
if (character.body.getPosition().getX() < Main.GU * 16 + character.gameworld.getViewportPosition().getX()) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.body.getPosition().getX() - Main.GU * 16,character.gameworld.getViewportPosition().getY()));
}
if (character.grounded) {
character.gameworld.setViewportPositionGoal(new Vector2f(character.gameworld.viewportgoal.getX(),character.body.getPosition().getY() - Main.GU * 48));
}
}