ViaRewind

ViaRewind

7.4k Downloads

replace CustomByteType with BYTE_ARRAY_PRIMITIVE and create ShortByteArray in viaversion

creeper123123321 opened this issue ยท 0 comments

commented

//Encryption Request
this.registerOutgoing(State.LOGIN, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); //Server ID
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper packetWrapper) throws Exception {
int publicKeyLength = packetWrapper.read(Type.VAR_INT);
packetWrapper.write(Type.SHORT, (short) publicKeyLength);
packetWrapper.passthrough(new CustomByteType(publicKeyLength));
int verifyTokenLength = packetWrapper.read(Type.VAR_INT);
packetWrapper.write(Type.SHORT, (short) verifyTokenLength);
packetWrapper.passthrough(new CustomByteType(verifyTokenLength));
}
});
}
});
//Set Compression
this.registerOutgoing(State.LOGIN, 0x03, 0x03, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper packetWrapper) throws Exception {
packetWrapper.cancel();
packetWrapper.user().get(CompressionSendStorage.class).setCompressionSend(true);
}
});
}
});
//Encryption Response
this.registerIncoming(State.LOGIN, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper packetWrapper) throws Exception {
int sharedSecretLength = packetWrapper.read(Type.SHORT);
packetWrapper.write(Type.VAR_INT, sharedSecretLength);
packetWrapper.passthrough(new CustomByteType(sharedSecretLength));
int verifyTokenLength = packetWrapper.read(Type.SHORT);