Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Need a little help with a mod idea... (client-side commands) #14

Closed
BigPanda97 opened this issue Jul 6, 2022 · 8 comments
Closed

Need a little help with a mod idea... (client-side commands) #14

BigPanda97 opened this issue Jul 6, 2022 · 8 comments
Assignees
Labels
done enhancement New feature or request
Milestone

Comments

@BigPanda97
Copy link

I'm currently trying to make some kind of mod/plugin for this chat client.
However, I need to be able to make some kind of command handler for client-side commands.
(For example: “/mod” etc.)
As far as I know, this chat client does not have something like client-side commands yet, so I have to do it on my own.

But therefore, I need to be able to do two things:

  1. Intercept messages which start with a client-side command
  2. Be able to display the output of the command in the chat (client-side), without sending it to the server.

So basically, into which methods of the code would I have to “hook” to be able to implement such a feature?

@Defective4
Copy link
Owner

Defective4 commented Jul 6, 2022

Currently there is only one dirty way of achieving what you want.
All chat messages from client to server are sent using MinecraftClient's sendChatMessage() method, which takes one String as an argument. This string is a plaintext command entered by user. You can modify this method to your liking, just keep in mind that the sendPacket(PacketFactory.constructPacket(reg, "ClientChatMessagePacket", message)); line is responsible for actually sending the message to the server.

If you want to display a custom message on the client-side chat, you can iterate over ClientListener interface instances returned by MinecraftClient's getClientListeners() method and invoke their messageReceived() method. Said method takes two arguments, first is a non-JSON chat message, which can be colored with "§" symbols. Second argument is ServerChatMessagePacket.Position enum, This enum has following values: CHAT, SYSTEM and HOTBAR and it tells the client where the received message should be displayed. Both CHAT and SYSTEM messages will be displayed in main chat box, while HOTBAR messages will be displayed in the small box on top of client window.
I can also create some interfaces to help you intercept and display custom messages if you want.
I hope you find this explanation useful.

@BigPanda97
Copy link
Author

Thanks for the explanation! I will try to get it working using the “dirty” way first. But some “official” interfaces might be a good idea for the next version, especially if there are maybe other developers too in the future who perhaps might want to interact with the chat messages too.

@BigPanda97
Copy link
Author

But some “official” interfaces might be a good idea for the next version, especially if there are maybe other developers too in the future who perhaps might want to interact with the chat messages too.

Did you already add that? It would be nice to have something like an “official” API for this, so I don't have to “rebuild” everything in the “dirty” way in each version.

@Defective4
Copy link
Owner

Defective4 commented Sep 1, 2022

@BigPanda97
Public API is still a Work In Progress and I plan to include it in the one of the upcoming releases along with JavaDocs.
Also, thank you for your interest in my project!

By the way, out of curiosity, may I ask what kind of mod are you going to make?

@BigPanda97
Copy link
Author

@BigPanda97 Public API is still a Work In Progress and I plan to include it in the one of the upcoming releases along with JavaDocs. Also, thank you for your interest in my project!

Perfect, thanks!

By the way, out of curiosity, may I ask what kind of mod are you going to make?

I'm playing around with several ideas I had in the past, but one of them would be something like this to make the private messages (/msg) more secure. ^^

@Defective4 Defective4 self-assigned this Sep 13, 2022
@Defective4 Defective4 added work in progress Requested feature is WIP enhancement New feature or request labels Sep 13, 2022
@Defective4 Defective4 reopened this Sep 13, 2022
@Defective4 Defective4 pinned this issue Sep 13, 2022
@Defective4 Defective4 unpinned this issue Jan 10, 2023
@Defective4 Defective4 mentioned this issue Jan 10, 2023
22 tasks
@Defective4
Copy link
Owner

Defective4 commented Jan 13, 2023

Hello @BigPanda97!
The first version of the public plugin API is now available!
I will soon start writing a wiki with guidelines, examples and tutorials, but until then you can use the generated javadocs.
If you are still interested in creating plugins for AMCC, you can download the Plugin API binaries and javadocs on the releases page.
Please let me know if you find it helpful!

@BigPanda97
Copy link
Author

Hello @Defective4! Thanks, that's really really nice. I have some exams in the upcoming weeks, so it will take some time until I can test everything, but it is really cool that you started the developing of this awesome tool again!

@Defective4
Copy link
Owner

Defective4 commented Jan 24, 2023

No problem!
Let me know if you need any help since the wiki and the documentation are not quite complete.
Also good luck on your exams @BigPanda97!

@Defective4 Defective4 added this to the AMCC v2 milestone Apr 3, 2023
@Defective4 Defective4 added done and removed work in progress Requested feature is WIP labels Apr 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
done enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants