
Originally Posted by
Naturality
Thank you for this, I read your post about reading/writing bytes. I somewhat understand the writing part, but I'm not too sure about the reading part.
Confused on actually how to read it on the server side.
It's usually the same exact method but with "read" instead of "write". Just look at the methods. Example it says:
Code:
class330_sub34.aClass330_Sub46_Sub2_7729.writeUnsignedShort(i_9_, (byte) 21);
class330_sub34.aClass330_Sub46_Sub2_7729.writeUnsignedByte(Class356.method4190((byte) 3) ? 1 : 0, (byte) 83);
on the client, you get this code after removing the junk:
Code:
writeUnsignedShort(X);
writeUnsignedByte(X);
Now, on the server, all you have to do is read:
Code:
stream.readShort();
stream.readByte();
in the packet decoder.
You can confirm your results by comparing the write/read of both client and server:
Code:
public void writeUnsignedShort() {
buffer[(offset += 323600977) * -824785231 - 1] = (byte) (i >> 8);
buffer[(offset += 323600977) * -824785231 - 1] = (byte) i;
}
public void readUnsignedShort() {
return (readUnsignedByte() << 8) + readUnsignedByte();
}
Without the junk it gives:
Code:
write: i >> 8 + i
read: i << 8 + i
The ">>" 8 encrypted the "i" so it needs to be "<<" in return. We can see that everything is in order so "readUnsignedShort" is the read equivalent of "writeUnsignedShort".