Skip to content

Conversation

Phoenix616
Copy link

@Phoenix616 Phoenix616 commented Jul 16, 2025

This fixes rendering issues with throwable projectiles. Previously they used the wrong textures and didn't properly always face the camera.

In order for movement to properly work this needs zardoy/mineflayer#6

Summary by CodeRabbit

  • New Features

    • Added support for rendering projectile entities (such as snowballs, eggs, ender pearls, experience bottles, splash potions, and lingering potions) as sprites that face the camera.
  • Improvements

    • Enhanced entity rendering logic to better distinguish between item and projectile types, adjusting their appearance and positioning accordingly.

Copy link

coderabbitai bot commented Jul 16, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a faceCamera parameter to the getItemMesh method, allowing certain entities (notably projectiles) to be rendered as camera-facing sprites instead of meshes. The update logic now handles additional projectile entities, and method signatures and related calls were updated to accommodate the new parameter.

Changes

File(s) Change Summary
renderer/viewer/three/entities.ts Added faceCamera parameter to getItemMesh; updated entity update logic for projectiles; extended supported entities; adjusted mesh creation and positioning.
renderer/viewer/three/holdingBlock.ts Updated call to getItemMesh to include explicit faceCamera argument.

Sequence Diagram(s)

sequenceDiagram
    participant GameLoop
    participant Entities
    participant THREE
    participant Viewer

    GameLoop->>Entities: update(entity, overrides)
    Entities->>Entities: Check entity type
    alt Entity is projectile
        Entities->>Entities: getItemMesh(item, props, faceCamera=true)
        Entities->>THREE: Create Sprite with item texture
    else Entity is item
        Entities->>Entities: getItemMesh(item, props, faceCamera=false)
        Entities->>THREE: Create Mesh with box geometry
    end
    Entities->>Viewer: Add mesh to scene
Loading

Suggested labels

Review effort 1/5

Poem

A hop and a skip, a sprite in the air,
Projectiles now face you with camera-aware flair!
Items still spin, but snowballs now gaze,
With meshes and sprites in a rendering daze.
The code’s been adjusted, the world’s more alive—
Three cheers for the update, and onward we strive!
🥕✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@zardoy
Copy link
Owner

zardoy commented Jul 16, 2025

Good!

@zardoy
Copy link
Owner

zardoy commented Jul 16, 2025

/deploy

Copy link

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

@zardoy
Copy link
Owner

zardoy commented Jul 17, 2025

/deploy

Copy link

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

@zardoy
Copy link
Owner

zardoy commented Jul 17, 2025

yes, this is very easy to see on egg projectile. Something that I thought never would be done, thanks! This is a really good improvement.
Though, sadly arrow model is still broken (not sure why), and it has incorrect rotation when landed (just an observation)

@Phoenix616
Copy link
Author

Yeah, arrows work completely differently as their movement and rotation actually gets updated by the server. I assume this is just a case of their model having the wrong rotation but I didn't look into this.

@zardoy
Copy link
Owner

zardoy commented Jul 17, 2025

Is it ready to merge, or is future work planned here?

@Phoenix616
Copy link
Author

Is it ready to merge, or is future work planned here?

Yes, it's ready. We don't have anything mor planned for now.

@zardoy zardoy changed the title feat: Item projectiles support feat: render Item projectiles correctly Jul 18, 2025
@zardoy zardoy merged commit 4d7e3df into zardoy:next Jul 18, 2025
3 checks passed
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