Skip to content

Conversation

@kirushkinx
Copy link

@kirushkinx kirushkinx commented Jan 19, 2026

Summary by CodeRabbit

  • New Features

    • Added support for enhanced player appearance customization in version 1.21.10 and later.
  • Improvements

    • Improved compatibility across server versions with expanded player metadata handling while maintaining backward compatibility with older versions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This change introduces per-version metadata indexing for the PlayerMeta class, expanding the metadata offset range and adding version-aware logic. New metadata index constants are introduced, and getters/setters for various player attributes now include conditional checks to use appropriate indices based on server version (>= 1.21.10 vs. older versions).

Changes

Cohort / File(s) Summary
Player Metadata Version-Aware Indexing
api/src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java
Expanded MAX_OFFSET from OFFSET+1 to OFFSET+6. Added private index constants for avatar main hand, avatar skin layers, hearts, score, and left/right shoulder data. Modified getters/setters for hearts, score, cape/jacket/sleeve/leg/hat flags, and shoulder data with version-conditional logic (>= 1.21.10). Server-version based routing for right-hand main via early return in older versions.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hops through versions with glee,
Metadata indices, one, two, three!
From 1.21 to times of old,
New shoulders and hearts, a story retold,
Per-version logic keeps compatibility sound,
Where backward paths and new ways are found! 🎪

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding version support for PlayerMeta in Minecraft version 1.21.10+, which aligns with the core modification of introducing per-version metadata indexing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 2

🤖 Fix all issues with AI agents
In `@api/src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java`:
- Around line 214-221: The setter setLeftShoulderData is missing the same
version guard used by getLeftShoulderData; add an early check using
isVersionNewer(ServerVersion.V_1_11) at the top of setLeftShoulderData and skip
(return) when the server version is older than V_1_11 so metadata isn't written
on unsupported versions, keeping the existing logic that chooses between
PLAYER_LEFT_SHOULDER_INDEX and offset(OFFSET,4) intact.
- Around line 231-238: The setter setRightShoulderData is missing the same
version guard used in the getter; update setRightShoulderData to check
isVersionNewer(ServerVersion.V_1_11) (like setLeftShoulderData does) and only
use PLAYER_RIGHT_SHOULDER_INDEX when that check passes, otherwise fall back to
using offset(OFFSET, 5) as before; keep the NBTCompound defaulting logic and the
super.metadata.setIndex(EntityDataTypes.NBT, value) calls intact.

Comment on lines 214 to 221
public void setLeftShoulderData(@Nullable NBTCompound value) {
if (value == null) value = new NBTCompound();
super.metadata.setIndex(offset(OFFSET,4), EntityDataTypes.NBT, value);
if (isVersion(ServerVersion.V_1_21_10, VersionComparison.NEWER_THAN_OR_EQUALS)) {
super.metadata.setIndex(PLAYER_LEFT_SHOULDER_INDEX, EntityDataTypes.NBT, value);
} else {
super.metadata.setIndex(offset(OFFSET,4), EntityDataTypes.NBT, value);
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing version check in setter.

The getter getLeftShoulderData() has isVersionNewer(ServerVersion.V_1_11) at line 207, but the setter is missing this guard. This could cause invalid metadata to be set on servers older than V_1_11.

Proposed fix
 public void setLeftShoulderData(`@Nullable` NBTCompound value) {
+    isVersionNewer(ServerVersion.V_1_11);
     if (value == null) value = new NBTCompound();
     if (isVersion(ServerVersion.V_1_21_10, VersionComparison.NEWER_THAN_OR_EQUALS)) {
🤖 Prompt for AI Agents
In `@api/src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java` around lines
214 - 221, The setter setLeftShoulderData is missing the same version guard used
by getLeftShoulderData; add an early check using
isVersionNewer(ServerVersion.V_1_11) at the top of setLeftShoulderData and skip
(return) when the server version is older than V_1_11 so metadata isn't written
on unsupported versions, keeping the existing logic that chooses between
PLAYER_LEFT_SHOULDER_INDEX and offset(OFFSET,4) intact.

Comment on lines 231 to 238
public void setRightShoulderData(@Nullable NBTCompound value) {
if (value == null) value = new NBTCompound();
super.metadata.setIndex(offset(OFFSET,5), EntityDataTypes.NBT, value);
if (isVersion(ServerVersion.V_1_21_10, VersionComparison.NEWER_THAN_OR_EQUALS)) {
super.metadata.setIndex(PLAYER_RIGHT_SHOULDER_INDEX, EntityDataTypes.NBT, value);
} else {
super.metadata.setIndex(offset(OFFSET,5), EntityDataTypes.NBT, value);
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing version check in setter.

Same issue as setLeftShoulderData — the getter at line 224 has isVersionNewer(ServerVersion.V_1_11), but the setter is missing this guard.

Proposed fix
 public void setRightShoulderData(`@Nullable` NBTCompound value) {
+    isVersionNewer(ServerVersion.V_1_11);
     if (value == null) value = new NBTCompound();
     if (isVersion(ServerVersion.V_1_21_10, VersionComparison.NEWER_THAN_OR_EQUALS)) {
🤖 Prompt for AI Agents
In `@api/src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java` around lines
231 - 238, The setter setRightShoulderData is missing the same version guard
used in the getter; update setRightShoulderData to check
isVersionNewer(ServerVersion.V_1_11) (like setLeftShoulderData does) and only
use PLAYER_RIGHT_SHOULDER_INDEX when that check passes, otherwise fall back to
using offset(OFFSET, 5) as before; keep the NBTCompound defaulting logic and the
super.metadata.setIndex(EntityDataTypes.NBT, value) calls intact.

@Bram1903
Copy link
Collaborator

Have you tested these changes?

@kirushkinx
Copy link
Author

Yes, it actually works on 1.21.8-1.21.11

@Bram1903
Copy link
Collaborator

I discussed this PR with Tofaa in DMs, and it looks like we primarily target the latest protocol specification. Given that, it might make more sense to properly implement the new Avatar entity within the Player entity rather than skipping its offset.

Could you take a look at #48 and share your thoughts?

@kirushkinx
Copy link
Author

Okay, it looks good. I think this would be a better solution

@Bram1903
Copy link
Collaborator

Closing in favor of #48. Thanks for your help nonetheless! Forced me to actually look into it besides other work I have :-)

@Bram1903 Bram1903 closed this Jan 20, 2026
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