Skip to content

Conversation

@SubAt0m1c
Copy link
Collaborator

@SubAt0m1c SubAt0m1c commented Aug 14, 2025

kinda bad rn but i dont know that i care to make it better

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @SubAt0m1c, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the existing SearchBar component from a singleton object to a reusable class. This change enables the introduction of a new "Search Bar" module, specifically designed for searching and highlighting items within inventories. The ClickGUI has also been updated to utilize an instance of this new SearchBar class, ensuring consistent functionality and improved modularity across the application.

Highlights

  • SearchBar Refactoring: The SearchBar component has been refactored from a Kotlin object (singleton) to a standard class, allowing for multiple independent instances.
  • New Inventory Search Module: A dedicated "Search Bar" module has been added under the Skyblock features, providing an in-game search bar for inventories that highlights matching items by display name or lore.
  • ClickGUI Integration Update: The ClickGUI has been updated to use an instantiated SearchBar object, replacing the previous static calls and adapting to the new draw method signature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the SearchBar from an object to a class, which is a great architectural improvement. It also adds a new feature to search within inventories. The code is mostly well-written, but I have a few suggestions to improve maintainability and readability, particularly around magic numbers, rendering logic, and complex conditional checks. A more descriptive pull request title would also be beneficial for history tracking.

Comment on lines +26 to +46
fun onRenderInventory(event: GuiEvent.DrawGuiForeground) {
NVGRenderer.beginFrame(mc.displayWidth.toFloat(), mc.displayHeight.toFloat())

searchBar.draw(mc.displayWidth / 2f - 175f, mc.displayHeight - 110f, 350f, 40f, mouseX, mouseY)

val scale = ScaledResolution(mc).scaleFactor.toFloat()
NVGRenderer.scale(scale, scale)

if (searchBar.currentSearch.isNotEmpty()) {
for (inventorySlot in event.gui.inventorySlots.inventorySlots) {
if (inventorySlot?.stack?.displayName?.contains(searchBar.currentSearch, ignoreCase = true) == true || inventorySlot?.stack?.lore?.any { it.contains(searchBar.currentSearch, ignoreCase = true) } == true) {
val slotX = inventorySlot.xDisplayPosition.toFloat() + event.guiLeft
val slotY = inventorySlot.yDisplayPosition.toFloat() + event.guiTop
NVGRenderer.rect(slotX, slotY, 16f, 16f, highlightColor.rgba)
}
}
}

NVGRenderer.scale(1f / scale, 1f / scale)
NVGRenderer.endFrame()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling NVGRenderer.beginFrame() and NVGRenderer.endFrame() within this event handler might lead to issues if other modules also render using NVG on the same event. This can cause nested frames or other rendering artifacts. While this follows a pattern seen elsewhere (ClickGUI), a more robust solution would be to have a single, centralized place that manages the frame for GUI overlays, with modules only responsible for their specific drawing calls. This would improve both performance and stability.

Comment on lines +36 to +40
if (inventorySlot?.stack?.displayName?.contains(searchBar.currentSearch, ignoreCase = true) == true || inventorySlot?.stack?.lore?.any { it.contains(searchBar.currentSearch, ignoreCase = true) } == true) {
val slotX = inventorySlot.xDisplayPosition.toFloat() + event.guiLeft
val slotY = inventorySlot.yDisplayPosition.toFloat() + event.guiTop
NVGRenderer.rect(slotX, slotY, 16f, 16f, highlightColor.rgba)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This conditional logic for checking the item name and lore can be made safer and more readable by using a let scope function to handle the nullable stack. This avoids the long chain of safe calls and the == true check.

                inventorySlot?.stack?.let { stack ->
                    if (stack.displayName.contains(searchBar.currentSearch, ignoreCase = true) || stack.lore.any { it.contains(searchBar.currentSearch, ignoreCase = true) }) {
                        val slotX = inventorySlot.xDisplayPosition.toFloat() + event.guiLeft
                        val slotY = inventorySlot.yDisplayPosition.toFloat() + event.guiTop
                        NVGRenderer.rect(slotX, slotY, 16f, 16f, highlightColor.rgba)
                    }
                }

Comment on lines +34 to +35
textInputHandler.width = width - 100 // ?? not sure if these should be handled like this but whatever
textInputHandler.height = height - 18 // ??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The magic numbers 100 and 18 make the code's intent unclear and harder to maintain. It would be better to define these as named constants (e.g., in a companion object) to describe what they represent, like padding or offsets. The comments indicating uncertainty should also be removed, as the code should be self-explanatory or have clear comments about its logic.

@SubAt0m1c SubAt0m1c marked this pull request as draft August 30, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants