Skip to content

๐ŸŽ“ Packet API

The following objects and APIs provide the basic BDS packet interface for scripts.

(Please refer to Nukkit, PokcetMine, BDS Reverse to know the packet structure) If the client crashes, it is a packet structure error, not a bug.

The documentation does not list the packet ID and its structure, please check it yourself.

็›ฎๅฝ•

๐Ÿ”‰ Packet Object API

In LLSE, ใ€ŒPacket Objectใ€ is used to get information about packets.

Get a packet object

Get from API

Call some return packet object function to get to the packet object given by BDS
See Binary Stream Objects for details

Packet Objects - Functions

Every packet object contains some member functions (member methods) that can be executed. For a particular entity object pkt, some operations can be performed on this packet by these functions

Get packet name

pkt.getName()

  • Return value๏ผšpacket name
  • Return value type๏ผš String

Get packet ID

pkt.getId()

  • Return value๏ผšpacket id
  • Return value type๏ผš Integer

๐Ÿ”Œ Binary Stream Object API

Create a binary stream object

[JavaScript] new BinaryStream()

[Lua] BinaryStream()

  • Return value: Binary stream object
  • Return value type๏ผš BinaryStream

Binary Stream Object - Functions

Every binary stream object contains some member functions (member methods) that can be executed. For a particular entity object bs, some operations can be performed on this binary stream by these functions

Resetting binary streams

bs.reset()

  • Return value: success or not
  • Return value type๏ผš Boolean

Write to binary stream

bs.writexxxx(value)

  • Parameters๏ผš
  • value : NULL
    Refer to the table below

  • Return value๏ผšsuccess or not

  • Return value type๏ผš Boolean
Available functions Parameter Type
writeBool Boolean
writeByte Integer
writeDouble Number
writeFloat Float
writeSignedBigEndianInt Number
writeSignedInt Number
writeSignedInt64 Number
writeSignedShort Integer
writeString String
writeUnsignedChar Integer
writeUnsignedInt Number
writeUnsignedInt64 Number
writeUnsignedShort Integer
writeUnsignedVarInt Number
writeUnsignedVarInt64 Number
writeVarInt Number
writeVarInt64 Number
writeVec3 FloatPos
writeCompoundTag NbtCompound

Building packet from binary stream

bs.createPacket(pktid)

  • Parameters๏ผš
  • pktid : Integer
    Packet ID

  • Return value๏ผšPacket object

  • Return value type๏ผš Packet

Dome Code

Send TextPacket packets to a player

JavaScript
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mc.listen("onChat",function(pl,msg){
    const bs = new BinaryStream()
    var text = "LLSE Packet Test"
    bs.reserve(text.length + 8)
    bs.writeUnsignedChar(0)
    bs.writeBool(true)
    bs.writeString(text)
    bs.writeString("")
    bs.writeString("")
    var pkt = bs.createPacket(9)
    pl.sendPacket(pkt)
})