Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to parse protocol #393

Closed
HurricanKai opened this issue Apr 8, 2021 · 7 comments
Closed

How to parse protocol #393

HurricanKai opened this issue Apr 8, 2021 · 7 comments

Comments

@HurricanKai
Copy link

I've been trying to parse the protocol.json files for two weeks now, and I can't get it to work for all the types. I can get some good approaches, but then I fail to parse things like particleDatas "compareTo": "$compareTo", or compareTos with ..
What's the intended way to parse the protocol files? There has to be some model they are produced from, how is that structured?
(I'm super confused about why the types are represented with arrays in the first place, shouldn't that be an object normally?)

@rom1504
Copy link
Member

rom1504 commented Apr 8, 2021

hi,
the format is https://github.com/ProtoDef-io/ProtoDef

@HurricanKai
Copy link
Author

Hi, thanks! That seems like it's going to be very helpful. In terms of code, what I can see at a glance is that the "base" format is
[ "type_name", { options } ] I guess what threw me off is that options is very very generic.
I'll try again with this though :) thanks a lot.

@HurricanKai
Copy link
Author

HurricanKai commented Apr 9, 2021

Bit of a follow-up question, and I didn't want to make yet another issue.
switch is documented in https://github.com/ProtoDef-io/ProtoDef/blob/master/doc/datatypes/conditional.md
and compareTo is documented as

compareTo : the value is the other field

what exactly is allowed there? I've seen constructs which use $something were they are then re-used somewhere else, providing something in the options.
I've also seen constructs with .., so I'm wondering what I should support here.

@ForeverZer0
Copy link

ForeverZer0 commented Dec 9, 2022

@rom1504 The problem is that ProtoDef is not documented properly. While the link you provided answers the headline of the question in the general sense, it fails to address the root problem and the specific description of it, which is related to the nebulous "variable system" that is not documented anywhere in the ProtoDef spec. While I understand this isn't the proper place to discuss it, the same issue has been open for nearly 6 years without being addressed, so it doesn't appear to be a focus there.

This project is pretty much the reference implementation for ProtoDef, and practically-speaking, more useful than its actual sparse and very lacking documentation, Both projects would benefit greatly from a few additions to the ProtoDef docs, and save the headache of digging through schemas and trying to discern whats going on in a large example file, and how it should be properly handled. This is especially important for statically typed languages and parsers only capable of forward-reading (i.e. "particleData" is referenced in "particle", but defined after it).

@rom1504
Copy link
Member

rom1504 commented Dec 9, 2022

ProtoDef-io/ProtoDef#20 yes would be great to document the variable system

Are you interested in helping out?

@ForeverZer0
Copy link

I would be happy to clarify and expand the ProtoDef wiki, it was actually already on my todo list once I get it figured out completely (I am creating a C# implementation of it). Though I still need to understand how the variables work myself before I attempt to document it. I have been searching around both projects and checking issues for clarification, but nothing answers it.

Even a general explanation on the "rules" regarding them would be helpful to figuring it out. As it stands, it is basically "this is what to expect, except sometimes there is just a word with a $ prefix" with no explicit explanation on what it means. I can make some educated guessed and surmise how it works. That might work well enough when using a fixed example (i.e. minecraft-data) if I just want to get it to work, but that is not helpful for implementing a specification with unknowns. I had assumed that, while closely linked, ProtoDef was a separate entity from this one, and could have other uses outside of it, hence my reluctance to just base it off what I see in minecraft-data.

@rom1504
Copy link
Member

rom1504 commented Dec 10, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants