Jump to content

[1.8.9] Send custom C01PacketChatMessage to server?


Recommended Posts

Posted (edited)

Hello everyone, thanks for stopping by.

 

I'm working on a mod for Forge 11.15.1.2318. I understand that's very outdated. My goal is to create a client-side-only mod that extends the maximum length you can type in the chat window from 100 characters to 256 characters, as was changed in the 1.11 update for Minecraft. The reasoning for this is that there are multiple Spigot servers which run 1.8.9 with plugins that allow newer versions to connect and, in turn, allow players to send longer messages... but the 1.8.9 client doesn't take advantage of the upgrade, obviously. (oh, and many people play 1.8 on these servers because the combat mechanics are much smoother than the approximations given to the newer clients, but that's a whole other conversation)

 

So with that explanation out of the way, here's what I've done so far:

 

1) I'm intercepting and cancelling a GuiOpenEvent every time the player tries to open chat, and instead opening my own LongGuiChat, where the maximum character length has been raised to 256.

 

2) As ClientChatEvent doesn't exist in 1.8, I've instead resorted to modifying the sendChatMessage(String, boolean) method of my LongGuiChat class. This method executes when the player presses Enter in chat, and from there creates a new C01PacketChatMessage and adds it to the Player's send queue.

 

3) C01PacketChatMessages truncates the String passed to it down to 100 characters in the constructor. There is no publicly accessible method for modifying the String, which left me creating my own LongC01PacketChatMessage, which extends C01PacketChatMessage but has a constructor which truncates messages to 256 characters.

 

At this point I was feeling pretty optimistic about the project so far. I do not claim to be great at Java by any means, so chances are I've already made several obvious mistakes by now... in which case please let me know, I'd love to learn how to improve.

 

But anyway, I tested on a singleplayer world and to my surprise, it actually let me send 256 character messages which even show up in chat. Apparently the server side doesn't actually check the length of the chat packets. I realize now that was just the client adding the message to its own history, not sending it to the client-server. Then I tested on a Spigot server set up as mentioned at the top of this post. I could open chat and type 256 characters, of course, but the moment I hit send (regardless of if I had typed more than 100 characters), I got kicked from the server with an "Internal Exception: io.netty.handler.codec.EncoderException: java.lang.NullPointerException" in the game, and stack traces in the logs. They seem to all lead to the first line of net.minecraft.util.MessageSerializer.encode:

protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
	Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

 

At first I thought it was crashing at the getPacketId call, although the stack trace ends at the line I just posted, so I suppose it never actually made it that far. And I have no idea what would be throwing up a null pointer exception in the line I just posted. On the chance that I'm wrong, though, here's the getPacketId method:

public Integer getPacketId(EnumPacketDirection direction, Packet packetIn)
{
    return (Integer)((BiMap)this.directionMaps.get(direction)).inverse().get(packetIn.getClass());
}

 

I assume that if the code does make it that far, it will fail anyway because of the "packetIn.getClass()" call being checked against the BiMap... I have a feeling my extension of C01PacketChatMessage will not be in that map, although I may just be misunderstanding how this works.

 

I should probably also mention that my custom code works 100% perfectly if I just replace my LongC01PacketChatMessage with the original C01PacketChatMessage on the line where I add the message packet to the player's send queue. The issue is, apparently, with my custom packet class, even if I do not change a single thing and simply call super() in the constructor.

 

That's where I'm at now. I'm used to being able to implement every feature I've ever wanted to in Forge, given enough time and research, but at this point I'm wondering if maybe I've chosen something that's beyond the realm of possibilities for once. Do any of you folks here have any suggestions, insights, or advice for this problem? I appreciate any time spent reading this thread, and apologize for the wall of text. Thanks in advance!

Edited by Kalman98
Fixed grammar.
Posted

1.8.9 is no longer supported on this forum due to its age.

Please update to a modern version of Minecraft to receive support.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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