Auto-Generate Protocol Types - #370
Conversation
|
It seems that the documents from mojang not support Debug Drawer PacketYoursfunc (x *ShapeDataPayload) Marshal(r protocol.IO) {
r.Varuint64(&x.NetworkID)
r.Uint8(&x.ShapeType)
r.Vec3(&x.Location)
r.Float32(&x.Scale)
r.Vec3(&x.Rotation)
r.Float32(&x.TotalTimeLeft)
r.Int32(&x.Color)
r.Varint32(&x.DimensionID)
switch val := x.ExtraShapeData.(type) {
case nil:
var typeID uint32 = 0
r.Uint32(&typeID)
_ = val // nil value, nothing more to write
}
}But the real// Marshal ...
func (x *DebugDrawerShape) Marshal(io IO) {
io.Varuint64(&x.NetworkID)
OptionalFunc(io, &x.Type, io.Uint8)
OptionalFunc(io, &x.Location, io.Vec3)
OptionalFunc(io, &x.Scale, io.Float32)
OptionalFunc(io, &x.Rotation, io.Vec3)
OptionalFunc(io, &x.TotalTimeLeft, io.Float32)
OptionalFunc(io, &x.Colour, io.BEARGB)
io.Varint32(&x.DimensionID)
io.ShapeData(&x.ExtraShapeData)
}Camera Instruction PacketYoursfunc (x *CameraInstructionEntry) Marshal(r protocol.IO) {
protocol.Single(r, &x.Set)
r.Bool(&x.Clear)
protocol.Single(r, &x.Fade)
protocol.Single(r, &x.Target)
r.Bool(&x.RemoveTarget)
protocol.Single(r, &x.FieldOfView)
protocol.Single(r, &x.Spline)
r.Int64(&x.AttachToEntity)
r.Bool(&x.DetachFromEntity)
}But the realfunc (pk *CameraInstruction) Marshal(io protocol.IO) {
protocol.OptionalMarshaler(io, &pk.Set)
protocol.OptionalFunc(io, &pk.Clear, io.Bool)
protocol.OptionalMarshaler(io, &pk.Fade)
protocol.OptionalMarshaler(io, &pk.Target)
protocol.OptionalFunc(io, &pk.RemoveTarget, io.Bool)
protocol.OptionalMarshaler(io, &pk.FieldOfView)
protocol.OptionalMarshaler(io, &pk.Spline)
protocol.OptionalFunc(io, &pk.AttachToEntity, io.Int64)
protocol.OptionalFunc(io, &pk.DetachFromEntity, io.Bool)
} |
|
Unfortunately the JSON docs still have a lot of discrepancies between what they say and what is actually required, as pointed out by Happy with a few examples. On top of this, there's still a large amount of packets not in the JSON format. Until all this issues are resolved, we will not be generating anything. If you're going to continue working on this, then it can stay open as a draft, but if you do not plan on turning this into something usable in the near future then I believe we should close this and come back to it at a better time |
|
It can be done using prismarine js minecraft-data which has reliable full json definitions for packets and protocol Heres an example of that |
|
The issue is still fully relevant. All three structural blockers cited remain unresolved in the current Mojang protocol exports, even though Mojang has made incremental progress and the protocol has advanced several releases. What's changed since the comments (Dec 2025 → now)The
So the docs are improving, but the kind of problems flagged are structurally unchanged. Issue-by-issue verification against the live protocol1. Optional fields still not representable — STILL BROKEN. "7894722": {
"title": "CameraInstruction",
...
"required": [
"AttachToEntity","Clear","DetachFromEntity","Fade",
"FieldOfView","RemoveTarget","Set","Spline","Target"
]
}I confirmed the same on Worse, 2. Missing packets — STILL TRUE. 26 packets are still only in the legacy
3. |
|
Thanks for the AI slop. I am fully aware this is still relevant which is why it's still open. Did not need an AI to tell me that all the issues I mentioned before are still present |
779d2ca to
a53e1fd
Compare
The
json/exports are very close to being a usable source-of-truth for code generation, This pr is an auto-generator for protocol types for gophertunnel #370). However two concrete gaps are currently blocking that work. Both look fixable on the export side without changing the underlying protocol.1. Optional fields are not representable in the current schema
The wire format uses
brstd::optional<T>/std::optional<T>for many fields (a single byte presence flag followed byTonly when present). In the JSON exports, those fields are emitted as ordinary properties and listed in"required", which is indistinguishable from a non-optional field.Example —
json/CameraInstructionPacket.json(r/21_u13, protocol 975), definition7894722(CameraInstruction):The actual packet has every one of those wrapped in
brstd::optional(matching changelogs back to r/21_u2 #12 and r/21_u3 #13, and the C++ source). A generator that trusts the JSON produces incorrect Marshal/Unmarshal code for this packet — and dozens of others (CameraPreset,CameraAimAssist*,DebugDrawerShape, etc.).2. Several packets are missing from
json/The
json/directory currently contains 191 packet files, but a number of packets referenced in the changelogs and present in the HTML/dot exports have no JSON counterpart.3. Minor:
"x-format-version": "MISSING VERSION"Several files (including
CameraInstructionPacket.jsonat protocol 975) ship with"x-format-version": "MISSING VERSION". If the format version is meant to be stamped at export time, it looks like that step is failing. A real value here would let downstream tools gate on schema changes.I have reached out to @JakeShirley regarding this:

Remaining Tasks:
ids