Program: 34593
Project: 34593
Buggy source:
@SubscribeEvent public void onClientTick(ClientTickEvent e){
  if (e.phase != Phase.START)   return;
  if ((keyOpenCompendium.isPressed() || Keyboard.getEventKeyState() && Keyboard.getEventKey() == keyOpenCompendium.getKeyCode()) && (mc.inGameHasFocus || mc.currentScreen instanceof GuiContainer)) {
    if (canOpenCompendium()) {
      KnowledgeObject<? extends IObjectHolder<?>> obj=null;
      if (mc.inGameHasFocus) {
      }
 else {
        GuiContainer container=(GuiContainer)mc.currentScreen;
        List<Slot> slots=container.inventorySlots.inventorySlots;
        ScaledResolution res=new ScaledResolution(mc,mc.displayWidth,mc.displayHeight);
        int mouseX=Mouse.getX() * res.getScaledWidth() / mc.displayWidth, mouseY=res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight - 1;
        mouseX-=(container.width - container.xSize) / 2;
        mouseY-=(container.height - container.ySize) / 2;
        for (        Slot slot : slots) {
          if (slot.getHasStack() && slot.func_111238_b() && mouseX >= slot.xDisplayPosition - 1 && mouseX <= slot.xDisplayPosition + 16 && mouseY >= slot.yDisplayPosition - 1 && mouseY <= slot.yDisplayPosition + 16) {
            obj=KnowledgeUtils.tryGetFromItemStack(slot.getStack());
            break;
          }
        }
        if (obj == null)         return;
      }
      openCompendium(obj);
      if (!mc.thePlayer.getStatFileWriter().hasAchievementUnlocked(AchievementManager.ENDER_COMPENDIUM)) {
        PacketPipeline.sendToServer(new S03SimpleEvent(EventType.OPEN_COMPENDIUM));
      }
    }
  }
}

Fixed version (ground truth):
@SubscribeEvent public void onClientTick(ClientTickEvent e){
  if (e.phase != Phase.START)   return;
  if ((keyOpenCompendium.isPressed() || Keyboard.getEventKeyState() && Keyboard.getEventKey() == keyOpenCompendium.getKeyCode()) && (mc.inGameHasFocus || mc.currentScreen instanceof GuiContainer)) {
    if (canOpenCompendium()) {
      KnowledgeObject<? extends IObjectHolder<?>> obj=null;
      if (mc.inGameHasFocus) {
      }
 else {
        GuiContainer container=(GuiContainer)mc.currentScreen;
        List<Slot> slots=container.inventorySlots.inventorySlots;
        ScaledResolution res=new ScaledResolution(mc,mc.displayWidth,mc.displayHeight);
        int mouseX=Mouse.getX() * res.getScaledWidth() / mc.displayWidth, mouseY=res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight - 1;
        mouseX-=(container.width - container.xSize) / 2;
        mouseY-=(container.height - container.ySize) / 2;
        for (        Slot slot : slots) {
          if (slot.getHasStack() && slot.func_111238_b() && mouseX >= slot.xDisplayPosition - 1 && mouseX <= slot.xDisplayPosition + 16 && mouseY >= slot.yDisplayPosition - 1 && mouseY <= slot.yDisplayPosition + 16) {
            obj=KnowledgeObject.fromObject(slot.getStack());
            break;
          }
        }
        if (obj == null)         return;
      }
      openCompendium(obj);
      if (!mc.thePlayer.getStatFileWriter().hasAchievementUnlocked(AchievementManager.ENDER_COMPENDIUM)) {
        PacketPipeline.sendToServer(new S03SimpleEvent(EventType.OPEN_COMPENDIUM));
      }
    }
  }
}