While working with NBT fields, I needed functions for writing raw utf-8 strings to the buffer.
I solve this problem and provide an expression for writing and reading strings.
Code:
write utf[-| ]8 %string% to %bytebuf%
Code:
read utf[(-| )]8 [with [len[gth]]] %number% from %bytebuf%
To read a string, you must also specify the length of the string in bytes.
Typically, in fields where you need to write exactly a string, you must also indicate its length before writing.
To do this, use the expression:
Code:
bytes of %string% [with charset %string%]
%string%'s bytes [with charset %string%]
It returns a list of bytes in a string with a specific encoding. UTF-8 is the default encoding.
Fixed some wrongs patterns, but these are minor things)
Also, a bug was fixed that caused some packets to be built incorrectly on versions below 1.17 and with Java version greater than 11.
Special thanks for @loyslow, he helped discover and correct a lot.