Skip to content

Conversation

Kesuaheli
Copy link

@Kesuaheli Kesuaheli commented Sep 4, 2025

When a player head has a data.profile.properties rather than data.SkullOwner.Properties data structure, it weren't rendered with its skin texture.

This fixes it by implementing a check wheather SkullOwner exists. This was also done in a similar way here:

let textureData
if (itemNbt.SkullOwner) {
textureData = itemNbt.SkullOwner.Properties.textures[0]?.Value
} else {
textureData = itemNbt['minecraft:profile']?.Properties?.find(p => p.name === 'textures')?.value
}

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of player head/skin rendering by supporting multiple texture sources in player profiles.
    • Added safe handling for missing or invalid texture data to prevent blank heads or crashes.
    • Fixed proxy rewriting to correctly handle both HTTP and HTTPS skin URLs, reducing failed texture downloads.
    • Enhanced error handling during head mesh creation for more stable rendering with varied profile formats.

Copy link

coderabbitai bot commented Sep 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The head rendering now reads base64 texture data from either SkullOwner.Properties.textures[0].Value or a profile.properties fallback, decodes it, extracts decodedData.textures.SKIN.url, rewrites http/https via skinTexturesProxy, and early-returns if texture data is missing; mesh construction and error logging remain.

Changes

Cohort / File(s) Change Summary
Head texture sourcing and proxying
renderer/viewer/three/worldrendererThree.ts
Added fallback to profile.properties when SkullOwner.Properties.textures is absent; introduced textureData with early return if missing; decode base64 from textureData; extract decodedData.textures.SKIN.url; apply skinTexturesProxy to both http/https variants; preserved mesh construction and logging.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant R as WorldRendererThree
  participant D as Skull/Profile Data
  participant B as Base64 Decoder
  participant P as Proxy Rewriter
  participant T as Texture Loader

  R->>D: Read SkullOwner.Properties.textures[0].Value
  alt SkullOwner textures present
    D-->>R: base64 textureData
  else Fallback to profile.properties
    R->>D: Find property name === "textures"
    D-->>R: base64 textureData (fallback)
  end

  alt textureData missing
    R-->>R: Early return (no head texture)
  else
    R->>B: Decode Buffer.from(textureData, 'base64')
    B-->>R: decodedData (JSON)
    R->>R: Extract decodedData.textures.SKIN.url
    R->>P: Rewrite URL via skinTexturesProxy (http/https)
    P-->>R: Proxied URL
    R->>T: Load texture and build head mesh
    T-->>R: Mesh/Texture applied
  end

  note over R: Errors are caught and logged
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I nibble bytes and hop with glee,
Two texture paths discovered by me.
Base64 blossoms, skins rewired,
HTTP and HTTPS admired.
A tiny rabbit cheers the view—head pops true! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 70534d8 and 528d8f5.

📒 Files selected for processing (1)
  • renderer/viewer/three/worldrendererThree.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
renderer/viewer/three/worldrendererThree.ts (1)

779-785: Guard against missing skinUrl and fix replace chaining (can crash on undefined).

When decodedData.textures?.SKIN?.url is absent, skinUrl?.replace(...).replace(...) evaluates the second .replace on undefined. Add an early return and drop optional chaining in replacements.

-      let skinUrl = decodedData.textures?.SKIN?.url
-      const { skinTexturesProxy } = this.worldRendererConfig
-      if (skinTexturesProxy) {
-        skinUrl = skinUrl?.replace('http://textures.minecraft.net/', skinTexturesProxy)
-          .replace('https://textures.minecraft.net/', skinTexturesProxy)
-      }
+      let skinUrl = decodedData.textures?.SKIN?.url
+      if (!skinUrl) return
+      const { skinTexturesProxy } = this.worldRendererConfig
+      if (skinTexturesProxy) {
+        skinUrl = skinUrl
+          .replace('http://textures.minecraft.net/', skinTexturesProxy)
+          .replace('https://textures.minecraft.net/', skinTexturesProxy)
+      }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9d54c70 and 70534d8.

📒 Files selected for processing (1)
  • renderer/viewer/three/worldrendererThree.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
renderer/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/vars-usage.mdc)

renderer/**/*.ts: Do not use the global variable bot directly in any file under the renderer/ directory or its subfolders (e.g., renderer/viewer/three/worldrendererThree.ts).
In renderer code, all bot/player state and events must be accessed via explicit interfaces, state managers, or passed-in objects, never by referencing bot directly.
In renderer code (such as in WorldRendererThree), use the playerState property (e.g., worldRenderer.playerState.gameMode) to access player state. The implementation for playerState lives in src/mineflayer/playerState.ts.

Files:

  • renderer/viewer/three/worldrendererThree.ts
🧠 Learnings (2)
📚 Learning: 2025-06-23T13:33:14.776Z
Learnt from: zardoy
PR: zardoy/minecraft-web-client#373
File: renderer/viewer/three/entities.ts:1120-1120
Timestamp: 2025-06-23T13:33:14.776Z
Learning: In the minecraft-web-client project, files under renderer/ directory must not access the global `bot` variable directly according to .cursor/rules/vars-usage.mdc. The updateNameTagVisibility method in renderer/viewer/three/entities.ts currently violates this rule by accessing bot.teamMap and bot.username. Team information should be passed through entity update events from the world data emitter instead.

Applied to files:

  • renderer/viewer/three/worldrendererThree.ts
📚 Learning: 2025-07-27T13:24:58.186Z
Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-27T13:24:58.186Z
Learning: Applies to renderer/**/*.ts : In renderer code (such as in `WorldRendererThree`), use the `playerState` property (e.g., `worldRenderer.playerState.gameMode`) to access player state. The implementation for `playerState` lives in `src/mineflayer/playerState.ts`.

Applied to files:

  • renderer/viewer/three/worldrendererThree.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-deploy

@zardoy zardoy merged commit 7043bf4 into zardoy:next Sep 4, 2025
2 of 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