Truncate tags command clipboard text to 1000 entries
This PR fixes #1543 by truncating the amount of lines in the copy-to-clipboard text of the /neoforge tags command to 1000 entries (plus two explanatory lines at the start and end), as I suggested in my comment on that issue.
Tested by modifying the list subcommand temporarily to have 2000+ dummy entries (adding to the count and using Stream.concat), and it works.
As explained in the comment, the 1,000 entries limit was chosen by seeing how many entries of 32 characters length fit into a limit of 32,767 characters (as that is the default limit for strings in FriendlyByteBuf) and rounding down to the nearest hundreds to account for differences in tag lengths. That should be plenty enough for most development uses.
This artificially constrains the clipboard text to 1000 entries, even if more can fit inside, which would render it less useful for modpacks who go above the limit but currently do not run into the string-length limit of FriendlyByteBuf.
We could perhaps consider adding a new subcommand to /neoforge dump which exports the list of tags for registries (or elements in a tag, or tags of an element). Should that be added, we may also remove the functionality of the copy-on-clipboard for /neoforge tags, and perhaps even have it instead give the appropriate /neoforge dump command to the user with arguments filled in.
- [x] Publish PR to GitHub Packages
Last commit published: 297c5cee1c93bb61f93d067837d7c1a1eaf49ede.
PR Publishing
The artifacts published by this PR:
- :package:
net.neoforged:neoforge:21.3.38-beta-pr-1546-1.21.1-GH-1543-tags-command-clipboard-truncation - :package:
net.neoforged:testframework:21.3.38-beta-pr-1546-1.21.1-GH-1543-tags-command-clipboard-truncation
Repository Declaration
In order to use the artifacts published by the PR, add the following repository to your buildscript:
repositories {
maven {
name 'Maven for PR #1546' // https://github.com/neoforged/NeoForge/pull/1546
url 'https://prmaven.neoforged.net/NeoForge/pr1546'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
}
MDK installation
In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1546.
On Powershell you will need to remove the -L flag from the curl invocation.
mkdir NeoForge-pr1546
cd NeoForge-pr1546
curl -L https://prmaven.neoforged.net/NeoForge/pr1546/net/neoforged/neoforge/21.3.38-beta-pr-1546-1.21.1-GH-1543-tags-command-clipboard-truncation/mdk-pr1546.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip
To test a production environment, you can download the installer from here.
One thought: Does this really need to run as a server command? Those registries are synced to the client, aren't they?
Not necessarily -- afaik that command dumps tags for any registry, including server only ones? Registries can have tags and not be synced.
Updated to use a new truncation strategy that fits as much text as possible into the clipboard text, rather than constraining the amount of elements based on a precalculated heuristic on element lengths. See updated PR description for details.
🚀 This PR has been released as NeoForge version 21.3.35-beta.