Jump to content

How to send and receive packets between spigot and forge


SunnyLo

Recommended Posts

1. I want to send a packet in forge client when a player joins the server

2. I want spigot to send a packet when issue a spigot command. Then the forge mod reacts back with another packet.

 

Spigot link with same things: https://www.spigotmc.org/threads/how-to-send-and-receive-packets-between-spigot-and-forge.321331/

Edited by SunnyLo
Added spigot link
Link to comment
Share on other sites

31 minutes ago, SunnyLo said:

How do I check if the "EntityPlayerMP" to the player that is playing?

On the server:

The player in the message context IS the player that sent the packet

 

On the client:

The player that received the message IS the player that is playing...

 

What more do you need?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

11 hours ago, Draco18s said:

On the server:

The player in the message context IS the player that sent the packet

 

On the client:

The player that received the message IS the player that is playing...

 

What more do you need?

EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;
if (entityPlayer == serverPlayer) {
    System.out.println(msg);
}

 

Like this?

Link to comment
Share on other sites

47 minutes ago, diesieben07 said:

This is not a spigot forum. The real answer is: Switch to Sponge, Bukkit is dead.

But if I use sponge, every player MUST install this mod, I just want this mod to be extra. Such as betterpvp mod or 5zig.

 

Please correct me if I'm wrong

Edited by SunnyLo
Link to comment
Share on other sites

7 hours ago, SunnyLo said:

EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;
if (entityPlayer == serverPlayer) {
    System.out.println(msg);
}

 

Like this?

 

This check makes no fucking sense.

On the server, the player that sent the packet is the only player that matters.

On the client, when the client receives the packet, that player is the only player that matters.

Do not perform this check. You do not need it. Just act on the context's player.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

13 hours ago, diesieben07 said:

You are sending the packet to the client, why are you registering it for both directions in Forge?

Because I want to send packets both from spigot to forge and forge to spigot.

 

13 hours ago, diesieben07 said:

No. No no no. Read and understand: https://mcforge.readthedocs.io/en/latest/concepts/sides/

I'll remove the thing.

 

13 hours ago, diesieben07 said:

On the Forge side you are using readUTF8String, which expects the text to be prefixed with it's byte-length as a VarInt (look at the code if you are unsure). The format for your message must match between sending and receiving end.

I've found this thread which someone ask the same thing as me. But he/you didn't show the code. Can you post an example code of using ByteArrayDataOutput?

http://www.minecraftforge.net/forum/topic/59154-communication-between-forge-mod-and-bukkit-plugin/

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.

Announcements



×
×
  • Create New...

Important Information

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