-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: next
Are you sure you want to change the base?
Nextgen physics #257
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
/deploy |
/deploy |
Deployed to Vercel Preview: https://prismarine-qozl2zdzp-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-460fn7r2l-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-piak1jfqs-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-2ppno71v6-zaro.vercel.app |
/deploy |
1 similar comment
/deploy |
Deployed to Vercel Preview: https://prismarine-qi4vytrgh-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-qs0cehyun-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-4vv9z846z-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-ope8e1sdz-zaro.vercel.app |
Deployed to Vercel Preview: https://prismarine-oq991tqot-zaro.vercel.app |
Deployed to Vercel Preview: https://prismarine-puaabiyak-zaro.vercel.app |
WalkthroughThis pull request updates several configuration and code files. The Changes
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
Poem
Suggested labels
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deployed to Vercel Preview: https://prismarine-2da8gpowz-zaro.vercel.app |
There was a problem hiding this 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-utilpackageJson.devDependencies['mineflayer']
for mineflayermcProtocolPkg.version
for minecraft-protocolThis 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
⛔ 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 jsonLength 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–12The 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
, orkaboom.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 inoptionsStorage.ts
.A search for the removed servers (
play.mcraft.fun
,play2.mcraft.fun
, andkaboom.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 tsxLength 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 referencegithub: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.
Deployed to Vercel Preview: https://prismarine-rbz1esuli-zaro.vercel.app |
There was a problem hiding this 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
⛔ 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 |
There was a problem hiding this comment.
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:
- Adding a more detailed explanation of why this temporary change is needed
- Creating a tracking issue for the reversion
- 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.
Deployed to Vercel Preview: https://prismarine-12jqpaouw-zaro.vercel.app |
There was a problem hiding this 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 detectedThe
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 approachThe component uses different approaches to retrieve version information:
- For
mineflayer-physics-util
andminecraft-protocol
, it uses the imported package.json files- For
mineflayer
, it uses the local project's package.json devDependenciesThis 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:
- 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 }
- 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 responsivenessThe current styling has some potential usability issues:
- The font size of 8px is very small and may be difficult to read
- The fixed positioning with hardcoded top value may not work well on all screen sizes
- Inline styles make the component harder to maintain
Consider these improvements:
- Increase font size for better readability
- Use relative positioning or consider a more responsive approach
- 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
📒 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 implementationThe 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 renderingConditionally returning null when gameLoaded is false is an efficient approach to prevent rendering when not needed.
Deployed to Vercel Preview: https://prismarine-4tta115c8-zaro.vercel.app |
Deployed to Vercel Preview: https://prismarine-et3knecrx-zaro.vercel.app |
There was a problem hiding this 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 issueFix 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
📒 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.
Deployed to Vercel Preview: https://prismarine-d5bulm7zq-zaro.vercel.app |
/deploy |
Deployed to Vercel Preview: https://prismarine-dqoiv9ipz-zaro.vercel.app |
Deployed to Vercel Preview: https://prismarine-endm4ucqg-zaro.vercel.app |
Deployed to Vercel Preview: https://prismarine-l9fj2bitt-zaro.vercel.app |
There was a problem hiding this 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
⛔ 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) returncorrectly 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, insrc/controls.ts
) that prints the current game mode and the state ofbot.entity.canFly
. This will help verify that the property is set appropriately when game modes change.
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 📝
package.json
Updated dependencies to local file references
package.json
mineflayer
dependency to a local file reference.@nxg-org/mineflayer-physics-util
dependency to a local filereference.
Summary by CodeRabbit
New Features
Bug Fixes
Chores
mineflayer
package to a new repository.