Skip to content

feat: basic support for text_display entity #230

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

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

Phoenix616
Copy link

This adds basic rendering for the text of text displays. This doesn't include any other options like transforms, rendering modes or formatting of the text but makes them at least kinda usable on servers that use them to display important information. This is done by simply using the name tag system already built-in and expanding it to have multi-line support.

How it looks:
image

Copy link

codesandbox bot commented Nov 19, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@Phoenix616 Phoenix616 force-pushed the pr/basic-text-display-support branch 3 times, most recently from 4a91471 to fc92a5c Compare November 19, 2024 15:06
@Phoenix616 Phoenix616 force-pushed the pr/basic-text-display-support branch from fc92a5c to 1e023f2 Compare November 19, 2024 15:18
@zardoy
Copy link
Owner

zardoy commented Nov 19, 2024

Oh, wow, probably the best pr so far! will check within 12h

@@ -454,6 +464,7 @@ export class Entities extends EventEmitter {
// ---
// not player
const displayText = entity.metadata?.[3] && this.parseEntityLabel(entity.metadata[2])
|| entity.metadata?.[23] && this.parseEntityLabel(entity.metadata[23]) // text displays
Copy link
Owner

Choose a reason for hiding this comment

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

Is the key (index number) consistent across the versions that support it? We can check it entities data of minecraft-data module

Copy link
Owner

Choose a reason for hiding this comment

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

Also, it is definitely not right here! The 3 index is custom_name_visible property for entities. However 23 for text_display is text and for block_display is block_state property (not text), so it will result in error spamming in the console. So we should do a check here, however I might think of a better solution. Definitely code needs to be refactored (I'll gladly help you here). At least we should use property names, not number :d

Copy link
Owner

Choose a reason for hiding this comment

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

for context:
image

Copy link
Owner

Choose a reason for hiding this comment

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

sadly dont have permissions to push

Copy link
Author

Choose a reason for hiding this comment

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

sadly dont have permissions to push

Sorry, forgot that GitHub treats org forks differently from personal ones :S Will make PRs from a personal one in the future.

Also, it is definitely not right here! The 3 index is custom_name_visible property for entities. However 23 for text_display is text and for block_display is block_state property (not text), so it will result in error spamming in the console. So we should do a check here, however I might think of a better solution. Definitely code needs to be refactored (I'll gladly help you here). At least we should use property names, not number :d

You are right, I didn't consider that. I kinda thought the indexes are entity-specific but it makes sense that they aren't. Feel free to leave PRs open in the future for me to fix such stuff directly in them. Will open another PR which improves the situation here (and maybe even adds more features of the text displays already, will have to look at how difficult to do that is with the current name tag system)

@zardoy zardoy changed the title feat: add basic rendering for text displays feat: basic support for text_display entity Nov 20, 2024
@zardoy
Copy link
Owner

zardoy commented Nov 20, 2024

Ok I don't know when it will be done and I can't push changes here anyway so I will just merge it as is

@zardoy zardoy merged commit 4dac577 into zardoy:next Nov 20, 2024
2 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