Skip to content

Allow copying chat lines when translating using /ctranslate#802

Open
xpple wants to merge 3 commits into
Earthcomputer:fabricfrom
xpple:ctranslate-copy
Open

Allow copying chat lines when translating using /ctranslate#802
xpple wants to merge 3 commits into
Earthcomputer:fabricfrom
xpple:ctranslate-copy

Conversation

@xpple

@xpple xpple commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/main/java/net/earthcomputer/clientcommands/command/TranslateCommand.java Outdated

@Inject(method = "onEdited", at = @At("TAIL"))
private void onEdited(String value, CallbackInfo ci) {
this.isTranslating = value.startsWith(Commands.COMMAND_PREFIX + TranslateCommand.LITERAL);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Storing this isTranslated boolean and keeping it up-to-date seems like unnecessary complexity and opportunity to get out of sync after a port to a new Minecraft version. May as well get the text of the chat box and check if it starts with the translate command inside of tryCopy

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's kept up to date in onEdited, which is kind of the purpose of that method (hook for changes). It cannot really get out of sync because the Mixin injection would fail. Checking it in tryCopy would also be a bit less efficient.

@xpple
xpple requested a review from Earthcomputer July 21, 2026 00:02
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