Program: 8865
Project: 8865
Buggy source:
@Override public void onMouseButtonEvent(MouseButtonEvent evt){
  timeFromLastUpdate=0;
  if (isOnGui || !isOnMap) {
    return;
  }
  if (evt.getButtonIndex() == MouseInput.BUTTON_LEFT) {
    if (evt.isPressed()) {
      if (interactionState.getType() == Type.SPELL) {
        if (interactiveControl != null && interactionState.getItemId() == SPELL_POSSESSION_ID && interactiveControl.isPickable(player.getPlayerId())) {
          CreatureControl cc=interactiveControl.getSpatial().getControl(CreatureControl.class);
          if (cc != null) {
            onPossession(cc);
            setInteractionState(Type.NONE,0);
          }
        }
      }
 else       if (interactionState.getType() == Type.TRAP) {
      }
 else       if (interactionState.getType() == Type.DOOR) {
      }
 else       if (interactionState.getType() == Type.NONE && interactiveControl != null && !keeperHand.isFull() && interactiveControl.isPickable(player.getPlayerId())) {
        pickupObject(interactiveControl);
      }
 else {
        if (selectionHandler.isVisible()) {
          selectionHandler.setActive(true);
        }
        if (isTaggable) {
          updateCursor();
          Vector2f pos=selectionHandler.getPointedTilePosition();
          getWorldHandler().playSoundAtTile((int)pos.x,(int)pos.y,"String_Node_Str");
        }
      }
    }
 else     if (evt.isReleased() && selectionHandler.isActive()) {
      SelectionArea selectionArea=selectionHandler.getSelectionArea();
      if (interactionState.getType() == Type.NONE || (interactionState.getType() == Type.ROOM && getWorldHandler().isTaggable((int)selectionArea.getRealStart().x,(int)selectionArea.getRealStart().y))) {
        boolean select=!getWorldHandler().isSelected((int)Math.max(0,selectionArea.getRealStart().x),(int)Math.max(0,selectionArea.getRealStart().y));
        getWorldHandler().selectTiles(selectionArea,select,player.getPlayerId());
      }
 else       if (interactionState.getType() == Type.ROOM && getWorldHandler().isBuildable((int)selectionArea.getRealStart().x,(int)selectionArea.getRealStart().y,player,gameState.getLevelData().getRoomById(interactionState.getItemId()))) {
        getWorldHandler().build(selectionArea,player,gameState.getLevelData().getRoomById(interactionState.getItemId()));
      }
 else       if (interactionState.getType() == Type.SELL) {
        getWorldHandler().sell(selectionArea,player);
      }
      selectionHandler.setActive(false);
      updateCursor();
    }
  }
 else   if (evt.getButtonIndex() == MouseInput.BUTTON_RIGHT && evt.isReleased()) {
    Vector2f pos=selectionHandler.getPointedTilePosition();
    if (interactionState.getType() == Type.NONE) {
      if (keeperHand.getItem() != null) {
        TileData tile=getWorldHandler().getMapData().getTile((int)pos.x,(int)pos.y);
        IInteractiveControl.DroppableStatus status=keeperHand.peek().getDroppableStatus(tile);
        if (status != IInteractiveControl.DroppableStatus.NOT_DROPPABLE) {
          keeperHand.pop().drop(tile,selectionHandler.getPointedPositionInTile(),interactiveControl);
          updateCursor();
        }
      }
 else       if (Main.isDebug()) {
        if (getWorldHandler().isTaggable((int)pos.x,(int)pos.y)) {
          getWorldHandler().digTile((int)pos.x,(int)pos.y);
        }
 else         if (getWorldHandler().isClaimable((int)pos.x,(int)pos.y,player.getPlayerId())) {
          getWorldHandler().claimTile((int)pos.x,(int)pos.y,player.getPlayerId());
        }
      }
 else       if (interactiveControl != null && interactiveControl.isInteractable(player.getPlayerId())) {
        getWorldHandler().playSoundAtTile((int)pos.x,(int)pos.y,KeeperHand.getSlapSound());
        interactiveControl.interact(player.getPlayerId());
      }
    }
    setInteractionState(Type.NONE,0);
    updateCursor();
    selectionHandler.setActive(false);
  }
 else   if (evt.getButtonIndex() == MouseInput.BUTTON_MIDDLE && evt.isReleased()) {
    Vector2f pos=selectionHandler.getPointedTilePosition();
    if (Main.isDebug()) {
      getWorldHandler().claimTile((int)pos.x,(int)pos.y,player.getPlayerId());
    }
  }
}

