Jump to content

Recommended Posts

Posted

Hi everyone,

 

I've been reading through the javadocs, but I can't find any way to use forge to handle chat. Specifically, I want to detect when a player sends a general chat message, intercept the message and only deliver it to players within a certain radius of the sender. Most of that would be fairly straightforward, if only I could find where to initially intercept all chat (and how to detect which player sent the mesage_.

 

Does anyone know how to do this with the latest forge/minecraft.

 

Thanks!

 

- Chronicide

Posted

Hello again, thanks for getting back to me so quickly! I was able to create a class that implements IChatListener, register it and modify chat programatically. My problem now is that I have no choice but to return a Packet3Chat object, which is then pushed to all players. I have no way to limit the chat to only certain players. Is there something that I'm missing?

Posted

Sorry if this response isnt helpful, as I am a total noob to modding.

However, just off the top of my head, could you not send an empty Packet3Chat to the players too far to hear, and send the 'actual' Packet3Chat to the ones within range?

 

Posted

Well quick glance at it shows that the packet does not support canceling it.

You may want to write a PR for FML to add support for returning null from the handler.

Best bet for getting a new feature into FML is a pull request on github. {If you dont know how to do it, get someone who does, or learn}

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Thanks TheDragon. No worries, I'm new to this too,and I appreciate any thoughts anyone can offer! =)

 

I had a similar idea, but there was a couple of issues with that. First, you cannot send an empty Packet3Chat. You can initialize it with an empty string, but it will still send the empty string, so everyone will receive a blank row in their chat.

 

The second and more troublesome issue is that there is still no way to selectively send the Packet3Chat to only certain players. It's an all or nothing sort of deal (at least, that's the case with adding a class that implements IChatListener... I'm hoping there is another method that will work). Even if I decided I could live with players receiving blank rows in their chat, I still have no way to limit it to those players within a given radius of the sender.

 

Again, I appreciate the idea. I'm thinking that I might have to subclass some other class, like NetHandler or something. I just need to find the class that is responsible for actually delivering the chat to everyone. if I can subclass it, I hope that I can override the default behaviour. Does anyone have a good grasp of the lifecycle of a chat message (as in, which classes/methods are involved)?

Posted

Hey LexManos, thanks for the reply. Is there some way that I can subclass the chat packet and handle it myself? I traced a chat message via debug, and it looks like it originates in the ChatGUI, is passed to the EntityClientPlayerMP, then wraps the message in a Packet3Chat object and adds it the the MemoryCollection cue. From there, the NetServerHandler handles the chat.

 

I'm new to minecraft modding... is there some way to jump in at any of the above stages to take control? I can extend any of the above methods that I want, but without some way to call the overridden method it won't do any good. I was thinking that I may be able to create my own chat gui/packet/network handler, but at that point I'm essentailly recreating forge.

 

I saw that there was a PR for a chat handler hook that was closed, so I'm not sure If I should make a new request.

 

Thanks again for your help!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • UPDATE: This seems to be happening every time I leave the Beneath dimension (2 for 2). Not sure why those 2 dimensions specifically. I have no problems with the nether or Twilight Forest.
    • I was exploring my world that is hosted on a server and when I go to a certain place that is not yet loaded on the map I get disconnected and the server closes. Could you help me, since I don't know what is causing this? crashlog https://gist.github.com/Dwolfwoood/89438cd77dd8796a6dfa6783c20adaed   log server https://gist.github.com/Dwolfwoood/2aa08cc2c554098c7833b2a02f70e6e6
    • I can launch the game, but whenever I try to get in my server I get the error: java.lang.indexoutofboundsexception: readerIndex(5) + length(8) exceeds writerIndex(9): PooledUnsafeByteBuf(ridx: 5, widx: 9, cap: 9)    I don't really know what's going on. https://pastebin.com/ujr0sRDZ I put the whole log in the Pastebin link.
    • I recently built a mod pack ,RLMCC Insanity Unfolds, and Ive been playing it to make sure its stable and playable, these last few days the game has been running fine with the exception of a few player loading quirks here and there but nothing game breaking, fast forward to this morning attempting to load into my survival world results in the game crashing, I will reach 100% on world loading, the joining game prompt will appear, the loading terrain prompt will appear, I get a large lag spike, and then the game says Saving world and then crashes throwing an unknown error in the launcher when checking the logs I can see that right before the world gets shut down better combat throws a fatal error, I had assumed at first that maybe when the world got shutdown last that something got stuck in an invalid state so I removed the mod and played for a bit to hopefully un-stick whatever it was, no luck there. When I placed the mod back into the game the world continued to crash the game when loading in. I figured that maybe there was a bug introduced in the latest version so I downgraded a couple versions and worked my way back up. The original version of Better Combat the mod pack was using was better combat 1.8.6 - 1.20.1, I tried better combat 1.8.1 - 1.20.1 and worked my way up to version 1.8.5 - 1.20.1, still running into the problem. Removing Better combat solves the problem but removing the mod renders a major part of my mod pack broken as one of the major aspects of the pack was focused around better combat. As mentioned the mod pack was working and running stable prior to this morning with Better Combat 1.8.6 - 1.20.1, and there was no change in the mod list this morning I do not believe that this is a mod compatibility issue as I am still able to generate a new world perfectly fine and the mod pack was working fine these last few days. The loading issue seems to only occur with my original survival world that I made when I built the mod pack.   Here is the last section from my latest.log file https://pastebin.com/6Q9e9ZLf  
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.