PrismarineJS / PrismarineJS/minecraft-data

varlong 64-bit integer data type (vs varint 32-bit) in protocol data

Open
#119 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

protocol
Dominant language
JavaScript
Stars
938
Forks
294
Avg merge
2d 10h
Merged PRs (30d)
23

Description

http://wiki.vg/Protocol#Data_types

Name Size Encodes Notes
VarInt ≥ 1 ≤ 5 An integer between -2147483648 and 2147483647 Protocol Buffer Varint, encoding a two's complement signed 32-bit integer
VarLong ≥ 1 ≤ 10 An integer between -9223372036854775808 and 9223372036854775807 Protocol Buffer Varint, encoding a two's complement signed 64-bit integer

According to http://wiki.vg/Protocol#World_Border this 'varlong' type is only used in the world_border packet (0x44 in 1.8, 0x35 in 1.9), for the speed field, minecraft-data specifies using a varint:

            {
              "name": "speed",
              "type": [
                "switch",
                {
                  "compareTo": "action",
                  "fields": {
                    "1": "varint",
                    "3": "varint"
                  },
                  "default": "void"
                }
              ]
            },

Should the type here be a varlong instead? Looks like protodef varint will shift up to 64, but this could be problematic since JavaScript can only natively support up to 53-bit, for 64-bit integers I think we would need something like https://www.npmjs.com/package/node-int64. Other platforms using minecraft-data may also need to handle 32-bit vs 64-bit in their own way (no difference with Python since it'll promote automatically, but C could use int32_t or int64_t, etc.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the World Border protocol entry and the minecraft-data definition for the speed field shown in the issue. Compare its switch cases with the protocol's VarLong specification and review how ProtoDef's varint decoder handles 64-bit values. Done means the data definition uses the correct type and the behavior is suitable for consumers on platforms with different integer limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.