Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Soon2BeATaco
Copy link

  • Added hollow wand module for ichor pool (with message sending and waypoint features)
  • Added a "specific coordinates" optional parameter to PlayerUtils.getPositionString()

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Soon2BeATaco, 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 PR introduces a new 'Hollow Wand' module for Ichor Pool management, enabling automatic party chat messages with precise coordinates upon casting and displaying temporary waypoints for incoming Ichor Pool messages. It also updates PlayerUtils to support more granular coordinate reporting.

Highlights

  • Intent: This pull request introduces a new 'Hollow Wand' module designed to assist with Ichor Pool casting by providing message sending and waypoint features. It also enhances the PlayerUtils.getPositionString() utility to allow for more precise coordinate reporting.
  • Changes: The primary change is the addition of a new module, HollowWand.kt, which enables users to automatically send their Ichor Pool coordinates to party chat and to visualize incoming Ichor Pool coordinates from party members as temporary waypoints. This module includes settings for enabling/disabling message sending and waypoint display, as well as customizing waypoint color and text size. To support the precise coordinate reporting for the new module, the PlayerUtils.getPositionString() function was modified to accept an optional parameter, allowing it to return coordinates with decimal precision instead of just block coordinates. Additionally, the .gitignore file was updated to ignore .DS_Store files, and the new HollowWand module was registered in ModuleManager.kt.
  • Reviewer Activity: No specific reviewer activity was provided in the context.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

Thank you for this contribution! I've reviewed the changes and have a few suggestions to improve correctness, maintainability, and clarity. My main points are:

  • In HollowWand.kt, the logic for removing waypoints is not entirely safe and could lead to a crash. I've suggested a more robust implementation.
  • I've also pointed out a few places where using named arguments would significantly improve code readability, especially for function calls with multiple parameters or boolean flags.
  • In PlayerUtils.kt, there's a small optimization to be made to avoid unnecessary object creation.

Overall, this is a great addition. Please take a look at my comments. Keep up the good work!

Comment on lines 43 to 50
val x: Double = it.groups[1]?.value?.toDouble() ?: return@onMessage
val y: Double = it.groups[2]?.value?.toDouble() ?: return@onMessage
val z: Double = it.groups[3]?.value?.toDouble() ?: return@onMessage
poolsToRender.add(IchorPoolCoordinate(x, y, z))

