neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://projects.neoforged.net/neoforged/neoforge
Other
1.22k stars 179 forks source link

Running command /neoforge tags <registry> list could kick player when there are too many tags #1543

Open YocyCraft opened 1 month ago

YocyCraft commented 1 month ago

Minecraft Version: {Minecraft version}

1.21.1

NeoForge Version: {NeoForge version. Version number, not latest/rb}

21.1.47

Logs: {Link(s) to GitHub Gist with full latest.log and/or crash report}

https://gist.github.com/YocyCraft/29d218b2409db9cf5d9d09cb48736635

Steps to Reproduce:

  1. Open ATM10 Modpack
  2. Run command /neoforge tags minecraft:items list
  3. Kicked off from the game

Description of issue:

There are too many tags of registry so the message returned from command is too long

屏幕截图 2024-09-15 220113
HenryLoenwind commented 1 month ago

While the result is paginated, there's a clickable element that copies ALL tag names to the clipboard. This is most likely what's overflowing.

final String allElementNames = names.get().sorted().collect(Collectors.joining("\n"));
...
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, allElementNames))
sciwhiz12 commented 1 month ago

Confirmed. As @HenryLoenwind shows, the /neoforge tags commands have a feature to copy all items across all pages (for listing tags of a registry, tags of an element, or elements of a tag) to the clipboard. For a huge amount of tags, that click event text exceeds the limit for encoding strings in packets.

I think, to keep it functional for most use cases but handle obscenely large lists, we will simply limit the copy-to-clipboard text to some reasonable limit of entries (with a message that it is a truncated list at the start and end). Assuming a size of 32 characters per tag key, that fits about 1,024 elements, which we'll just round down to 1,000.

Perhaps we can consider a new /neoforge dump sub-command for specifically dumping tag-related entries?