Novoline
  • Main Page
  • Scripting
    • Introduction
      • Casts
      • Security
      • Globals
      • Object Members
    • Client API
    • Objects
      • Features
        • Feature Settings
      • Settings
      • Minecraft
        • Entities
        • Packets
          • Play Serverbound
          • Play Clientbound
        • MathHelper
    • Events
    • Examples
Powered by GitBook
On this page
  • Definitions
  • Packet States
  • Packet Sides
  • Sending Packets

Was this helpful?

  1. Scripting
  2. Objects
  3. Minecraft

Packets

NovoScript allows its users to send and manipulate Packets sent both from the Client and the Server. In this section, you will gain knowledge on the Packets you're allowed to send and handle.

Definitions

Packet States

A Packet can be assigned to a Connection State:

  1. Handshaking (ord: -1) - initial state, the Client sends its Protocol Version

  2. Login (ord: 2) - state, that is used to authenticate on the Server

  3. Play (ord: 0) - the main state, which is activated after Login. Packets are related to the game process itself

  4. Status (ord: 1) - used for Server pinging in the Server List

Currently, only Play packets are provided.

Packet Sides

A Packet can either be on the Clientbound or Serverbound sides. Clientbound means a packet is sent to the Client, while Serverbound means a packet is sent to the Server. Minecraft inverts these types in class names: a C04PacketPlayerPosition is a Serverbound packet, despite the "C" prefix.

Sending Packets

To send a Serverbound packet, you need to use the following snippet:

client.connection.sendPacket({
    packetId: 0x01,     // packet's hexadecimal ID
    packetType: 'PLAY', // optional, defaults to PLAY
    // rest of the packet data, example:
    message: 'Hello, world!'
});

But what if there are multiple ways to instantiate the packet? First, you have to decide which one you're going to use. Next, supply the properties, required for this macro. In these examples, property names are the argument names.

If you'd like to use a more simpler way to instantiate packets, you can use packet macros: new C01PacketChatMessage('Hello, world!'). Packet macros are available for every packet in NovoScript. They essentially fill the properties for you, including packetId, packetType and other specific properties for the packet ("packet data").

PreviousEntitiesNextPlay Serverbound

Last updated 3 years ago

Was this helpful?

Here we use a manual way of entering the packet data. You can find out which properties need to be filled by looking up the packet in the respective subpage. For this example, you'll have to check the Instantiation section in .

C01PacketChatMessage