Skip to content

Fix attribute_modifiers structure in protocol.json for 1.21.5-1.21.11#1155

Open
reallyoldfogie wants to merge 2 commits intoPrismarineJS:masterfrom
reallyoldfogie:fix_attribute_modifiers_1.21.5-1.21.11
Open

Fix attribute_modifiers structure in protocol.json for 1.21.5-1.21.11#1155
reallyoldfogie wants to merge 2 commits intoPrismarineJS:masterfrom
reallyoldfogie:fix_attribute_modifiers_1.21.5-1.21.11

Conversation

@reallyoldfogie
Copy link
Copy Markdown

@reallyoldfogie reallyoldfogie commented Mar 7, 2026

The attribute_modifiers component was incorrectly structured as a container with "attributes" and "display" as sibling top-level fields. Based on an analysis of AttributeModifiersComponent in the affected versions, the correct structure is an array of entries where each entry contains typeId, name, value, operation, slot, and display fields inline (except 1.21.5, which doesn't have a display).

Affected versions: 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11

The attribute_modifiers component was incorrectly structured as a
container with "attributes" and "display" as sibling top-level fields.
Based on an analysis of AttributeModifiersComponent in the affected versions,
the correct structure is an array of entries where each entry contains
typeId, name, value, operation, slot, and display fields inline (except 1.21.5, where display remains at the outer level).

Affected versions: 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11
The attribute_modifiers component was incorrectly structured as a
container with "attributes" and "display" as sibling top-level fields.
Based on an analysis of AttributeModifiersComponent in the affected versions,
the correct structure is an array of entries where each entry contains
typeId, name, value, operation, slot, and display fields inline (except 1.21.5, where display remains at the outer level).

Affected versions: 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11
@reallyoldfogie reallyoldfogie reopened this Mar 7, 2026
Comment thread data/pc/1.21.5/proto.yml
- armor
- body
- saddle
showTooltip: bool
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Erroneously removed?

@extremeheat
Copy link
Copy Markdown
Member

Are you sure this is necessary? Seems to me you are only unwrapping a field which should not affect serialization/deserialization beyond an extra container. There are changes between versions also, see comment

@reallyoldfogie
Copy link
Copy Markdown
Author

@extremeheat

This PR fixes two serialization errors in attribute_modifiers that cause incorrect parsing of the wire format. These are not cosmetic container-unwrapping changes — they change the byte layout that parsers must follow.


Issue 1: showInTooltip removed in 1.21.5 but protocol still reads it

What changed in 1.21.5

In versions 1.21.1–1.21.4 (I didn't examine versions prior to 1.21.1), AttributeModifiersComponent was a record with two fields:

// 1.21.1–1.21.4
public record AttributeModifiersComponent(List<Entry> modifiers, boolean showInTooltip)

Its PACKET_CODEC serialized both:

// 1.21.1–1.21.4 PACKET_CODEC
PacketCodec.tuple(
    Entry.PACKET_CODEC.collect(PacketCodecs.toList()),  // varint-prefixed array
    AttributeModifiersComponent::modifiers,
    PacketCodecs.BOOL,                                   // trailing bool
    AttributeModifiersComponent::showInTooltip,
    AttributeModifiersComponent::new
);

In 1.21.5, the record was reduced to a single field:

// 1.21.5+
public record AttributeModifiersComponent(List<Entry> modifiers)

And the PACKET_CODEC was simplified to match:

// 1.21.5+ PACKET_CODEC
PacketCodec.tuple(
    Entry.PACKET_CODEC.collect(PacketCodecs.toList()),  // varint-prefixed array only
    AttributeModifiersComponent::modifiers,
    AttributeModifiersComponent::new
);

Source file: net/minecraft/component/type/AttributeModifiersComponent.java

Wire format comparison

1.21.1–1.21.4 (correct, unchanged by this PR):

[varint: entry count] [entry]... [bool: showInTooltip]

1.21.5+ actual wire format:

[varint: entry count] [entry]...

Pre-PR protocol.json for 1.21.5 (wrong — still had 1.21.4 structure):

["container", [
  {"name": "attributes", "type": ["array", ...]},
  {"name": "showTooltip", "type": "bool"}        ← does not exist on the wire
]]

A parser following the pre-PR protocol.json would read one extra byte (showTooltip) after the array that does not exist in the actual data stream. This would either consume the first byte of the next component or cause a read error.

Was showTooltip erroneously removed?

No. The removal was intentional by Mojang. In 1.21.5, tooltip visibility was moved to a new, separate tooltip_display component (which is present in the protocol for 1.21.5+). The showInTooltip boolean was removed from attribute_modifiers, enchantments, can_place_on, and can_break simultaneously. Notice that these other components also lost their showTooltip field in the 1.21.5 protocol.json — attribute_modifiers was the only one still incorrectly carrying it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants