• 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!

Contributors
TPGamesNL
Supported Skript Version
  1. 2.6
Supported Minecraft Versions
  1. 1.8
  2. 1.9
  3. 1.10
  4. 1.11
  5. 1.12
  6. 1.13
  7. 1.14
  8. 1.15
  9. 1.16
  10. 1.17
  11. 1.18
  12. 1.19
  13. 1.20
Dependencies: skript-reflect

AT THE MOMENT SAMPLE-PACKETS DOESN'T WORK WITH NEW SKRIPT-REFLECT DUE TO CUSTOM EVENTS ARE BROKEN USE SKCREW INSTEAD

Firstly, it is a remake of PacketListenerNMSK by TPGamesNL which works on versions 1.8 to 1.20.4.

What does this script include:
- In, out packet listener
- Auto splitter for BundlePacket (in 1.19.4+)
- auto-detection available packets
- auto-detection of packet constructors
- auto-detection of packet decoders
- stuff to create packets and decrypt them
- method to send packets to players
- auto apply dataWatchers in 1.8

API syntax:

event: packet event
fired when packet received or sended

Code:
on packet [%packet name%]:
  #what packet sended\received
  [event-]packet
  #can be setted to new packet for overwrite
  #set event-packet to %new packet%

  #can be cancelled and not sended
  #cancel event

  #who sended\to whom it was sent
  [event-]player


effect: send packet
sends packets to specified players
Code:
send packet %packets% to %players%


function: create empty buffer
returns an empty buffer to create the packet
Code:
EmptyBuffer()


functions: write data to the buffer
write specific type to buffer

Code:
writeBytes(%buffer to%, %buffer from%)
writeBoolean(%boolean%, %buffer%)
writeByte(%number%, %buffer%)
writeShort(%number%, %buffer%)
writeFloat(%number%, %buffer%)
writeDouble(%number%, %buffer%)
writeInt(%number%, %buffer%)
writeLong(%number%, %buffer%)
writePosition(%x number%,%y number%,%z number%,%buffer%)
writeVarInt(%number%, %buffer%)
writeVarLong(%number%, %buffer%)
writeString(%text%, %buffer%)
writeUUID(%uuid object or string%, %buffer%)
writeAngle(%number%, %buffer%)

functions: read data from the buffer
read specified type from buffer and return it

Code:
readBoolean(%buffer%) :: boolean
readByte(%buffer%) :: number
readShort(%buffer%) :: number
readFloat(%buffer%) :: number
readDouble(%buffer%) :: number
readInt(%buffer%) :: number
readLong(%buffer%) :: number
readPosition(%buffer%) :: numbers list of 3
readVarInt(%buffer%) :: number
readVarLong(%buffer%) :: number
readString(%buffer%) :: text
readUUID(%buffer%) :: uuid_object
readAngle(%buffer%) :: number


function: create packet
creates and returns packet by simplied class name with data from the buffer, buffer data defined at WIKI.VG
Code:
createPacket(%packet name%,%buffer%) :: %packet%


function: get packet name by protocol
returns packet simplied name by its STATE, BOUND and ID, defined at WIKI.VG
Code:
getWrappedPacketNameByProtocol(%number id%,%text state%,%text bound%) :: text:


function: decode packet
returns buffer of received or sended packet (created packet)
Code:
decodePacket(%packet%) :: buffer:


expression: player's skin signature and value
returns string what contains signature or value. Can be used in player spawn packet or creating custom heads

Code:
%player%'s skin (signature|value)
skin (signature|value) of %player%



Also its include some ready to use packets what has less differences on different versions, such as:
- PacketPlayOutEntityDestroy
- PacketPlayOutCamera
- PacketPlayOutEntityTeleport
- PacketPlayOutOpenSignEditor
- PacketPlayOutPosition
- PacketPlayOutUpdateHealth
- PacketPlayOutBlockBreakAnimation
- PacketPlayOutAnimation
- PacketPlayOutEntityHeadRotation
- PacketPlayOutEntityLook

The list will be updated in future updates.



How to create packet if not included?
1.
Go to this site and select your core version
2. Find the required packet, find its id (in decimal), state and bound.
3. Get wrapped packet name with function getWrappedPacketNameByProtocol(...)
4. Create EmptyBuffer and fill it with data
5. Create packet with function CreatePacket(...)

Example, I need this packet:


Screenshot_2023-06-04_02-43-12.png

I converted id to decimal, I know which State and Bound. Now I can get the packet name with function - it's PacketPlayOutCamera.

Code:
function PacketPlayOutCamera(id: number) :: object:
    set {_buffer} to EmptyBuffer()
    writeVarInt({_id},{_buffer})
    return createPacket("PacketPlayOutCamera",{_buffer})


I populated a buffer based on information from the site, created a packet, and wrapped it all in a function to call it in the future. Now putting the number of the entity into the function - I can create a packet and send it to any player.

ezgif.com-optimize.gif
Author
lotzy
Downloads
516
Views
1,247
First release
Last update
Rating
5.00 star(s) 3 ratings

More resources from lotzy

Latest updates

  1. 1.20.x support

    Now its works on 1.20.x versions
  2. trrr brrrr boring

    - Auto apply DataWatcher on 1.8.8 version. Its allow you to create living entity spawn packets...
  3. BundlePacket splitter and some stuff

    Added auto splitting and packing 1.19.4 BundlePackets. This is a packet that contains several...

Latest reviews

good job, works as a Skript replacement for ProtocolLib :)
lotzy
lotzy
Very surprised by your feedback, I really like your addon 'Hippo'. Surprisingly, I never looked at the ProtocolLib sources, but at some point I caught a stupor as ViaVersion converts packets :D, it turned out to be in vain. This work still has a lot of flaws, for example, package constructors could be stored not as a skript-reflect class, but as a real constructor, this should be faster than the current implementation. In any case, thanks for the feedback!
well done mate ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
lotzy
lotzy
thanks, but its has some troubles, like new BoundlePacket
eren approved ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