MundoSK Packets

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Tlatoani

Addon Developer
Jan 24, 2017
151
92
28
22
Milky Way
This is a tutorial that will teach you how to use packets.

What are packets?

Packets are what Minecraft uses to send information between a server and client. Each packet has a packettype. Packettypes describe what kind of information a packet holds and for what purpose that information should be used. There are two main kinds of packettypes: server and client. Server packettypes describe packets that are sent to a client from the server, and client packettypes describe packets that are received by the server from the client. Every packettype has a name that looks kinda like this: play_server_player_info. Here, play is that packettypes's group (Another classification of packets that you don't need to worry about) server means that that packettype is a server packettype, and player_info is the rest of its name.

How do we get a packet?

There are two ways you can get an actual packet: intercepting one by using a packet event, or creating one yourself. Packet events are called when a packet is either sent or received. They look like this:

code_language.skript:
on packet event %packettypes%:
    #do stuff

This event has the following event-values:

code_language.skript:
event-packet #(The packet being sent/received)
event-packettype #(The packettype of the packet)
event-player #(The player sending/receiving)

And can also be cancelled.

Packet creation is done using this simple expression:

code_language.skript:
new %packettype% packet

What information is stored in a packet, and how do we access and modify it?

Now that you have access to a packet, you can modify its information. Here's a list of all the different syntaxes for packet information:

code_language.skript:
%type% pinfo %number% of %packet%
%type% array pinfo %number% of %packet%
%string% pinfo %number% of %packet%
%world% pentity %number% of %packet%
byte pnum %number% of %packet%
short pnum %number% of %packet%
int pnum %number% of %packet%
long pnum %number% of %packet%
float pnum %number% of %packet%
double pnum %number% of %packet%
byte array pnum %number% of %packet%
int array pnum %number% of %packet%
%string% pjson %number% of %packet%
%string% array pjson %number% of %packet%
%string% penum %number% of %packet%

Here, %number% is the index (starting from 0) and %packet% is the packet you are getting information from.
  • The first two allow you to put in a type, like 'string', to get all the strings. Keep in mind this doesn't work for all types.
  • The third one allows you to specify the method name for getting infos of a specific type in special cases.
  • The fourth allows you to get all the entities of the packet provided you specify the world (Either player's world or the world of the player who you will send to)
  • 5 through 12 allow you to get infos of different number types.
  • The next two are for getting infos of types that aren't in Skript yet, only one of which is supported - "ChatComponent" for the first one (Not the second one). Doing things with JsonObjects should be pretty easy if you look at skUnity. If not, feel free to ask questions on the MundoSK skUnity thread.
  • The last one is for modifying enum values of packets, where %string% is the name of the enum, like "WorldBorderAction".

All these infos are setttable, which is very important, as it allows you to modify the information in the packet.

How do we send and simulate receiving packets?

To send a packet that you have created, use this effect:

code_language.skript:
send %players% packet[s] %packets%

You can simulate the server receiving a packet from a player using this effect:

code_language.skript:
receive packet[s] %packets% from %players%

Helpful Resources

wiki.vg provides a list of packets, their fields, and what their fields represent. It can be useful for knowing what each pinfo of a packet means, however most of the packet names are different from their MundoSK names (which are based on their ProtocolLib names), and the fields aren't always 100% the same.

PacketWrapper created by one of ProtocolLib's developers is a library of wrappers for all the packets, It has methods that tell you exactly what each pinfo represents and sometimes also has int values telling you what an int pnum's different values mean. It was made for 1.11, but if you go through its history you will be able to see older versions of the wrappers for previous versions.

The PacketType class from ProtocolLib has a 100% up-to-date list of all of the packettypes available.

The EnumWrappers class from ProtocolLib has a list of all the enums/values that can be used in the penum expression.

Questions? Comments? Suggestions or improvements? Comment below!
 
Last edited:
This is a tutorial that will teach you how to use packets.

What are packets?

Packets are what Minecraft uses to send information between a server and client. Each packet has a packettype. Packettypes describe what kind of information a packet holds and for what purpose that information should be used. There are two main kinds of packettypes: server and client. Server packettypes describe packets that are sent to a client from the server, and client packettypes describe packets that are received by the server from the client. Every packettype has a name that looks kinda like this: play_server_player_info. Here, play is that packettypes's group (Another classification of packets that you don't need to worry about) server means that that packettype is a server packettype, and player_info is the rest of its name.

