Skip to content
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

Hover contents name can also be a component #61

Merged
merged 2 commits into from
Jan 1, 2025

Conversation

creesch
Copy link
Owner

@creesch creesch commented Jan 1, 2025

Fixes #60

Copy link
Collaborator

@danthedaniel danthedaniel left a comment

Choose a reason for hiding this comment

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

You'll need to update the type (and the downstream code):

message_parsing.mjs line 69

/**
 * @typedef {Object} ShowEntityHoverEvent
 * @property {'show_entity'} action - Displays entity information
 * @property {{ type: string, id: unknown, name?: string | Component }} [contents] - The entity data to show
 * @property {string} [value] - Deprecated: SNBT representation of the entity data to show.
 */

message_parsing.mjs line 830

        case 'show_entity': {
            if (!hoverEvent.contents) {
                // Don't attempt to parse SNBT data in hoverEvent.value
                console.warn('Unsupported legacy hoverEvent');
                return '';
            }

            if (typeof hoverEvent.contents.name === 'object') {
                return formatComponentPlainText(hoverEvent.contents.name);
            }

            return hoverEvent.contents.name || 'Unnamed Entity';

@creesch creesch merged commit 51473f5 into main Jan 1, 2025
4 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.

Death messages showing up as invalid
2 participants