public static void writeVarInt(ByteBuf byteBuf, int varInt) {
        int part;
        while (true) {
            part = varInt & 0x7F;
            varInt >>>= 7;
            if (varInt != 0) {
                part |= 0x80;
            }
            byteBuf.writeByte(part);
            if (varInt == 0) {
                break;
            }
        }
    }