How do we get a packet?

There are two ways you can get an actual packet: intercepting one by using a packet event, or creating one yourself. Packet events are called when a packet is either sent or received. They look like this:

code_language.skript:
on packet event %packettypes%:
    #do stuff

This event has the following event-values:

code_language.skript:
event-packet #(The packet being sent/received)
event-packettype #(The packettype of the packet)
event-player #(The player sending/receiving)

And can also be cancelled.

Packet creation is done using this simple expression:

code_language.skript:
new %packettype% packet

What information is stored in a packet, and how do we access and modify it?

Now that you have access to a packet, you can modify its information. Here's a list of all the different syntaxes for packet information:

code_language.skript:
%type% pinfo %number% of %packet%
%type% array pinfo %number% of %packet%
%string% pinfo %number% of %packet%
%world% pentity %number% of %packet%
byte pnum %number% of %packet%
short pnum %number% of %packet%
int pnum %number% of %packet%
long pnum %number% of %packet%
float pnum %number% of %packet%
double pnum %number% of %packet%
byte array pnum %number% of %packet%
int array pnum %number% of %packet%
%string% pjson %number% of %packet%
%string% array pjson %number% of %packet%
%string% penum %number% of %packet%

Here, %number% is the index (starting from 0) and %packet% is the packet you are getting information from.
  • The first two allow you to put in a type, like 'string', to get all the strings. Keep in mind this doesn't work for all types.
  • The third one allows you to specify the method name for getting infos of a specific type in special cases.
  • The fourth allows you to get all the entities of the packet provided you specify the world (Either player's world or the world of the player who you will send to)
  • 5 through 12 allow you to get infos of different number types.
  • The next two are for getting infos of types that aren't in Skript yet, only one of which is supported - "ChatComponent" for the first one (Not the second one). Doing things with JsonObjects should be pretty easy if you look at skUnity. If not, feel free to ask questions on the MundoSK skUnity thread.
  • The last one is for modifying enum values of packets, where %string% is the name of the enum, like "WorldBorderAction".

All these infos are setttable, which is very important, as it allows you to modify the information in the packet.

How do we send and simulate receiving packets?

To send a packet that you have created, use this effect:

code_language.skript:
send %player% packet %packet%

You can simulate the server receiving a packet from a player using this effect:

code_language.skript:
receive packet %packet% from %player%

Questions? Comments? Suggestions or improvements? Comment below!
How can i use the play_client_look packet. What do i need to change to make the player rotate or look in a specified direction?
 
How can i use the play_client_look packet. What do i need to change to make the player rotate or look in a specified direction?
In the play_client_look packet, the float 0 is the yaw and the float 1 is the pitch. Keep in mind that this is a client packet, so you will have to make the server receive the packet from whoever you are rotating (unless you are modifying an intercepted packet)
 
In the play_client_look packet, the float 0 is the yaw and the float 1 is the pitch. Keep in mind that this is a client packet, so you will have to make the server receive the packet from whoever you are rotating (unless you are modifying an intercepted packet)
Thanks
[doublepost=1488555050,1488554772][/doublepost]
In the play_client_look packet, the float 0 is the yaw and the float 1 is the pitch. Keep in mind that this is a client packet, so you will have to make the server receive the packet from whoever you are rotating (unless you are modifying an intercepted packet)
command /rotate:
trigger:
set {_} to new play_client_look packet
set float pnum 1 of {_} to 90
receive packet {_} from player

I did this and typed /rotate but i wont get rotated?
 
Thanks
[doublepost=1488555050,1488554772][/doublepost]
command /rotate:
trigger:
set {_} to new play_client_look packet
set float pnum 1 of {_} to 90
receive packet {_} from player

I did this and typed /rotate but i wont get rotated?
You mean you didn't get rotated yourself, or that other players didn't see you get rotated?
 
I did not get rotated
That is what you would expect to happen by usig his packet. If you want to get rotated yourself, it is better to use the normal expression for yaw and pitch,
code_language.skript:
set %player%'s pitch to 90
The only thing is that this will require RandomSK (or another addon that has it).

If you only want to rotate yourself without other players seeing it, then you have to use the
code_language.skript:
play_server_position
packet, which I do not know exactly how to use, but I can find out if that it what you want to do.
 
That is what you would expect to happen by usig his packet. If you want to get rotated yourself, it is better to use the normal expression for yaw and pitch,
code_language.skript:
set %player%'s pitch to 90
The only thing is that this will require RandomSK (or another addon that has it).

If you only want to rotate yourself without other players seeing it, then you have to use the
code_language.skript:
play_server_position
packet, which I do not know exactly how to use, but I can find out if that it what you want to do.
My goal was to rotate the player further than normaly posible this is done in de CraftVenture server in 1.11 in 1.8 you can do that by opening the chat or a Inventory. So i am trying to do the same in 1.11 but using packets
[doublepost=1488664539,1488662338][/doublepost]
That is what you would expect to happen by usig his packet. If you want to get rotated yourself, it is better to use the normal expression for yaw and pitch,
code_language.skript:
set %player%'s pitch to 90
The only thing is that this will require RandomSK (or another addon that has it).

If you only want to rotate yourself without other players seeing it, then you have to use the
code_language.skript:
play_server_position
packet, which I do not know exactly how to use, but I can find out if that it what you want to do.
So if you could help me with the packets maybe it works, it would be awesome :emoji_slight_smile:
[doublepost=1488665271][/doublepost]
That is what you would expect to happen by usig his packet. If you want to get rotated yourself, it is better to use the normal expression for yaw and pitch,
code_language.skript:
set %player%'s pitch to 90
The only thing is that this will require RandomSK (or another addon that has it).

If you only want to rotate yourself without other players seeing it, then you have to use the
code_language.skript:
play_server_position
packet, which I do not know exactly how to use, but I can find out if that it what you want to do.
I have tried it and i think it works, One problem though, when i send the player the packet al blocks will be invisible and you will have to reload the chunks to make them visible again :/
 
My goal was to rotate the player further than normaly posible this is done in de CraftVenture server in 1.11 in 1.8 you can do that by opening the chat or a Inventory. So i am trying to do the same in 1.11 but using packets
[doublepost=1488664539,1488662338][/doublepost]
So if you could help me with the packets maybe it works, it would be awesome :emoji_slight_smile:
[doublepost=1488665271][/doublepost]
I have tried it and i think it works, One problem though, when i send the player the packet al blocks will be invisible and you will have to reload the chunks to make them visible again :/
Good to see that you got it to work, for the chunks thing if reloading the chunks fixes it then that is the best you can do probably. I am trying to see if the expression for pitch from RandomSK works, but it does not seem to be doing anything at all.
 
Good to see that you got it to work, for the chunks thing if reloading the chunks fixes it then that is the best you can do probably. I am trying to see if the expression for pitch from RandomSK works, but it does not seem to be doing anything at all.
Okay thanks for the help! i hope you can figure a way out to make the chunks not unload themselfs :emoji_slight_smile:
 
Hey, great tutorial, I'm a huge noob when it comes to packets and I'm trying to modify the player list shown when a player hovers over the player count while in the server browser

This is what I'm talking about:
http://i.imgur.com/T8FfgPZ.png

Some servers modify it to have a fancy Motd in them as shown in that picture but I personally don't want to do that, I just want it to hide the list/show nothing simply because I don't want players to know who is online without joining the server, after some searching around I read on a few different forum posts that it was possible to modify that player list through packets, like I said I'm a huge noob when it comes to packets so I kinda just want to know if I'm on the right track or not, I believe this is the packet event I should be working with?:
http://wiki.vg/Protocol#Request

which I'm not sure if that is the packet event I should be listening for but if it is I tried:
on packet event status_serverbound_request:

and a few other variations of that but I haven't had any luck getting it right, so I was hoping you can lead me in the right direction, I probably have the wrong packet or doing something obvious wrong so I rather ask for some help here
 
Hey, great tutorial, I'm a huge noob when it comes to packets and I'm trying to modify the player list shown when a player hovers over the player count while in the server browser

This is what I'm talking about:
http://i.imgur.com/T8FfgPZ.png

Some servers modify it to have a fancy Motd in them as shown in that picture but I personally don't want to do that, I just want it to hide the list/show nothing simply because I don't want players to know who is online without joining the server, after some searching around I read on a few different forum posts that it was possible to modify that player list through packets, like I said I'm a huge noob when it comes to packets so I kinda just want to know if I'm on the right track or not, I believe this is the packet event I should be working with?:
http://wiki.vg/Protocol#Request

which I'm not sure if that is the packet event I should be listening for but if it is I tried:
on packet event status_serverbound_request:

and a few other variations of that but I haven't had any luck getting it right, so I was hoping you can lead me in the right direction, I probably have the wrong packet or doing something obvious wrong so I rather ask for some help here
Hello, and thanks!

The first thing you will want to know is that the packet names used in MundoSK are different from the ones you will find in wiki.vg as they are based on the names used by ProtocolLib, you can find a list of the packettypes from ProtocolLib here. Instead of writing clientbound or serverbound, you just write server, or client - server and client actually signify where they are coming from, so server in ProtocolLib packets = clientbound from wiki.vg and client = serverbound. In addition to this mix-up, they also may have completely different names in ProtocolLib and wiki.vg, like in this case there does not appear to be any packet named status_client_request.

In this case however, we want to focus on a server packet (clientbound) as that will be sent to the client containing the player list, which is what we want to modify. In this case this would appear to be the packet status_server_server_info, so that's the packet you will want to use.
 
Hello, and thanks!

The first thing you will want to know is that the packet names used in MundoSK are different from the ones you will find in wiki.vg as they are based on the names used by ProtocolLib, you can find a list of the packettypes from ProtocolLib here. Instead of writing clientbound or serverbound, you just write server, or client - server and client actually signify where they are coming from, so server in ProtocolLib packets = clientbound from wiki.vg and client = serverbound. In addition to this mix-up, they also may have completely different names in ProtocolLib and wiki.vg, like in this case there does not appear to be any packet named status_client_request.

In this case however, we want to focus on a server packet (clientbound) as that will be sent to the client containing the player list, which is what we want to modify. In this case this would appear to be the packet status_server_server_info, so that's the packet you will want to use.
Ah I see, thank you very much, this information is super helpful
 
  • Like
Reactions: Tlatoani
code_language.skript:
command /test:
 trigger:
  set {_player} to player
  set {_loc} to location of targeted block
  set {_packet} to new PLAY_SERVER_BLOCK_CHANGE packet
  set location pinfo 0 of {_packet} to {_loc}
  set int pnum 0 of {_packet} to 56
  send {_player} packet {_packet}

This is my code.
I am not get error but is not working.
I don't see the block change.

Where is error?
 
code_language.skript:
command /test:
 trigger:
  set {_player} to player
  set {_loc} to location of targeted block
  set {_packet} to new PLAY_SERVER_BLOCK_CHANGE packet
  set location pinfo 0 of {_packet} to {_loc}
  set int pnum 0 of {_packet} to 56
  send {_player} packet {_packet}

This is my code.
I am not get error but is not working.
I don't see the block change.

Where is error?
The play_server_block_change packet doesn't have an int pnum, but it does need a different pinfo known as "blockdata". I added a converter for this pinfo in the BETA.7.148 version (download: Download), so you can use it like this:
code_language.skript:
blockdata pinfo %number% of %packet%
For example:
code_language.skript:
set blockdata pinfo 0 of {_packet} to emerald block
 
My code:
code_language.skript:
command /test:
    trigger:
        set {_packet} to new PLAY_CLIENT_LOOK packet
        wait a second
        set float pnum 0 of {_packet} to 90
        send player packet {_packet}

I get error: https://pastebin.com/KrbES6Xc
You can't send client packets to the player, you have to use the packet receive effect for make the player receive that packet. But do you know what that packet does? What are you trying to achieve with this?