PrismarineJS / minecraft-data

Language independent module providing minecraft data for minecraft clients, servers and libraries.
https://prismarinejs.github.io/minecraft-data
644 stars 218 forks source link

Problems that prevent me from generating packets in C# #899

Open Titlehhhh opened 1 month ago

Titlehhhh commented 1 month ago

I am in the process of building a library to work with the minecraft protocol in c#. Like all libraries, I need support for all minecraft packets, so I decided to generate them using this repository. While reading protodef I noticed a few issues that prevent me from fully generating packets:

1) The Slot type has an anonymous field and a present field, when it would be possible to make the Slot type just optional container:

{
  "slot": [
    "optional",
    [
      "container",
      [
        {
          "name": "itemId",
          "type": "varint"
        },
        {
          "name": "itemCount",
          "type": "i8"
        },
        {
          "name": "nbtData",
          "type": "optionalNbt"
        }
      ]
    ]
  ]
}

2) On version 1.13.X there is a tags type in the play.toClient namespace, which is supposed to be declared at the beginning, i.e. in types. This does not contradict protodef, but it is not uniform. https://github.com/PrismarineJS/minecraft-data/blob/a748994fe231c356ffece37c533bcda5816b3d7a/data/pc/1.13.2/protocol.json#L3931

3) Switch constructs sometimes have cases that are objects(container) and don't have a name, just a number. image

4) Old versions had the type nbt, now it is called anonymousNbt. Why it was necessary to change the name is unclear.

Question: can I rely on these problems being fixed, or should I choose another way to generate packets?

wgaylord commented 1 month ago

I can explain number 4. anonymousNbt is its own type, introduced in new versions where the root tag does not send a tag name. So in 1.13 it is still normal nbt since root tags require names in that verison.