Jump to content

C17PacketCustomPayload Packet Sending To Bukkit Server


MCCoding

Recommended Posts

I'm trying to send some data to my bukkit server for those who are running my custom client that I'm trying to set up to prevent client side hacks, but I'm new to Forge Modding and this is my first try at it. From what I can understand I need to send a C17PacketCustomPayload Packet when the S01PacketJoinGame gets sent when someone joins a multiplayer server, so here is my code that I have go currently on the client side. What I'm not sure of if the pack it even getting sent since the server is not receiving it. I'm not sure if I have just create a packet and it's just sitting there waiting to be sent or there is an issue somewhere on the Server Side.

 

    public S01PacketJoinGame(int p_i45976_1_, WorldSettings.GameType p_i45976_2_, boolean p_i45976_3_, int p_i45976_4_, EnumDifficulty p_i45976_5_, int p_i45976_6_, WorldType p_i45976_7_, boolean p_i45976_8_)
    {
        this.field_149206_a = p_i45976_1_;
        this.field_149202_d = p_i45976_4_;
        this.field_149203_e = p_i45976_5_;
        this.field_149205_c = p_i45976_2_;
        this.field_149200_f = p_i45976_6_;
        this.field_149204_b = p_i45976_3_;
        this.field_149201_g = p_i45976_7_;
        this.field_179745_h = p_i45976_8_;
        
        ByteArrayOutputStream b = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(b);
        
        try {
            out.writeUTF("Send");
            out.writeUTF("Client MD5 HERE");
        } catch (IOException ex) {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(b.toByteArray()));
        C17PacketCustomPayload packet = new C17PacketCustomPayload("MBAH", buffer);
    }

Link to comment
Share on other sites

Didn't you just make the method 'S01PacketJoinGame' and want minecraft to call it automatically?

If not, please post the code on the method call.

+ In most case, you should set up your own IMessage and IMessageHandler. Also, you should send packet(message) on FMLNetworkEvent.ClientConnectedToServerEvent.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I have managed to code it all without using on the Forge API but every time I get my modified 1.8 client from MCP an put it into my main version directory (without launching the client with the startclient batch file) and I press play it overrides the modified files with new ones which stop the mod from running, any idea how I can stop this or what is causing it to occur?

Link to comment
Share on other sites

oh okay, as I said in the OP I'm new to all this client stuff so bit of a noob when it comes to this. What classes would I need to modify to prevent the launcher from overriding my modified classes? Also what would I need to do with ITweaker?

Link to comment
Share on other sites

I'm not new to coding or Java it's that I've never really stepped outside of the server side of thing the majority of things I code are Bukkit plugins, as for coding a class transformer that allows me to modify the class itself right before it's loaded I don't even know where to start. Do I add it inside of the minecraft.jar? the launcher? What is the ASM library, what is it used for?

Link to comment
Share on other sites

Ah okay, I'm looking into it all now since i have not added any extra classes I have only modified NetHandlerPlayClient class would I have to do anything different since the client is going to try and run that class regardless? or do I allow it to run then override the class with the modified version of it?

 

I have found the constructor of the ITweaker, where would I call for this class to override the class? also is there any documentation on how the constructor works and what each argument does?

 

 @Override
    public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
    {

    }

Link to comment
Share on other sites

All I need to do it get the client to send a plugin message to my plugin of the clients MD5 so I can check if it is not running any hacks, all of that is done the only problem is that when I add the modified files they get deleted by the launcher when I start the game.

Link to comment
Share on other sites

But then you don't need to cahnge anything in base classes (if with forge). Subscribe to entity join world event, check for being on client, that it's player, do your stuff and send packet to server. There are plenty tutorials about events, packets, forge-bucket packet handling...

Link to comment
Share on other sites

The reason I don't want to use Forge is that people who would be trying to bypass the Anti-Hack would have a really easy job since all they would need to do is go through my Forge mod and change around some code to bypass the client, where changing the base files would require then to go though hundreds of files and find what has been changed from the original vanilla client that's why I just want to know how to stop the launcher from overriding my modified bas classes.

 

Link to comment
Share on other sites

Anti-Cheat systems on the client do not work.

Flat truth of the matter.

You should not be editing base classes at all.

There is literally nothing you can do to make sure the client is unmodified.

It all comes down to 'did this packet say what it should say?' and that can EASILY be spoofed by any client.

Hell, you don't even know that the client connecting is running java, or if it's even running on a computer! It could be running on a toaster!

What you really want is potential cheat detection. And the onyl way you're gunna get that is on the server side alone validating user input if it's possible.

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

Link to comment
Share on other sites

I understand that it can be spoofed easily, but 95% of people who would be playing on the server would have no idea on how to do it. I do potential cheat detection on the server side all the client would be is just another security measure that would be put into place to reduce the amount of people that would be hacking making their job a lot harder.

Link to comment
Share on other sites

Well the point is, you won't get help for jar modding here. We are in 2015, jar modding has been dead for ages. Don't do it.

Especially considering your reason for doing it is just bad, a futile effort.

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

Link to comment
Share on other sites

Use server plugins that check incoming packet data with big anti-cheat net?

 

I don't quite get what your mod adds that is so different from other mods.

Read again what Lex told you - ani cheat systems should be on server, doing ANY checks on client is close to pointless.

You argument that "is will make it harder in 90% cases" is not really correct. If person can code - passing such MD5 check is easy. If person cannot - you are still better off with server-side anti-cheat.

 

If you want client side mod - write it in Forge. If you want ani-cheat system - write it on server.

If you want what you want - which is additional VERY EASY to falsificate packet that will tell server if client is cheating (since it's being sent from client), you can simply send packet from mod to bukkit plugin:

http://www.minecraftforge.net/forum/index.php/topic,28953.0.html

 

Please tell - what is the point of all that? :)

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I'll give the Forge mod a go if that works out sweet if not I always have the server side anti-hack in place. I have created a IMessage Handler based off this tutorial http://www.minecraftforge.net/forum/index.php/topic,28953.0.html and I'm now trying to send the server a message from the client but it seems that the server is not recieving anything. I know the server side stuff works since it was before, Here is the FMLInitializationEvent code that should be registering the channel

 

	@EventHandler
public void init(FMLInitializationEvent event) {
	network = NetworkRegistry.INSTANCE.newSimpleChannel("MBAH");
	network.registerMessage(Messenger.Handler.class, Messenger.class, 0, Side.SERVER);
	FMLCommonHandler.instance().bus().register(new ConnectionHandler());
}

 

This should send a message to the server when a client joins a server, I tried different variations of the message encase the plugin wasn't picking it up and still nothing, so I'm assuming I'm sending it wrong or something.

 

	@SubscribeEvent
public void onConenctionEvent(ClientConnectedToServerEvent event) {
	FairFight.network.sendToServer(new Messenger("Send"));
	FairFight.network.sendToServer(new Messenger("MBAH Send MD5"));
}

Link to comment
Share on other sites

This is pretty much right. Now you just need to catch and handle message on Bukkit. To do that you will need:

//Not really sure about code below (method names)
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "YourChannel");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "YourChannel", new YourMessageHandler());

And just catch it. Remember that you will need to skip 1st byte (message id) or don't send it at all (I suggest using native vanilla packet code).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
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.
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.



×
×
  • Create New...

Important Information

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