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 69 commits into
base: next
Choose a base branch
from
Open

Nextgen physics #257

wants to merge 69 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

    • Chores
      • Updated server promotions for enhanced configuration clarity.
      • Modified dependency configurations to improve version management.
    • Refactor
      • Streamlined in-game flight controls for a smoother experience.
    • New Features
      • Introduced a new on-screen widget displaying library version information.
      • Enhanced styling for better appearance on Firefox and iPhone devices.

    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-mbai3hxol-zaro.vercel.app
    Playground
    Storybook

    @zardoy
    Copy link
    Owner Author

    zardoy commented Mar 23, 2025

    /deploy

    Copy link

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

    Copy link

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

    Copy link

    Deployed to Vercel Preview: https://prismarine-1a7r7sci8-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 e2b7833 and 9057d3a.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (2)
    • package.json (3 hunks)
    • src/mineflayer/cameraShake.ts (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (1)
    • package.json
    🧰 Additional context used
    🧬 Code Definitions (1)
    src/mineflayer/cameraShake.ts (1)
    src/customChannels.ts (1)
    • customEvents (6-18)
    🪛 GitHub Check: build-and-deploy
    src/mineflayer/cameraShake.ts

    [failure] 4-4:
    Cannot find name 'cameraShake'.

    🪛 GitHub Actions: CI
    src/mineflayer/cameraShake.ts

    [error] 4-4: error TS2304: Cannot find name 'cameraShake'.

    🔇 Additional comments (1)
    src/mineflayer/cameraShake.ts (1)

    3-10: Potential duplicate event listeners for 'hurtAnimation'.

    There are now two event listeners for the 'hurtAnimation' event - one at the top level (lines 3-5) and another within the 'mineflayerBotCreated' event (lines 7-10). This might cause the camera shake effect to be triggered twice for a single damage event.

    If this is intentional, please add a comment explaining why both listeners are needed. Otherwise, consider unifying the implementations to avoid duplicated behavior.

    🧰 Tools
    🪛 GitHub Check: build-and-deploy

    [failure] 4-4:
    Cannot find name 'cameraShake'.

    🪛 GitHub Actions: CI

    [error] 4-4: error TS2304: Cannot find name 'cameraShake'.

    Comment on lines 3 to 5
    customEvents.on('hurtAnimation', () => {
    cameraShake.shakeFromDamage()
    })
    Copy link

    Choose a reason for hiding this comment

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

    ⚠️ Potential issue

    Missing cameraShake definition causes build failure.

    The static analysis and pipeline logs indicate a critical error: 'cameraShake' is not defined. This variable needs to be imported or defined before use.

    To fix this issue, you need to either:

    1. Import cameraShake from its module:
    import { getThreeJsRendererMethods } from 'renderer/viewer/three/threeJsMethods'
    +import { cameraShake } from './path/to/cameraShake'
    
    customEvents.on('hurtAnimation', () => {
    1. Or if cameraShake is meant to be the same as what's used in the nested listener, use the ThreeJS renderer methods instead:
    customEvents.on('hurtAnimation', () => {
    -  cameraShake.shakeFromDamage()
    +  getThreeJsRendererMethods()?.shakeFromDamage()
    })
    📝 Committable suggestion

    ‼️ IMPORTANT
    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    Suggested change
    customEvents.on('hurtAnimation', () => {
    cameraShake.shakeFromDamage()
    })
    import { getThreeJsRendererMethods } from 'renderer/viewer/three/threeJsMethods'
    import { cameraShake } from './path/to/cameraShake'
    customEvents.on('hurtAnimation', () => {
    cameraShake.shakeFromDamage()
    })
    Suggested change
    customEvents.on('hurtAnimation', () => {
    cameraShake.shakeFromDamage()
    })
    customEvents.on('hurtAnimation', () => {
    getThreeJsRendererMethods()?.shakeFromDamage()
    })
    🧰 Tools
    🪛 GitHub Check: build-and-deploy

    [failure] 4-4:
    Cannot find name 'cameraShake'.

    🪛 GitHub Actions: CI

    [error] 4-4: error TS2304: Cannot find name 'cameraShake'.

    @GenerelSchwerz
    Copy link

    /deploy

    Copy link

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

    Copy link

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

    Copy link

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

    Copy link

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

    Copy link

    Deployed to Vercel Preview: https://prismarine-l5fp3qujx-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 (6)
    src/react/components/LibraryVersions.tsx (6)

    2-6: Consider handling potential import failures.

    The component directly imports package.json files from dependencies. If any of these packages are missing or have a different structure than expected, it could lead to runtime errors. Consider adding error handling or fallback values.


    10-14: Inconsistent version sourcing strategy.

    While @nxg-org/mineflayer-physics-util and minecraft-protocol versions are pulled directly from their package.json files, mineflayer version is pulled from the project's package.json devDependencies. This inconsistency might cause confusion or maintenance issues.

    - 'mineflayer': packageJson.devDependencies['mineflayer'],
    + 'mineflayer': mineflayerPkg.version,

    Or if the current approach is intentional (based on the PR objective of referencing local files), consider adding a comment explaining the difference.


    16-18: Remove or uncomment conditional rendering code.

    There's commented out code related to conditional rendering based on gameLoaded state. Either remove unused code or uncomment it if it's necessary for the component's functionality.


    5-7: Remove unused imports.

    The useSnapshot hook is imported but not used since the related code is commented out. Remove unused imports to avoid unnecessary bundle size.

    -import { useSnapshot } from 'valtio'
    -import { miscUiState } from '../../globalState'

    22-33: Improve accessibility of the component.

    The component has some potential accessibility issues:

    1. pointerEvents: 'none' makes it non-interactive
    2. fontSize: '8px' is extremely small and may be difficult to read
    3. The fixed positioning might overlap with other UI elements on smaller screens

    Consider making these styles configurable or increasing the font size for better readability.


    36-40: Add fallback for potentially undefined versions.

    The component doesn't handle the case where a version value might be undefined. Add a fallback to ensure the UI doesn't break in unexpected scenarios.

    {Object.entries(versions).map(([lib, version]) => (
      <div key={lib} style={{ marginTop: '5px' }}>
    -    {lib}: {version}
    +    {lib}: {version || 'unknown'}
      </div>
    ))}
    📜 Review details

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

    📥 Commits

    Reviewing files that changed from the base of the PR and between 9057d3a and 07e7c6f.

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

    Copy link

    Deployed to Vercel Preview: https://prismarine-hk01mk9js-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/controls.ts (1)

    724-724: Direct property assignment for flying state.

    Setting the flying property directly simplifies the code by removing complex flying vector management that was previously implemented.

    Consider adding a type definition for the bot entity that includes the flying property instead of using as any to improve type safety.

    📜 Review details

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

    📥 Commits

    Reviewing files that changed from the base of the PR and between 07e7c6f and 0839889.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (2)
    • package.json (4 hunks)
    • src/controls.ts (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (1)
    • package.json
    🧰 Additional context used
    🧬 Code Definitions (1)
    src/controls.ts (3)
    renderer/viewer/lib/basePlayerState.ts (1)
    • isFlying (80-82)
    src/mineflayer/playerState.ts (1)
    • isFlying (132-134)
    src/mineflayer/plugins/mouse.ts (1)
    • bot (31-38)
    🔇 Additional comments (4)
    src/controls.ts (4)

    716-716: Improved flying check for simplicity.

    The function now directly checks the flying property of the bot's entity instead of using a more complex gravity-based check, making the code more straightforward.


    728-728: Good defensive programming check.

    Adding this guard clause prevents unnecessary calls to end flying when the entity is not currently flying.


    734-734: Consistent with the start flying implementation.

    This matches the approach used in startFlying, maintaining consistency in how flying state is managed.


    741-741:

    ✅ Verification successful

    Simplified fly toggle condition.

    The condition now directly checks the canFly property instead of complex game mode checks, which aligns with the overall simplification of the flying mechanics.


    🏁 Script executed:

    #!/bin/bash
    # Check if canFly property is consistently used across the codebase
    rg -A 2 -B 2 "canFly" --type typescript

    Length of output: 74


    Below is a new verification script to search for all occurrences of “canFly” in the repository’s TypeScript files. This will allow you to manually verify that the simplified condition at src/controls.ts:741 is consistently used across the codebase:

    Simplified Fly Toggle Verification

    • The condition at src/controls.ts:741 now directly checks bot.entity.canFly, reflecting the simplified logic without extra game mode checks.
    • Please run the above script and manually review its output to verify that similar simplifications using canFly are consistently applied elsewhere in the codebase.

    Once you’ve confirmed the output is as expected, you can approve this simplified change.


    🏁 Script executed:

    #!/bin/bash
    # Re-run search for occurrences of "canFly" in TypeScript files.
    rg -A 2 -B 2 "canFly" -g "*.ts"

    Length of output: 359


    Simplified fly toggle condition verified

    The condition in src/controls.ts:741 now directly checks bot.entity.canFly, and the search confirms that this pattern is consistently applied. No further changes are necessary; please proceed with the simplified implementation.

    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