runIn(400, true) {
poolsToRender.removeAt(0)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using removeAt(0) is not safe and can lead to an IndexOutOfBoundsException if poolsToRender is cleared (e.g., on world load) before the runIn task executes. It's also fragile if the list is modified elsewhere.

A more robust approach is to remove the specific IchorPoolCoordinate instance that was added. This ensures you're always removing the correct element and avoids crashes on an empty list. I've also used toDoubleOrNull() which is slightly safer.

            val x = it.groups[1]?.value?.toDoubleOrNull() ?: return@onMessage
            val y = it.groups[2]?.value?.toDoubleOrNull() ?: return@onMessage
            val z = it.groups[3]?.value?.toDoubleOrNull() ?: return@onMessage
            val newPool = IchorPoolCoordinate(x, y, z)
            poolsToRender.add(newPool)

            runIn(400, true) {
                poolsToRender.remove(newPool)
            }

Copy link
Owner

Choose a reason for hiding this comment

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

Implmenet ^


private val incomingIchorRegex = Regex("""^Party > (?:\[[\wዞ]+\+*] )?[\w_]+: Ichor Pool x: (-?\d+\.\d{3}), y: (-?\d+), z: (-?\d+\.\d{3})$""")
private val outgoingIchorRegex = Regex("""^Casting Spell: Ichor Pool!$""")
private val messageSize by NumberSetting("Message Size", 1f, 0.1f, 4f, 0.1f, desc = "Whether or not to display the message size in the box.").withDependency { true }
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 dependency { true } is redundant, as settings are visible by default.

Additionally, the description is a bit misleading for a NumberSetting. A clearer description would be better.

Since this setting only affects rendering when showWaypoint is enabled, it should be dependent on it to improve the user experience in the GUI.

Suggested change
private val messageSize by NumberSetting("Message Size", 1f, 0.1f, 4f, 0.1f, desc = "Whether or not to display the message size in the box.").withDependency { true }
private val messageSize by NumberSetting("Message Size", 1f, 0.1f, 4f, 0.1f, desc = "The size of the waypoint text.").withDependency { showWaypoint }

if(!showWaypoint) return

poolsToRender.forEach { pool ->
Renderer.drawCylinder(Vec3(pool.x, pool.y, pool.z), 6, 6, 0.05, 80f, 1f, 0f, 90f, 90f, waypointColor, true)
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 call to drawCylinder uses many magic numbers, which makes the code hard to understand and maintain. What do 6, 0.05, 80f, etc., represent?

Using named arguments would significantly improve readability by making the purpose of each argument explicit. Consider also defining these values as constants if they are used elsewhere or have special meaning.

Example with named arguments:

Renderer.drawCylinder(
    pos = Vec3(pool.x, pool.y, pool.z),
    baseRadius = 6,
    topRadius = 6,
    height = 0.05,
    slices = 80,
    stacks = 1,
    rot1 = 0f,
    rot2 = 90f,
    rot3 = 90f,
    color = waypointColor,
    depth = true
)


poolsToRender.forEach { pool ->
Renderer.drawCylinder(Vec3(pool.x, pool.y, pool.z), 6, 6, 0.05, 80f, 1f, 0f, 90f, 90f, waypointColor, true)
Renderer.drawStringInWorld("Ichor Pool", Vec3(pool.x, pool.y + 0.5, pool.z), Colors.WHITE, true, 0.03f * messageSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using positional arguments with default values can make the call ambiguous and hard to read. For example, it's not immediately clear what true refers to without looking up the function definition.

Using named arguments would make this call much clearer and more maintainable.

            Renderer.drawStringInWorld("Ichor Pool", Vec3(pool.x, pool.y + 0.5, pool.z), color = Colors.WHITE, depth = true, scale = 0.03f * messageSize)


fun getPositionString(): String {
fun getPositionString(getSpecificCoordinates: Boolean = false): String {
val blockPos = BlockPos(posX, posY, posZ)
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 BlockPos object is created unconditionally, but it's only used in the else branch. To avoid unnecessary object allocation when getSpecificCoordinates is true, you can move the blockPos instantiation inside the else block.

    fun getPositionString(getSpecificCoordinates: Boolean = false): String {
        return if (getSpecificCoordinates) {
            "x: ${posX.toFixed(3)}, y: ${posY.toFixed(0)}, z: ${posZ.toFixed(3)}"
        } else {
            val blockPos = BlockPos(posX, posY, posZ)
            "x: ${blockPos.x}, y: ${blockPos.y}, z: ${blockPos.z}"
        }
    }

Copy link
Owner

Choose a reason for hiding this comment

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

Why was this file modified?

data class IchorPoolCoordinate(val x: Double, val y: Double, val z: Double)
private val poolsToRender = mutableListOf<IchorPoolCoordinate>()

private val incomingIchorRegex = Regex("""^Party > (?:\[[\wዞ]+\+*] )?[\w_]+: Ichor Pool x: (-?\d+\.\d{3}), y: (-?\d+), z: (-?\d+\.\d{3})$""")
Copy link
Owner

Choose a reason for hiding this comment

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

Use a single " when defining all the regexes

) {
private val sendChatMessage by BooleanSetting("Send Message", false, "Sends a message when ichor pool is casted.")
private val showWaypoint by BooleanSetting("Show Waypoint", false,"Sends a waypoint when party ichor pool message is detected.")
private val waypointColor by ColorSetting("Waypoint Color", Color(166, 21, 3), allowAlpha = false, desc = "Color of the ichor pool waypoint.").withDependency { showWaypoint }
Copy link
Owner

Choose a reason for hiding this comment

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

Simply use Colors.MINECRAFT_RED default is allow alpha off so remvoe that

description = "Messages and waypoints for ichor pool casting."
) {
private val sendChatMessage by BooleanSetting("Send Message", false, "Sends a message when ichor pool is casted.")
private val showWaypoint by BooleanSetting("Show Waypoint", false,"Sends a waypoint when party ichor pool message is detected.")
Copy link
Owner

Choose a reason for hiding this comment

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

Add a space between the false, and the description

private val messageSize by NumberSetting("Message Size", 1f, 0.1f, 4f, 0.1f, desc = "Whether or not to display the message size in the box.").withDependency { true }

init {
// Sending Ichor Pool Messages
Copy link
Owner

Choose a reason for hiding this comment

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

Pointless comments

init {
// Sending Ichor Pool Messages
onMessage(outgoingIchorRegex) {
if(!sendChatMessage) return@onMessage
Copy link
Owner

Choose a reason for hiding this comment

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

Invert the if statement and inline the send command function call


// Receiving Ichor Pool Messages
onMessage(incomingIchorRegex) {
val x: Double = it.groups[1]?.value?.toDouble() ?: return@onMessage
Copy link
Owner

Choose a reason for hiding this comment

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

No need to explicitly tell its a double

Comment on lines 43 to 50
val x: Double = it.groups[1]?.value?.toDouble() ?: return@onMessage
val y: Double = it.groups[2]?.value?.toDouble() ?: return@onMessage
val z: Double = it.groups[3]?.value?.toDouble() ?: return@onMessage
poolsToRender.add(IchorPoolCoordinate(x, y, z))

runIn(400, true) {
poolsToRender.removeAt(0)
}
Copy link
Owner

Choose a reason for hiding this comment

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

Implmenet ^

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