Jump to content

[1.8.9] Send custom C01PacketChatMessage to server?


Kalman98

Recommended Posts

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.
Link to comment
Share on other sites

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]

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • There is an issue with overloadedarmorbar - make a test without it
    • I started two worlds and I ran into the same problem on both of them. Both times my game froze after looting a chest on a ship from the ''When Dungeons Arise'' Mod. I assumed it was because of the sudden amount of achievements even tho that wasnt a problem in the past (my pc is pretty bad). But when I join the world it says ''joining world'' then I just see the unloaded world for a few seconds, so nothing but void. Then it says ''Loading terrain...'' as if i stepped in a portal. On the top right appears a message of a skill tree mod for a split second before the game then crashes. This happens every time for whatever reason on both worlds now. This is the crash report I got: The game crashed whilst unexpected error Error: java.lang.IncompatibleClassChangeError: Expecting non-static method 'void net.minecraft.client.gui.GuiComponent.m_93228_(com.mojang.blaze3d.vertex.PoseStack, int, int, int, int, int, int)' The link for the debug.log: https://paste.ee/p/u3eou# The link for the crash report: https://paste.ee/p/iBYik Dont know what helps here as info so heres a list of the mods. Advancement Plaques [Neo/Forge] AmbientSounds 6 Anvil Never Too Expensive AppleSkin Aquamirae (Forge) AttributeFix Balm Better Advancements Better Than Mending Bookshelf Born in Chaos Caelus API (Forge/NeoForge) Charm of Undying (Fabric/Forge/Quilt) Citadel Clumps Collective Colorful Hearts CorgiLib CraftPresence CreativeCore Curios API (Forge/NeoForge) DisenchantingForge Double Doors Easy Anvils [Forge & Fabric] EASY CRAFT Easy Experience Easy Piglins Easy Villagers Elytra Slot (Fabric/Forge/Quilt) Enchantment Descriptions End Remastered [NeoForge/Fabric] Enhanced Celestials - Blood, Blue, & Harvest (Super) Moons Equipment Compare [Neo/Forge] Even More Instruments! Forgiving Void GeckoLib Genshin Instruments Iceberg [Neo/Forge] Inventory HUD+ Item Highlighter [Neo/Forge] Jade 🔍 Jumpy Boats Just Enough Items (JEI) Just Zoom KleeSlabs Konkrete [Forge/NeoForge] L_Ender 's Cataclysm Legendary Tooltips [Neo/Forge] Majrusz Library Majrusz's Enchantments Mouse Tweaks Neat Obscure API (Forge) Overloaded Armor Bar Prism [Neo/Forge] Pufferfish's Skills [Fabric & Forge & NeoForge] Puzzles Lib [Forge & Fabric] Responsive Shields Royal Variations Savage Ender Dragon[Forge/Fabric] Structory: Towers Traveler's Backpack UniLib Upgraded Core Upgraded Netherite Upgraded Netherite : Ultimerite Vein Mining (Fabric/Forge/Quilt) When Dungeons Arise - Forge! When Dungeons Arise - Seven Seas Xaero's Minimap Xaero's World Map YUNG's API (Forge) YUNG's Better End Island (Forge) YUNG's Better Strongholds (Forge)
    • Make a test with another Launcher like MultiMC or AT Launcher
    • I'm playing on a Mac and when I launch from the normal forge launcher I get a GLFW error. So i'm using the Prism Launcher with java 8 trying to be able to make it run on a Mac. I've looked online but I keep getting hit with these logs and i'm not sure what to do. Log: https://mclo.gs/OVzhZtd
  • Topics

×
×
  • Create New...

Important Information

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