Another-Minecraft-Chat-Client icon indicating copy to clipboard operation
Another-Minecraft-Chat-Client copied to clipboard

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

Open BigPanda97 opened this issue 3 years ago • 5 comments

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?

BigPanda97 avatar Jul 06 '22 17:07 BigPanda97

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.

Defective4 avatar Jul 06 '22 18:07 Defective4

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 avatar Jul 06 '22 19:07 BigPanda97

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.

BigPanda97 avatar Aug 31 '22 21:08 BigPanda97

@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?

Defective4 avatar Sep 01 '22 08:09 Defective4

@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. ^^

BigPanda97 avatar Sep 08 '22 18:09 BigPanda97

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!

Defective4 avatar Jan 13 '23 23:01 Defective4

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!

BigPanda97 avatar Jan 16 '23 19:01 BigPanda97

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 avatar Jan 24 '23 10:01 Defective4