Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

how to intercept and handle chat?


Recommended Posts

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

Link to post
Share on other sites

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?

Link to post
Share on other sites

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.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to post
Share on other sites

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

Link to post
Share on other sites

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!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ---- Minecraft Crash Report ---- // My bad. Time: 4/16/21 7:24 AM Description: Exception ticking world java.lang.NoSuchMethodError: net.minecraft.world.server.ChunkManager$ProxyTicketManager.shouldForceTicks(J)Z     at net.minecraft.world.server.ServerChunkProvider.func_241099_a_(ServerChunkProvider.java:356) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerChunkProvider$$Lambda$6027/670031023.accept(Unknown Source) ~[?:?] {}     at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_51] {}     at net.minecraft.world.server.ServerChunkProvider.func_217220_m(ServerChunkProvider.java:346) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerChunkProvider.func_217207_a(ServerChunkProvider.java:321) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerWorld.func_72835_b(ServerWorld.java:333) ~[?:?] {re:mixin,re:classloading}     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:851) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:118) ~[?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer$$Lambda$5714/74774173.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at net.minecraft.world.server.ServerChunkProvider.func_241099_a_(ServerChunkProvider.java:356) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerChunkProvider$$Lambda$6027/670031023.accept(Unknown Source) ~[?:?] {}     at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_51] {}     at net.minecraft.world.server.ServerChunkProvider.func_217220_m(ServerChunkProvider.java:346) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerChunkProvider.func_217207_a(ServerChunkProvider.java:321) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ServerWorld.func_72835_b(ServerWorld.java:333) ~[?:?] {re:mixin,re:classloading} -- Affected level -- Details:     All players: 0 total; []     Chunk stats: ServerChunkCache: 2025     Level dimension: minecraft:overworld     Level spawn location: World: (-128,65,130), Chunk: (at 0,4,2 in -8,8; contains blocks -128,0,128 to -113,255,143), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)     Level time: 2 game time, 2 day time     Level name: rena     Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false     Level weather: Rain time: 30168 (now: false), thunder time: 83943 (now: false)     Known server brands: forge     Level was modded: true     Level storage version: 0x04ABD - Anvil Stacktrace:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:851) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:118) ~[?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer$$Lambda$5714/74774173.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 8 (amd64) version 6.2     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 665613832 bytes (634 MB) / 1744830464 bytes (1664 MB) up to 2147483648 bytes (2048 MB)     CPUs: 16     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 8.0.9+86+master.3cf110c     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.2.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.1.4.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.1.4.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.1.4.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.1.4.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE          /OptiFine_1.16.4_HD_U_G5.jar OptiFine TRANSFORMATIONSERVICE          /forge-1.16.5-36.1.4.jar fml TRANSFORMATIONSERVICE      FML: 36.1     Forge: net.minecraftforge:36.1.4     FML Language Providers:          javafml@36.1         minecraft@1     Mod List:          forge-1.16.5-36.1.4-client.jar                    |Minecraft                     |minecraft                     |1.16.5              |DONE      |NOSIGNATURE         True+Weaponry+1.0.0.jar                           |True Weaponry                 |true_weaponry                 |1.0.0               |DONE      |NOSIGNATURE         More+Totems+Effects+1.16.5++v1.3.jar              |More Totems                   |more_totems                   |1.0.0               |DONE      |NOSIGNATURE         enderitemod-1.16.3-0.7.0-forge-34.1.34.jar        |Enderite Mod                  |enderitemod                   |1.16.3-0.7.0-forge-3|DONE      |NOSIGNATURE         VillagersFollowEmeralds-1.16.5-1.0.0.jar          |Villagers Follow Emeralds     |vfe                           |1.0.0               |DONE      |NOSIGNATURE         forge-1.16.5-36.1.4-universal.jar                 |Forge                         |forge                         |36.1.4              |DONE      |22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         EndRemastered-R36.jar                             |End Remastered 3.6            |endrem                        |1.16.3              |DONE      |NOSIGNATURE         Xaeros_Minimap_21.5.0_Forge_1.16.5.jar            |Xaero's Minimap               |xaerominimap                  |21.5.0              |DONE      |NOSIGNATURE         soulsandmobs-beta0.3-1.16.4.jar                   |Soul Sands Mobs               |soul_sands_mobs               |0.3                 |DONE      |NOSIGNATURE         MoreEnchantments_MC_1.16.4_Vers.1.0.1.jar         |More Enchantments             |more_enchantments             |1.0.1               |DONE      |NOSIGNATURE         CrimsonCompass-1.3.3.jar                          |Crimson Compasses             |crimsoncompass                |1.3.3               |DONE      |NOSIGNATURE         MinecraftCapes+Forge+1.16.5-v10.jar               |MinecraftCapes Mod            |minecraftcapes                |v10                 |DONE      |NOSIGNATURE     Crash Report UUID: f4e8c2e3-d4b3-4533-b638-15e1f7ec2912     Player Count: 0 / 8; []     Data Packs: vanilla, mod:true_weaponry, mod:more_totems, mod:enderitemod (incompatible), mod:vfe, mod:forge, mod:endrem, mod:xaerominimap, mod:soul_sands_mobs, mod:more_enchantments, mod:crimsoncompass, mod:minecraftcapes     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'     OptiFine Version: OptiFine_1.16.4_HD_U_G5     OptiFine Build: 20201106-171901     Render Distance Chunks: 12     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: BSL_v8.0.01.zip     OpenGlVersion: 4.6.0 NVIDIA 457.74     OpenGlRenderer: GeForce RTX 2080 Super with Max-Q Design/PCIe/SSE2     OpenGlVendor: NVIDIA Corporation     CpuCount: 16  
    • thanks   and do i get an answer to this question? is that on purpose or a mistake in my IDE
    • 1.7 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • !mcp -c moj mcpName to convert from MCP to Mojang names. !moj -c mcp mojangName to convert from Mojang names to MCP.
    • which command do i have to use because when i use !mcpm i get the old the names
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.