Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextgen physics #257

Open
wants to merge 24 commits into
base: next
Choose a base branch
from
Open

Nextgen physics #257

wants to merge 24 commits into from

Conversation

zardoy
Copy link
Owner

@zardoy zardoy commented Jan 29, 2025

PR Type

enhancement, configuration changes


Description

  • Updated mineflayer dependency to use a local file reference.

  • Updated @nxg-org/mineflayer-physics-util dependency to use a local file reference.

  • Adjusted package.json to reflect dependency changes for local development.


Changes walkthrough 📝

Relevant files
Configuration changes
package.json
Updated dependencies to local file references                       

package.json

  • Changed mineflayer dependency to a local file reference.
  • Changed @nxg-org/mineflayer-physics-util dependency to a local file
    reference.
  • Adjusted dependency paths for local development purposes.
  • +2/-2     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features

      • Added a new overlay in the application that displays current library versions.
    • Bug Fixes

      • Disabled the bot’s flight functionality to enhance stability.
    • Chores

      • Streamlined server promotion settings by reducing the number of promoted servers.
      • Locked the default version selection to a specific version.
      • Upgraded core dependencies to ensure improved performance.
      • Updated the source for the mineflayer package to a new repository.
      • Introduced a new method to access the bot's game mode.
      • Enhanced rendering logic to account for player game modes.
      • Added a new optional property for player state to include game mode information.

    Copy link

    codesandbox bot commented Jan 29, 2025

    Review or Edit in CodeSandbox

    Open the branch in Web EditorVS CodeInsiders

    Open Preview

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Dependency Path

    The local file paths for mineflayer and physics-util dependencies may not work in all environments. Ensure the relative paths are correct and the referenced local packages exist.

      "mineflayer": "file:../mineflayer",
      "mineflayer-pathfinder": "^2.4.4",
      "npm-run-all": "^4.1.5",
      "os-browserify": "^0.3.0",
      "path-browserify": "^1.0.1",
      "path-exists-cli": "^2.0.0",
      "prismarine-viewer": "link:prismarine-viewer",
      "process": "github:PrismarineJS/node-process",
      "rimraf": "^5.0.1",
      "storybook": "^7.4.6",
      "stream-browserify": "^3.0.0",
      "three": "0.154.0",
      "timers-browserify": "^2.0.12",
      "typescript": "5.5.4",
      "vitest": "^0.34.6",
      "yaml": "^2.3.2"
    },
    "optionalDependencies": {
      "cypress": "^10.11.0",
      "cypress-plugin-snapshots": "^1.4.4",
      "systeminformation": "^5.21.22"
    },
    "pnpm": {
      "overrides": {
        "buffer": "^6.0.3",
        "@nxg-org/mineflayer-physics-util": "file:../mineflayer-physics-utils",

    Copy link

    qodo-merge-pro-for-open-source bot commented Jan 29, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    ✅ Use versioned dependencies instead of local
    Suggestion Impact:The commit partially implements the suggestion by replacing the local file path dependency with 'latest' version instead of a specific commit hash

    code diff:

    +      "@nxg-org/mineflayer-physics-util": "latest",
           "buffer": "^6.0.3",
    -      "@nxg-org/mineflayer-physics-util": "file:../mineflayer-physics-utils",

    Using local file dependencies without version control can lead to inconsistent
    builds. Consider using git URLs with specific commits/tags instead of local file
    paths.

    package.json [148-173]

    -"mineflayer": "file:../mineflayer",
    -"@nxg-org/mineflayer-physics-util": "file:../mineflayer-physics-utils",
    +"mineflayer": "github:username/mineflayer#commit-hash",
    +"@nxg-org/mineflayer-physics-util": "github:username/mineflayer-physics-utils#commit-hash",
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using local file dependencies can lead to build inconsistencies and makes it harder to track dependency versions. The suggestion to use git URLs with specific commit hashes would improve reproducibility and version control.

    7

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 30, 2025

    /deploy

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 30, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-qozl2zdzp-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 30, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-460fn7r2l-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 30, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-piak1jfqs-zaro.vercel.app
    Playground
    Storybook

    @GenerelSchwerz
    Copy link

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-2ppno71v6-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 30, 2025

    /deploy

    1 similar comment
    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 31, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-qi4vytrgh-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 31, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-qs0cehyun-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 31, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-4vv9z846z-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Jan 31, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-ope8e1sdz-zaro.vercel.app
    Playground
    Storybook

    Copy link

    Deployed to Vercel Preview: https://prismarine-oq991tqot-zaro.vercel.app
    Playground
    Storybook

    Copy link

    Deployed to Vercel Preview: https://prismarine-puaabiyak-zaro.vercel.app
    Playground
    Storybook

    Copy link

    coderabbitai bot commented Feb 27, 2025

    Walkthrough

    This pull request updates several configuration and code files. The config.json now features a simplified server list with one promoted entry, while the package.json adjusts dependency sources and version constraints. Code related to bot flying mechanics in src/controls.ts is streamlined, and the default auto-version option in src/optionsStorage.ts is replaced with a fixed version. A new React component, LibraryVersions, is added and integrated into the UI to display library version information.

    Changes

    File(s) Change Summary
    config.json Modified the promoteServers array by removing several server entries and adding a single entry (grim.mcraft.fun, version 1.19.4) to simplify configuration.
    package.json Updated mineflayer dependency source from zardoy to GenerelSchwerz and changed @nxg-org/mineflayer-physics-util version from 1.5.8 to latest.
    src/controls.ts Streamlined flying mechanics by simplifying the isFlying function and updating flying state management functions.
    src/optionsStorage.ts Changed the default serversAutoVersionSelect value from 'auto' to '1.19.4' within the configuration options.
    src/react/components/LibraryVersions.tsx, src/reactUi.tsx Introduced a new React component LibraryVersions that displays library version info and integrated it into the main App UI.
    renderer/viewer/lib/basePlayerState.ts Added an optional property gameMode to the IPlayerState interface to enhance player state representation.
    renderer/viewer/lib/worldrendererThree.ts Updated rendering logic to prevent rendering blocks when the player is in spectator mode by adding a condition based on playerState.gameMode.
    src/mineflayer/playerState.ts Introduced a new getter method gameMode in the PlayerStateManager class to access the current game mode of the bot.

    Sequence Diagram(s)

    sequenceDiagram
        participant User
        participant App
        participant LibraryVersions
        participant PackageData
    
        User->>App: Load UI
        App->>LibraryVersions: Render component
        LibraryVersions->>PackageData: Import & fetch version info
        PackageData-->>LibraryVersions: Return version data
        LibraryVersions-->>App: Display library versions UI
        App-->>User: Render complete UI
    
    Loading

    Poem

    I'm a rabbit in the code, hopping with cheer,
    Changes prance by, crisp and clear.
    No more skies for bot to fly,
    New versions sparkle as they pass by.
    With servers trimmed so neat,
    I celebrate with a joyful beat!

    Suggested labels

    Review effort 3/5, Review effort 4/5

    ✨ Finishing Touches
    • 📝 Generate Docstrings

    🪧 Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>, please review it.
      • Generate unit testing code for this file.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai generate unit testing code for this file.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
      • @coderabbitai read src/utils.ts and generate unit testing code.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai generate docstrings to generate docstrings for this PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
    • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
    • Add @coderabbitai anywhere in the PR title to generate the title automatically.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    Copy link

    Deployed to Vercel Preview: https://prismarine-2da8gpowz-zaro.vercel.app
    Playground
    Storybook

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 0

    🧹 Nitpick comments (1)
    src/react/components/LibraryVersions.tsx (1)

    8-12: Inconsistent version retrieval approach.

    The component uses different approaches to retrieve version information:

    • physicsUtilPkg.version for physics-util
    • packageJson.devDependencies['mineflayer'] for mineflayer
    • mcProtocolPkg.version for minecraft-protocol

    This inconsistency could lead to confusion when maintaining the code.

    Consider using a consistent approach for all packages:

    const versions = {
      '@nxg-org/mineflayer-physics-util': physicsUtilPkg.version,
    - 'mineflayer': packageJson.devDependencies['mineflayer'],
    + 'mineflayer': mineflayerPkg.version,
      'minecraft-protocol': mcProtocolPkg.version
    }

    Or if using package.json's dependencies is intentional for mineflayer:

    const versions = {
    - '@nxg-org/mineflayer-physics-util': physicsUtilPkg.version,
    + '@nxg-org/mineflayer-physics-util': packageJson.dependencies['@nxg-org/mineflayer-physics-util'] || physicsUtilPkg.version,
      'mineflayer': packageJson.devDependencies['mineflayer'],
    - 'minecraft-protocol': mcProtocolPkg.version
    + 'minecraft-protocol': packageJson.dependencies['minecraft-protocol'] || mcProtocolPkg.version
    }
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between dec93c2 and 34972e4.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (6)
    • config.json (1 hunks)
    • package.json (2 hunks)
    • src/controls.ts (2 hunks)
    • src/optionsStorage.ts (1 hunks)
    • src/react/components/LibraryVersions.tsx (1 hunks)
    • src/reactUi.tsx (2 hunks)
    ✅ Files skipped from review due to trivial changes (1)
    • src/controls.ts
    🔇 Additional comments (8)
    src/reactUi.tsx (2)

    49-49: LGTM: New import for LibraryVersions component.

    The import statement is correctly placed at the end of the imports section.


    197-197: LGTM: Successfully integrated LibraryVersions component.

    The LibraryVersions component is appropriately placed within the App component render tree, making it visible to users.

    config.json (1)

    9-12:

    ❓ Verification inconclusive

    Server configuration simplified.

    The promoted servers list has been reduced to a single server with a specific version (1.19.4), which aligns with the version set in optionsStorage.ts.


    🏁 Script executed:

    #!/bin/bash
    # Check if there are any hardcoded references to the removed servers that might need updating
    rg -i "play.mcraft.fun|play2.mcraft.fun|kaboom.pw" --type ts --type tsx --type json

    Length of output: 113


    Below is a revised verification step. The original search encountered an error because ripgrep didn’t recognize the “tsx” file type. Please re-run the following script—which uses a file glob—to search for leftover references to the removed servers:

    Once you’ve confirmed that this command produces no output (i.e. no unintended server references remain), you can be confident that the configuration change is isolated and consistent.


    Server configuration update: Simplified and aligned with optionsStorage.ts

    File: config.json, Lines: 9–12

    The updated configuration now features a single server:

    {
      "ip": "grim.mcraft.fun",
      "version": "1.19.4"
    }

    This change removes the previous multiple server entries and now aligns the server version with what is specified in optionsStorage.ts. Additionally, please verify that no hardcoded references to the removed servers (play.mcraft.fun, play2.mcraft.fun, or kaboom.pw) exist elsewhere in the codebase by using the revised search command above.


    🏁 Script executed:

    [run_scripts]
    #!/bin/bash
    # Search for any references to removed servers using file globbing for ts, tsx, and json files
    rg -i "play\.mcraft\.fun|play2\.mcraft\.fun|kaboom\.pw" -g "*.{ts,tsx,json}"

    Length of output: 200


    Server configuration update verified—please manually confirm no lingering references remain.

    The updated configuration in config.json (lines 9–12) now contains a single server entry with the IP "grim.mcraft.fun" and version "1.19.4". This aligns with the version configured in optionsStorage.ts.

    A search for the removed servers (play.mcraft.fun, play2.mcraft.fun, and kaboom.pw) using an updated file glob command (targeting *.ts, *.tsx, and *.json files) returned no results. However, because of an encountered error with the initial tagging in the script, please manually verify that there are no unintended hardcoded references elsewhere in the codebase.

    src/react/components/LibraryVersions.tsx (2)

    1-6: LGTM: Clean imports.

    The component properly imports React and version information from various package.json files.


    14-35: LGTM: Well-structured UI component.

    The component is well-structured with appropriate styling. The fixed positioning makes it always visible, which is useful for debugging.

    src/optionsStorage.ts (1)

    60-60:

    ❓ Verification inconclusive

    Temporary version selection change with TODO.

    The change from 'auto' to a hardcoded '1.19.4' version is marked with a comment indicating it should be reverted later. This change aligns with the server configuration in config.json.


    🏁 Script executed:

    #!/bin/bash
    # Check for any references to the auto version selection that might be affected by this change
    rg "serversAutoVersionSelect.*auto" --type ts --type tsx

    Length of output: 86


    Revised Verification Note: Temporary Hardcoded Version Selection

    • In src/optionsStorage.ts (line 60), the property is temporarily set to:
      serversAutoVersionSelect: '1.19.4' as 'auto' | 'latest' | '1.20.4' | string, // TODO! revert
    • This update replaces the 'auto' selection with a hardcoded version to align with the server configuration in config.json. The accompanying TODO reminds us to revert this change later.
    • Note: The original verification command using rg "serversAutoVersionSelect.*auto" --type ts --type tsx produced an error (unrecognized file type: tsx). To properly verify that no references to 'auto' are unintentionally affected, please re-run the search with an updated command that recognizes TypeScript JSX files, for example:
      rg "serversAutoVersionSelect.*auto" --type ts --type-add 'tsx:*.tsx'
    package.json (2)

    150-150: Local Dependency Update for "mineflayer"
    The dependency has been updated to reference github:GenerelSchwerz/mineflayer instead of the previous repository. This aligns with the objective of using local or alternative sources for development. Please verify that the new source is maintained and that any integration points (such as the LibraryVersions component) correctly interpret its version data.


    190-190: Version Constraint Adjustment for "@nxg-org/mineflayer-physics-util"
    The pnpm override has been updated from a fixed version ("1.5.8") to "latest", ensuring that the development environment uses the most recent iteration of the dependency. While this supports local development, please be mindful that using "latest" may introduce unexpected changes if upstream updates include breaking changes. Consider adding safeguards or documentation to ensure compatibility for production builds.

    Copy link

    github-actions bot commented Mar 7, 2025

    Deployed to Vercel Preview: https://prismarine-rbz1esuli-zaro.vercel.app
    Playground
    Storybook

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 1

    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 34972e4 and cefdf53.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (4)
    • config.json (1 hunks)
    • package.json (2 hunks)
    • src/optionsStorage.ts (1 hunks)
    • src/reactUi.tsx (2 hunks)
    🚧 Files skipped from review as they are similar to previous changes (3)
    • src/reactUi.tsx
    • package.json
    • config.json

    @@ -57,7 +57,7 @@ const defaultOptions = {
    viewBobbing: true,
    displayRecordButton: true,
    packetsLoggerPreset: 'all' as 'all' | 'no-buffers',
    serversAutoVersionSelect: 'auto' as 'auto' | 'latest' | '1.20.4' | string,
    serversAutoVersionSelect: '1.19.4' as 'auto' | 'latest' | '1.20.4' | string, // TODO! revert
    Copy link

    Choose a reason for hiding this comment

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

    💡 Verification agent

    🧩 Analysis chain

    Fixed version selection may limit compatibility

    The default for serversAutoVersionSelect has been changed from 'auto' to a fixed version '1.19.4'. While this aligns with the local development dependency changes mentioned in the PR objectives, it restricts users to a specific Minecraft version by default.

    The TODO comment indicates this change should be reverted in the future. Consider:

    1. Adding a more detailed explanation of why this temporary change is needed
    2. Creating a tracking issue for the reversion
    3. Ensuring this change doesn't get lost in future releases

    🏁 Script executed:

    #!/bin/bash
    # Check if this hardcoded version is used consistently across the project
    echo "Checking for '1.19.4' references in the codebase:"
    rg "1\.19\.4" --type ts --type json

    Length of output: 66186


    Action Required: Document and Track Temporary Fixed Version Change

    The hardcoding of '1.19.4' in the serversAutoVersionSelect option (in src/optionsStorage.ts line 60) restricts the dynamic version selection and may limit compatibility. The shell search confirms that '1.19.4' is used consistently across various modules, which suggests this fix is a deliberate, temporary alignment with local development dependency changes. Before shipping this change, please consider the following:

    • Add a Detailed Explanation: Enhance the inline comment to clearly state the rationale behind choosing '1.19.4' as the temporary default.
    • Track for Future Reversion: Create and reference a tracking issue to ensure this temporary change is revisited and, ideally, reverted to allow dynamic version selection (e.g., reverting to 'auto').
    • Impact Verification: Double-check that this change does not inadvertently break or limit compatibility in areas of the codebase that rely on the dynamic behavior.

    Copy link

    github-actions bot commented Mar 9, 2025

    Deployed to Vercel Preview: https://prismarine-12jqpaouw-zaro.vercel.app
    Playground
    Storybook

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 0

    🧹 Nitpick comments (3)
    src/react/components/LibraryVersions.tsx (3)

    2-3: Unused import detected

    The mineflayerPkg is imported on line 3 but never used in the component. Instead, the mineflayer version is retrieved from the local package.json on line 12.

     import React from 'react'
     import physicsUtilPkg from '@nxg-org/mineflayer-physics-util/package.json'
    -import mineflayerPkg from 'mineflayer/package.json'
     import mcProtocolPkg from 'minecraft-protocol/package.json'
     import { useSnapshot } from 'valtio'
     import packageJson from '../../../package.json'
     import { miscUiState } from '../../globalState'

    10-14: Inconsistent version retrieval approach

    The component uses different approaches to retrieve version information:

    • For mineflayer-physics-util and minecraft-protocol, it uses the imported package.json files
    • For mineflayer, it uses the local project's package.json devDependencies

    This inconsistency may be intentional based on the PR objectives (updating dependencies for local development), but it could cause confusion for future maintenance.

    If you want to make the approach more consistent, consider one of these options:

    1. Use imported package.json for all:
     const versions = {
       '@nxg-org/mineflayer-physics-util': physicsUtilPkg.version,
    -  'mineflayer': packageJson.devDependencies['mineflayer'],
    +  'mineflayer': mineflayerPkg.version,
       'minecraft-protocol': mcProtocolPkg.version
     }
    1. Or use package.json devDependencies for all (if all are listed there):
     const versions = {
    -  '@nxg-org/mineflayer-physics-util': physicsUtilPkg.version,
    +  '@nxg-org/mineflayer-physics-util': packageJson.devDependencies['@nxg-org/mineflayer-physics-util'],
       'mineflayer': packageJson.devDependencies['mineflayer'],
    -  'minecraft-protocol': mcProtocolPkg.version
    +  'minecraft-protocol': packageJson.devDependencies['minecraft-protocol']
     }

    22-33: Improve UI readability and responsiveness

    The current styling has some potential usability issues:

    1. The font size of 8px is very small and may be difficult to read
    2. The fixed positioning with hardcoded top value may not work well on all screen sizes
    3. Inline styles make the component harder to maintain

    Consider these improvements:

    1. Increase font size for better readability
    2. Use relative positioning or consider a more responsive approach
    3. Extract styles to a separate CSS file or use styled-components
     <div
       style={{
         pointerEvents: 'none',
         position: 'fixed',
         left: 0,
         top: '300px',
         backgroundColor: 'rgba(0, 0, 0, 0.6)',
         color: 'white',
         padding: '10px',
         borderRadius: '0 5px 5px 0',
    -    fontSize: '8px',
    +    fontSize: '12px',
         zIndex: 1000
       }}
     >
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between cefdf53 and 0597a3d.

    📒 Files selected for processing (1)
    • src/react/components/LibraryVersions.tsx (1 hunks)
    ⏰ Context from checks skipped due to timeout of 90000ms (1)
    • GitHub Check: deploy
    🔇 Additional comments (2)
    src/react/components/LibraryVersions.tsx (2)

    36-40: LGTM - Good mapping implementation

    The component correctly uses Object.entries().map() to iterate over the versions object and properly assigns a unique key for each mapped element, which is a React best practice.


    18-18: LGTM - Good conditional rendering

    Conditionally returning null when gameLoaded is false is an efficient approach to prevent rendering when not needed.

    Copy link

    Deployed to Vercel Preview: https://prismarine-4tta115c8-zaro.vercel.app
    Playground
    Storybook

    Copy link

    Deployed to Vercel Preview: https://prismarine-et3knecrx-zaro.vercel.app
    Playground
    Storybook

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 0

    🔭 Outside diff range comments (1)
    src/mineflayer/playerState.ts (1)

    64-64: ⚠️ Potential issue

    Fix TypeScript error with 'heldItemChanged' event.

    The pipeline failure indicates that 'heldItemChanged' is not assignable to parameter of type 'keyof BotEvents'. This suggests there might be a mismatch between the event name and what's expected by the TypeScript definitions.

    Consider using a properly typed event or adding a type assertion if you're certain the event exists:

    -bot.on('heldItemChanged', () => {
    +bot.on('heldItemChanged' as keyof BotEvents, () => {

    Alternatively, you might need to check if there's a different event name that should be used instead.

    🧰 Tools
    🪛 GitHub Check: build-and-deploy

    [failure] 64-64:
    Argument of type '"heldItemChanged"' is not assignable to parameter of type 'keyof BotEvents'.

    🪛 GitHub Actions: CI

    [error] 64-64: error TS2345: Argument of type '"heldItemChanged"' is not assignable to parameter of type 'keyof BotEvents'.

    🧹 Nitpick comments (1)
    src/mineflayer/playerState.ts (1)

    32-34: Add null check for bot.game when retrieving gameMode.

    The current implementation might cause runtime errors if bot.game is undefined.

    get gameMode () {
    -  return bot.game?.gameMode
    +  return bot.game?.gameMode ?? undefined
    }
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 3a9e2aa and 847314d.

    📒 Files selected for processing (4)
    • renderer/viewer/lib/basePlayerState.ts (1 hunks)
    • renderer/viewer/lib/worldrendererThree.ts (1 hunks)
    • src/controls.ts (1 hunks)
    • src/mineflayer/playerState.ts (1 hunks)
    🧰 Additional context used
    🪛 GitHub Actions: CI
    src/mineflayer/playerState.ts

    [error] 64-64: error TS2345: Argument of type '"heldItemChanged"' is not assignable to parameter of type 'keyof BotEvents'.

    🔇 Additional comments (8)
    renderer/viewer/lib/basePlayerState.ts (1)

    27-27: Nice addition of gameMode property to the IPlayerState interface.

    This addition allows the interface to represent the player's state in different game modes, enhancing the flexibility of the player state system throughout the application.

    renderer/viewer/lib/worldrendererThree.ts (1)

    244-244: Good check for spectator mode before rendering hand items.

    Adding the condition to check if this.playerState.gameMode !== 'spectator' ensures that hand items aren't rendered in spectator mode, which aligns with Minecraft's behavior.

    src/controls.ts (6)

    709-709: Simplified flying state check.

    This is a good simplification, directly checking the flying property on the bot entity rather than using a more complex approach.


    716-717: Direct assignment to the flying property.

    The change directly sets the flying property on the bot entity, which simplifies the implementation.


    720-721: Good early return when already not flying.

    Adding an early return if the bot is not already flying prevents unnecessary processing.


    726-727: Direct disabling of flying state.

    Similar to the start flying implementation, this directly modifies the flying state property.


    734-734: Check if bot can fly before attempting to toggle flying.

    This is an important check that prevents attempts to fly when it's not allowed for the entity.


    730-732: Simplified onBotCreate function.

    The function has been simplified, removing previous flying-related logic which is now handled directly through properties.

    Copy link

    Deployed to Vercel Preview: https://prismarine-d5bulm7zq-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Mar 15, 2025

    /deploy

    Copy link

    Deployed to Vercel Preview: https://prismarine-dqoiv9ipz-zaro.vercel.app
    Playground
    Storybook

    Copy link

    Deployed to Vercel Preview: https://prismarine-endm4ucqg-zaro.vercel.app
    Playground
    Storybook

    Copy link

    Deployed to Vercel Preview: https://prismarine-l9fj2bitt-zaro.vercel.app
    Playground
    Storybook

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

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

    Actionable comments posted: 0

    🧹 Nitpick comments (3)
    src/controls.ts (3)

    718-718: Clean flying state check improvement.

    The flying state check has been simplified to directly access the flying property on the bot entity. This is more direct and cleaner than the previous implementation.

    Consider creating a proper type definition for the extended entity properties instead of using as any:

    -const isFlying = () => (bot.entity as any).flying
    +interface ExtendedEntity extends Entity {
    +  flying: boolean;
    +  canFly: boolean;
    +}
    +const isFlying = () => (bot.entity as ExtendedEntity).flying

    726-727: Simplified flying activation.

    The implementation now directly sets the flying property on the bot entity, which aligns with the local development version of mineflayer.

    Consider using the same type definition suggested earlier to avoid as any:

    -  (bot.entity as any).flying = true
    +  (bot.entity as ExtendedEntity).flying = true

    736-737: Consistent flying property manipulation.

    The implementation consistently sets the flying property directly, aligning with the approach used in startFlying.

    Use the same type definition as suggested earlier for consistency:

    -  (bot.entity as any).flying = false
    +  (bot.entity as ExtendedEntity).flying = false
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between f230763 and e851f4f.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (3)
    • package.json (3 hunks)
    • src/controls.ts (1 hunks)
    • src/reactUi.tsx (2 hunks)
    🚧 Files skipped from review as they are similar to previous changes (2)
    • src/reactUi.tsx
    • package.json
    🔇 Additional comments (2)
    src/controls.ts (2)

    730-731: Good defensive programming with early return.

    Adding the check to prevent unnecessary operations when the entity is not flying is a good defensive programming practice that improves efficiency.


    743-743:

    ❓ Verification inconclusive

    Improved flying capability check.

    The code now checks if the entity can fly before attempting to toggle flying state, which is a more robust approach that aligns with the properties available in the local mineflayer version.

    Verify that canFly is always set properly across different game modes by adding a debug log when transitioning between game modes:


    🏁 Script executed:

    #!/bin/bash
    # Search for game mode changes to check if canFly is properly handled
    rg -A 5 "gameMode|canFly" src/

    Length of output: 16544


    Improved Flying Capability Check – Please Add Debug Logging

    The updated check using

    if (!bot.entity.canFly) return

    correctly prevents toggling flying state when the entity cannot fly. This aligns with the local mineflayer version. However, the grep output did not reveal any debug statements during game mode transitions. To ensure that canFly is reliably updated across different game modes, please add a debug log in the game mode transition handler (for example, in src/controls.ts) that prints the current game mode and the state of bot.entity.canFly. This will help verify that the property is set appropriately when game modes change.

    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