Fixed version (ground truth):
@Override public void onMouseButtonEvent(MouseButtonEvent evt){
  timeFromLastUpdate=0;
  if (isOnGui || !isOnMap) {
    return;
  }
  if (evt.getButtonIndex() == MouseInput.BUTTON_LEFT) {
    if (evt.isPressed()) {
      if (interactionState.getType() == Type.SPELL) {
        if (interactiveControl != null && interactionState.getItemId() == SPELL_POSSESSION_ID && interactiveControl.isPickable(player.getPlayerId())) {
          CreatureControl cc=interactiveControl.getSpatial().getControl(CreatureControl.class);
          if (cc != null) {
            onPossession(cc);
            setInteractionState(Type.NONE,0);
          }
        }
      }
 else       if (interactionState.getType() == Type.TRAP) {
      }
 else       if (interactionState.getType() == Type.DOOR) {
      }
 else       if (interactionState.getType() == Type.NONE && interactiveControl != null && !keeperHand.isFull() && interactiveControl.isPickable(player.getPlayerId())) {
        pickupObject(interactiveControl);
      }
 else {
        if (selectionHandler.isVisible()) {
          selectionHandler.setActive(true);
        }
        if (isTaggable) {
          updateCursor();
          Vector2f pos=selectionHandler.getPointedTilePosition();
          getWorldHandler().playSoundAtTile((int)pos.x,(int)pos.y,"String_Node_Str");
        }
      }
    }
 else     if (evt.isReleased() && selectionHandler.isActive()) {
      SelectionArea selectionArea=selectionHandler.getSelectionArea();
      if (interactionState.getType() == Type.NONE || (interactionState.getType() == Type.ROOM && getWorldHandler().isTaggable((int)selectionArea.getRealStart().x,(int)selectionArea.getRealStart().y))) {
        boolean select=!getWorldHandler().isSelected((int)Math.max(0,selectionArea.getRealStart().x),(int)Math.max(0,selectionArea.getRealStart().y));
        getWorldHandler().selectTiles(selectionArea,select,player.getPlayerId());
      }
 else       if (interactionState.getType() == Type.ROOM && getWorldHandler().isBuildable((int)selectionArea.getRealStart().x,(int)selectionArea.getRealStart().y,player,gameState.getLevelData().getRoomById(interactionState.getItemId()))) {
        getWorldHandler().build(selectionArea,player,gameState.getLevelData().getRoomById(interactionState.getItemId()));
      }
 else       if (interactionState.getType() == Type.SELL) {
        getWorldHandler().sell(selectionArea,player);
      }
      selectionHandler.setActive(false);
      updateCursor();
    }
  }
 else   if (evt.getButtonIndex() == MouseInput.BUTTON_RIGHT && evt.isReleased()) {
    Vector2f pos=selectionHandler.getPointedTilePosition();
    if (interactionState.getType() == Type.NONE) {
      if (keeperHand.getItem() != null) {
        TileData tile=getWorldHandler().getMapData().getTile((int)pos.x,(int)pos.y);
        IInteractiveControl.DroppableStatus status=keeperHand.peek().getDroppableStatus(tile);
        if (status != IInteractiveControl.DroppableStatus.NOT_DROPPABLE) {
          keeperHand.pop().drop(tile,selectionHandler.getPointedPositionInTile(),interactiveControl);
          updateCursor();
        }
      }
 else       if (interactiveControl != null && interactiveControl.isInteractable(player.getPlayerId())) {
        getWorldHandler().playSoundAtTile((int)pos.x,(int)pos.y,KeeperHand.getSlapSound());
        interactiveControl.interact(player.getPlayerId());
      }
 else       if (Main.isDebug()) {
        if (getWorldHandler().isTaggable((int)pos.x,(int)pos.y)) {
          getWorldHandler().digTile((int)pos.x,(int)pos.y);
        }
 else         if (getWorldHandler().isClaimable((int)pos.x,(int)pos.y,player.getPlayerId())) {
          getWorldHandler().claimTile((int)pos.x,(int)pos.y,player.getPlayerId());
        }
      }
    }
    setInteractionState(Type.NONE,0);
    updateCursor();
    selectionHandler.setActive(false);
  }
 else   if (evt.getButtonIndex() == MouseInput.BUTTON_MIDDLE && evt.isReleased()) {
    Vector2f pos=selectionHandler.getPointedTilePosition();
    if (Main.isDebug()) {
      getWorldHandler().claimTile((int)pos.x,(int)pos.y,player.getPlayerId());
    }
  }
}